Add 'UseBumpPtrAllocator' flag to ASTUnit::LoadFromPCHFile() to cause the created ASTContext to use

its own BumpPtrAllocator to allocate ASTs.

Change clang_createTranslationUnit (CIndex) to pass 'UseBumpPtrAllocator = true' to
ASTUnit::LoadFromPCHFile().

llvm-svn: 84296
This commit is contained in:
Ted Kremenek 2009-10-17 00:34:24 +00:00
parent 0d3d9ee03e
commit 8bcb1c6883
3 changed files with 7 additions and 4 deletions

View File

@ -88,7 +88,8 @@ public:
Diagnostic &Diags,
FileManager &FileMgr,
std::string *ErrMsg = 0,
bool OnlyLocalDecls = false);
bool OnlyLocalDecls = false,
bool UseBumpAllocator = false);
};
} // namespace clang

View File

@ -95,7 +95,8 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
Diagnostic &Diags,
FileManager &FileMgr,
std::string *ErrMsg,
bool OnlyLocalDecls) {
bool OnlyLocalDecls,
bool UseBumpAllocator) {
llvm::OwningPtr<ASTUnit> AST(new ASTUnit(Diags));
AST->OnlyLocalDecls = OnlyLocalDecls;
AST->HeaderInfo.reset(new HeaderSearch(FileMgr));
@ -146,7 +147,7 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
PP.getIdentifierTable(),
PP.getSelectorTable(),
PP.getBuiltinInfo(),
/* FreeMemory = */ true,
/* FreeMemory = */ !UseBumpAllocator,
/* size_reserve = */0));
ASTContext &Context = *AST->Ctx.get();

View File

@ -323,7 +323,8 @@ CXTranslationUnit clang_createTranslationUnit(
return ASTUnit::LoadFromPCHFile(astName, CXXIdx->getDiagnostics(),
CXXIdx->getFileManager(), &ErrMsg,
CXXIdx->getOnlyLocalDecls());
CXXIdx->getOnlyLocalDecls(),
/* UseBumpAllocator = */ true);
}
CXTranslationUnit clang_createTranslationUnitFromSourceFile(