diff options
author | Chris Lattner <sabre@nondot.org> | 2008-11-21 01:18:36 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-11-21 01:18:36 +0000 |
commit | a39f04857a6eb12925dfcf01b35f9dabf787d7a0 (patch) | |
tree | ab31648b5faf731d97c9e9457948e8cb332164b7 /Driver/DiagChecker.cpp | |
parent | 34eaa24e6c2dc72bbbd5ad09694368cfd09c5f14 (diff) |
Change -verify mode to find the "expected-error" and "expected-warning" strings
with a raw lexer instead of a PP lexer. This means that -verify doesn't scan
#include'd headers for expected-error/warning strings, and it also means that it
doesn't ignore them in #if 0.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59774 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/DiagChecker.cpp')
-rw-r--r-- | Driver/DiagChecker.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/Driver/DiagChecker.cpp b/Driver/DiagChecker.cpp index c474951244..d6321d60ad 100644 --- a/Driver/DiagChecker.cpp +++ b/Driver/DiagChecker.cpp @@ -93,28 +93,29 @@ static void FindExpectedDiags(Preprocessor &PP, DiagList &ExpectedErrors, DiagList &ExpectedWarnings, DiagList &ExpectedNotes) { + // Create a raw lexer to pull all the comments out of the main file. We don't + // want to look in #include'd headers for expected-error strings. + + unsigned FileID = PP.getSourceManager().getMainFileID(); + std::pair<const char*,const char*> File = + PP.getSourceManager().getBufferData(FileID); + + // Create a lexer to lex all the tokens of the main file in raw mode. + Lexer RawLex(SourceLocation::getFileLoc(FileID, 0), + PP.getLangOptions(), File.first, File.second); + // Return comments as tokens, this is how we find expected diagnostics. - PP.SetCommentRetentionState(true, true); + RawLex.SetCommentRetentionState(true); - // Enter the cave. - PP.EnterMainSourceFile(); - - // Turn off all warnings from relexing or preprocessing. - PP.getDiagnostics().setWarnOnExtensions(false); - PP.getDiagnostics().setErrorOnExtensions(false); - for (unsigned i = 0; i != diag::NUM_BUILTIN_DIAGNOSTICS; ++i) - if (PP.getDiagnostics().isBuiltinNoteWarningOrExtension((diag::kind)i)) - PP.getDiagnostics().setDiagnosticMapping((diag::kind)i, diag::MAP_IGNORE); - Token Tok; do { - PP.Lex(Tok); + RawLex.Lex(Tok); if (Tok.is(tok::comment)) { std::string Comment = PP.getSpelling(Tok); // Find all expected errors - FindDiagnostics(Comment, ExpectedErrors,PP.getSourceManager(), + FindDiagnostics(Comment, ExpectedErrors, PP.getSourceManager(), Tok.getLocation(), ExpectedErrStr); // Find all expected warnings @@ -126,8 +127,6 @@ static void FindExpectedDiags(Preprocessor &PP, Tok.getLocation(), ExpectedNoteStr); } } while (Tok.isNot(tok::eof)); - - PP.SetCommentRetentionState(false, false); } /// PrintProblem - This takes a diagnostic map of the delta between expected and |