summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/PTHLexer.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-11-21 00:58:35 +0000
committerTed Kremenek <kremenek@apple.com>2008-11-21 00:58:35 +0000
commit53ab374d9f69db337cf15f2789a422f0955cd753 (patch)
tree1bf54cdfc4ce74648f3a8924ddc4c1efb85f00ef /clang/lib/Lex/PTHLexer.cpp
parentc2ad6dc3b4685c764004e73dc98ec83566365d80 (diff)
downloadbcm5719-llvm-53ab374d9f69db337cf15f2789a422f0955cd753.tar.gz
bcm5719-llvm-53ab374d9f69db337cf15f2789a422f0955cd753.zip
PTHLexer:
- Move out logic for handling the end-of-file to LexEndOfFile (to match the Lexer) class. The logic now mirrors the Lexer class more, which allows us to pass most of the Preprocessor test cases. llvm-svn: 59768
Diffstat (limited to 'clang/lib/Lex/PTHLexer.cpp')
-rw-r--r--clang/lib/Lex/PTHLexer.cpp40
1 files changed, 26 insertions, 14 deletions
diff --git a/clang/lib/Lex/PTHLexer.cpp b/clang/lib/Lex/PTHLexer.cpp
index a88470bbad6..5c6341f57dc 100644
--- a/clang/lib/Lex/PTHLexer.cpp
+++ b/clang/lib/Lex/PTHLexer.cpp
@@ -41,23 +41,17 @@ Token PTHLexer::GetToken() {
void PTHLexer::Lex(Token& Tok) {
LexNextToken:
+ Tok = GetToken();
+
if (AtLastToken()) {
- if (ParsingPreprocessorDirective) {
- ParsingPreprocessorDirective = false;
- Tok = GetToken();
- Tok.setKind(tok::eom);
- MIOpt.ReadToken();
+ Preprocessor *PPCache = PP;
+
+ if (LexEndOfFile(Tok))
return;
- }
-
- assert(!LexingRawMode && "PTHLexer cannot lex in raw mode.");
-
- // FIXME: Issue diagnostics similar to Lexer.
- PP->HandleEndOfFile(Tok, false);
- return;
- }
- Tok = GetToken();
+ assert(PPCache && "Raw buffer::LexEndOfFile should return a token");
+ return PPCache->Lex(Tok);
+ }
// Don't advance to the next token yet. Check if we are at the
// start of a new line and we're processing a directive. If so, we
@@ -91,6 +85,24 @@ LexNextToken:
}
}
+bool PTHLexer::LexEndOfFile(Token &Tok) {
+
+ if (ParsingPreprocessorDirective) {
+ ParsingPreprocessorDirective = false;
+ Tok.setKind(tok::eom);
+ MIOpt.ReadToken();
+ return true; // Have a token.
+ }
+
+ if (LexingRawMode) {
+ MIOpt.ReadToken();
+ return true; // Have an eof token.
+ }
+
+ // FIXME: Issue diagnostics similar to Lexer.
+ return PP->HandleEndOfFile(Tok, false);
+}
+
void PTHLexer::setEOF(Token& Tok) {
Tok = Tokens[LastTokenIdx];
}
OpenPOWER on IntegriCloud