[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280339 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
George Rimar 2016-09-01 08:00:28 +00:00
parent f4e1029357
commit ee728f8830
2 changed files with 11 additions and 0 deletions

View File

@ -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();

View File

@ -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));
}
}