diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index fed3c1b770383..2d9c53cdf5bde 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -2829,17 +2829,18 @@ class Preprocessor { } void emitMacroExpansionWarnings(const Token &Identifier) const { - if (Identifier.getIdentifierInfo()->isDeprecatedMacro()) + IdentifierInfo *Info = Identifier.getIdentifierInfo(); + if (Info->isDeprecatedMacro()) emitMacroDeprecationWarning(Identifier); - if (Identifier.getIdentifierInfo()->isRestrictExpansion() && + if (Info->isRestrictExpansion() && !SourceMgr.isInMainFile(Identifier.getLocation())) emitRestrictExpansionWarning(Identifier); - if (Identifier.getIdentifierInfo()->getName() == "INFINITY") + if (Info->getName() == "INFINITY") if (getLangOpts().NoHonorInfs) emitRestrictInfNaNWarning(Identifier, 0); - if (Identifier.getIdentifierInfo()->getName() == "NAN") + if (Info->getName() == "NAN") if (getLangOpts().NoHonorNaNs) emitRestrictInfNaNWarning(Identifier, 1); }