File tree Expand file tree Collapse file tree 5 files changed +27
-11
lines changed
lib/StaticAnalyzer/Checkers/WebKit
test/Analysis/Checkers/WebKit Expand file tree Collapse file tree 5 files changed +27
-11
lines changed Original file line number Diff line number Diff line change @@ -264,7 +264,7 @@ class RawPtrRefCallArgsChecker
264264 auto *callee = MemberOp->getDirectCallee ();
265265 if (auto *calleeDecl = dyn_cast<CXXMethodDecl>(callee)) {
266266 if (const CXXRecordDecl *classDecl = calleeDecl->getParent ()) {
267- if (isRefCounted (classDecl))
267+ if (isSafePtr (classDecl))
268268 return true ;
269269 }
270270 }
Original file line number Diff line number Diff line change 1- // RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s
1+ // RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncheckedCallArgsChecker -verify %s
22
33#include " mock-types.h"
44
@@ -10,10 +10,10 @@ namespace call_args_unchecked_uncounted {
1010
1111static void foo () {
1212 someFunction (makeObj ());
13- // expected-warning@-1{{Call argument is uncounted and unsafe [alpha.webkit.UncountedCallArgsChecker ]}}
13+ // expected-warning@-1{{Call argument is unchecked and unsafe [alpha.webkit.UncheckedCallArgsChecker ]}}
1414}
1515
16- } // namespace call_args_checked
16+ } // namespace call_args_unchecked_uncounted
1717
1818namespace call_args_checked {
1919
@@ -35,7 +35,7 @@ static void baz() {
3535namespace call_args_default {
3636
3737void someFunction (RefCountableAndCheckable* = makeObj());
38- // expected-warning@-1{{Call argument is uncounted and unsafe [alpha.webkit.UncountedCallArgsChecker ]}}
38+ // expected-warning@-1{{Call argument is unchecked and unsafe [alpha.webkit.UncheckedCallArgsChecker ]}}
3939void otherFunction (RefCountableAndCheckable* = makeObjChecked().ptr());
4040
4141void foo () {
@@ -44,3 +44,13 @@ void foo() {
4444}
4545
4646}
47+
48+ namespace call_args_checked_assignment {
49+
50+ CheckedObj* provide ();
51+ void foo () {
52+ CheckedPtr<CheckedObj> ptr;
53+ ptr = provide ();
54+ }
55+
56+ }
Original file line number Diff line number Diff line change @@ -249,7 +249,7 @@ template <typename T> struct CheckedPtr {
249249 T *get () const { return t; }
250250 T *operator ->() const { return t; }
251251 T &operator *() const { return *t; }
252- CheckedPtr &operator =(T *) { return * this ; }
252+ CheckedPtr &operator =(T *);
253253 operator bool () const { return t; }
254254};
255255
Original file line number Diff line number Diff line change @@ -216,11 +216,7 @@ template <typename T> struct RetainPtr {
216216 PtrType get () const { return t; }
217217 PtrType operator->() const { return t; }
218218 T &operator*() const { return *t; }
219- RetainPtr &operator=(PtrType t) {
220- RetainPtr o (t);
221- swap (o);
222- return *this;
223- }
219+ RetainPtr &operator=(PtrType t);
224220 PtrType leakRef ()
225221 {
226222 PtrType s = t;
Original file line number Diff line number Diff line change @@ -271,6 +271,16 @@ void foo() {
271271 }
272272}
273273
274+ namespace cxx_assignment_op {
275+
276+ SomeObj* provide ();
277+ void foo () {
278+ RetainPtr<SomeObj> ptr;
279+ ptr = provide ();
280+ }
281+
282+ }
283+
274284namespace call_with_ptr_on_ref {
275285 RetainPtr<SomeObj> provideProtected ();
276286 RetainPtr<CFMutableArrayRef> provideProtectedCF ();
You can’t perform that action at this time.
0 commit comments