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

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


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

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


>From cfef1ae29685ebc50fc0cfb5350ed56085c10f05 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Thu, 11 Jun 2026 07:21:42 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.7
---
 llvm/unittests/Support/GlobPatternTest.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

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"));
+}
 }



More information about the llvm-commits mailing list