[cfe-commits] r117162 - in /cfe/trunk: include/clang/Analysis/Visitors/CFGRecStmtVisitor.h test/Analysis/dead-stores.m
Ted Kremenek
kremenek at apple.com
Fri Oct 22 15:08:32 PDT 2010
Author: kremenek
Date: Fri Oct 22 17:08:32 2010
New Revision: 117162
URL: http://llvm.org/viewvc/llvm-project?rev=117162&view=rev
Log:
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).
Modified:
cfe/trunk/include/clang/Analysis/Visitors/CFGRecStmtVisitor.h
cfe/trunk/test/Analysis/dead-stores.m
Modified: cfe/trunk/include/clang/Analysis/Visitors/CFGRecStmtVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Visitors/CFGRecStmtVisitor.h?rev=117162&r1=117161&r2=117162&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/Visitors/CFGRecStmtVisitor.h (original)
+++ cfe/trunk/include/clang/Analysis/Visitors/CFGRecStmtVisitor.h Fri Oct 22 17:08:32 2010
@@ -26,6 +26,11 @@
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;
Modified: cfe/trunk/test/Analysis/dead-stores.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dead-stores.m?rev=117162&r1=117161&r2=117162&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/dead-stores.m (original)
+++ cfe/trunk/test/Analysis/dead-stores.m Fri Oct 22 17:08:32 2010
@@ -41,3 +41,21 @@
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();
+ at interface RDar8527823
+- (void) bar_rbar8527823;
+ at end
+ at implementation RDar8527823
+- (void) bar_rbar8527823
+{
+ @synchronized(self) {
+ BOOL isExec = baz_rdar8527823(); // no-warning
+ if (isExec) foo_rdar8527823();
+ }
+}
+ at end
More information about the cfe-commits
mailing list