summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/BugReporter.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-03-12 23:41:59 +0000
committerTed Kremenek <kremenek@apple.com>2009-03-12 23:41:59 +0000
commite413a76004f51a8d729a32e6d35f6f3a51e9fdac (patch)
treebafb878673a17d8f88199817a3b0e7293580f774 /clang/lib/Analysis/BugReporter.cpp
parented6f5a8253bef4154fd387c5675ed8d4236f1a90 (diff)
downloadbcm5719-llvm-e413a76004f51a8d729a32e6d35f6f3a51e9fdac.tar.gz
bcm5719-llvm-e413a76004f51a8d729a32e6d35f6f3a51e9fdac.zip
Use the correct data structures!
ExplodedGraph::TrimGraph: - Just do a DFS both ways instead of BFS-DFS. We're just determining what subset of the nodes are reachable from the root and reverse-reachable from the bug nodes. DFS is more efficient for this task. BugReporter: - MakeReportGraph: Do a reverse-BFS instead of a reverse-DFS to determine the approximate shortest path through the simulation graph. We were seeing some weird cases where too many loops were being reported for simple bugs. Possibly we will need to replace this with actually computing the shortest path in terms of line numbers. llvm-svn: 66842
Diffstat (limited to 'clang/lib/Analysis/BugReporter.cpp')
-rw-r--r--clang/lib/Analysis/BugReporter.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/clang/lib/Analysis/BugReporter.cpp b/clang/lib/Analysis/BugReporter.cpp
index 8719be7fddd..ffa1593fd56 100644
--- a/clang/lib/Analysis/BugReporter.cpp
+++ b/clang/lib/Analysis/BugReporter.cpp
@@ -24,6 +24,7 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
+#include <queue>
using namespace clang;
@@ -298,18 +299,19 @@ MakeReportGraph(const ExplodedGraph<GRState>* G,
new ExplodedGraph<GRState>(GTrim->getCFG(), GTrim->getCodeDecl(),
GTrim->getContext());
- // Sometimes the trimmed graph can contain a cycle. Perform a reverse DFS
+ // Sometimes the trimmed graph can contain a cycle. Perform a reverse BFS
// to the root node, and then construct a new graph that contains only
// a single path.
llvm::DenseMap<const void*,unsigned> Visited;
- llvm::SmallVector<const ExplodedNode<GRState>*, 10> WS;
- WS.push_back(N);
+ std::queue<const ExplodedNode<GRState>*> WS;
+ WS.push(N);
+
unsigned cnt = 0;
const ExplodedNode<GRState>* Root = 0;
while (!WS.empty()) {
- const ExplodedNode<GRState>* Node = WS.back();
- WS.pop_back();
+ const ExplodedNode<GRState>* Node = WS.front();
+ WS.pop();
if (Visited.find(Node) != Visited.end())
continue;
@@ -323,12 +325,12 @@ MakeReportGraph(const ExplodedGraph<GRState>* G,
for (ExplodedNode<GRState>::const_pred_iterator I=Node->pred_begin(),
E=Node->pred_end(); I!=E; ++I)
- WS.push_back(*I);
+ WS.push(*I);
}
assert (Root);
- // Now walk from the root down the DFS path, always taking the successor
+ // Now walk from the root down the BFS path, always taking the successor
// with the lowest number.
ExplodedNode<GRState> *Last = 0, *First = 0;
NodeBackMap *BM = new NodeBackMap();
OpenPOWER on IntegriCloud