aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-10-22 22:08:32 +0000
committerTed Kremenek <kremenek@apple.com>2010-10-22 22:08:32 +0000
commitf50595df931bde89e3acd3ec18e4c7e41aa80852 (patch)
tree05bc6a0a3e06035ca8c6233a0d0b2d3e33121efa
parent35fa76d0bb6fb8c86159a7506efd094a4fe376d2 (diff)
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
-rw-r--r--include/clang/Analysis/Visitors/CFGRecStmtVisitor.h5
-rw-r--r--test/Analysis/dead-stores.m18
2 files changed, 23 insertions, 0 deletions
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