/// 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
// 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.
// 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];
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.");
+}
}
void Preprocessor::HandlePragmaMark() {
- assert(CurLexer && "No current lexer?");
- CurLexer->ReadToEndOfLine();
+ assert(CurPPLexer && "No current lexer?");
+ if (CurLexer) CurLexer->ReadToEndOfLine();
+ else CurPTHLexer->DiscardToEndOfLine();
}