File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed
lib/StaticAnalyzer/Checkers/WebKit
test/Analysis/Checkers/WebKit Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -154,10 +154,10 @@ bool isConstOwnerPtrMemberExpr(const clang::Expr *E) {
154154 if (auto *MCE = dyn_cast<CXXMemberCallExpr>(E)) {
155155 if (auto *Callee = MCE->getDirectCallee ()) {
156156 auto Name = safeGetName (Callee);
157- if (Name == " get" || Name == " ptr" ) {
158- auto *ThisArg = MCE->getImplicitObjectArgument ();
159- E = ThisArg;
160- }
157+ if (Name == " get" || Name == " ptr" )
158+ E = MCE->getImplicitObjectArgument ();
159+ if ( auto *CD = dyn_cast<CXXConversionDecl>(Callee))
160+ E = MCE-> getImplicitObjectArgument ();
161161 }
162162 } else if (auto *OCE = dyn_cast<CXXOperatorCallExpr>(E)) {
163163 if (OCE->getOperator () == OO_Star && OCE->getNumArgs () == 1 )
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ class Foo {
3131public:
3232 Foo ();
3333 void bar ();
34+ RefCountable& obj1 () const { return m_obj1; }
3435
3536private:
3637 const Ref<RefCountable> m_obj1;
@@ -41,6 +42,7 @@ void Foo::bar() {
4142 m_obj1->method ();
4243 m_obj2->method ();
4344 // expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}}
45+ obj1 ().method ();
4446}
4547
4648} // namespace call_args_const_ref_member
@@ -100,6 +102,7 @@ class Foo {
100102public:
101103 Foo ();
102104 void bar ();
105+ RefCountable& obj1 () { return m_obj1; }
103106
104107private:
105108 const UniqueRef<RefCountable> m_obj1;
@@ -110,6 +113,7 @@ void Foo::bar() {
110113 m_obj1->method ();
111114 m_obj2->method ();
112115 // expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}}
116+ obj1 ().method ();
113117}
114118
115119} // namespace call_args_const_unique_ref
Original file line number Diff line number Diff line change @@ -289,6 +289,7 @@ class UniqueRef {
289289 u.t = nullptr ;
290290 }
291291 T &get () const { return *t; }
292+ operator T&() const { return *t; }
292293 T *operator ->() const { return t; }
293294 UniqueRef &operator =(T &) { return *this ; }
294295};
You can’t perform that action at this time.
0 commit comments