File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed
lib/StaticAnalyzer/Checkers/WebKit
test/Analysis/Checkers/WebKit Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -504,6 +504,10 @@ class TrivialFunctionAnalysisVisitor
504504 if (!Callee)
505505 return false ;
506506
507+ auto Name = safeGetName (Callee);
508+ if (Name == " ref" || Name == " incrementCheckedPtrCount" )
509+ return true ;
510+
507511 std::optional<bool > IsGetterOfRefCounted = isGetterOfSafePtr (Callee);
508512 if (IsGetterOfRefCounted && *IsGetterOfRefCounted)
509513 return true ;
Original file line number Diff line number Diff line change @@ -365,3 +365,22 @@ namespace call_with_explicit_temporary_obj {
365365 CheckedPtr { provide () }->method ();
366366 }
367367}
368+
369+ namespace call_with_checked_ptr {
370+
371+ class Foo : public CheckedObj {
372+ public:
373+ CheckedPtr<CheckedObj> obj1 () { return m_obj; }
374+ CheckedRef<CheckedObj> obj2 () { return *m_obj; }
375+ private:
376+ CheckedObj* m_obj;
377+ };
378+
379+ Foo* getFoo ();
380+
381+ void bar () {
382+ getFoo ()->obj1 ()->method ();
383+ getFoo ()->obj2 ()->method ();
384+ }
385+
386+ }
Original file line number Diff line number Diff line change @@ -366,6 +366,8 @@ class RefCounted {
366366 void trivial65 () {
367367 __libcpp_verbose_abort (" %s" , " aborting" );
368368 }
369+ RefPtr<RefCounted> trivial66 () { return children[0 ]; }
370+ Ref<RefCounted> trivial67 () { return *children[0 ]; }
369371
370372 static RefCounted& singleton () {
371373 static RefCounted s_RefCounted;
@@ -550,6 +552,8 @@ class UnrelatedClass {
550552 getFieldTrivial ().trivial63 (); // no-warning
551553 getFieldTrivial ().trivial64 (); // no-warning
552554 getFieldTrivial ().trivial65 (); // no-warning
555+ getFieldTrivial ().trivial66 ()->trivial6 (); // no-warning
556+ getFieldTrivial ().trivial67 ()->trivial6 (); // no-warning
553557
554558 RefCounted::singleton ().trivial18 (); // no-warning
555559 RefCounted::singleton ().someFunction (); // no-warning
You can’t perform that action at this time.
0 commit comments