Skip to content

Commit

Permalink
[LLVM/Support] - Create no-arguments constructor for llvm::Regex
Browse files Browse the repository at this point in the history
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
  • Loading branch information
George Rimar committed Sep 1, 2016
1 parent e656642 commit a9ff072
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions llvm/lib/Support/Regex.cpp
Expand Up @@ -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();
Expand Down
9 changes: 9 additions & 0 deletions llvm/unittests/Support/RegexTest.cpp
Expand Up @@ -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));
}

}

0 comments on commit a9ff072

Please sign in to comment.