[cfe-commits] [PATCH] Fix broken diagnostic pragmas

Argyrios Kyrtzidis kyrtzidis at apple.com
Wed Nov 10 19:34:59 PST 2010


Diagnostic pragmas are broken because we don't keep track of the diagnostic state changes and we only check the current/latest state.
Problems manifest if a diagnostic is emitted for a source line that has different diagnostic state than the current state; this can affect
a lot of places, like C++ inline methods, template instantiations, the lexer, etc. For example:

struct S {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wtautological-compare"
	void m() { int b = b==b; }
#pragma clang diagnostic pop
};

the pragmas do not work for suppressing the warning in the above case.

The attached patch fixes the issue by having the Diagnostic object keep track of the source location of the pragmas so that it is able to know what is the diagnostic state at any given source location.

I've also made measurements to see how this fix impacts performance. I basically measured how long it takes to do a -fsyntax-only over the llvm/clang codebase and the results were:

before the fix: 722.83 sec
after the fix: 727.24 sec

So avoiding the fix only provides a 0.6% gain.

Please review.

-Argiris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: diag-pragma.diff
Type: application/octet-stream
Size: 39328 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20101110/dc2ac678/attachment.obj>
-------------- next part --------------




More information about the cfe-commits mailing list