From: Alp Toker Date: Thu, 12 Jun 2014 10:15:20 +0000 (+0000) Subject: Complete the switch from mappings to declarative diagnostic severities X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18a9b6654286356870c6c336ad9fdc6ad7599dbe;p=clang Complete the switch from mappings to declarative diagnostic severities This begins to address cognitive dissonance caused by treating the Note diagnostic level as a severity in the diagnostic engine. No change in functionality. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210758 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/Diagnostic.td b/include/clang/Basic/Diagnostic.td index 5bcc2d5c16..dd16a6a78c 100644 --- a/include/clang/Basic/Diagnostic.td +++ b/include/clang/Basic/Diagnostic.td @@ -12,13 +12,15 @@ // //===----------------------------------------------------------------------===// -// Define the diagnostic mappings. -class DiagMapping; -def MAP_IGNORE : DiagMapping; -def MAP_REMARK : DiagMapping; -def MAP_WARNING : DiagMapping; -def MAP_ERROR : DiagMapping; -def MAP_FATAL : DiagMapping; +// Define the diagnostic severities. +class Severity { + string Name = N; +} +def SEV_Ignored : Severity<"Ignored">; +def SEV_Remark : Severity<"Remark">; +def SEV_Warning : Severity<"Warning">; +def SEV_Error : Severity<"Error">; +def SEV_Fatal : Severity<"Fatal">; // Define the diagnostic classes. class DiagClass; @@ -59,7 +61,7 @@ include "DiagnosticGroups.td" // All diagnostics emitted by the compiler are an indirect subclass of this. -class Diagnostic { +class Diagnostic { /// Component is specified by the file with a big let directive. string Component = ?; string Text = text; @@ -68,7 +70,7 @@ class Diagnostic { bit AccessControl = 0; bit WarningNoWerror = 0; bit WarningShowInSystemHeader = 0; - DiagMapping DefaultMapping = defaultmapping; + Severity DefaultSeverity = defaultmapping; DiagGroup Group; string CategoryName = ""; } @@ -84,25 +86,25 @@ class AccessControl { } // FIXME: ExtWarn and Extension should also be SFINAEFailure by default. -class Error : Diagnostic, SFINAEFailure; -class Warning : Diagnostic; -class Remark : Diagnostic; -class Extension : Diagnostic; -class ExtWarn : Diagnostic; -class Note : Diagnostic; - - -class DefaultIgnore { DiagMapping DefaultMapping = MAP_IGNORE; } -class DefaultWarn { DiagMapping DefaultMapping = MAP_WARNING; } -class DefaultError { DiagMapping DefaultMapping = MAP_ERROR; } -class DefaultFatal { DiagMapping DefaultMapping = MAP_FATAL; } +class Error : Diagnostic, SFINAEFailure; +class Warning : Diagnostic; +class Remark : Diagnostic; +class Extension : Diagnostic; +class ExtWarn : Diagnostic; +class Note : Diagnostic; + + +class DefaultIgnore { Severity DefaultSeverity = SEV_Ignored; } +class DefaultWarn { Severity DefaultSeverity = SEV_Warning; } +class DefaultError { Severity DefaultSeverity = SEV_Error; } +class DefaultFatal { Severity DefaultSeverity = SEV_Fatal; } class DefaultWarnNoWerror { bit WarningNoWerror = 1; } class DefaultWarnShowInSystemHeader { bit WarningShowInSystemHeader = 1; } -class DefaultRemark { DiagMapping DefaultMapping = MAP_REMARK; } +class DefaultRemark { Severity DefaultSeverity = SEV_Remark; } // Definitions for Diagnostics. include "DiagnosticASTKinds.td" diff --git a/include/clang/Basic/DiagnosticIDs.h b/include/clang/Basic/DiagnosticIDs.h index 9f0a03be83..8b670500cf 100644 --- a/include/clang/Basic/DiagnosticIDs.h +++ b/include/clang/Basic/DiagnosticIDs.h @@ -56,17 +56,16 @@ namespace clang { }; /// Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs - /// to either MAP_IGNORE (nothing), MAP_REMARK (emit a remark), MAP_WARNING - /// (emit a warning), MAP_ERROR (emit as an error). It allows clients to - /// map errors to MAP_ERROR/MAP_DEFAULT or MAP_FATAL (stop emitting - /// diagnostics after this one). - enum Severity { + /// to either Ignore (nothing), Remark (emit a remark), Warning + /// (emit a warning) or Error (emit as an error). It allows clients to + /// map ERRORs to Error or Fatal (stop emitting diagnostics after this one). + enum class Severity { // NOTE: 0 means "uncomputed". - MAP_IGNORE = 1, ///< Map this diagnostic to nothing, ignore it. - MAP_REMARK = 2, ///< Map this diagnostic to a remark. - MAP_WARNING = 3, ///< Map this diagnostic to a warning. - MAP_ERROR = 4, ///< Map this diagnostic to an error. - MAP_FATAL = 5 ///< Map this diagnostic to a fatal error. + Ignored = 1, ///< Do not present this diagnostic, ignore it. + Remark = 2, ///< Present this diagnostic as a remark. + Warning = 3, ///< Present this diagnostic as a warning. + Error = 4, ///< Present this diagnostic as an error. + Fatal = 5 ///< Present this diagnostic as a fatal error. }; } @@ -81,7 +80,7 @@ public: static DiagnosticMapping Make(diag::Severity Severity, bool IsUser, bool IsPragma) { DiagnosticMapping Result; - Result.Severity = Severity; + Result.Severity = (unsigned)Severity; Result.IsUser = IsUser; Result.IsPragma = IsPragma; Result.HasNoWarningAsError = 0; @@ -89,8 +88,8 @@ public: return Result; } - diag::Severity getSeverity() const { return diag::Severity(Severity); } - void setSeverity(diag::Severity Value) { Severity = Value; } + diag::Severity getSeverity() const { return (diag::Severity)Severity; } + void setSeverity(diag::Severity Value) { Severity = (unsigned)Value; } bool isUser() const { return IsUser; } bool isPragma() const { return IsPragma; } @@ -257,9 +256,9 @@ private: /// \brief An internal implementation helper used when \p DiagClass is /// already known. - DiagnosticIDs::Level - getDiagnosticLevel(unsigned DiagID, unsigned DiagClass, SourceLocation Loc, - const DiagnosticsEngine &Diag) const LLVM_READONLY; + diag::Severity + getDiagnosticSeverity(unsigned DiagID, unsigned DiagClass, SourceLocation Loc, + const DiagnosticsEngine &Diag) const LLVM_READONLY; /// \brief Used to report a diagnostic that is finally fully formed. /// diff --git a/lib/ARCMigrate/ARCMT.cpp b/lib/ARCMigrate/ARCMT.cpp index 617bb6875e..6032b001d3 100644 --- a/lib/ARCMigrate/ARCMT.cpp +++ b/lib/ARCMigrate/ARCMT.cpp @@ -313,7 +313,7 @@ bool arcmt::checkForManualIssues(CompilerInvocation &origCI, pass.setNoFinalizeRemoval(NoFinalizeRemoval); if (!NoNSAllocReallocError) Diags->setDiagnosticMapping(diag::warn_arcmt_nsalloc_realloc, - diag::MAP_ERROR, SourceLocation()); + diag::Severity::Error, SourceLocation()); for (unsigned i=0, e = transforms.size(); i != e; ++i) transforms[i](pass); diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp index 97299611f0..9882688289 100644 --- a/lib/Basic/Diagnostic.cpp +++ b/lib/Basic/Diagnostic.cpp @@ -166,7 +166,7 @@ void DiagnosticsEngine::setDiagnosticMapping(diag::kind Diag, assert(Diag < diag::DIAG_UPPER_LIMIT && "Can only map builtin diagnostics"); assert((Diags->isBuiltinWarningOrExtension(Diag) || - (Map == diag::MAP_FATAL || Map == diag::MAP_ERROR)) && + (Map == diag::Severity::Fatal || Map == diag::Severity::Error)) && "Cannot map errors into warnings!"); assert(!DiagStatePoints.empty()); assert((L.isInvalid() || SourceMgr) && "No SourceMgr for valid location"); @@ -174,10 +174,10 @@ void DiagnosticsEngine::setDiagnosticMapping(diag::kind Diag, FullSourceLoc Loc = SourceMgr? FullSourceLoc(L, *SourceMgr) : FullSourceLoc(); FullSourceLoc LastStateChangePos = DiagStatePoints.back().Loc; // Don't allow a mapping to a warning override an error/fatal mapping. - if (Map == diag::MAP_WARNING) { + if (Map == diag::Severity::Warning) { DiagnosticMapping &Info = GetCurDiagState()->getOrAddMapping(Diag); - if (Info.getSeverity() == diag::MAP_ERROR || - Info.getSeverity() == diag::MAP_FATAL) + if (Info.getSeverity() == diag::Severity::Error || + Info.getSeverity() == diag::Severity::Fatal) Map = Info.getSeverity(); } DiagnosticMapping Mapping = makeUserMapping(Map, L); @@ -249,7 +249,7 @@ bool DiagnosticsEngine::setDiagnosticGroupWarningAsError(StringRef Group, // If we are enabling this feature, just set the diagnostic mappings to map to // errors. if (Enabled) - return setDiagnosticGroupMapping(Group, diag::MAP_ERROR); + return setDiagnosticGroupMapping(Group, diag::Severity::Error); // Otherwise, we want to set the diagnostic mapping's "no Werror" bit, and // potentially downgrade anything already mapped to be a warning. @@ -263,9 +263,9 @@ bool DiagnosticsEngine::setDiagnosticGroupWarningAsError(StringRef Group, for (unsigned i = 0, e = GroupDiags.size(); i != e; ++i) { DiagnosticMapping &Info = GetCurDiagState()->getOrAddMapping(GroupDiags[i]); - if (Info.getSeverity() == diag::MAP_ERROR || - Info.getSeverity() == diag::MAP_FATAL) - Info.setSeverity(diag::MAP_WARNING); + if (Info.getSeverity() == diag::Severity::Error || + Info.getSeverity() == diag::Severity::Fatal) + Info.setSeverity(diag::Severity::Warning); Info.setNoWarningAsError(true); } @@ -278,7 +278,7 @@ bool DiagnosticsEngine::setDiagnosticGroupErrorAsFatal(StringRef Group, // If we are enabling this feature, just set the diagnostic mappings to map to // fatal errors. if (Enabled) - return setDiagnosticGroupMapping(Group, diag::MAP_FATAL); + return setDiagnosticGroupMapping(Group, diag::Severity::Fatal); // Otherwise, we want to set the diagnostic mapping's "no Werror" bit, and // potentially downgrade anything already mapped to be an error. @@ -292,8 +292,8 @@ bool DiagnosticsEngine::setDiagnosticGroupErrorAsFatal(StringRef Group, for (unsigned i = 0, e = GroupDiags.size(); i != e; ++i) { DiagnosticMapping &Info = GetCurDiagState()->getOrAddMapping(GroupDiags[i]); - if (Info.getSeverity() == diag::MAP_FATAL) - Info.setSeverity(diag::MAP_ERROR); + if (Info.getSeverity() == diag::Severity::Fatal) + Info.setSeverity(diag::Severity::Error); Info.setNoErrorAsFatal(true); } diff --git a/lib/Basic/DiagnosticIDs.cpp b/lib/Basic/DiagnosticIDs.cpp index a99ae2661b..0bf4355770 100644 --- a/lib/Basic/DiagnosticIDs.cpp +++ b/lib/Basic/DiagnosticIDs.cpp @@ -155,13 +155,13 @@ CATEGORY(ANALYSIS, SEMA) static DiagnosticMapping GetDefaultDiagMapping(unsigned DiagID) { DiagnosticMapping Info = DiagnosticMapping::Make( - diag::MAP_FATAL, /*IsUser=*/false, /*IsPragma=*/false); + diag::Severity::Fatal, /*IsUser=*/false, /*IsPragma=*/false); if (const StaticDiagInfoRec *StaticInfo = GetDiagInfo(DiagID)) { Info.setSeverity((diag::Severity)StaticInfo->DefaultSeverity); if (StaticInfo->WarnNoWerror) { - assert(Info.getSeverity() == diag::MAP_WARNING && + assert(Info.getSeverity() == diag::Severity::Warning && "Unexpected mapping with no-Werror bit!"); Info.setNoWarningAsError(true); } @@ -342,7 +342,7 @@ bool DiagnosticIDs::isBuiltinExtensionDiag(unsigned DiagID, return false; EnabledByDefault = - GetDefaultDiagMapping(DiagID).getSeverity() != diag::MAP_IGNORE; + GetDefaultDiagMapping(DiagID).getSeverity() != diag::Severity::Ignored; return true; } @@ -350,7 +350,7 @@ bool DiagnosticIDs::isDefaultMappingAsError(unsigned DiagID) { if (DiagID >= diag::DIAG_UPPER_LIMIT) return false; - return GetDefaultDiagMapping(DiagID).getSeverity() == diag::MAP_ERROR; + return GetDefaultDiagMapping(DiagID).getSeverity() == diag::Severity::Error; } bool DiagnosticIDs::isRemark(unsigned DiagID) { @@ -366,6 +366,21 @@ StringRef DiagnosticIDs::getDescription(unsigned DiagID) const { return CustomDiagInfo->getDescription(DiagID); } +static DiagnosticIDs::Level toLevel(diag::Severity SV) { + switch (SV) { + case diag::Severity::Ignored: + return DiagnosticIDs::Ignored; + case diag::Severity::Remark: + return DiagnosticIDs::Remark; + case diag::Severity::Warning: + return DiagnosticIDs::Warning; + case diag::Severity::Error: + return DiagnosticIDs::Error; + case diag::Severity::Fatal: + return DiagnosticIDs::Fatal; + } +} + /// getDiagnosticLevel - Based on the way the client configured the /// DiagnosticsEngine object, classify the specified diagnostic ID into a Level, /// by consumable the DiagnosticClient. @@ -378,7 +393,7 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, SourceLocation Loc, unsigned DiagClass = getBuiltinDiagClass(DiagID); if (DiagClass == CLASS_NOTE) return DiagnosticIDs::Note; - return getDiagnosticLevel(DiagID, DiagClass, Loc, Diag); + return toLevel(getDiagnosticSeverity(DiagID, DiagClass, Loc, Diag)); } /// \brief Based on the way the client configured the Diagnostic @@ -387,13 +402,15 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, SourceLocation Loc, /// /// \param Loc The source location we are interested in finding out the /// diagnostic state. Can be null in order to query the latest state. -DiagnosticIDs::Level -DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass, - SourceLocation Loc, - const DiagnosticsEngine &Diag) const { +diag::Severity +DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, unsigned DiagClass, + SourceLocation Loc, + const DiagnosticsEngine &Diag) const { + assert(DiagClass != CLASS_NOTE); + // Specific non-error diagnostics may be mapped to various levels from ignored // to error. Errors can only be mapped to fatal. - DiagnosticIDs::Level Result = DiagnosticIDs::Fatal; + diag::Severity Result = diag::Severity::Fatal; DiagnosticsEngine::DiagStatePointsTy::iterator Pos = Diag.GetDiagStatePointForLoc(Loc); @@ -402,33 +419,19 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass, // Get the mapping information, or compute it lazily. DiagnosticMapping &Mapping = State->getOrAddMapping((diag::kind)DiagID); - switch (Mapping.getSeverity()) { - case diag::MAP_IGNORE: - Result = DiagnosticIDs::Ignored; - break; - case diag::MAP_REMARK: - Result = DiagnosticIDs::Remark; - break; - case diag::MAP_WARNING: - Result = DiagnosticIDs::Warning; - break; - case diag::MAP_ERROR: - Result = DiagnosticIDs::Error; - break; - case diag::MAP_FATAL: - Result = DiagnosticIDs::Fatal; - break; - } + // TODO: Can a null severity really get here? + if (Mapping.getSeverity() != diag::Severity()) + Result = Mapping.getSeverity(); // Upgrade ignored diagnostics if -Weverything is enabled. - if (Diag.EnableAllWarnings && Result == DiagnosticIDs::Ignored && + if (Diag.EnableAllWarnings && Result == diag::Severity::Ignored && !Mapping.isUser()) - Result = DiagnosticIDs::Warning; + Result = diag::Severity::Warning; // Diagnostics of class REMARK are either printed as remarks or in case they // have been added to -Werror they are printed as errors. - if (DiagClass == CLASS_REMARK && Result == DiagnosticIDs::Warning) - Result = DiagnosticIDs::Remark; + if (DiagClass == CLASS_REMARK && Result == diag::Severity::Warning) + Result = diag::Severity::Remark; // Ignore -pedantic diagnostics inside __extension__ blocks. // (The diagnostics controlled by -pedantic are the extension diagnostics @@ -436,7 +439,7 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass, bool EnabledByDefault = false; bool IsExtensionDiag = isBuiltinExtensionDiag(DiagID, EnabledByDefault); if (Diag.AllExtensionsSilenced && IsExtensionDiag && !EnabledByDefault) - return DiagnosticIDs::Ignored; + return diag::Severity::Ignored; // For extension diagnostics that haven't been explicitly mapped, check if we // should upgrade the diagnostic. @@ -446,37 +449,38 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass, break; case DiagnosticsEngine::Ext_Warn: // Upgrade ignored diagnostics to warnings. - if (Result == DiagnosticIDs::Ignored) - Result = DiagnosticIDs::Warning; + if (Result == diag::Severity::Ignored) + Result = diag::Severity::Warning; break; case DiagnosticsEngine::Ext_Error: // Upgrade ignored or warning diagnostics to errors. - if (Result == DiagnosticIDs::Ignored || Result == DiagnosticIDs::Warning) - Result = DiagnosticIDs::Error; + if (Result == diag::Severity::Ignored || + Result == diag::Severity::Warning) + Result = diag::Severity::Error; break; } } // At this point, ignored errors can no longer be upgraded. - if (Result == DiagnosticIDs::Ignored) + if (Result == diag::Severity::Ignored) return Result; // Honor -w, which is lower in priority than pedantic-errors, but higher than // -Werror. - if (Result == DiagnosticIDs::Warning && Diag.IgnoreAllWarnings) - return DiagnosticIDs::Ignored; + if (Result == diag::Severity::Warning && Diag.IgnoreAllWarnings) + return diag::Severity::Ignored; // If -Werror is enabled, map warnings to errors unless explicitly disabled. - if (Result == DiagnosticIDs::Warning) { + if (Result == diag::Severity::Warning) { if (Diag.WarningsAsErrors && !Mapping.hasNoWarningAsError()) - Result = DiagnosticIDs::Error; + Result = diag::Severity::Error; } // If -Wfatal-errors is enabled, map errors to fatal unless explicity // disabled. - if (Result == DiagnosticIDs::Error) { + if (Result == diag::Severity::Error) { if (Diag.ErrorsAsFatal && !Mapping.hasNoErrorAsFatal()) - Result = DiagnosticIDs::Fatal; + Result = diag::Severity::Fatal; } // Custom diagnostics always are emitted in system headers. @@ -486,11 +490,11 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass, // If we are in a system header, we ignore it. We look at the diagnostic class // because we also want to ignore extensions and warnings in -Werror and // -pedantic-errors modes, which *map* warnings/extensions to errors. - if (Result >= DiagnosticIDs::Warning && DiagClass != CLASS_ERROR && + if (Result >= diag::Severity::Warning && DiagClass != CLASS_ERROR && !ShowInSystemHeader && Diag.SuppressSystemWarnings && Loc.isValid() && Diag.getSourceManager().isInSystemHeader( Diag.getSourceManager().getExpansionLoc(Loc))) - return DiagnosticIDs::Ignored; + return diag::Severity::Ignored; return Result; } diff --git a/lib/Basic/Warnings.cpp b/lib/Basic/Warnings.cpp index df72ef7186..a0a2164423 100644 --- a/lib/Basic/Warnings.cpp +++ b/lib/Basic/Warnings.cpp @@ -107,7 +107,7 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags, // Figure out how this option affects the warning. If -Wfoo, map the // diagnostic to a warning, if -Wno-foo, map it to ignore. diag::Severity Mapping = - isPositive ? diag::MAP_WARNING : diag::MAP_IGNORE; + isPositive ? diag::Severity::Warning : diag::Severity::Ignored; // -Wsystem-headers is a special case, not driven by the option table. It // cannot be controlled with -Werror. @@ -125,7 +125,7 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags, Diags.setEnableAllWarnings(true); } else { Diags.setEnableAllWarnings(false); - Diags.setMappingForAllDiagnostics(diag::MAP_IGNORE); + Diags.setMappingForAllDiagnostics(diag::Severity::Ignored); } } continue; diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp index bde1fa1631..4a6f8dbef9 100644 --- a/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/lib/Frontend/PrintPreprocessedOutput.cpp @@ -447,19 +447,19 @@ void PrintPPOutputPPCallbacks::PragmaDiagnostic(SourceLocation Loc, MoveToLine(Loc); OS << "#pragma " << Namespace << " diagnostic "; switch (Map) { - case diag::MAP_REMARK: + case diag::Severity::Remark: OS << "remark"; break; - case diag::MAP_WARNING: + case diag::Severity::Warning: OS << "warning"; break; - case diag::MAP_ERROR: + case diag::Severity::Error: OS << "error"; break; - case diag::MAP_IGNORE: + case diag::Severity::Ignored: OS << "ignored"; break; - case diag::MAP_FATAL: + case diag::Severity::Fatal: OS << "fatal"; break; } diff --git a/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp index ea3a10d536..f1b96f8b55 100644 --- a/lib/Lex/Pragma.cpp +++ b/lib/Lex/Pragma.cpp @@ -954,16 +954,7 @@ public: IdentifierInfo *II = Tok.getIdentifierInfo(); PPCallbacks *Callbacks = PP.getPPCallbacks(); - diag::Severity Map; - if (II->isStr("warning")) - Map = diag::MAP_WARNING; - else if (II->isStr("error")) - Map = diag::MAP_ERROR; - else if (II->isStr("ignored")) - Map = diag::MAP_IGNORE; - else if (II->isStr("fatal")) - Map = diag::MAP_FATAL; - else if (II->isStr("pop")) { + if (II->isStr("pop")) { if (!PP.getDiagnostics().popMappings(DiagLoc)) PP.Diag(Tok, diag::warn_pragma_diagnostic_cannot_pop); else if (Callbacks) @@ -974,7 +965,16 @@ public: if (Callbacks) Callbacks->PragmaDiagnosticPush(DiagLoc, Namespace); return; - } else { + } + + diag::Severity SV = llvm::StringSwitch(II->getName()) + .Case("ignored", diag::Severity::Ignored) + .Case("warning", diag::Severity::Warning) + .Case("error", diag::Severity::Error) + .Case("fatal", diag::Severity::Fatal) + .Default(diag::Severity()); + + if (SV == diag::Severity()) { PP.Diag(Tok, diag::warn_pragma_diagnostic_invalid); return; } @@ -998,12 +998,12 @@ public: return; } - if (PP.getDiagnostics().setDiagnosticGroupMapping(WarningName.substr(2), - Map, DiagLoc)) + if (PP.getDiagnostics().setDiagnosticGroupMapping(WarningName.substr(2), SV, + DiagLoc)) PP.Diag(StringLoc, diag::warn_pragma_diagnostic_unknown_warning) << WarningName; else if (Callbacks) - Callbacks->PragmaDiagnostic(DiagLoc, Namespace, Map, WarningName); + Callbacks->PragmaDiagnostic(DiagLoc, Namespace, SV, WarningName); } }; diff --git a/lib/Parse/ParsePragma.cpp b/lib/Parse/ParsePragma.cpp index 751a836177..723d414015 100644 --- a/lib/Parse/ParsePragma.cpp +++ b/lib/Parse/ParsePragma.cpp @@ -1216,7 +1216,7 @@ PragmaNoOpenMPHandler::HandlePragma(Preprocessor &PP, DiagnosticsEngine::Ignored) { PP.Diag(FirstTok, diag::warn_pragma_omp_ignored); PP.getDiagnostics().setDiagnosticMapping(diag::warn_pragma_omp_ignored, - diag::MAP_IGNORE, + diag::Severity::Ignored, SourceLocation()); } PP.DiscardUntilEndOfDirective(); diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index cbb6401e2e..855991d914 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -2542,7 +2542,7 @@ void ASTWriter::WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag, I = point.State->begin(), E = point.State->end(); I != E; ++I) { if (I->second.isPragma()) { Record.push_back(I->first); - Record.push_back(I->second.getSeverity()); + Record.push_back((unsigned)I->second.getSeverity()); } } Record.push_back(-1); // mark the end of the diag/map pairs for this diff --git a/utils/TableGen/ClangDiagnosticsEmitter.cpp b/utils/TableGen/ClangDiagnosticsEmitter.cpp index b4cc70669e..76b484e783 100644 --- a/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -358,8 +358,9 @@ bool InferPedantic::isExtension(const Record *Diag) { } bool InferPedantic::isOffByDefault(const Record *Diag) { - const std::string &DefMap = Diag->getValueAsDef("DefaultMapping")->getName(); - return DefMap == "MAP_IGNORE"; + const std::string &DefSeverity = + Diag->getValueAsDef("DefaultSeverity")->getValueAsString("Name"); + return DefSeverity == "Ignored"; } bool InferPedantic::groupInPedantic(const Record *Group, bool increment) { @@ -538,7 +539,8 @@ void EmitClangDiagsDefs(RecordKeeper &Records, raw_ostream &OS, OS << "DIAG(" << R.getName() << ", "; OS << R.getValueAsDef("Class")->getName(); - OS << ", diag::" << R.getValueAsDef("DefaultMapping")->getName(); + OS << ", (unsigned)diag::Severity::" + << R.getValueAsDef("DefaultSeverity")->getValueAsString("Name"); // Description string. OS << ", \"";