[cfe-commits] r156870 - in /cfe/trunk: lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp test/Analysis/unused-ivars.m

Anna Zaks ganna at apple.com
Tue May 15 15:31:56 PDT 2012


Author: zaks
Date: Tue May 15 17:31:56 2012
New Revision: 156870

URL: http://llvm.org/viewvc/llvm-project?rev=156870&view=rev
Log:
[analyzer] Fix a regression in ObjCUnusedIVars checker.

We can no longer rely on children iterator to visit all the AST
tree children of an expression (OpaqueValueExpr has no children).

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp
    cfe/trunk/test/Analysis/unused-ivars.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp?rev=156870&r1=156869&r2=156870&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp Tue May 15 17:31:56 2012
@@ -47,6 +47,15 @@
     return;
   }
 
+  if (const PseudoObjectExpr *POE = dyn_cast<PseudoObjectExpr>(S))
+    for (PseudoObjectExpr::const_semantics_iterator
+        i = POE->semantics_begin(), e = POE->semantics_end(); i != e; ++i) {
+      const Expr *sub = *i;
+      if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(sub))
+        sub = OVE->getSourceExpr();
+      Scan(M, sub);
+    }
+
   for (Stmt::const_child_iterator I=S->child_begin(),E=S->child_end(); I!=E;++I)
     Scan(M, *I);
 }

Modified: cfe/trunk/test/Analysis/unused-ivars.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/unused-ivars.m?rev=156870&r1=156869&r2=156870&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/unused-ivars.m (original)
+++ cfe/trunk/test/Analysis/unused-ivars.m Tue May 15 17:31:56 2012
@@ -108,3 +108,24 @@
 
 @implementation RDar8481311
 @end
+
+ at class NSString;
+ at interface Radar11059352_1 {
+ at private
+    NSString *_pathString;
+}
+ at property (readonly, strong) NSString *pathString;
+ at end
+
+ at interface Radar11059352 {
+ at private
+Radar11059352_1 *_workspacePath;
+}
+ at end
+
+ at implementation Radar11059352
+
+- (void)useWorkspace {
+    NSString *workspacePathString = _workspacePath.pathString;
+}
+ at end
\ No newline at end of file





More information about the cfe-commits mailing list