c2c/Clang/Preprocessor.cpp
/// HandleIdentifier - This callback is invoked when the lexer reads an
/// identifier.  This callback looks up the identifier in the map and/or
/// potentially macro expands it or turns it into a named token (like 'for').
///
/// Note that callers of this method are guarded by checking the
/// IdentifierInfo's 'isHandleIdentifierCase' bit.  If this method changes, the
/// IdentifierInfo methods that compute these properties will need to change to
/// match.
This callback is invoked when the lexer reads an
identifier.  This callback looks up the identifier in the map and/or
potentially macro expands it or turns it into a named token (like 'for').

Note that callers of this method are guarded by checking the
IdentifierInfo's 'isHandleIdentifierCase' bit.  If this method changes, the
IdentifierInfo methods that compute these properties will need to change to
match.
This callback is invoked when the lexer reads an identifier . This callback looks up the identifier in the map and / or potentially macro expands it or turns it into a named token ( like ' for ' ) . Note that callers of this method are guarded by checking the IdentifierInfo ' s ' isHandleIdentifierCase ' bit . If this method changes the IdentifierInfo methods that compute these properties will need to change to match .
bool Preprocessor::HandleIdentifier(Token &Identifier) {
  assert(Identifier.getIdentifierInfo() &&
         "Can't handle identifiers without identifier info!");
  IdentifierInfo &II = *Identifier.getIdentifierInfo();
  if (II.isPoisoned() && CurPPLexer) {
    HandlePoisonedIdentifier(Identifier);
  }
  if (MacroDefinition MD = getMacroDefinition(&II)) {
    auto *MI = MD.getMacroInfo();
    assert(MI && "macro definition with no macro info?");
    if (!DisableMacroExpansion) {
      if (!Identifier.isExpandDisabled() && MI->isEnabled()) {
        if (!MI->isFunctionLike() || isNextPPTokenLParen())
          return HandleMacroExpandedIdentifier(Identifier, MD);
      } else {
        Identifier.setFlag(Token::DisableExpand);
        if (MI->isObjectLike() || isNextPPTokenLParen())
          Diag(Identifier, diag::pp_disabled_macro_expansion);
      }
    }
  }
  if (II.isFutureCompatKeyword() && !DisableMacroExpansion) {
    Diag(Identifier, getFutureCompatDiagKind(II))
        << II.getName();
    II.setIsFutureCompatKeyword(false);
  }
  if (II.isExtensionToken() && !DisableMacroExpansion)
    Diag(Identifier, diag::ext_token_used);
  return true;
}
bool Preprocessor :: HandleIdentifier ( Token & Identifier ) { assert ( Identifier . getIdentifierInfo ( ) && " " ) ; IdentifierInfo & II = * Identifier . getIdentifierInfo ( ) ; if ( II . isPoisoned ( ) && CurPPLexer ) { HandlePoisonedIdentifier ( Identifier ) ; } if ( MacroDefinition MD = getMacroDefinition ( & II ) ) { auto * MI = MD . getMacroInfo ( ) ; assert ( MI && " " ) ; if ( ! DisableMacroExpansion ) { if ( ! Identifier . isExpandDisabled ( ) && MI -> isEnabled ( ) ) { if ( ! MI -> isFunctionLike ( ) || isNextPPTokenLParen ( ) ) return HandleMacroExpandedIdentifier ( Identifier , MD ) ; } else { Identifier . setFlag ( Token :: DisableExpand ) ; if ( MI -> isObjectLike ( ) || isNextPPTokenLParen ( ) ) Diag ( Identifier , diag :: pp_disabled_macro_expansion ) ; } } } if ( II . isFutureCompatKeyword ( ) && ! DisableMacroExpansion ) { Diag ( Identifier , getFutureCompatDiagKind ( II ) ) << II . getName ( ) ; II . setIsFutureCompatKeyword ( false ) ; } if ( II . isExtensionToken ( ) && ! DisableMacroExpansion ) Diag ( Identifier , diag :: ext_token_used ) ; return true ; }
HandleIdentifier - This callback is invoked when the lexer reads an
identifier.
HandleIdentifier - This callback is invoked when the lexer reads an identifier .
// If this identifier was poisoned, and if it was not produced from a macro // expansion, emit an error. // If this is a macro to be expanded, do it. // C99 6.10.3p10: If the preprocessing token immediately after the // macro name isn't a '(', this macro should not be expanded. // C99 6.10.3.4p2 says that a disabled macro may never again be // expanded, even if it's in a context where it could be expanded in the // future. // If this identifier is a keyword in a newer Standard or proposed Standard, // produce a warning. Don't warn if we're not considering macro expansion, // since this identifier might be the name of a macro. // FIXME: This warning is disabled in cases where it shouldn't be, like //   "#define constexpr constexpr", "int constexpr;" // Don't diagnose this keyword again in this translation unit. // If this is an extension token, diagnose its use. // We avoid diagnosing tokens that originate from macro definitions. // FIXME: This warning is disabled in cases where it shouldn't be, // like "#define TY typeof", "TY(1) x".