================ @@ -164,6 +164,40 @@ TEST_F(MatchFilePathTest, Path) { EXPECT_FALSE(match("foo\\", R"(foo*\)")); } +TEST_F(MatchFilePathTest, DoubleAsterisk) { + EXPECT_TRUE(match("a/b/c/d.cpp", "**b**")); + EXPECT_TRUE(match("a/b/c/d.cpp", "**/b/**")); + EXPECT_TRUE(match("a/b/c/d_e.cpp", "**d_*")); + EXPECT_TRUE(match("a/b/c/d_e.cpp", "**/d_*")); + EXPECT_TRUE(match("a/b/c/d_e.cpp", "**d_**")); + EXPECT_TRUE(match("a/b/c/d_e.cpp", "**/d_**")); + + EXPECT_TRUE(match("a/b/c/d_e.cpp", "**/b/c/**")); + + EXPECT_TRUE(match("a/b/c/d_e.cpp", "a/**/b/c/d_e.cpp")); + EXPECT_TRUE(match("a/b/c/d_e.cpp", "a/**/c/d_e.cpp")); + EXPECT_TRUE(match("a/b/c/d_e.cpp", "a/**/b/**/d_e.cpp")); + EXPECT_TRUE(match("a/b/c/d_e.cpp", "**/b/**/d_e.cpp")); + EXPECT_TRUE(match("a/b/c/d_e.cpp", "a/**/**/b/**")); + + EXPECT_FALSE(match("a/b/c/d_e.cpp", "**/d")); + EXPECT_FALSE(match("a/b/c/d_e.cpp", "**/b/d")); + EXPECT_FALSE(match("a/b/c/d_e.cpp", "**/b/d/**")); + EXPECT_FALSE(match("a/b/c/d_e.cpp", "**/b/c/")); + + // Multiple consecutive asterisks are treated as ** + EXPECT_TRUE(match("a/b/c/d.cpp", "***b****")); + EXPECT_TRUE(match("a/b/c/d.cpp", "****/b/***")); + EXPECT_TRUE(match("a/b/c/d_e.cpp", "***d_**")); + EXPECT_TRUE(match("a/b/c/d_e.cpp", "****/d_*")); + EXPECT_TRUE(match("a/b/c/d_e.cpp", "***/b/c/*****")); + + EXPECT_FALSE(match("a/b/c/d_e.cpp", "*****/d")); + EXPECT_FALSE(match("a/b/c/d_e.cpp", "***/b/d")); + EXPECT_FALSE(match("a/b/c/d_e.cpp", "*****/b/d/***")); + EXPECT_FALSE(match("a/b/c/d_e.cpp", "***/b/c")); ---------------- owenca wrote:
> > unless there's a good reason > > This came up as I have been working on adding support for clang-format within > [AMD's PAL repository](https://github.com/GPUOpen-Drivers/pal) and found > clang-format-ignore to be extremely limiting. How is it _extremely_ limited? Just because it doesn't support `**` in the middle of the pathnames? How did you manage before clang-format gained the `.clang-format-ignore` functionality? > There are 2 key reasons I am adding this feature: > > * Simplifying Subdirectory Exclusion: `**` allows for easy exclusion of > entire subdirectories. Currently you need to specify each depth level in a > subdirectory individually. We have `DisableFormat` for that. > * Pattern-Based File Ignoring: `**` simplifies ignoring specific file > patterns that may appear at any level within a directory tree, which is > especially useful when the exact depth of these files can vary I was conscious of this use case, but you can do something like `find . -name dont-format-me >> .clang-format-ignore` even though it's less than ideal. > > and strong demand for it. > > How do we gauge how much of a demand there is for this feature? See https://github.com/llvm/llvm-project/issues/52975#issue-1093103318. If we were to add `**` to match gitignore, we should also handle it at the beginning and the end of a pathname. https://github.com/llvm/llvm-project/pull/110560 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits