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 @@ -267,7 +267,7 @@ class RawPtrRefCallArgsChecker
267267 auto *callee = MemberOp->getDirectCallee ();
268268 if (auto *calleeDecl = dyn_cast<CXXMethodDecl>(callee)) {
269269 if (const CXXRecordDecl *classDecl = calleeDecl->getParent ()) {
270- if (isRefCounted (classDecl))
270+ if (isSafePtr (classDecl))
271271 return true ;
272272 }
273273 }
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 @@ -270,6 +270,16 @@ void foo() {
270270 }
271271}
272272
273+ namespace cxx_assignment_op {
274+
275+ SomeObj* provide ();
276+ void foo () {
277+ RetainPtr<SomeObj> ptr;
278+ ptr = provide ();
279+ }
280+
281+ }
282+
273283namespace call_with_ptr_on_ref {
274284 RetainPtr<SomeObj> provideProtected ();
275285 RetainPtr<CFMutableArrayRef> provideProtectedCF ();
You can’t perform that action at this time.
0 commit comments