diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-11-21 19:41:29 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-11-21 19:41:29 +0000 |
commit | 72d9912b08c5492cc2eaff9a666e45718f1dea07 (patch) | |
tree | ba4a2489a16a4892e3ec42361c19039e50dc75c6 /clang/lib/Lex/PPLexerChange.cpp | |
parent | b885a91a1281c3f63aff7c9377e1114d3973fa7e (diff) | |
download | bcm5719-llvm-72d9912b08c5492cc2eaff9a666e45718f1dea07.tar.gz bcm5719-llvm-72d9912b08c5492cc2eaff9a666e45718f1dea07.zip |
When creating raw tokens for the PTHLexer specially handle angled strings for #include directives.
llvm-svn: 59840
Diffstat (limited to 'clang/lib/Lex/PPLexerChange.cpp')
-rw-r--r-- | clang/lib/Lex/PPLexerChange.cpp | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp index a12309a7bfc..da877493a0f 100644 --- a/clang/lib/Lex/PPLexerChange.cpp +++ b/clang/lib/Lex/PPLexerChange.cpp @@ -90,18 +90,42 @@ void Preprocessor::EnterSourceFile(unsigned FileID, // 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(); |