diff options
author | George Rimar <grimar@accesssoftek.com> | 2016-09-01 08:00:28 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2016-09-01 08:00:28 +0000 |
commit | a9ff072fe810e1f4bbd1ef21eb2535ee8cfe6304 (patch) | |
tree | 3fb38603e4ef37f1d6b5e9e2269d856d4855fc25 | |
parent | e656642295cb7730e9b7d511ffc0b2402add3df7 (diff) | |
download | bcm5719-llvm-a9ff072fe810e1f4bbd1ef21eb2535ee8cfe6304.tar.gz bcm5719-llvm-a9ff072fe810e1f4bbd1ef21eb2535ee8cfe6304.zip |
[LLVM/Support] - Create no-arguments constructor for llvm::Regex
This is useful when need to defer the construction,
e.g. using Regex as a member of class.
Differential revision: https://reviews.llvm.org/D24101
llvm-svn: 280339
-rw-r--r-- | llvm/lib/Support/Regex.cpp | 2 | ||||
-rw-r--r-- | llvm/unittests/Support/RegexTest.cpp | 9 |
2 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Support/Regex.cpp b/llvm/lib/Support/Regex.cpp index e8344ef74d9..60ce528e577 100644 --- a/llvm/lib/Support/Regex.cpp +++ b/llvm/lib/Support/Regex.cpp @@ -19,6 +19,8 @@ #include <string> using namespace llvm; +Regex::Regex() : error(REG_BADPAT), preg(nullptr) {} + Regex::Regex(StringRef regex, unsigned Flags) { unsigned flags = 0; preg = new llvm_regex(); diff --git a/llvm/unittests/Support/RegexTest.cpp b/llvm/unittests/Support/RegexTest.cpp index c045c49bc3d..7b61a03dd9b 100644 --- a/llvm/unittests/Support/RegexTest.cpp +++ b/llvm/unittests/Support/RegexTest.cpp @@ -153,4 +153,13 @@ TEST_F(RegexTest, MoveAssign) { EXPECT_TRUE(r2.match("916")); } +TEST_F(RegexTest, NoArgConstructor) { + std::string Error; + Regex r1; + EXPECT_FALSE(r1.isValid(Error)); + EXPECT_EQ("invalid regular expression", Error); + r1 = Regex("abc"); + EXPECT_TRUE(r1.isValid(Error)); +} + } |