[cfe-commits] r54429 - in /cfe/trunk: include/clang/AST/CFG.h lib/AST/CFG.cpp

Ted Kremenek kremenek at apple.com
Wed Aug 6 15:22:32 PDT 2008


Author: kremenek
Date: Wed Aug  6 17:22:32 2008
New Revision: 54429

URL: http://llvm.org/viewvc/llvm-project?rev=54429&view=rev
Log:
Always construct the BumpPtrAllocator used by CFG as an instance variable.

Modified:
    cfe/trunk/include/clang/AST/CFG.h
    cfe/trunk/lib/AST/CFG.cpp

Modified: cfe/trunk/include/clang/AST/CFG.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CFG.h?rev=54429&r1=54428&r2=54429&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/CFG.h (original)
+++ cfe/trunk/include/clang/AST/CFG.h Wed Aug  6 17:22:32 2008
@@ -16,6 +16,7 @@
 #define LLVM_CLANG_CFG_H
 
 #include "llvm/ADT/GraphTraits.h"
+#include "llvm/Support/Allocator.h"
 #include <list>
 #include <vector>
 #include <iosfwd>
@@ -283,9 +284,13 @@
   //===--------------------------------------------------------------------===//
 
   CFG() : Entry(NULL), Exit(NULL), IndirectGotoBlock(NULL), NumBlockIDs(0), 
-          BlkExprMap(NULL), BlkEdgeSet(NULL), Allocator(NULL) {};
+          BlkExprMap(NULL), BlkEdgeSet(NULL) {};
   
   ~CFG();
+  
+  llvm::BumpPtrAllocator& getAllocator() {
+    return Alloc;
+  }
     
 private:
   CFGBlock* Entry;
@@ -308,7 +313,7 @@
   void*     BlkEdgeSet;
   
   /// Alloc - An internal allocator used for BlkEdgeSet.
-  void*     Allocator;
+  llvm::BumpPtrAllocator Alloc;
   
   friend class BlockEdge;
   

Modified: cfe/trunk/lib/AST/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CFG.cpp?rev=54429&r1=54428&r2=54429&view=diff

==============================================================================
--- cfe/trunk/lib/AST/CFG.cpp (original)
+++ cfe/trunk/lib/AST/CFG.cpp Wed Aug  6 17:22:32 2008
@@ -1177,12 +1177,6 @@
 const std::pair<CFGBlock*,CFGBlock*>*
 CFG::getBlockEdgeImpl(const CFGBlock* B1, const CFGBlock* B2) {
   
-  if (!Allocator)
-    Allocator = new llvm::BumpPtrAllocator();
-  
-  llvm::BumpPtrAllocator* Alloc =
-    static_cast<llvm::BumpPtrAllocator*>(Allocator);
-
   if (!BlkEdgeSet)
     BlkEdgeSet = new BlkEdgeSetTy();
     
@@ -1201,13 +1195,13 @@
     assert (llvm::AlignOf<BPairTy>::Alignment_LessEqual_8Bytes);
     
     // Allocate the pair, forcing an 8-byte alignment.
-    BPairTy* pair = (BPairTy*) Alloc->Allocate(sizeof(*pair), 8);
+    BPairTy* pair = (BPairTy*) Alloc.Allocate(sizeof(*pair), 8);
 
     new (pair) BPairTy(const_cast<CFGBlock*>(B1),
                        const_cast<CFGBlock*>(B2));
     
     // Allocate the meta data to store the pair in the FoldingSet.
-    PersistPairTy* ppair = (PersistPairTy*) Alloc->Allocate<PersistPairTy>();
+    PersistPairTy* ppair = (PersistPairTy*) Alloc.Allocate<PersistPairTy>();
     new (ppair) PersistPairTy(pair);
     
     p->InsertNode(ppair, InsertPos);
@@ -1225,7 +1219,6 @@
 CFG::~CFG() {
   delete reinterpret_cast<const BlkExprMapTy*>(BlkExprMap);
   delete reinterpret_cast<BlkEdgeSetTy*>(BlkEdgeSet);
-  delete reinterpret_cast<llvm::BumpPtrAllocator*> (Allocator);
 }
   
 //===----------------------------------------------------------------------===//





More information about the cfe-commits mailing list