[cfe-commits] r143644 - in /cfe/trunk: lib/Frontend/ASTUnit.cpp test/Index/pragma-diag-reparse.c

Argyrios Kyrtzidis akyrtzi at gmail.com
Thu Nov 3 13:28:19 PDT 2011


Author: akirtzidis
Date: Thu Nov  3 15:28:19 2011
New Revision: 143644

URL: http://llvm.org/viewvc/llvm-project?rev=143644&view=rev
Log:
[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.

Modified:
    cfe/trunk/lib/Frontend/ASTUnit.cpp
    cfe/trunk/test/Index/pragma-diag-reparse.c

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=143644&r1=143643&r2=143644&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu Nov  3 15:28:19 2011
@@ -1388,8 +1388,6 @@
 
         // 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 @@
     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);
   

Modified: cfe/trunk/test/Index/pragma-diag-reparse.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/pragma-diag-reparse.c?rev=143644&r1=143643&r2=143644&view=diff
==============================================================================
--- cfe/trunk/test/Index/pragma-diag-reparse.c (original)
+++ cfe/trunk/test/Index/pragma-diag-reparse.c Thu Nov  3 15:28:19 2011
@@ -1,13 +1,18 @@
-// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local %s | FileCheck %s
+#pragma clang diagnostic ignored "-Wtautological-compare"
 
 int main (int argc, const char * argv[])
 {
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
-  int x;
+  int x=0;
 #pragma clang diagnostic pop
 
-  return 0;
+  return x;
 }
 
-// CHECK: pragma-diag-reparse.c:7:7: VarDecl=x:7:7 (Definition) Extent=[7:3 - 7:8]
+void foo() { int b=0; while (b==b); }
+
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source-reparse 5 local \
+// RUN:   %s -Wall -Werror | FileCheck %s
+
+// CHECK: pragma-diag-reparse.c:7:7: VarDecl=x:7:7 (Definition) Extent=[7:3 - 7:10]





More information about the cfe-commits mailing list