diff options
| author | Chris Lattner <sabre@nondot.org> | 2006-07-20 04:31:52 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2006-07-20 04:31:52 +0000 |
| commit | 538d7f3c27cc6afe15cad65c3967318d74121666 (patch) | |
| tree | 1397031e08fd320135ad1d731013602b5edf9d30 /clang/Lex/Lexer.cpp | |
| parent | 22549fe6a54285aa6e834118683290573ded43b6 (diff) | |
| download | bcm5719-llvm-538d7f3c27cc6afe15cad65c3967318d74121666.tar.gz bcm5719-llvm-538d7f3c27cc6afe15cad65c3967318d74121666.zip | |
Simplify "raw lexing mode" even further. Now the preprocessor is only called
into when a hard error is found. This simplifies logic and eliminates the need
for the preprocessor to know about raw mode.
llvm-svn: 38746
Diffstat (limited to 'clang/Lex/Lexer.cpp')
| -rw-r--r-- | clang/Lex/Lexer.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/clang/Lex/Lexer.cpp b/clang/Lex/Lexer.cpp index 81ccbca7b83..f3e6337151d 100644 --- a/clang/Lex/Lexer.cpp +++ b/clang/Lex/Lexer.cpp @@ -158,8 +158,17 @@ SourceLocation Lexer::getSourceLocation(const char *Loc) const { /// position in the current buffer into a SourceLocation object for rendering. void Lexer::Diag(const char *Loc, unsigned DiagID, const std::string &Msg) const { + if (LexingRawMode && Diagnostic::isNoteWarningOrExtension(DiagID)) + return; PP.Diag(getSourceLocation(Loc), DiagID, Msg); } +void Lexer::Diag(SourceLocation Loc, unsigned DiagID, + const std::string &Msg) const { + if (LexingRawMode && Diagnostic::isNoteWarningOrExtension(DiagID)) + return; + PP.Diag(Loc, DiagID, Msg); +} + //===----------------------------------------------------------------------===// // Trigraph and Escaped Newline Handling Code. @@ -814,7 +823,7 @@ std::string Lexer::LexIncludeFilename(LexerToken &FilenameTok) { // No filename? if (FilenameTok.getKind() == tok::eom) { - PP.Diag(FilenameTok, diag::err_pp_expects_filename); + Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename); return ""; } @@ -825,25 +834,25 @@ std::string Lexer::LexIncludeFilename(LexerToken &FilenameTok) { // Make sure the filename is <x> or "x". if (Filename[0] == '<') { if (Filename[Filename.size()-1] != '>') { - PP.Diag(FilenameTok, diag::err_pp_expects_filename); + Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename); FilenameTok.SetKind(tok::eom); return ""; } } else if (Filename[0] == '"') { if (Filename[Filename.size()-1] != '"') { - PP.Diag(FilenameTok, diag::err_pp_expects_filename); + Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename); FilenameTok.SetKind(tok::eom); return ""; } } else { - PP.Diag(FilenameTok, diag::err_pp_expects_filename); + Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename); FilenameTok.SetKind(tok::eom); return ""; } // Diagnose #include "" as invalid. if (Filename.size() == 2) { - PP.Diag(FilenameTok, diag::err_pp_empty_filename); + Diag(FilenameTok.getLocation(), diag::err_pp_empty_filename); FilenameTok.SetKind(tok::eom); return ""; } @@ -922,8 +931,7 @@ bool Lexer::LexEndOfFile(LexerToken &Result, const char *CurPtr) { // If we are in a #if directive, emit an error. while (!ConditionalStack.empty()) { - PP.Diag(ConditionalStack.back().IfLoc, - diag::err_pp_unterminated_conditional); + Diag(ConditionalStack.back().IfLoc, diag::err_pp_unterminated_conditional); ConditionalStack.pop_back(); } |

