From: Ted Kremenek Date: Fri, 22 Oct 2010 22:08:32 +0000 (+0000) Subject: Fix a horrible bug in all dataflow analyses that use CFGRecStmtVisitor (including... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f50595df931bde89e3acd3ec18e4c7e41aa80852;p=clang Fix a horrible bug in all dataflow analyses that use CFGRecStmtVisitor (including live variables analysis). 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 --- diff --git a/include/clang/Analysis/Visitors/CFGRecStmtVisitor.h b/include/clang/Analysis/Visitors/CFGRecStmtVisitor.h index 75a4ac6601..bb7cf0b97e 100644 --- a/include/clang/Analysis/Visitors/CFGRecStmtVisitor.h +++ b/include/clang/Analysis/Visitors/CFGRecStmtVisitor.h @@ -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; diff --git a/test/Analysis/dead-stores.m b/test/Analysis/dead-stores.m index 701e5802b2..730b8266bd 100644 --- a/test/Analysis/dead-stores.m +++ b/test/Analysis/dead-stores.m @@ -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