#define LLVM_CLANG_CFG_H
#include "llvm/ADT/GraphTraits.h"
+#include "llvm/Support/Allocator.h"
#include <list>
#include <vector>
#include <iosfwd>
//===--------------------------------------------------------------------===//
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;
void* BlkEdgeSet;
/// Alloc - An internal allocator used for BlkEdgeSet.
- void* Allocator;
+ llvm::BumpPtrAllocator Alloc;
friend class BlockEdge;
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();
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);
CFG::~CFG() {
delete reinterpret_cast<const BlkExprMapTy*>(BlkExprMap);
delete reinterpret_cast<BlkEdgeSetTy*>(BlkEdgeSet);
- delete reinterpret_cast<llvm::BumpPtrAllocator*> (Allocator);
}
//===----------------------------------------------------------------------===//