diff options
author | Alp Toker <alp@nuanti.com> | 2013-12-12 02:51:58 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2013-12-12 02:51:58 +0000 |
commit | d0d1a74ac9588ab13cc88af5ec2db31235ead154 (patch) | |
tree | 3c3a811850a14fb7ead2fa03e20bd43ef8ef9cb8 /llvm/unittests | |
parent | 48d1b65541e9eeb3d48f6b86948ac6ea03bf8921 (diff) | |
download | bcm5719-llvm-d0d1a74ac9588ab13cc88af5ec2db31235ead154.tar.gz bcm5719-llvm-d0d1a74ac9588ab13cc88af5ec2db31235ead154.zip |
Add missing escape characters to the new Regex::escape() function
The old AddFixedStringToRegEx() it was based on got away with this for the
longest time, but the problem became easy to spot after the cleanup in r197096.
Also add a quick unit test to cover regex escaping.
llvm-svn: 197121
Diffstat (limited to 'llvm/unittests')
-rw-r--r-- | llvm/unittests/Support/RegexTest.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/unittests/Support/RegexTest.cpp b/llvm/unittests/Support/RegexTest.cpp index 7b977f74466..abc8d0f38e0 100644 --- a/llvm/unittests/Support/RegexTest.cpp +++ b/llvm/unittests/Support/RegexTest.cpp @@ -127,6 +127,11 @@ TEST_F(RegexTest, IsLiteralERE) { EXPECT_FALSE(Regex::isLiteralERE("abc{1,2}")); } +TEST_F(RegexTest, Escape) { + EXPECT_EQ(Regex::escape("a[bc]"), "a\\[bc\\]"); + EXPECT_EQ(Regex::escape("abc{1\\,2}"), "abc\\{1\\\\,2\\}"); +} + TEST_F(RegexTest, IsValid) { std::string Error; EXPECT_FALSE(Regex("(foo").isValid(Error)); |