diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index ae71758bc81e0..55efd5ffafcec 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/lib/Basic/Diagnostic.cpp @@ -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(WarningFlavor) << DiagGroup - << !Suggestion.empty() << Suggestion; + // If a diagnostic group name is unknown, simply ignore the + // suppressions. This allows use of a single suppression file on multiple + // versions of clang. continue; } for (diag::kind Diag : GroupDiags) diff --git a/clang/test/Misc/Inputs/suppression-mapping.txt b/clang/test/Misc/Inputs/suppression-mapping.txt index abe4fde0c265d..cea8c50daee1c 100644 --- a/clang/test/Misc/Inputs/suppression-mapping.txt +++ b/clang/test/Misc/Inputs/suppression-mapping.txt @@ -11,3 +11,7 @@ src:*foo/*=emit [format=2] src:* src:*foo/*=emit + +# A warning group that clang doesn't know about should be silently ignored. +[barglegunk] +src:* diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp index 74923247b7ee1..5ef64a6a6ad99 100644 --- a/clang/tools/driver/driver.cpp +++ b/clang/tools/driver/driver.cpp @@ -319,6 +319,10 @@ int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContext) { IntrusiveRefCntPtr DiagOpts = CreateAndPopulateDiagOpts(Args); + // The _driver_ (vs cc1) diagnostics engine shouldn't bother to load a + // suppression file. + DiagOpts->DiagnosticSuppressionMappingsFile = ""; + TextDiagnosticPrinter *DiagClient = new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts); FixupDiagPrefixExeName(DiagClient, ProgName); diff --git a/clang/unittests/Basic/DiagnosticTest.cpp b/clang/unittests/Basic/DiagnosticTest.cpp index e03d9a464df7f..6c431ed81c491 100644 --- a/clang/unittests/Basic/DiagnosticTest.cpp +++ b/clang/unittests/Basic/DiagnosticTest.cpp @@ -253,8 +253,7 @@ TEST_F(SuppressionMappingTest, UnknownDiagName) { FS->addFile("foo.txt", /*ModificationTime=*/{}, llvm::MemoryBuffer::getMemBuffer("[non-existing-warning]")); clang::ProcessWarningOptions(Diags, Diags.getDiagnosticOptions(), *FS); - EXPECT_THAT(diags(), ElementsAre(WithMessage( - "unknown warning option 'non-existing-warning'"))); + EXPECT_THAT(diags(), IsEmpty()); } TEST_F(SuppressionMappingTest, SuppressesGroup) {