diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-09-12 18:09:38 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-09-12 18:09:38 +0000 |
commit | 14c32e8894923eb18d78b461c83b03d70bfd18ac (patch) | |
tree | 5a8513b8ef4e84f8b9dff391a10a61582376a443 /clang/lib/Frontend/ASTUnit.cpp | |
parent | 3405baa3f049fcc07a5f3134289b0ce946166f46 (diff) | |
download | bcm5719-llvm-14c32e8894923eb18d78b461c83b03d70bfd18ac.tar.gz bcm5719-llvm-14c32e8894923eb18d78b461c83b03d70bfd18ac.zip |
[libclang] In ASTUnit::Parse copy the CompilerInvocation object instead of
modifying directly for the preamble.
This avoids an awful, hard to find, bug where "PreprocessorOpts.DisablePCHValidation = true"
would be persistent for subsequent reparses of the translation unit which would result
in defines, present in command-line but not in the PCH, being ignored.
Fixes rdar://9615399.
llvm-svn: 139512
Diffstat (limited to 'clang/lib/Frontend/ASTUnit.cpp')
-rw-r--r-- | clang/lib/Frontend/ASTUnit.cpp | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index a680d9254b3..6f9b4378141 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -879,7 +879,10 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) { llvm::CrashRecoveryContextCleanupRegistrar<CompilerInstance> CICleanup(Clang.get()); - Clang->setInvocation(&*Invocation); + llvm::IntrusiveRefCntPtr<CompilerInvocation> + CCInvocation(new CompilerInvocation(*Invocation)); + + Clang->setInvocation(CCInvocation.getPtr()); OriginalSourceFile = Clang->getFrontendOpts().Inputs[0].second; // Set up diagnostics, capturing any diagnostics that would @@ -942,13 +945,11 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) { PreprocessorOptions &PreprocessorOpts = Clang->getPreprocessorOpts(); PreprocessorOpts.DetailedRecordIncludesNestedMacroExpansions = NestedMacroExpansions; - std::string PriorImplicitPCHInclude; if (OverrideMainBuffer) { PreprocessorOpts.addRemappedFile(OriginalSourceFile, OverrideMainBuffer); PreprocessorOpts.PrecompiledPreambleBytes.first = Preamble.size(); PreprocessorOpts.PrecompiledPreambleBytes.second = PreambleEndsAtStartOfLine; - PriorImplicitPCHInclude = PreprocessorOpts.ImplicitPCHInclude; PreprocessorOpts.ImplicitPCHInclude = PreambleFile; PreprocessorOpts.DisablePCHValidation = true; @@ -967,9 +968,6 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) { // Keep track of the override buffer; SavedMainFileBuffer = OverrideMainBuffer; - } else { - PreprocessorOpts.PrecompiledPreambleBytes.first = 0; - PreprocessorOpts.PrecompiledPreambleBytes.second = false; } llvm::OwningPtr<TopLevelDeclTrackerAction> Act( @@ -1003,21 +1001,11 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) { Act->EndSourceFile(); - // Remove the overridden buffer we used for the preamble. - if (OverrideMainBuffer) { - PreprocessorOpts.eraseRemappedFile( - PreprocessorOpts.remapped_file_buffer_end() - 1); - PreprocessorOpts.ImplicitPCHInclude = PriorImplicitPCHInclude; - } - return false; error: // Remove the overridden buffer we used for the preamble. if (OverrideMainBuffer) { - PreprocessorOpts.eraseRemappedFile( - PreprocessorOpts.remapped_file_buffer_end() - 1); - PreprocessorOpts.ImplicitPCHInclude = PriorImplicitPCHInclude; delete OverrideMainBuffer; SavedMainFileBuffer = 0; } |