mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-12 14:20:33 +00: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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280339 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f4e1029357
commit
ee728f8830
@ -19,6 +19,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
Regex::Regex() : error(REG_BADPAT), preg(nullptr) {}
|
||||||
|
|
||||||
Regex::Regex(StringRef regex, unsigned Flags) {
|
Regex::Regex(StringRef regex, unsigned Flags) {
|
||||||
unsigned flags = 0;
|
unsigned flags = 0;
|
||||||
preg = new llvm_regex();
|
preg = new llvm_regex();
|
||||||
|
@ -153,4 +153,13 @@ TEST_F(RegexTest, MoveAssign) {
|
|||||||
EXPECT_TRUE(r2.match("916"));
|
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…
Reference in New Issue
Block a user