From: Ted Kremenek Date: Sat, 17 Oct 2009 00:34:24 +0000 (+0000) Subject: Add 'UseBumpPtrAllocator' flag to ASTUnit::LoadFromPCHFile() to cause the created... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5cf48766d626ff6b223acc9d4b7e415ca8480836;p=clang 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(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84296 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h index 0ce473f2af..dd3db39343 100644 --- a/include/clang/Frontend/ASTUnit.h +++ b/include/clang/Frontend/ASTUnit.h @@ -88,7 +88,8 @@ public: Diagnostic &Diags, FileManager &FileMgr, std::string *ErrMsg = 0, - bool OnlyLocalDecls = false); + bool OnlyLocalDecls = false, + bool UseBumpAllocator = false); }; } // namespace clang diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index 15002385a8..7ee6648699 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -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 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(); diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp index d0638d0772..d355025da9 100644 --- a/tools/CIndex/CIndex.cpp +++ b/tools/CIndex/CIndex.cpp @@ -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(