]> granicus.if.org Git - clang/commitdiff
Fix a horrible bug in all dataflow analyses that use CFGRecStmtVisitor (including...
authorTed Kremenek <kremenek@apple.com>
Fri, 22 Oct 2010 22:08:32 +0000 (22:08 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 22 Oct 2010 22:08:32 +0000 (22:08 +0000)
We shouldn't recurse into CompoundStmts since they are already inlined in the CFG.  This could result in
bogus dead stores warnings (among other things).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117162 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/Visitors/CFGRecStmtVisitor.h
test/Analysis/dead-stores.m

index 75a4ac66012e7adf6d2f4b74f8a13c40860f2fc0..bb7cf0b97e53453c5bff57e822a6c6b28acca339 100644 (file)
@@ -26,6 +26,11 @@ public:
     static_cast< ImplClass* >(this)->VisitChildren(S);
   }
   
+  void VisitCompoundStmt(CompoundStmt *S) {
+    // Do nothing.  Everything in a CompoundStmt is inlined
+    // into the CFG.
+  }
+  
   void VisitConditionVariableInit(Stmt *S) {
     assert(S == this->getCurrentBlkStmt());
     VarDecl *CondVar = 0;
index 701e5802b25e5f9cc1c1331b43d41a81f299b059..730b8266bd10162a47e5bf80607ce3d76b5aa290 100644 (file)
@@ -41,3 +41,21 @@ void DeadStoreTest(NSObject *anObject) {
 void rdar_7631278(NSObject *x) {
   x = ((void*)0);
 }
+
+// This test case issuing a bogus warning for the declaration of 'isExec'
+// because the compound statement for the @synchronized was being visited
+// twice by the LiveVariables analysis.
+BOOL baz_rdar8527823();
+void foo_rdar8527823();
+@interface RDar8527823
+- (void) bar_rbar8527823;
+@end
+@implementation RDar8527823
+- (void) bar_rbar8527823
+{
+ @synchronized(self) {
+   BOOL isExec = baz_rdar8527823(); // no-warning
+   if (isExec) foo_rdar8527823();
+ }
+}
+@end