[PATCH] D27318: Support escaping in TrigramIndex.
Ivan Krasin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 2 11:01:13 PST 2016
krasin marked an inline comment as done.
krasin added inline comments.
================
Comment at: lib/Support/TrigramIndex.cpp:60-68
+ case 'n':
+ Char = '\n';
+ break;
+ case 't':
+ Char = '\t';
+ break;
+ // Decimal escapes are backreferences.
----------------
pcc wrote:
> This part doesn't look right. Neither 'n', 't' nor '0' are special. See: http://llvm-cs.pcc.me.uk/lib/Support/regcomp.c#379
>
> I confirmed it with this passing test:
> ```
> diff --git a/llvm/unittests/Support/RegexTest.cpp b/llvm/unittests/Support/RegexTest.cpp
> index 5e3ce39..e151f47 100644
> --- a/llvm/unittests/Support/RegexTest.cpp
> +++ b/llvm/unittests/Support/RegexTest.cpp
> @@ -171,4 +171,16 @@ TEST_F(RegexTest, MatchInvalid) {
> EXPECT_FALSE(r1.match("X"));
> }
>
> +TEST_F(RegexTest, foo) {
> + Regex r1("\\t");
> + EXPECT_TRUE(r1.match("t"));
> + EXPECT_FALSE(r1.match("\t"));
> + Regex r2("\\n");
> + EXPECT_TRUE(r2.match("n"));
> + EXPECT_FALSE(r2.match("\n"));
> + Regex r3("\\0");
> + EXPECT_TRUE(r3.match("0"));
> + EXPECT_FALSE(r3.match("x"));
> +}
> +
> }
>
> ```
You're right. Thank you for the catch. Fixed.
https://reviews.llvm.org/D27318
More information about the llvm-commits
mailing list