From f50f7b2c6553c871bb7e2c9b278beadf973a9135 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Thu, 3 Nov 2011 20:28:19 +0000 Subject: [libclang] Fix crash when a #pragma diagnostic is included in the preamble. A PCH file keeps track of #pragma diagnostics state; when loading the preamble, they conflicted with the #pragma diagnostic state already present in the DiagnosticsEngine object due to parsing the preamble. Fix this by clearing the state of the DiagnosticsEngine object. Fixes rdar://10363572 && http://llvm.org/PR11254. llvm-svn: 143644 --- clang/lib/Frontend/ASTUnit.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'clang/lib/Frontend') diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index 015e92dfcd7..0dd3a38da47 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -1388,8 +1388,6 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble( // Set the state of the diagnostic object to mimic its state // after parsing the preamble. - // FIXME: This won't catch any #pragma push warning changes that - // have occurred in the preamble. getDiagnostics().Reset(); ProcessWarningOptions(getDiagnostics(), PreambleInvocation->getDiagnosticOpts()); @@ -1940,11 +1938,9 @@ bool ASTUnit::Reparse(RemappedFile *RemappedFiles, unsigned NumRemappedFiles) { OverrideMainBuffer = getMainBufferWithPrecompiledPreamble(*Invocation); // Clear out the diagnostics state. - if (!OverrideMainBuffer) { - getDiagnostics().Reset(); - ProcessWarningOptions(getDiagnostics(), Invocation->getDiagnosticOpts()); - } - + getDiagnostics().Reset(); + ProcessWarningOptions(getDiagnostics(), Invocation->getDiagnosticOpts()); + // Parse the sources bool Result = Parse(OverrideMainBuffer); -- cgit v1.2.3