[clang] [Clang] Silently ignore unknown warnings in `--warning-suppression-mappings` (PR #124141)

kadir çetinkaya via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 24 00:29:52 PST 2025


================
@@ -547,11 +547,9 @@ void WarningsSpecialCaseList::processSections(DiagnosticsEngine &Diags) {
     StringRef DiagGroup = SectionEntry->getKey();
     if (Diags.getDiagnosticIDs()->getDiagnosticsInGroup(
             WarningFlavor, DiagGroup, GroupDiags)) {
-      StringRef Suggestion =
-          DiagnosticIDs::getNearestOption(WarningFlavor, DiagGroup);
-      Diags.Report(diag::warn_unknown_diag_option)
-          << static_cast<unsigned>(WarningFlavor) << DiagGroup
-          << !Suggestion.empty() << Suggestion;
+      // If a diagnostic group name is unknown, simply ignore the
----------------
kadircet wrote:

it's intentional to emit these warnings so can we keep that but rather make sure we do respect rest of the warning options?

we can do that by moving https://github.com/llvm/llvm-project/blob/main/clang/lib/Basic/Warnings.cpp#L76-L84 past processing of other warning flags.

in addition to that, we should propagate `ReportDiags` into `DiagnosticsEngine::setDiagSuppressionMapping` and not emit warnings when it's set to false (to prevent double emitting in driver & cc1).

this is more of a FR, but we should also use source-manager and attach source-location to these warnings.

--

I am happy to do these changes myself, as they're more involved then what's in this PR currently. PLMK if you'd prefer that.

https://github.com/llvm/llvm-project/pull/124141


More information about the cfe-commits mailing list