[cfe-commits] r59840 - /cfe/trunk/lib/Lex/PPLexerChange.cpp
Ted Kremenek
kremenek at apple.com
Fri Nov 21 11:41:29 PST 2008
Author: kremenek
Date: Fri Nov 21 13:41:29 2008
New Revision: 59840
URL: http://llvm.org/viewvc/llvm-project?rev=59840&view=rev
Log:
When creating raw tokens for the PTHLexer specially handle angled strings for #include directives.
Modified:
cfe/trunk/lib/Lex/PPLexerChange.cpp
Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=59840&r1=59839&r2=59840&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp Fri Nov 21 13:41:29 2008
@@ -90,18 +90,42 @@
// Lex the file, populating our data structures.
std::vector<Token>* Tokens = new std::vector<Token>();
- Token Tok;
+ Token Tok;
do {
L.LexFromRawLexer(Tok);
- if (Tok.is(tok::identifier))
+ if (Tok.is(tok::identifier)) {
Tok.setIdentifierInfo(LookUpIdentifierInfo(Tok));
-
- // Store the token.
- Tokens->push_back(Tok);
+ }
+ else if (Tok.is(tok::hash) && Tok.isAtStartOfLine()) {
+ // Special processing for #include. Store the '#' token and lex
+ // the next token.
+ Tokens->push_back(Tok);
+ L.LexFromRawLexer(Tok);
+
+ // Did we see 'include'/'import'/'include_next'?
+ if (!Tok.is(tok::identifier))
+ continue;
+
+ IdentifierInfo* II = LookUpIdentifierInfo(Tok);
+ Tok.setIdentifierInfo(II);
+ tok::PPKeywordKind K = II->getPPKeywordID();
+
+ if (K == tok::pp_include || K == tok::pp_import ||
+ K == tok::pp_include_next) {
+
+ // Save the 'include' token.
+ Tokens->push_back(Tok);
+
+ // Lex the next token as an include string.
+ L.ParsingPreprocessorDirective = true;
+ L.LexIncludeFilename(Tok);
+ L.ParsingPreprocessorDirective = false;
+ }
+ }
}
- while (Tok.isNot(tok::eof));
+ while (Tokens->push_back(Tok), Tok.isNot(tok::eof));
if (CurPPLexer || CurTokenLexer)
PushIncludeMacroStack();
More information about the cfe-commits
mailing list