mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[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
This commit is contained in:
parent
9f1d6410bd
commit
1c08997bc8
@ -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();
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user