As GRState seems general enough, it is time to merge some template classes 
and their impl base classes. This can greatly simply some code of the core 
analysis engine. This patch merges ExplodedNodeImpl into ExplodedNode.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78270 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp
index f00583e..19a031a 100644
--- a/lib/Analysis/BugReporter.cpp
+++ b/lib/Analysis/BugReporter.cpp
@@ -49,17 +49,17 @@
   return 0;
 }
 
-static inline const ExplodedNode<GRState>*
-GetPredecessorNode(const ExplodedNode<GRState>* N) {
+static inline const ExplodedNode*
+GetPredecessorNode(const ExplodedNode* N) {
   return N->pred_empty() ? NULL : *(N->pred_begin());
 }
 
-static inline const ExplodedNode<GRState>*
-GetSuccessorNode(const ExplodedNode<GRState>* N) {
+static inline const ExplodedNode*
+GetSuccessorNode(const ExplodedNode* N) {
   return N->succ_empty() ? NULL : *(N->succ_begin());
 }
 
-static const Stmt* GetPreviousStmt(const ExplodedNode<GRState>* N) {
+static const Stmt* GetPreviousStmt(const ExplodedNode* N) {
   for (N = GetPredecessorNode(N); N; N = GetPredecessorNode(N))
     if (const Stmt *S = GetStmt(N->getLocation()))
       return S;
@@ -67,7 +67,7 @@
   return 0;
 }
 
-static const Stmt* GetNextStmt(const ExplodedNode<GRState>* N) {
+static const Stmt* GetNextStmt(const ExplodedNode* N) {
   for (N = GetSuccessorNode(N); N; N = GetSuccessorNode(N))
     if (const Stmt *S = GetStmt(N->getLocation())) {
       // Check if the statement is '?' or '&&'/'||'.  These are "merges",
@@ -96,7 +96,7 @@
 }
 
 static inline const Stmt*
-GetCurrentOrPreviousStmt(const ExplodedNode<GRState>* N) {  
+GetCurrentOrPreviousStmt(const ExplodedNode* N) {  
   if (const Stmt *S = GetStmt(N->getLocation()))
     return S;
   
@@ -104,7 +104,7 @@
 }
         
 static inline const Stmt*
-GetCurrentOrNextStmt(const ExplodedNode<GRState>* N) {  
+GetCurrentOrNextStmt(const ExplodedNode* N) {  
   if (const Stmt *S = GetStmt(N->getLocation()))
     return S;
           
@@ -115,8 +115,8 @@
 // PathDiagnosticBuilder and its associated routines and helper objects.
 //===----------------------------------------------------------------------===//
 
-typedef llvm::DenseMap<const ExplodedNode<GRState>*,
-const ExplodedNode<GRState>*> NodeBackMap;
+typedef llvm::DenseMap<const ExplodedNode*,
+const ExplodedNode*> NodeBackMap;
 
 namespace {
 class VISIBILITY_HIDDEN NodeMapClosure : public BugReport::NodeResolver {
@@ -125,7 +125,7 @@
   NodeMapClosure(NodeBackMap *m) : M(*m) {}
   ~NodeMapClosure() {}
   
-  const ExplodedNode<GRState>* getOriginalNode(const ExplodedNode<GRState>* N) {
+  const ExplodedNode* getOriginalNode(const ExplodedNode* N) {
     NodeBackMap::iterator I = M.find(N);
     return I == M.end() ? 0 : I->second;
   }
@@ -146,10 +146,10 @@
     addVisitor(R);
   }
   
-  PathDiagnosticLocation ExecutionContinues(const ExplodedNode<GRState>* N);
+  PathDiagnosticLocation ExecutionContinues(const ExplodedNode* N);
   
   PathDiagnosticLocation ExecutionContinues(llvm::raw_string_ostream& os,
-                                            const ExplodedNode<GRState>* N);
+                                            const ExplodedNode* N);
   
   ParentMap& getParentMap() {
     if (PM.get() == 0)
@@ -185,7 +185,7 @@
 } // end anonymous namespace
 
 PathDiagnosticLocation
-PathDiagnosticBuilder::ExecutionContinues(const ExplodedNode<GRState>* N) {
+PathDiagnosticBuilder::ExecutionContinues(const ExplodedNode* N) {
   if (const Stmt *S = GetNextStmt(N))
     return PathDiagnosticLocation(S, getSourceManager());
 
@@ -194,7 +194,7 @@
   
 PathDiagnosticLocation
 PathDiagnosticBuilder::ExecutionContinues(llvm::raw_string_ostream& os,
-                                          const ExplodedNode<GRState>* N) {
+                                          const ExplodedNode* N) {
 
   // Slow, but probably doesn't matter.
   if (os.str().empty())
@@ -327,7 +327,7 @@
 //===----------------------------------------------------------------------===//
 
 static const VarDecl*
-GetMostRecentVarDeclBinding(const ExplodedNode<GRState>* N,
+GetMostRecentVarDeclBinding(const ExplodedNode* N,
                             GRStateManager& VMgr, SVal X) {
   
   for ( ; N ; N = N->pred_empty() ? 0 : *N->pred_begin()) {
@@ -366,14 +366,14 @@
   const GRState* PrevSt;
   const Stmt* S;
   GRStateManager& VMgr;
-  const ExplodedNode<GRState>* Pred;
+  const ExplodedNode* Pred;
   PathDiagnostic& PD; 
   BugReporter& BR;
   
 public:
   
   NotableSymbolHandler(SymbolRef sym, const GRState* prevst, const Stmt* s,
-                       GRStateManager& vmgr, const ExplodedNode<GRState>* pred,
+                       GRStateManager& vmgr, const ExplodedNode* pred,
                        PathDiagnostic& pd, BugReporter& br)
   : Sym(sym), PrevSt(prevst), S(s), VMgr(vmgr), Pred(pred), PD(pd), BR(br) {}
   
@@ -440,12 +440,12 @@
 };
 }
 
-static void HandleNotableSymbol(const ExplodedNode<GRState>* N,
+static void HandleNotableSymbol(const ExplodedNode* N,
                                 const Stmt* S,
                                 SymbolRef Sym, BugReporter& BR,
                                 PathDiagnostic& PD) {
   
-  const ExplodedNode<GRState>* Pred = N->pred_empty() ? 0 : *N->pred_begin();
+  const ExplodedNode* Pred = N->pred_empty() ? 0 : *N->pred_begin();
   const GRState* PrevSt = Pred ? Pred->getState() : 0;
   
   if (!PrevSt)
@@ -463,13 +463,13 @@
 : public StoreManager::BindingsHandler {
   
   llvm::SmallSet<SymbolRef, 10> AlreadyProcessed;
-  const ExplodedNode<GRState>* N;
+  const ExplodedNode* N;
   const Stmt* S;
   GRBugReporter& BR;
   PathDiagnostic& PD;
   
 public:
-  ScanNotableSymbols(const ExplodedNode<GRState>* n, const Stmt* s,
+  ScanNotableSymbols(const ExplodedNode* n, const Stmt* s,
                      GRBugReporter& br, PathDiagnostic& pd)
   : N(n), S(s), BR(br), PD(pd) {}
   
@@ -503,10 +503,10 @@
 
 static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
                                           PathDiagnosticBuilder &PDB,
-                                          const ExplodedNode<GRState> *N) {
+                                          const ExplodedNode *N) {
 
   SourceManager& SMgr = PDB.getSourceManager();
-  const ExplodedNode<GRState>* NextNode = N->pred_empty() 
+  const ExplodedNode* NextNode = N->pred_empty() 
                                         ? NULL : *(N->pred_begin());
   while (NextNode) {
     N = NextNode;    
@@ -1113,12 +1113,12 @@
 
 static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD,
                                             PathDiagnosticBuilder &PDB,
-                                            const ExplodedNode<GRState> *N) {
+                                            const ExplodedNode *N) {
   
   
   EdgeBuilder EB(PD, PDB);
 
-  const ExplodedNode<GRState>* NextNode = N->pred_empty() 
+  const ExplodedNode* NextNode = N->pred_empty() 
                                         ? NULL : *(N->pred_begin());
   while (NextNode) {
     N = NextNode;
@@ -1221,7 +1221,7 @@
 
 PathDiagnosticPiece*
 BugReport::getEndPath(BugReporterContext& BRC,
-                      const ExplodedNode<GRState>* EndPathNode) {
+                      const ExplodedNode* EndPathNode) {
   
   const Stmt* S = getStmt(BRC.getBugReporter());
   
@@ -1269,8 +1269,8 @@
   return FullSourceLoc();
 }
 
-PathDiagnosticPiece* BugReport::VisitNode(const ExplodedNode<GRState>* N,
-                                          const ExplodedNode<GRState>* PrevN,
+PathDiagnosticPiece* BugReport::VisitNode(const ExplodedNode* N,
+                                          const ExplodedNode* PrevN,
                                           BugReporterContext &BRC) {
   return NULL;
 }
@@ -1333,17 +1333,17 @@
 //===----------------------------------------------------------------------===//
 
 static std::pair<std::pair<ExplodedGraph<GRState>*, NodeBackMap*>,
-                 std::pair<ExplodedNode<GRState>*, unsigned> >
+                 std::pair<ExplodedNode*, unsigned> >
 MakeReportGraph(const ExplodedGraph<GRState>* G,
-                const ExplodedNode<GRState>** NStart,
-                const ExplodedNode<GRState>** NEnd) {
+                const ExplodedNode** NStart,
+                const ExplodedNode** NEnd) {
   
   // Create the trimmed graph.  It will contain the shortest paths from the
   // error nodes to the root.  In the new graph we should only have one 
   // error node unless there are two or more error nodes with the same minimum
   // path length.
   ExplodedGraph<GRState>* GTrim;
-  InterExplodedGraphMap<GRState>* NMap;
+  InterExplodedGraphMap* NMap;
 
   llvm::DenseMap<const void*, const void*> InverseMap;
   llvm::tie(GTrim, NMap) = G->Trim(NStart, NEnd, &InverseMap);
@@ -1351,18 +1351,18 @@
   // Create owning pointers for GTrim and NMap just to ensure that they are
   // released when this function exists.
   llvm::OwningPtr<ExplodedGraph<GRState> > AutoReleaseGTrim(GTrim);
-  llvm::OwningPtr<InterExplodedGraphMap<GRState> > AutoReleaseNMap(NMap);
+  llvm::OwningPtr<InterExplodedGraphMap> AutoReleaseNMap(NMap);
   
   // Find the (first) error node in the trimmed graph.  We just need to consult
   // the node map (NMap) which maps from nodes in the original graph to nodes
   // in the new graph.
 
-  std::queue<const ExplodedNode<GRState>*> WS;
-  typedef llvm::DenseMap<const ExplodedNode<GRState>*,unsigned> IndexMapTy;
+  std::queue<const ExplodedNode*> WS;
+  typedef llvm::DenseMap<const ExplodedNode*,unsigned> IndexMapTy;
   IndexMapTy IndexMap;
 
-  for (const ExplodedNode<GRState>** I = NStart; I != NEnd; ++I)
-    if (const ExplodedNode<GRState> *N = NMap->getMappedNode(*I)) {
+  for (const ExplodedNode** I = NStart; I != NEnd; ++I)
+    if (const ExplodedNode *N = NMap->getMappedNode(*I)) {
       unsigned NodeIndex = (I - NStart) / sizeof(*I);
       WS.push(N);
       IndexMap[*I] = NodeIndex;
@@ -1382,10 +1382,10 @@
   llvm::DenseMap<const void*,unsigned> Visited;
   
   unsigned cnt = 0;
-  const ExplodedNode<GRState>* Root = 0;
+  const ExplodedNode* Root = 0;
   
   while (!WS.empty()) {
-    const ExplodedNode<GRState>* Node = WS.front();
+    const ExplodedNode* Node = WS.front();
     WS.pop();
     
     if (Visited.find(Node) != Visited.end())
@@ -1398,7 +1398,7 @@
       break;
     }
     
-    for (ExplodedNode<GRState>::const_pred_iterator I=Node->pred_begin(),
+    for (ExplodedNode::const_pred_iterator I=Node->pred_begin(),
          E=Node->pred_end(); I!=E; ++I)
       WS.push(*I);
   }
@@ -1407,24 +1407,24 @@
   
   // Now walk from the root down the BFS path, always taking the successor
   // with the lowest number.
-  ExplodedNode<GRState> *Last = 0, *First = 0;  
+  ExplodedNode *Last = 0, *First = 0;  
   NodeBackMap *BM = new NodeBackMap();
   unsigned NodeIndex = 0;
   
-  for ( const ExplodedNode<GRState> *N = Root ;;) {
+  for ( const ExplodedNode *N = Root ;;) {
     // Lookup the number associated with the current node.
     llvm::DenseMap<const void*,unsigned>::iterator I = Visited.find(N);
     assert(I != Visited.end());
     
     // Create the equivalent node in the new graph with the same state
     // and location.
-    ExplodedNode<GRState>* NewN =
+    ExplodedNode* NewN =
       GNew->getNode(N->getLocation(), N->getState());
     
     // Store the mapping to the original node.
     llvm::DenseMap<const void*, const void*>::iterator IMitr=InverseMap.find(N);
     assert(IMitr != InverseMap.end() && "No mapping to original node.");
-    (*BM)[NewN] = (const ExplodedNode<GRState>*) IMitr->second;
+    (*BM)[NewN] = (const ExplodedNode*) IMitr->second;
     
     // Link up the new node with the previous node.
     if (Last)
@@ -1434,7 +1434,7 @@
     
     // Are we at the final node?
     IndexMapTy::iterator IMI =
-      IndexMap.find((const ExplodedNode<GRState>*)(IMitr->second));
+      IndexMap.find((const ExplodedNode*)(IMitr->second));
     if (IMI != IndexMap.end()) {
       First = NewN;
       NodeIndex = IMI->second;
@@ -1443,8 +1443,8 @@
     
     // Find the next successor node.  We choose the node that is marked
     // with the lowest DFS number.
-    ExplodedNode<GRState>::const_succ_iterator SI = N->succ_begin();
-    ExplodedNode<GRState>::const_succ_iterator SE = N->succ_end();
+    ExplodedNode::const_succ_iterator SI = N->succ_begin();
+    ExplodedNode::const_succ_iterator SE = N->succ_end();
     N = 0;
     
     for (unsigned MinVal = 0; SI != SE; ++SI) {
@@ -1564,10 +1564,10 @@
 void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD,
                                            BugReportEquivClass& EQ) {
  
-  std::vector<const ExplodedNode<GRState>*> Nodes;
+  std::vector<const ExplodedNode*> Nodes;
   
   for (BugReportEquivClass::iterator I=EQ.begin(), E=EQ.end(); I!=E; ++I) {
-    const ExplodedNode<GRState>* N = I->getEndNode();
+    const ExplodedNode* N = I->getEndNode();
     if (N) Nodes.push_back(N);
   }
   
@@ -1577,7 +1577,7 @@
   // Construct a new graph that contains only a single path from the error
   // node to a root.  
   const std::pair<std::pair<ExplodedGraph<GRState>*, NodeBackMap*>,
-  std::pair<ExplodedNode<GRState>*, unsigned> >&
+  std::pair<ExplodedNode*, unsigned> >&
   GPair = MakeReportGraph(&getGraph(), &Nodes[0], &Nodes[0] + Nodes.size());
   
   // Find the BugReport with the original location.
@@ -1590,7 +1590,7 @@
   
   llvm::OwningPtr<ExplodedGraph<GRState> > ReportGraph(GPair.first.first);
   llvm::OwningPtr<NodeBackMap> BackMap(GPair.first.second);
-  const ExplodedNode<GRState> *N = GPair.second.first;
+  const ExplodedNode *N = GPair.second.first;
  
   // Start building the path diagnostic... 
   PathDiagnosticBuilder PDB(*this, R, BackMap.get(), getPathDiagnosticClient());