static const char * const ExpectedErrStr = "expected-error";
static const char * const ExpectedWarnStr = "expected-warning";
+static const char * const ExpectedNoteStr = "expected-note";
/// FindDiagnostics - Go through the comment and see if it indicates expected
/// diagnostics. If so, then put them in a diagnostic list.
// expected errors and warnings.
static void FindExpectedDiags(Preprocessor &PP,
DiagList &ExpectedErrors,
- DiagList &ExpectedWarnings) {
+ DiagList &ExpectedWarnings,
+ DiagList &ExpectedNotes) {
// Return comments as tokens, this is how we find expected diagnostics.
PP.SetCommentRetentionState(true, true);
// Find all expected warnings
FindDiagnostics(Comment, ExpectedWarnings, PP.getSourceManager(),
Tok.getLocation(), ExpectedWarnStr);
+
+ // Find all expected notes
+ FindDiagnostics(Comment, ExpectedNotes, PP.getSourceManager(),
+ Tok.getLocation(), ExpectedNoteStr);
}
} while (Tok.isNot(tok::eof));
///
static bool CheckResults(Preprocessor &PP,
const DiagList &ExpectedErrors,
- const DiagList &ExpectedWarnings) {
+ const DiagList &ExpectedWarnings,
+ const DiagList &ExpectedNotes) {
const DiagnosticClient *DiagClient = PP.getDiagnostics().getClient();
assert(DiagClient != 0 &&
"DiagChecker requires a valid TextDiagnosticBuffer");
ExpectedWarnings.end(),
"Warnings seen but not expected:");
+ // See if there were notes that were expected but not seen.
+ HadProblem |= CompareDiagLists(SourceMgr,
+ ExpectedNotes.begin(),
+ ExpectedNotes.end(),
+ Diags.note_begin(), Diags.note_end(),
+ "Notes expected but not seen:");
+
+ // See if there were notes that were seen but not expected.
+ HadProblem |= CompareDiagLists(SourceMgr,
+ Diags.note_begin(), Diags.note_end(),
+ ExpectedNotes.begin(),
+ ExpectedNotes.end(),
+ "Notes seen but not expected:");
+
return HadProblem;
}
/// CheckDiagnostics - Gather the expected diagnostics and check them.
bool clang::CheckDiagnostics(Preprocessor &PP) {
// Gather the set of expected diagnostics.
- DiagList ExpectedErrors, ExpectedWarnings;
- FindExpectedDiags(PP, ExpectedErrors, ExpectedWarnings);
+ DiagList ExpectedErrors, ExpectedWarnings, ExpectedNotes;
+ FindExpectedDiags(PP, ExpectedErrors, ExpectedWarnings, ExpectedNotes);
// Check that the expected diagnostics occurred.
- return CheckResults(PP, ExpectedErrors, ExpectedWarnings);
+ return CheckResults(PP, ExpectedErrors, ExpectedWarnings, ExpectedNotes);
}
typedef DiagList::iterator iterator;
typedef DiagList::const_iterator const_iterator;
private:
- DiagList Errors, Warnings;
+ DiagList Errors, Warnings, Notes;
public:
const_iterator err_begin() const { return Errors.begin(); }
const_iterator err_end() const { return Errors.end(); }
const_iterator warn_begin() const { return Warnings.begin(); }
const_iterator warn_end() const { return Warnings.end(); }
+ const_iterator note_begin() const { return Notes.begin(); }
+ const_iterator note_end() const { return Notes.end(); }
+
virtual void HandleDiagnostic(Diagnostic &Diags,
Diagnostic::Level DiagLevel,
FullSourceLoc Pos,