[cfe-commits] r159577 - in /cfe/trunk: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m test/Analysis/traversal-algorithm.mm
Ted Kremenek
kremenek at apple.com
Mon Jul 2 13:21:48 PDT 2012
Author: kremenek
Date: Mon Jul 2 15:21:48 2012
New Revision: 159577
URL: http://llvm.org/viewvc/llvm-project?rev=159577&view=rev
Log:
Fix subtle bug in AnalysisConsumer where we would not analyze functions whose parent
in the call graph had been inlined but for whatever reason we did not inline some
of its callees.
Also, fix a related traversal bug where we meant to do a BFS of the callgraph but
instead were doing a DFS.
Modified:
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
cfe/trunk/test/Analysis/traversal-algorithm.mm
Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=159577&r1=159576&r2=159577&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Mon Jul 2 15:21:48 2012
@@ -22,6 +22,7 @@
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Analysis/CFG.h"
#include "clang/Analysis/CallGraph.h"
+#include "clang/Analysis/Analyses/LiveVariables.h"
#include "clang/StaticAnalyzer/Frontend/CheckerRegistration.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Checkers/LocalCheckers.h"
@@ -347,7 +348,7 @@
for (llvm::SmallVector<CallGraphNode*, 24>::reverse_iterator
TI = TopLevelFunctions.rbegin(), TE = TopLevelFunctions.rend();
TI != TE; ++TI)
- BFSQueue.push_front(*TI);
+ BFSQueue.push_back(*TI);
// BFS over all of the functions, while skipping the ones inlined into
// the previously processed functions. Use external Visited set, which is
@@ -357,6 +358,13 @@
CallGraphNode *N = BFSQueue.front();
BFSQueue.pop_front();
+ // Push the children into the queue.
+ for (CallGraphNode::const_iterator CI = N->begin(),
+ CE = N->end(); CI != CE; ++CI) {
+ if (!Visited.count(*CI))
+ BFSQueue.push_back(*CI);
+ }
+
// Skip the functions which have been processed already or previously
// inlined.
if (Visited.count(N))
@@ -377,12 +385,6 @@
Visited.insert(VN);
}
Visited.insert(N);
-
- // Push the children into the queue.
- for (CallGraphNode::const_iterator CI = N->begin(),
- CE = N->end(); CI != CE; ++CI) {
- BFSQueue.push_front(*CI);
- }
}
}
Modified: cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m?rev=159577&r1=159576&r2=159577&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m (original)
+++ cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m Mon Jul 2 15:21:48 2012
@@ -80,11 +80,11 @@
int marker(void) { // control reaches end of non-void function
}
-// CHECK-darwin8: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage
// CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
-// CHECK-darwin8: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage
// CHECK-darwin8: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage
+// CHECK-darwin8: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage
// CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
+// CHECK-darwin8: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage
// CHECK-darwin9-NOT: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
// CHECK-darwin9-NOT: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage
Modified: cfe/trunk/test/Analysis/traversal-algorithm.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/traversal-algorithm.mm?rev=159577&r1=159576&r2=159577&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/traversal-algorithm.mm (original)
+++ cfe/trunk/test/Analysis/traversal-algorithm.mm Mon Jul 2 15:21:48 2012
@@ -23,43 +23,6 @@
work();
}
-// This ordering assumes that true cases happen before the false cases.
-
-// BFS: 10 IfStmt
-// BFS-NEXT: 11 IfStmt
-// BFS-NEXT: 16 IfStmt
-// BFS-NEXT: 22 IfStmt
-// BFS-NEXT: 22 IfStmt
-// BFS-NEXT: 22 IfStmt
-// BFS-NEXT: 22 IfStmt
-// BFS-NEXT: --END PATH--
-// BFS-NEXT: --END PATH--
-// BFS-NEXT: --END PATH--
-// BFS-NEXT: --END PATH--
-// BFS-NEXT: --END PATH--
-// BFS-NEXT: --END PATH--
-// BFS-NEXT: --END PATH--
-// BFS-NEXT: --END PATH--
-
-// And this ordering assumes that false cases happen before the true cases.
-
-// DFS: 10 IfStmt
-// DFS-NEXT: 16 IfStmt
-// DFS-NEXT: 22 IfStmt
-// DFS-NEXT: --END PATH--
-// DFS-NEXT: --END PATH--
-// DFS-NEXT: 22 IfStmt
-// DFS-NEXT: --END PATH--
-// DFS-NEXT: --END PATH--
-// DFS-NEXT: 11 IfStmt
-// DFS-NEXT: 22 IfStmt
-// DFS-NEXT: --END PATH--
-// DFS-NEXT: --END PATH--
-// DFS-NEXT: 22 IfStmt
-// DFS-NEXT: --END PATH--
-// DFS-NEXT: --END PATH--
-
-
void testLoops(id input) {
while (a()) {
work();
@@ -85,13 +48,166 @@
}
}
-// BFS: 64 WhileStmt
-// BFS: 70 ForStmt
-// BFS-NOT-NEXT: ObjCForCollectionStmt
-// BFS: 74 ObjCForCollectionStmt
-// BFS: 81 CXXForRangeStmt
-
-// DFS: 64 While
-// DFS-NEXT: 70 ForStmt
-// DFS-NEXT: 74 ObjCForCollectionStmt
-// DFS-NEXT: 81 CXXForRangeStmt
+// This ordering assumes that false cases happen before the true cases.
+
+// DFS:27 WhileStmt
+// DFS-next:33 ForStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:--END PATH--
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:--END PATH--
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:33 ForStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:--END PATH--
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:33 ForStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:--END PATH--
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:33 ForStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:--END PATH--
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:27 WhileStmt
+// DFS-next:33 ForStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:--END PATH--
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:33 ForStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:--END PATH--
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:33 ForStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:--END PATH--
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:33 ForStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:--END PATH--
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:27 WhileStmt
+// DFS-next:33 ForStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:--END PATH--
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:33 ForStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:--END PATH--
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:33 ForStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:--END PATH--
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:33 ForStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:--END PATH--
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:27 WhileStmt
+// DFS-next:33 ForStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:--END PATH--
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:33 ForStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:--END PATH--
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:33 ForStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:--END PATH--
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:33 ForStmt
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:44 CXXForRangeStmt
+// DFS-next:--END PATH--
+// DFS-next:37 ObjCForCollectionStmt
+// DFS-next:10 IfStmt
+// DFS-next:16 IfStmt
+// DFS-next:22 IfStmt
+// DFS-next:--END PATH--
+// DFS-next:--END PATH--
+// DFS-next:22 IfStmt
+// DFS-next:--END PATH--
+// DFS-next:--END PATH--
+// DFS-next:11 IfStmt
+// DFS-next:22 IfStmt
+// DFS-next:--END PATH--
+// DFS-next:--END PATH--
+// DFS-next:22 IfStmt
+// DFS-next:--END PATH--
+// DFS-next:--END PATH--
+
More information about the cfe-commits
mailing list