[analyzer] Skip printing duplicate nodes, even if nodes have multiple predecessors...
authorGeorge Karpenkov <ekarpenkov@apple.com>
Sat, 15 Sep 2018 02:01:26 +0000 (02:01 +0000)
committerGeorge Karpenkov <ekarpenkov@apple.com>
Sat, 15 Sep 2018 02:01:26 +0000 (02:01 +0000)
Still generate a node, but leave the redundant field empty.

Differential Revision: https://reviews.llvm.org/D51821

llvm-svn: 342308

clang/lib/StaticAnalyzer/Core/ExprEngine.cpp

index 638fc5d..a1fcd12 100644 (file)
@@ -3177,7 +3177,12 @@ struct DOTGraphTraits<ExplodedNode*> : public DefaultDOTGraphTraits {
         << ")"
         << " NodeID: " << N->getID(&Graph) << " (" << (const void *)N << ")\\|";
 
-    State->printDOT(Out, N->getLocationContext());
+    bool SameAsAllPredecessors =
+        std::all_of(N->pred_begin(), N->pred_end(), [&](const ExplodedNode *P) {
+          return P->getState() == State;
+        });
+    if (!SameAsAllPredecessors)
+      State->printDOT(Out, N->getLocationContext());
     return Out.str();
   }
 };