next round of diagnostics cleanups, moving some
diags around, eliminating #defines, etc. Patch by
Anders Johnsen!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63318 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp
index 6e39beb..5b1145f 100644
--- a/lib/Basic/Diagnostic.cpp
+++ b/lib/Basic/Diagnostic.cpp
@@ -68,21 +68,21 @@
/// getDiagClass - Return the class field of the diagnostic.
///
static unsigned getBuiltinDiagClass(unsigned DiagID) {
- assert(DiagID < DIAG_UPPER_LIMIT &&
+ assert(DiagID < diag::DIAG_UPPER_LIMIT &&
"Diagnostic ID out of range!");
unsigned res;
- if (DiagID < DIAG_START_LEX)
+ if (DiagID < diag::DIAG_START_LEX)
res = DiagnosticFlagsCommon[DiagID];
- else if (DiagID < DIAG_START_PARSE)
- res = DiagnosticFlagsLex[DiagID - DIAG_START_LEX - 1];
- else if (DiagID < DIAG_START_AST)
- res = DiagnosticFlagsParse[DiagID - DIAG_START_PARSE - 1];
- else if (DiagID < DIAG_START_SEMA)
- res = DiagnosticFlagsAST[DiagID - DIAG_START_AST - 1];
- else if (DiagID < DIAG_START_ANALYSIS)
- res = DiagnosticFlagsSema[DiagID - DIAG_START_SEMA - 1];
+ else if (DiagID < diag::DIAG_START_PARSE)
+ res = DiagnosticFlagsLex[DiagID - diag::DIAG_START_LEX - 1];
+ else if (DiagID < diag::DIAG_START_AST)
+ res = DiagnosticFlagsParse[DiagID - diag::DIAG_START_PARSE - 1];
+ else if (DiagID < diag::DIAG_START_SEMA)
+ res = DiagnosticFlagsAST[DiagID - diag::DIAG_START_AST - 1];
+ else if (DiagID < diag::DIAG_START_ANALYSIS)
+ res = DiagnosticFlagsSema[DiagID - diag::DIAG_START_SEMA - 1];
else
- res = DiagnosticFlagsAnalysis[DiagID - DIAG_START_ANALYSIS - 1];
+ res = DiagnosticFlagsAnalysis[DiagID - diag::DIAG_START_ANALYSIS - 1];
return res & class_mask;
}
@@ -216,26 +216,26 @@
/// 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_UPPER_LIMIT && getBuiltinDiagClass(DiagID) < ERROR;
+ return DiagID < diag::DIAG_UPPER_LIMIT && getBuiltinDiagClass(DiagID) < ERROR;
}
/// getDescription - Given a diagnostic ID, return a description of the
/// issue.
const char *Diagnostic::getDescription(unsigned DiagID) const {
- if (DiagID < DIAG_UPPER_LIMIT) {
- if (DiagID < DIAG_START_LEX)
+ if (DiagID < diag::DIAG_UPPER_LIMIT) {
+ if (DiagID < diag::DIAG_START_LEX)
return DiagnosticTextCommon[DiagID];
- else if (DiagID < DIAG_START_PARSE)
- return DiagnosticTextLex[DiagID - DIAG_START_LEX - 1];
- else if (DiagID < DIAG_START_AST)
- return DiagnosticTextParse[DiagID - DIAG_START_PARSE - 1];
- else if (DiagID < DIAG_START_SEMA)
- return DiagnosticTextAST[DiagID - DIAG_START_AST - 1];
- else if (DiagID < DIAG_START_ANALYSIS)
- return DiagnosticTextSema[DiagID - DIAG_START_SEMA - 1];
- else if (DiagID < DIAG_UPPER_LIMIT)
- return DiagnosticTextAnalysis[DiagID - DIAG_START_ANALYSIS - 1];
+ else if (DiagID < diag::DIAG_START_PARSE)
+ return DiagnosticTextLex[DiagID - diag::DIAG_START_LEX - 1];
+ else if (DiagID < diag::DIAG_START_AST)
+ return DiagnosticTextParse[DiagID - diag::DIAG_START_PARSE - 1];
+ else if (DiagID < diag::DIAG_START_SEMA)
+ return DiagnosticTextAST[DiagID - diag::DIAG_START_AST - 1];
+ else if (DiagID < diag::DIAG_START_ANALYSIS)
+ return DiagnosticTextSema[DiagID - diag::DIAG_START_SEMA - 1];
+ else if (DiagID < diag::DIAG_UPPER_LIMIT)
+ return DiagnosticTextAnalysis[DiagID - diag::DIAG_START_ANALYSIS - 1];
}
return CustomDiagInfo->getDescription(DiagID);
@@ -246,7 +246,7 @@
/// the DiagnosticClient.
Diagnostic::Level Diagnostic::getDiagnosticLevel(unsigned DiagID) const {
// Handle custom diagnostics, which cannot be mapped.
- if (DiagID >= DIAG_UPPER_LIMIT)
+ if (DiagID >= diag::DIAG_UPPER_LIMIT)
return CustomDiagInfo->getLevel(DiagID);
unsigned DiagClass = getBuiltinDiagClass(DiagID);
@@ -307,7 +307,7 @@
// ignore extensions and warnings in -Werror and -pedantic-errors modes,
// which *map* warnings/extensions to errors.
if (SuppressSystemWarnings &&
- Info.getID() < DIAG_UPPER_LIMIT &&
+ Info.getID() < diag::DIAG_UPPER_LIMIT &&
getBuiltinDiagClass(Info.getID()) != ERROR &&
Info.getLocation().isValid() &&
Info.getLocation().getSpellingLoc().isInSystemHeader())