This brings ASTContext closer to LLVM's Allocator concept. Ideally we
would just derive ASTContext from llvm::AllocatorBase, but that does
not work because ASTContext's allocator is mutable and we allocate using
const ASTContext& everywhere.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243972
91177308-0d34-0410-b5e6-
96231b3b80d8
void *Allocate(size_t Size, unsigned Align = 8) const {
return BumpAlloc.Allocate(Size, Align);
}
+ template <typename T> T *Allocate(size_t Num = 1) const {
+ return static_cast<T *>(Allocate(Num * sizeof(T), llvm::alignOf<T>()));
+ }
void Deallocate(void *Ptr) const { }
/// Return the total amount of physical memory allocated for representing
}
static StringRef copyIntoContext(const ASTContext &C, StringRef str) {
- return str.copy(C.getAllocator());
+ return str.copy(C);
}
void MSAsmStmt::initialize(const ASTContext &C, StringRef asmstr,