diff options
Diffstat (limited to 'clang/lib/Lex')
| -rw-r--r-- | clang/lib/Lex/Lexer.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Lex/PTHLexer.cpp | 6 | ||||
| -rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Lex/TokenLexer.cpp | 11 |
4 files changed, 18 insertions, 7 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index fca8fd4eb16..3174a059174 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -558,6 +558,10 @@ FinishIdentifier: // identifier table. IdentifierInfo *II = PP->LookUpIdentifierInfo(Result, IdStart); + // Change the kind of this identifier to the appropriate token kind, e.g. + // turning "for" into a keyword. + Result.setKind(II->getTokenID()); + // Finally, now that we know we have an identifier, pass this off to the // preprocessor, which may macro expand it or something. if (II->isHandleIdentifierCase()) diff --git a/clang/lib/Lex/PTHLexer.cpp b/clang/lib/Lex/PTHLexer.cpp index b0f06271c4f..ec76a299845 100644 --- a/clang/lib/Lex/PTHLexer.cpp +++ b/clang/lib/Lex/PTHLexer.cpp @@ -101,7 +101,13 @@ LexNextToken: if (IdentifierID) { MIOpt.ReadToken(); IdentifierInfo *II = PTHMgr.GetIdentifierInfo(IdentifierID-1); + Tok.setIdentifierInfo(II); + + // Change the kind of this identifier to the appropriate token kind, e.g. + // turning "for" into a keyword. + Tok.setKind(II->getTokenID()); + if (II->isHandleIdentifierCase()) PP->HandleIdentifier(Tok); return; diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index e53c392c388..d0a15e45c41 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -759,10 +759,6 @@ void Preprocessor::HandleIdentifier(Token &Identifier) { if (II.isCPlusPlusOperatorKeyword()) Identifier.setIdentifierInfo(0); - // Change the kind of this identifier to the appropriate token kind, e.g. - // turning "for" into a keyword. - Identifier.setKind(II.getTokenID()); - // If this is an extension token, diagnose its use. // We avoid diagnosing tokens that originate from macro definitions. if (II.isExtensionToken() && Features.C99 && !DisableMacroExpansion) diff --git a/clang/lib/Lex/TokenLexer.cpp b/clang/lib/Lex/TokenLexer.cpp index c945843459f..dd5352c1b61 100644 --- a/clang/lib/Lex/TokenLexer.cpp +++ b/clang/lib/Lex/TokenLexer.cpp @@ -326,9 +326,14 @@ void TokenLexer::Lex(Token &Tok) { } // Handle recursive expansion! - if (Tok.getIdentifierInfo() && !DisableMacroExpansion && - Tok.getIdentifierInfo()->isHandleIdentifierCase()) - PP.HandleIdentifier(Tok); + if (IdentifierInfo *II = Tok.getIdentifierInfo()) { + // Change the kind of this identifier to the appropriate token kind, e.g. + // turning "for" into a keyword. + Tok.setKind(II->getTokenID()); + + if (!DisableMacroExpansion && II->isHandleIdentifierCase()) + PP.HandleIdentifier(Tok); + } // Otherwise, return a normal token. } |

