Support escaping in TrigramIndex.
Summary:
This is a follow up to r288303, where I have introduced TrigramIndex
to speed up SpecialCaseList for the cases when all rules are
simple wildcards, like *hello*wor.d*.
Here, I add support for escaping, so that it's possible to
specify rules like *c\+\+abi*.
Reviewers: pcc
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D27318
llvm-svn: 288553
diff --git a/llvm/unittests/Support/SpecialCaseListTest.cpp b/llvm/unittests/Support/SpecialCaseListTest.cpp
index 4647499..e86eecb 100644
--- a/llvm/unittests/Support/SpecialCaseListTest.cpp
+++ b/llvm/unittests/Support/SpecialCaseListTest.cpp
@@ -178,4 +178,15 @@
EXPECT_TRUE(SCL->inSection("fun", "aaaabbbaaa"));
}
+TEST_F(SpecialCaseListTest, EscapedSymbols) {
+ std::unique_ptr<SpecialCaseList> SCL = makeSpecialCaseList("src:*c\\+\\+abi*\n"
+ "src:*hello\\\\world*\n");
+ EXPECT_TRUE(SCL->inSection("src", "dir/c++abi"));
+ EXPECT_FALSE(SCL->inSection("src", "dir/c\\+\\+abi"));
+ EXPECT_FALSE(SCL->inSection("src", "c\\+\\+abi"));
+ EXPECT_TRUE(SCL->inSection("src", "C:\\hello\\world"));
+ EXPECT_TRUE(SCL->inSection("src", "hello\\world"));
+ EXPECT_FALSE(SCL->inSection("src", "hello\\\\world"));
+}
+
}