[cfe-commits] r62347 - /cfe/trunk/lib/Lex/PPDirectives.cpp
Chris Lattner
sabre at nondot.org
Fri Jan 16 11:50:11 PST 2009
Author: lattner
Date: Fri Jan 16 13:50:11 2009
New Revision: 62347
URL: http://llvm.org/viewvc/llvm-project?rev=62347&view=rev
Log:
As a performance optimization, don't bother calling MacroInfo::isIdenticalTo
if warnings in system headers are disabled. isIdenticalTo can end up
calling the expensive getSpelling method, and other bad stuff and is
completely unneeded if the warning will be discarded anyway. rdar://6502956
Modified:
cfe/trunk/lib/Lex/PPDirectives.cpp
Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=62347&r1=62346&r2=62347&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Fri Jan 16 13:50:11 2009
@@ -1060,16 +1060,23 @@
// Finally, if this identifier already had a macro defined for it, verify that
// the macro bodies are identical and free the old definition.
if (MacroInfo *OtherMI = getMacroInfo(MacroNameTok.getIdentifierInfo())) {
- if (!OtherMI->isUsed())
- Diag(OtherMI->getDefinitionLoc(), diag::pp_macro_not_used);
-
- // Macros must be identical. This means all tokes and whitespace separation
- // must be the same. C99 6.10.3.2.
- if (!MI->isIdenticalTo(*OtherMI, *this)) {
- Diag(MI->getDefinitionLoc(), diag::ext_pp_macro_redef)
- << MacroNameTok.getIdentifierInfo();
- Diag(OtherMI->getDefinitionLoc(), diag::note_previous_definition);
+ // It is very common for system headers to have tons of macro redefinitions
+ // and for warnings to be disabled in system headers. If this is the case,
+ // then don't bother calling MacroInfo::isIdenticalTo.
+ if (!Diags.getSuppressSystemWarnings() ||
+ !SourceMgr.isInSystemHeader(DefineTok.getLocation())) {
+ if (!OtherMI->isUsed())
+ Diag(OtherMI->getDefinitionLoc(), diag::pp_macro_not_used);
+
+ // Macros must be identical. This means all tokes and whitespace
+ // separation must be the same. C99 6.10.3.2.
+ if (!MI->isIdenticalTo(*OtherMI, *this)) {
+ Diag(MI->getDefinitionLoc(), diag::ext_pp_macro_redef)
+ << MacroNameTok.getIdentifierInfo();
+ Diag(OtherMI->getDefinitionLoc(), diag::note_previous_definition);
+ }
}
+
ReleaseMacroInfo(OtherMI);
}
More information about the cfe-commits
mailing list