Index: include/clang/Lex/Preprocessor.h =================================================================== --- include/clang/Lex/Preprocessor.h +++ include/clang/Lex/Preprocessor.h @@ -939,11 +939,11 @@ void setPredefines(const char *P) { Predefines = P; } void setPredefines(StringRef P) { Predefines = P; } - /// Return information about the specified preprocessor - /// identifier token. - IdentifierInfo *getIdentifierInfo(StringRef Name) const { - return &Identifiers.get(Name); - } + /// Return information about the specified preprocessor identifier token. + /// If \p CheckOutOfDate is true, then the returned information is ensured + /// to be not out of date. + IdentifierInfo *getIdentifierInfo(StringRef Name, + bool CheckOutOfDate = true) const; /// \brief Add the specified pragma handler to this preprocessor. /// Index: lib/Lex/Preprocessor.cpp =================================================================== --- lib/Lex/Preprocessor.cpp +++ lib/Lex/Preprocessor.cpp @@ -245,6 +245,27 @@ llvm::errs() << ">"; } +IdentifierInfo *Preprocessor::getIdentifierInfo(StringRef Name, + bool CheckOutOfDate) const { + IdentifierInfo &II = Identifiers.get(Name); + // If the information about this identifier is out of date, update it from + // the external source. + // We have to treat __VA_ARGS__ in a special way, since it gets + // serialized with isPoisoned = true, but our preprocessor may have + // unpoisoned it if we're defining a C99 macro. + if (CheckOutOfDate && II.isOutOfDate()) { + bool CurrentIsPoisoned = false; + if (&II == Ident__VA_ARGS__) + CurrentIsPoisoned = Ident__VA_ARGS__->isPoisoned(); + + updateOutOfDateIdentifier(II); + + if (&II == Ident__VA_ARGS__) + II.setIsPoisoned(CurrentIsPoisoned); + } + return &II; +} + void Preprocessor::DumpLocation(SourceLocation Loc) const { Loc.dump(SourceMgr); } @@ -646,23 +667,8 @@ IdentifierInfo &II = *Identifier.getIdentifierInfo(); - // If the information about this identifier is out of date, update it from - // the external source. - // We have to treat __VA_ARGS__ in a special way, since it gets - // serialized with isPoisoned = true, but our preprocessor may have - // unpoisoned it if we're defining a C99 macro. - if (II.isOutOfDate()) { - bool CurrentIsPoisoned = false; - if (&II == Ident__VA_ARGS__) - CurrentIsPoisoned = Ident__VA_ARGS__->isPoisoned(); - - updateOutOfDateIdentifier(II); - Identifier.setKind(II.getTokenID()); + Identifier.setKind(II.getTokenID()); - if (&II == Ident__VA_ARGS__) - II.setIsPoisoned(CurrentIsPoisoned); - } - // If this identifier was poisoned, and if it was not produced from a macro // expansion, emit an error. if (II.isPoisoned() && CurPPLexer) {