[cfe-commits] r62347 - /cfe/trunk/lib/Lex/PPDirectives.cpp
Daniel Dunbar
daniel at zuster.org
Fri Jan 16 12:04:13 PST 2009
Nice; one question though: I suspect this is not the only place we are
doing such things. Did you audit Sema at all for this kind of stuff?
We have -suppress-system-warnings=false to show when we are emitting
diagnostics that get ignored, but there is no way to see places where
we do needless computation without manual inspection...
- Daniel
On Fri, Jan 16, 2009 at 11:50 AM, Chris Lattner <sabre at nondot.org> wrote:
> 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);
> }
>
>
>
> _______________________________________________
> 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