File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
lib/StaticAnalyzer/Checkers/WebKit
test/Analysis/Checkers/WebKit Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,8 @@ struct GuardianVisitor : public RecursiveASTVisitor<GuardianVisitor> {
9595 }
9696
9797 bool VisitCXXOperatorCallExpr (const CXXOperatorCallExpr *OCE) {
98- if (OCE->isAssignmentOp () && OCE->getNumArgs () == 2 ) {
98+ if (OCE->isAssignmentOp ()) {
99+ assert (OCE->getNumArgs () == 2 );
99100 auto *ThisArg = OCE->getArg (0 )->IgnoreParenCasts ();
100101 if (auto *VarRef = dyn_cast<DeclRefExpr>(ThisArg)) {
101102 if (VarRef->getDecl () == Guardian)
Original file line number Diff line number Diff line change @@ -111,6 +111,12 @@ void foo8(RefCountable* obj) {
111111 foo.releaseNonNull ();
112112 bar->method ();
113113 }
114+ {
115+ RefCountable *bar = foo.get ();
116+ // expected-warning@-1{{Local variable 'bar' is uncounted and unsafe [alpha.webkit.UncountedLocalVarsChecker]}}
117+ foo = obj ? obj : nullptr ;
118+ bar->method ();
119+ }
114120}
115121
116122void foo9 (RefCountable& o) {
@@ -140,6 +146,12 @@ void foo9(RefCountable& o) {
140146 guardian.leakRef ();
141147 bar->method ();
142148 }
149+ {
150+ RefCountable *bar = guardian.ptr ();
151+ // expected-warning@-1{{Local variable 'bar' is uncounted and unsafe [alpha.webkit.UncountedLocalVarsChecker]}}
152+ guardian = o.trivial () ? o : *bar;
153+ bar->method ();
154+ }
143155}
144156
145157} // namespace guardian_scopes
You can’t perform that action at this time.
0 commit comments