[llvm] [NFC][Support] Add test for inverted slash-agnostic matching (PR #203290)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 11 07:24:22 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-support

Author: Vitaly Buka (vitalybuka)

<details>
<summary>Changes</summary>

Add a test case to GlobPatternTest to verify that inverted character
classes containing slashes (e.g. [^/] or [^\\]) behave correctly
under SlashAgnostic mode (i.e. they do not match either slash).

Assisted-by: Gemini


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


1 Files Affected:

- (modified) llvm/unittests/Support/GlobPatternTest.cpp (+14) 


``````````diff
diff --git a/llvm/unittests/Support/GlobPatternTest.cpp b/llvm/unittests/Support/GlobPatternTest.cpp
index 35423e37a3ae0..aac02bc1d7e7d 100644
--- a/llvm/unittests/Support/GlobPatternTest.cpp
+++ b/llvm/unittests/Support/GlobPatternTest.cpp
@@ -471,4 +471,18 @@ TEST_F(GlobPatternTest, SlashAgnosticMatchInverted) {
   EXPECT_FALSE(Pat->match("foo/barb"));
   EXPECT_TRUE(Pat->match("foo/bar1"));
 }
+
+TEST_F(GlobPatternTest, SlashAgnosticInvertedSlash) {
+  auto Pat1 = GlobPattern::create("foo[^/]", 1024, /*SlashAgnostic=*/true);
+  ASSERT_TRUE((bool)Pat1);
+  EXPECT_FALSE(Pat1->match("foo/"));
+  EXPECT_FALSE(Pat1->match("foo\\"));
+  EXPECT_TRUE(Pat1->match("fooa"));
+
+  auto Pat2 = GlobPattern::create("foo[^\\]", 1024, /*SlashAgnostic=*/true);
+  ASSERT_TRUE((bool)Pat2);
+  EXPECT_FALSE(Pat2->match("foo/"));
+  EXPECT_FALSE(Pat2->match("foo\\"));
+  EXPECT_TRUE(Pat2->match("fooa"));
+}
 }

``````````

</details>


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


More information about the llvm-commits mailing list