track whether an error has been emitted.

llvm-svn: 39502
This commit is contained in:
Chris Lattner 2007-05-28 00:46:44 +00:00
parent 9358c715da
commit c49b9051f4
2 changed files with 10 additions and 0 deletions

View File

@ -57,6 +57,8 @@ Diagnostic::Diagnostic(DiagnosticClient &client) : Client(client) {
ErrorOnExtensions = false;
// Clear all mappings, setting them to MAP_DEFAULT.
memset(DiagMappings, 0, sizeof(DiagMappings));
ErrorOccurred = false;
}
/// isNoteWarningOrExtension - Return true if the unmapped diagnostic level of
@ -126,6 +128,9 @@ void Diagnostic::Report(SourceLocation Pos, unsigned DiagID,
if (DiagLevel == Diagnostic::Ignored)
return;
if (DiagLevel >= Diagnostic::Error)
ErrorOccurred = true;
// Finally, report it.
Client.HandleDiagnostic(DiagLevel, Pos, (diag::kind)DiagID, Strs, NumStrs,
Ranges, NumRanges);

View File

@ -55,6 +55,10 @@ class Diagnostic {
/// DiagMappings - Mapping information for diagnostics. Mapping info is
/// packed into two bits per diagnostic.
unsigned char DiagMappings[(diag::NUM_DIAGNOSTICS+3)/4];
/// ErrorOccurred - This is set to true when an error is emitted, and is
/// sticky.
bool ErrorOccurred;
public:
explicit Diagnostic(DiagnosticClient &client);
@ -93,6 +97,7 @@ public:
return (diag::Mapping)((DiagMappings[Diag/4] >> (Diag & 3)*2) & 3);
}
bool hasErrorOccurred() const { return ErrorOccurred; }
//===--------------------------------------------------------------------===//
// Diagnostic classification and reporting interfaces.