start partitioning the diagnostics into two classes: those
that are builtin and those that are aren't. This is a bunch
of API refactoring that will make this possible, but there is
no functionality change yet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44473 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Basic/Diagnostic.cpp b/Basic/Diagnostic.cpp
index bef3033..239211b 100644
--- a/Basic/Diagnostic.cpp
+++ b/Basic/Diagnostic.cpp
@@ -36,8 +36,9 @@
/// getDiagClass - Return the class field of the diagnostic.
///
-static unsigned getDiagClass(unsigned DiagID) {
- assert(DiagID < diag::NUM_DIAGNOSTICS && "Diagnostic ID out of range!");
+static unsigned getBuiltinDiagClass(unsigned DiagID) {
+ assert(DiagID < diag::NUM_BUILTIN_DIAGNOSTICS &&
+ "Diagnostic ID out of range!");
return DiagnosticFlags[DiagID] & class_mask;
}
@@ -61,25 +62,34 @@
NumErrors = 0;
}
-/// isNoteWarningOrExtension - Return true if the unmapped diagnostic level of
-/// the specified diagnostic ID is a Note, Warning, or Extension.
-bool Diagnostic::isNoteWarningOrExtension(unsigned DiagID) {
- return getDiagClass(DiagID) < ERROR;
+/// isBuiltinNoteWarningOrExtension - Return true if the unmapped diagnostic
+/// level of the specified diagnostic ID is a Note, Warning, or Extension.
+/// Note that this only works on builtin diagnostics, not custom ones.
+bool Diagnostic::isBuiltinNoteWarningOrExtension(unsigned DiagID) {
+ return DiagID < diag::NUM_BUILTIN_DIAGNOSTICS &&
+ getBuiltinDiagClass(DiagID) < ERROR;
}
/// getDescription - Given a diagnostic ID, return a description of the
/// issue.
const char *Diagnostic::getDescription(unsigned DiagID) {
- assert(DiagID < diag::NUM_DIAGNOSTICS && "Diagnostic ID out of range!");
- return DiagnosticText[DiagID];
+ if (DiagID < diag::NUM_BUILTIN_DIAGNOSTICS)
+ return DiagnosticText[DiagID];
+ else
+ assert(0 && "FIXME: IMPLEMENT");
}
/// getDiagnosticLevel - Based on the way the client configured the Diagnostic
/// object, classify the specified diagnostic ID into a Level, consumable by
/// the DiagnosticClient.
Diagnostic::Level Diagnostic::getDiagnosticLevel(unsigned DiagID) const {
- unsigned DiagClass = getDiagClass(DiagID);
+ if (DiagID >= diag::NUM_BUILTIN_DIAGNOSTICS) {
+ // FIXME: HAndle custom here.
+ assert(0 && "unimp");
+ }
+
+ unsigned DiagClass = getBuiltinDiagClass(DiagID);
// Specific non-error diagnostics may be mapped to various levels from ignored
// to error.
@@ -137,8 +147,8 @@
return;
// Finally, report it.
- Client.HandleDiagnostic(DiagLevel, Pos, (diag::kind)DiagID, Strs, NumStrs,
- Ranges, NumRanges);
+ Client.HandleDiagnostic(*this, DiagLevel, Pos, (diag::kind)DiagID,
+ Strs, NumStrs, Ranges, NumRanges);
++NumDiagnostics;
}