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
diag-pragma.diff
Description: Binary data
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
