File tree 3 files changed +28
-0
lines changed
lib/StaticAnalyzer/Checkers/WebKit
test/Analysis/Checkers/WebKit 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,16 @@ class UncountedCallArgsChecker
125
125
// of object on LHS.
126
126
if (auto *MemberOp = dyn_cast<CXXOperatorCallExpr>(CE)) {
127
127
// Note: assignemnt to built-in type isn't derived from CallExpr.
128
+ if (MemberOp->getOperator () ==
129
+ OO_Equal) { // Ignore assignment to Ref/RefPtr.
130
+ auto *callee = MemberOp->getDirectCallee ();
131
+ if (auto *calleeDecl = dyn_cast<CXXMethodDecl>(callee)) {
132
+ if (const CXXRecordDecl *classDecl = calleeDecl->getParent ()) {
133
+ if (isRefCounted (classDecl))
134
+ return true ;
135
+ }
136
+ }
137
+ }
128
138
if (MemberOp->isAssignmentOp ())
129
139
return false ;
130
140
}
Original file line number Diff line number Diff line change
1
+ // RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s
2
+ // expected-no-diagnostics
3
+
4
+ #include " mock-types.h"
5
+
6
+ class Node {
7
+ public:
8
+ Node* nextSibling () const ;
9
+
10
+ void ref () const ;
11
+ void deref () const ;
12
+ };
13
+
14
+ static void removeDetachedChildren (Node* firstChild)
15
+ {
16
+ for (RefPtr child = firstChild; child; child = child->nextSibling ());
17
+ }
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ template <typename T> struct RefPtr {
20
20
T *operator ->() { return t; }
21
21
T &operator *() { return *t; }
22
22
RefPtr &operator =(T *) { return *this ; }
23
+ operator bool () { return t; }
23
24
};
24
25
25
26
template <typename T> bool operator ==(const RefPtr<T> &, const RefPtr<T> &) {
You can’t perform that action at this time.
0 commit comments