summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-11-19 22:21:33 +0000
committerTed Kremenek <kremenek@apple.com>2008-11-19 22:21:33 +0000
commit76c3441a4eef8d605831f0e16e8f996efebedef5 (patch)
tree7a75cd116a0aea338a229b7ee3490c0c03d511e9
parentf4d95fdce9101b959c093f08d6df881886edcc07 (diff)
downloadbcm5719-llvm-76c3441a4eef8d605831f0e16e8f996efebedef5.tar.gz
bcm5719-llvm-76c3441a4eef8d605831f0e16e8f996efebedef5.zip
When using a PTHLexer, use DiscardToEndOfLine() instead of ReadToEndOfLine().
llvm-svn: 59668
-rw-r--r--clang/include/clang/Lex/PTHLexer.h4
-rw-r--r--clang/lib/Lex/PPDirectives.cpp13
-rw-r--r--clang/lib/Lex/PPMacroExpansion.cpp2
-rw-r--r--clang/lib/Lex/PTHLexer.cpp7
-rw-r--r--clang/lib/Lex/Pragma.cpp5
5 files changed, 24 insertions, 7 deletions
diff --git a/clang/include/clang/Lex/PTHLexer.h b/clang/include/clang/Lex/PTHLexer.h
index 2985b24cb5c..bdaba760cf3 100644
--- a/clang/include/clang/Lex/PTHLexer.h
+++ b/clang/include/clang/Lex/PTHLexer.h
@@ -56,6 +56,10 @@ public:
/// the virtual location encodes where we should *claim* the characters came
/// from. Currently this is only used by _Pragma handling.
SourceLocation getFileLoc() const { return FileLoc; }
+
+ /// ReadToEndOfLine - Read the rest of the current preprocessor line as an
+ /// uninterpreted string. This switches the lexer out of directive mode.
+ void DiscardToEndOfLine();
};
} // end namespace clang
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index a1216b15bcc..68f49574997 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -473,10 +473,15 @@ void Preprocessor::HandleUserDiagnosticDirective(Token &Tok,
// tokens. For example, this is allowed: "#warning ` 'foo". GCC does
// collapse multiple consequtive white space between tokens, but this isn't
// specified by the standard.
- std::string Message = CurLexer->ReadToEndOfLine();
-
- unsigned DiagID = isWarning ? diag::pp_hash_warning : diag::err_pp_hash_error;
- Diag(Tok, DiagID) << Message;
+
+ if (CurLexer) {
+ std::string Message = CurLexer->ReadToEndOfLine();
+ unsigned DiagID = isWarning ? diag::pp_hash_warning : diag::err_pp_hash_error;
+ Diag(Tok, DiagID) << Message;
+ }
+ else {
+ CurPTHLexer->DiscardToEndOfLine();
+ }
}
/// HandleIdentSCCSDirective - Handle a #ident/#sccs directive.
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp
index 1d4d85a8973..abb21cb4745 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -111,7 +111,7 @@ bool Preprocessor::isNextPPTokenLParen() {
// We have run off the end. If it's a source file we don't
// examine enclosing ones (C99 5.1.1.2p4). Otherwise walk up the
// macro stack.
- if (CurLexer)
+ if (CurPPLexer)
return false;
for (unsigned i = IncludeMacroStack.size(); i != 0; --i) {
IncludeStackInfo &Entry = IncludeMacroStack[i-1];
diff --git a/clang/lib/Lex/PTHLexer.cpp b/clang/lib/Lex/PTHLexer.cpp
index d22285cae5c..15d56039692 100644
--- a/clang/lib/Lex/PTHLexer.cpp
+++ b/clang/lib/Lex/PTHLexer.cpp
@@ -76,3 +76,10 @@ void PTHLexer::setEOF(Token& Tok) {
Tok = Tokens[NumTokens]; // NumTokens is already adjusted, so this isn't
// an overflow.
}
+
+void PTHLexer::DiscardToEndOfLine() {
+ assert(ParsingPreprocessorDirective && ParsingFilename == false &&
+ "Must be in a preprocessing directive!");
+
+ assert (0 && "Not implemented.");
+}
diff --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp
index d4c5c6b8359..0e0841da9a9 100644
--- a/clang/lib/Lex/Pragma.cpp
+++ b/clang/lib/Lex/Pragma.cpp
@@ -193,8 +193,9 @@ void Preprocessor::HandlePragmaOnce(Token &OnceTok) {
}
void Preprocessor::HandlePragmaMark() {
- assert(CurLexer && "No current lexer?");
- CurLexer->ReadToEndOfLine();
+ assert(CurPPLexer && "No current lexer?");
+ if (CurLexer) CurLexer->ReadToEndOfLine();
+ else CurPTHLexer->DiscardToEndOfLine();
}
OpenPOWER on IntegriCloud