From ce1eb34bbea1e0408f1952776d7d52ccde1bd275 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Wed, 6 Aug 2008 22:22:32 +0000 Subject: [PATCH] Always construct the BumpPtrAllocator used by CFG as an instance variable. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54429 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/CFG.h | 9 +++++++-- lib/AST/CFG.cpp | 11 ++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/include/clang/AST/CFG.h b/include/clang/AST/CFG.h index 9f5d9d0e57..b9ceee0836 100644 --- a/include/clang/AST/CFG.h +++ b/include/clang/AST/CFG.h @@ -16,6 +16,7 @@ #define LLVM_CLANG_CFG_H #include "llvm/ADT/GraphTraits.h" +#include "llvm/Support/Allocator.h" #include #include #include @@ -283,9 +284,13 @@ public: //===--------------------------------------------------------------------===// 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 @@ private: void* BlkEdgeSet; /// Alloc - An internal allocator used for BlkEdgeSet. - void* Allocator; + llvm::BumpPtrAllocator Alloc; friend class BlockEdge; diff --git a/lib/AST/CFG.cpp b/lib/AST/CFG.cpp index 9f87dc6adf..ffc42bb6e1 100644 --- a/lib/AST/CFG.cpp +++ b/lib/AST/CFG.cpp @@ -1177,12 +1177,6 @@ typedef llvm::FoldingSet BlkEdgeSetTy; const std::pair* CFG::getBlockEdgeImpl(const CFGBlock* B1, const CFGBlock* B2) { - if (!Allocator) - Allocator = new llvm::BumpPtrAllocator(); - - llvm::BumpPtrAllocator* Alloc = - static_cast(Allocator); - if (!BlkEdgeSet) BlkEdgeSet = new BlkEdgeSetTy(); @@ -1201,13 +1195,13 @@ CFG::getBlockEdgeImpl(const CFGBlock* B1, const CFGBlock* B2) { assert (llvm::AlignOf::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(B1), const_cast(B2)); // Allocate the meta data to store the pair in the FoldingSet. - PersistPairTy* ppair = (PersistPairTy*) Alloc->Allocate(); + PersistPairTy* ppair = (PersistPairTy*) Alloc.Allocate(); new (ppair) PersistPairTy(pair); p->InsertNode(ppair, InsertPos); @@ -1225,7 +1219,6 @@ CFG::getBlockEdgeImpl(const CFGBlock* B1, const CFGBlock* B2) { CFG::~CFG() { delete reinterpret_cast(BlkExprMap); delete reinterpret_cast(BlkEdgeSet); - delete reinterpret_cast (Allocator); } //===----------------------------------------------------------------------===// -- 2.40.0