Use the BugReports in BugReporter to determine the root nodes for "trim-egraph".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66622 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index f2e4b18..222ef17 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -3015,7 +3015,6 @@
#endif
#ifndef NDEBUG
-
template <typename ITERATOR>
GRExprEngine::NodeTy* GetGraphNode(ITERATOR I) { return *I; }
@@ -3025,42 +3024,27 @@
(llvm::DenseMap<GRExprEngine::NodeTy*, Expr*>::iterator I) {
return I->first;
}
-
-template <typename ITERATOR>
-static void AddSources(std::vector<GRExprEngine::NodeTy*>& Sources,
- ITERATOR I, ITERATOR E) {
-
- llvm::SmallSet<ProgramPoint,10> CachedSources;
-
- for ( ; I != E; ++I ) {
- GRExprEngine::NodeTy* N = GetGraphNode(I);
- ProgramPoint P = N->getLocation();
-
- if (CachedSources.count(P))
- continue;
-
- CachedSources.insert(P);
- Sources.push_back(N);
- }
-}
#endif
void GRExprEngine::ViewGraph(bool trim) {
#ifndef NDEBUG
if (trim) {
std::vector<NodeTy*> Src;
-
- // FIXME: Migrate over to the new way of adding nodes.
- AddSources(Src, null_derefs_begin(), null_derefs_end());
- AddSources(Src, undef_derefs_begin(), undef_derefs_end());
- AddSources(Src, explicit_bad_divides_begin(), explicit_bad_divides_end());
- AddSources(Src, undef_results_begin(), undef_results_end());
- AddSources(Src, bad_calls_begin(), bad_calls_end());
- AddSources(Src, undef_arg_begin(), undef_arg_end());
- AddSources(Src, undef_branches_begin(), undef_branches_end());
-
- // FIXME: Enhance BugReporter to have a clean way to query if a node
- // is involved in an error... and what kind.
+
+ // Flush any outstanding reports to make sure we cover all the nodes.
+ // This does not cause them to get displayed.
+ for (BugReporter::iterator I=BR.begin(), E=BR.end(); I!=E; ++I)
+ const_cast<BugType*>(*I)->FlushReports(BR);
+
+ // Iterate through the reports and get their nodes.
+ for (BugReporter::iterator I=BR.begin(), E=BR.end(); I!=E; ++I) {
+ for (BugType::const_iterator I2=(*I)->begin(), E2=(*I)->end(); I2!=E2; ++I2) {
+ const BugReportEquivClass& EQ = *I2;
+ const BugReport &R = **EQ.begin();
+ NodeTy *N = const_cast<NodeTy*>(R.getEndNode());
+ if (N) Src.push_back(N);
+ }
+ }
ViewGraph(&Src[0], &Src[0]+Src.size());
}