Skip to content

Conversation

vitalybuka
Copy link
Collaborator

I want to change behavior, but none of existing tests sees the difference.

Created using spr 1.3.6
@vitalybuka vitalybuka requested a review from kadircet October 6, 2025 23:11
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Oct 6, 2025
@vitalybuka vitalybuka requested review from fmayer and thurstond October 6, 2025 23:11
@llvmbot
Copy link
Member

llvmbot commented Oct 6, 2025

@llvm/pr-subscribers-clang

Author: Vitaly Buka (vitalybuka)

Changes

I want to change behavior, but none of existing tests sees the difference.


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

1 Files Affected:

  • (modified) clang/unittests/Basic/DiagnosticTest.cpp (+19)
diff --git a/clang/unittests/Basic/DiagnosticTest.cpp b/clang/unittests/Basic/DiagnosticTest.cpp
index 4b3af00c3b0ce..bf0d68ba3b41e 100644
--- a/clang/unittests/Basic/DiagnosticTest.cpp
+++ b/clang/unittests/Basic/DiagnosticTest.cpp
@@ -314,6 +314,25 @@ TEST_F(SuppressionMappingTest, LongestMatchWins) {
                                            locForFile("clang/lib/Sema/foo.h")));
 }
 
+TEST_F(SuppressionMappingTest, LongShortMatch) {
+  llvm::StringLiteral SuppressionMappingFile = R"(
+  [unused]
+  src:*test/*
+  src:*lld/*=emit)";
+  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("test/my_test1.cpp")));
+
+  // FIXME: This is confusing.
+  EXPECT_TRUE(Diags.isSuppressedViaMapping(diag::warn_unused_function,
+                                           locForFile("lld/test/my_test2.cpp")));
+}
+
 TEST_F(SuppressionMappingTest, IsIgnored) {
   llvm::StringLiteral SuppressionMappingFile = R"(
   [unused]

@vitalybuka vitalybuka changed the title [NFC][clang] Precommit test with confusing behavior os suppression list [NFC][clang] Precommit test with confusing behavior of suppression list Oct 6, 2025
@vitalybuka vitalybuka enabled auto-merge (squash) October 6, 2025 23:12
Copy link

github-actions bot commented Oct 6, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@vitalybuka vitalybuka disabled auto-merge October 6, 2025 23:18
Created using spr 1.3.6
@vitalybuka vitalybuka enabled auto-merge (squash) October 6, 2025 23:43
@vitalybuka vitalybuka merged commit 4e71976 into main Oct 7, 2025
9 checks passed
@vitalybuka vitalybuka deleted the users/vitalybuka/spr/nfcclang-precommit-test-with-confusing-behavior-os-suppression-list branch October 7, 2025 00:03
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.

4 participants