r177765 - Revert "[analyzer] Break cycles (optionally) when trimming an ExplodedGraph."

Jordan Rose jordan_rose at apple.com
Fri Mar 22 14:15:33 PDT 2013


Author: jrose
Date: Fri Mar 22 16:15:33 2013
New Revision: 177765

URL: http://llvm.org/viewvc/llvm-project?rev=177765&view=rev
Log:
Revert "[analyzer] Break cycles (optionally) when trimming an ExplodedGraph."

The algorithm used here was ridiculously slow when a potential back-edge
pointed to a node that already had a lot of successors. The previous commit
makes this feature unnecessary anyway.

This reverts r177468 / f4cf6b10f863b9bc716a09b2b2a8c497dcc6aa9b.

Conflicts:

	lib/StaticAnalyzer/Core/BugReporter.cpp

Modified:
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
    cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
    cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h?rev=177765&r1=177764&r2=177765&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h Fri Mar 22 16:15:33 2013
@@ -363,16 +363,12 @@ public:
   ///
   /// \param Nodes The nodes which must appear in the final graph. Presumably
   ///              these are end-of-path nodes (i.e. they have no successors).
-  /// \param BreakCycles Whether or not the trimmed graph should make an effort
-  ///                    to eliminate cycles. Note that this may result in some
-  ///                    unnecessary nodes being included in the final graph
-  ///                    (i.e. nodes that would have only appeared in a cycle).
   /// \param[out] ForwardMap A optional map from nodes in this graph to nodes in
   ///                        the returned graph.
   /// \param[out] InverseMap An optional map from nodes in the returned graph to
   ///                        nodes in this graph.
   /// \returns The trimmed graph
-  ExplodedGraph *trim(ArrayRef<const NodeTy *> Nodes, bool BreakCycles = false,
+  ExplodedGraph *trim(ArrayRef<const NodeTy *> Nodes,
                       InterExplodedGraphMap *ForwardMap = 0,
                       InterExplodedGraphMap *InverseMap = 0) const;
 

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=177765&r1=177764&r2=177765&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Fri Mar 22 16:15:33 2013
@@ -1936,8 +1936,7 @@ TrimmedGraph::TrimmedGraph(const Explode
   // The trimmed graph is created in the body of the constructor to ensure
   // that the DenseMaps have been initialized already.
   InterExplodedGraphMap ForwardMap;
-  G.reset(OriginalGraph->trim(Nodes, /*BreakCycles=*/false,
-                              &ForwardMap, &InverseMap));
+  G.reset(OriginalGraph->trim(Nodes, &ForwardMap, &InverseMap));
 
   // Find the (first) error node in the trimmed graph.  We just need to consult
   // the node map which maps from nodes in the original graph to nodes

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp?rev=177765&r1=177764&r2=177765&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp Fri Mar 22 16:15:33 2013
@@ -331,22 +331,8 @@ ExplodedNode *ExplodedGraph::getNode(con
   return V;
 }
 
-static bool isDescendent(const ExplodedNode *Parent, const ExplodedNode *Child){
-  SmallVector<const ExplodedNode *, 16> WL;
-  WL.push_back(Parent);
-
-  while (!WL.empty()) {
-    const ExplodedNode *N = WL.pop_back_val();
-    if (N == Child)
-      return true;
-    WL.append(N->succ_begin(), N->succ_end());
-  }
-
-  return false;
-}
-
 ExplodedGraph *
-ExplodedGraph::trim(ArrayRef<const NodeTy *> Sinks, bool BreakCycles,
+ExplodedGraph::trim(ArrayRef<const NodeTy *> Sinks,
                     InterExplodedGraphMap *ForwardMap,
                     InterExplodedGraphMap *InverseMap) const{
 
@@ -443,8 +429,7 @@ ExplodedGraph::trim(ArrayRef<const NodeT
          I != E; ++I) {
       Pass2Ty::iterator PI = Pass2.find(*I);
       if (PI != Pass2.end()) {
-        if (!BreakCycles || !isDescendent(PI->second, NewN))
-          const_cast<ExplodedNode *>(PI->second)->addPredecessor(NewN, *G);
+        const_cast<ExplodedNode *>(PI->second)->addPredecessor(NewN, *G);
         continue;
       }
 





More information about the cfe-commits mailing list