Skip to content

Conversation

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Oct 14, 2025
@dyung dyung merged commit ee6c92f into main Oct 14, 2025
8 of 11 checks passed
@dyung dyung deleted the revert-163277-users/vitalybuka/spr/nfcdiagnostic-try-all-permutations-in-longest-match branch October 14, 2025 08:45
@llvmbot
Copy link
Member

llvmbot commented Oct 14, 2025

@llvm/pr-subscribers-clang

Author: None (dyung)

Changes

Reverts llvm/llvm-project#163277

The test is failing on many bots including:


Full diff: https://github.com/llvm/llvm-project/pull/163342.diff

1 Files Affected:

  • (modified) clang/unittests/Basic/DiagnosticTest.cpp (+17-30)
diff --git a/clang/unittests/Basic/DiagnosticTest.cpp b/clang/unittests/Basic/DiagnosticTest.cpp
index 0f1b1d8865af7..de090864e5095 100644
--- a/clang/unittests/Basic/DiagnosticTest.cpp
+++ b/clang/unittests/Basic/DiagnosticTest.cpp
@@ -21,7 +21,6 @@
 #include "llvm/Support/VirtualFileSystem.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
-#include <algorithm>
 #include <memory>
 #include <optional>
 #include <vector>
@@ -296,35 +295,23 @@ TEST_F(SuppressionMappingTest, EmitCategoryIsExcluded) {
 }
 
 TEST_F(SuppressionMappingTest, LongestMatchWins) {
-  StringRef Lines[] = {
-      "[unused]",
-      "src:*clang/*",
-      "src:*clang/lib/Sema/*",
-      "src:*clang/lib/Sema/*=emit",
-      "src:*clang/lib/Sema/foo*",
-  };
-  llvm::MutableArrayRef<StringRef> Rules = Lines;
-  Rules = Rules.drop_front();
-  llvm::sort(Rules);
-
-  do {
-    Diags.getDiagnosticOptions().DiagnosticSuppressionMappingsFile = "foo.txt";
-    std::string Contents = join(std::begin(Lines), std::end(Lines), "\n");
-    FS->addFile("foo.txt", /*ModificationTime=*/{},
-                llvm::MemoryBuffer::getMemBuffer(Contents));
-    clang::ProcessWarningOptions(Diags, Diags.getDiagnosticOptions(), *FS);
-    EXPECT_THAT(diags(), IsEmpty());
-
-    EXPECT_TRUE(Diags.isSuppressedViaMapping(
-        diag::warn_unused_function, locForFile("clang/lib/Basic/foo.h")))
-        << Contents;
-    EXPECT_FALSE(Diags.isSuppressedViaMapping(
-        diag::warn_unused_function, locForFile("clang/lib/Sema/bar.h")))
-        << Contents;
-    EXPECT_TRUE(Diags.isSuppressedViaMapping(
-        diag::warn_unused_function, locForFile("clang/lib/Sema/foo.h")))
-        << Contents;
-  } while (std::next_permutation(Rules.begin(), Rules.end()));
+  llvm::StringLiteral SuppressionMappingFile = R"(
+  [unused]
+  src:*clang/*
+  src:*clang/lib/Sema/*=emit
+  src:*clang/lib/Sema/foo*)";
+  Diags.getDiagnosticOptions().DiagnosticSuppressionMappingsFile = "foo.txt";
+  FS->addFile("foo.txt", /*ModificationTime=*/{},
+              llvm::MemoryBuffer::getMemBuffer(SuppressionMappingFile));
+  clang::ProcessWarningOptions(Diags, Diags.getDiagnosticOptions(), *FS);
+  EXPECT_THAT(diags(), IsEmpty());
+
+  EXPECT_TRUE(Diags.isSuppressedViaMapping(
+      diag::warn_unused_function, locForFile("clang/lib/Basic/foo.h")));
+  EXPECT_FALSE(Diags.isSuppressedViaMapping(
+      diag::warn_unused_function, locForFile("clang/lib/Sema/bar.h")));
+  EXPECT_TRUE(Diags.isSuppressedViaMapping(diag::warn_unused_function,
+                                           locForFile("clang/lib/Sema/foo.h")));
 }
 
 TEST_F(SuppressionMappingTest, LongShortMatch) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants