summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-07-01 18:22:13 +0000
committerDouglas Gregor <dgregor@apple.com>2011-07-01 18:22:13 +0000
commit3cc1581020a7d3ad21455b3fd1cf3f999270fd3b (patch)
tree0f387b2d4738517dfb51366ce29ccc4f514c62c0 /clang/lib/Frontend
parent703a0fbf390bae4a6c087fb28f40e0b8e21644e5 (diff)
downloadbcm5719-llvm-3cc1581020a7d3ad21455b3fd1cf3f999270fd3b.tar.gz
bcm5719-llvm-3cc1581020a7d3ad21455b3fd1cf3f999270fd3b.zip
When we create a precompiled preamble, don't copy the
CompilerInvocation on the stack, because other objects (e.g., the CompilerInstance) maintain an intrusive reference-counted pointer to the CompilerInvocation. This doesn't matter in the normal case, because we take back the CompilerInvocation. However, during crash recovery, this leads to us trying to free an object on the stack, and hilarity ensues. Fixes <rdar://problem/9652540>. llvm-svn: 134245
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 8827116f2e4..86a9a351d25 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -1150,16 +1150,19 @@ static llvm::MemoryBuffer *CreatePaddedMainFileBuffer(llvm::MemoryBuffer *Old,
/// buffer that should be used in place of the main file when doing so.
/// Otherwise, returns a NULL pointer.
llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble(
- CompilerInvocation PreambleInvocation,
+ const CompilerInvocation &PreambleInvocationIn,
bool AllowRebuild,
unsigned MaxLines) {
- FrontendOptions &FrontendOpts = PreambleInvocation.getFrontendOpts();
+
+ llvm::IntrusiveRefCntPtr<CompilerInvocation>
+ PreambleInvocation(new CompilerInvocation(PreambleInvocationIn));
+ FrontendOptions &FrontendOpts = PreambleInvocation->getFrontendOpts();
PreprocessorOptions &PreprocessorOpts
- = PreambleInvocation.getPreprocessorOpts();
+ = PreambleInvocation->getPreprocessorOpts();
bool CreatedPreambleBuffer = false;
std::pair<llvm::MemoryBuffer *, std::pair<unsigned, bool> > NewPreamble
- = ComputePreamble(PreambleInvocation, MaxLines, CreatedPreambleBuffer);
+ = ComputePreamble(*PreambleInvocation, MaxLines, CreatedPreambleBuffer);
// If ComputePreamble() Take ownership of the
llvm::OwningPtr<llvm::MemoryBuffer> OwnedPreambleBuffer;
@@ -1260,7 +1263,7 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble(
// have occurred in the preamble.
getDiagnostics().Reset();
ProcessWarningOptions(getDiagnostics(),
- PreambleInvocation.getDiagnosticOpts());
+ PreambleInvocation->getDiagnosticOpts());
getDiagnostics().setNumWarnings(NumWarningsInPreamble);
if (StoredDiagnostics.size() > NumStoredDiagnosticsInPreamble)
StoredDiagnostics.erase(
@@ -1357,7 +1360,7 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble(
llvm::CrashRecoveryContextCleanupRegistrar<CompilerInstance>
CICleanup(Clang.get());
- Clang->setInvocation(&PreambleInvocation);
+ Clang->setInvocation(&*PreambleInvocation);
OriginalSourceFile = Clang->getFrontendOpts().Inputs[0].second;
// Set up diagnostics, capturing all of the diagnostics produced.
OpenPOWER on IntegriCloud