[cfe-commits] r143644 - in /cfe/trunk: lib/Frontend/ASTUnit.cpp test/Index/pragma-diag-reparse.c
Argyrios Kyrtzidis
kyrtzidis at apple.com
Mon Nov 7 09:17:04 PST 2011
On Nov 7, 2011, at 8:04 AM, Matthias Kleine wrote:
> This still asserts when including a file that uses pragma diagnostic, if pragma diagnostic is used before the include. See the attached patch for a test.
Thanks for the test case, this appears to be another, PCH issue.
>
> Cheers,
> Matthias
>
> <pragma_reparse_crash_test2.patch>
> On Nov 3, 2011, at 9:28 PM, Argyrios Kyrtzidis wrote:
>
>> 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]
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
More information about the cfe-commits
mailing list