ProgramPoint now takes the space of two pointers instead of one. This change was
motivated because it became clear that the number of subclasses of ProgramPoint
would expand and we ran out of bits to represent a pointer variant. As a plus of
this change, BlockEdge program points can now be represented explicitly without
using a cache of CFGBlock* pairs in CFG.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56245 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp
index 7e3db7a..b163eea 100644
--- a/lib/Analysis/BugReporter.cpp
+++ b/lib/Analysis/BugReporter.cpp
@@ -689,13 +689,10 @@
 }
 
 bool BugTypeCacheLocation::isCached(ProgramPoint P) {
-  
-  void* p = P.getRawData();
-  
-  if (CachedErrors.count(p))
+  if (CachedErrors.count(P))
     return true;
   
-  CachedErrors.insert(p);  
+  CachedErrors.insert(P);  
   return false;
 }
 
diff --git a/lib/Analysis/GRCoreEngine.cpp b/lib/Analysis/GRCoreEngine.cpp
index a7e1458..84a8d55 100644
--- a/lib/Analysis/GRCoreEngine.cpp
+++ b/lib/Analysis/GRCoreEngine.cpp
@@ -69,7 +69,7 @@
     
     // Construct an edge representing the
     // starting location in the function.
-    BlockEdge StartLoc(getCFG(), Entry, Succ);
+    BlockEdge StartLoc(Entry, Succ);
     
     // Set the current block counter to being empty.
     WList->setBlockCounter(BCounterFactory.GetEmptyCounter());
@@ -230,7 +230,7 @@
   assert (B->succ_size() == 1 &&
           "Blocks with no terminator should have at most 1 successor.");
     
-  GenerateNode(BlockEdge(getCFG(),B,*(B->succ_begin())), Pred->State, Pred);
+  GenerateNode(BlockEdge(B, *(B->succ_begin())), Pred->State, Pred);
 }
 
 void GRCoreEngineImpl::HandleBranch(Expr* Cond, Stmt* Term, CFGBlock * B,
@@ -350,8 +350,7 @@
   bool IsNew;
   
   ExplodedNodeImpl* Succ =
-    Eng.G->getNodeImpl(BlockEdge(Eng.getCFG(), Src, branch ? DstT : DstF),
-                       State, &IsNew);
+    Eng.G->getNodeImpl(BlockEdge(Src, branch ? DstT : DstF), State, &IsNew);
   
   Succ->addPredecessor(Pred);
   
@@ -382,8 +381,7 @@
   bool IsNew;
   
   ExplodedNodeImpl* Succ =
-    Eng.G->getNodeImpl(BlockEdge(Eng.getCFG(), Src, I.getBlock(), true),
-                       St, &IsNew);
+    Eng.G->getNodeImpl(BlockEdge(Src, I.getBlock()), St, &IsNew);
               
   Succ->addPredecessor(Pred);
   
@@ -407,9 +405,8 @@
 
   bool IsNew;
   
-  ExplodedNodeImpl* Succ = Eng.G->getNodeImpl(BlockEdge(Eng.getCFG(), Src,
-                                                        I.getBlock()),
-                                              St, &IsNew);  
+  ExplodedNodeImpl* Succ = Eng.G->getNodeImpl(BlockEdge(Src, I.getBlock()),
+                                                St, &IsNew);  
   Succ->addPredecessor(Pred);
   
   if (IsNew) {
@@ -431,9 +428,8 @@
   
   bool IsNew;
   
-  ExplodedNodeImpl* Succ = Eng.G->getNodeImpl(BlockEdge(Eng.getCFG(), Src,
-                                                        DefaultBlock),
-                                              St, &IsNew);  
+  ExplodedNodeImpl* Succ = Eng.G->getNodeImpl(BlockEdge(Src, DefaultBlock),
+                                                St, &IsNew);  
   Succ->addPredecessor(Pred);
   
   if (IsNew) {
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index d8c0320..aa5ab6a 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -2324,17 +2324,16 @@
 static void AddSources(std::vector<GRExprEngine::NodeTy*>& Sources,
                        ITERATOR I, ITERATOR E) {
   
-  llvm::SmallPtrSet<void*,10> CachedSources;
+  llvm::SmallSet<ProgramPoint,10> CachedSources;
   
   for ( ; I != E; ++I ) {
     GRExprEngine::NodeTy* N = GetGraphNode(I);
-    void* p = N->getLocation().getRawData();
+    ProgramPoint P = N->getLocation();
     
-    if (CachedSources.count(p))
+    if (CachedSources.count(P))
       continue;
     
-    CachedSources.insert(p);
-    
+    CachedSources.insert(P);    
     Sources.push_back(N);
   }
 }
diff --git a/lib/Analysis/ProgramPoint.cpp b/lib/Analysis/ProgramPoint.cpp
deleted file mode 100644
index d95680f..0000000
--- a/lib/Analysis/ProgramPoint.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-//= ProgramPoint.cpp - Program Points for Path-Sensitive Analysis --*- C++ -*-//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-//  This file implements methods for subclasses of ProgramPoint.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/AST/CFG.h"
-#include "clang/Analysis/ProgramPoint.h"
-
-using namespace clang;
-
-BlockEdge::BlockEdge(CFG& cfg, const CFGBlock* B1, const CFGBlock* B2) {    
-  if (B1->succ_size() == 1) {
-    assert (*(B1->succ_begin()) == B2);
-    setRawData(B1, BlockEdgeSrcKind);
-  }
-  else if (B2->pred_size() == 1) {
-    assert (*(B2->pred_begin()) == B1);
-    setRawData(B2, BlockEdgeDstKind);
-  }
-  else 
-    setRawData(cfg.getBlockEdgeImpl(B1,B2), BlockEdgeAuxKind);
-}
-
-CFGBlock* BlockEdge::getSrc() const {
-  switch (getKind()) {
-    default:
-      assert (false && "Invalid BlockEdgeKind.");
-      return NULL;
-      
-    case BlockEdgeSrcKind:
-      return reinterpret_cast<CFGBlock*>(getRawPtr());
-      
-    case BlockEdgeDstKind:
-      return *(reinterpret_cast<CFGBlock*>(getRawPtr())->pred_begin());        
-      
-    case BlockEdgeAuxKind:
-      return reinterpret_cast<BPair*>(getRawPtr())->first;
-  }
-}
-
-CFGBlock* BlockEdge::getDst() const {
-  switch (getKind()) {
-    default:
-      assert (false && "Invalid BlockEdgeKind.");
-      return NULL;
-      
-    case BlockEdgeSrcKind:
-      return *(reinterpret_cast<CFGBlock*>(getRawPtr())->succ_begin());
-      
-    case BlockEdgeDstKind:
-      return reinterpret_cast<CFGBlock*>(getRawPtr());
-      
-    case BlockEdgeAuxKind:
-      return reinterpret_cast<BPair*>(getRawPtr())->second;
-  }
-}