[PATCH] D24101: [LLVM/Support] - Create no-arguments constructor for llvm::Regex

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 1 01:08:49 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL280339: [LLVM/Support] - Create no-arguments constructor for llvm::Regex (authored by grimar).

Changed prior to commit:
  https://reviews.llvm.org/D24101?vs=69901&id=69955#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24101

Files:
  llvm/trunk/lib/Support/Regex.cpp
  llvm/trunk/unittests/Support/RegexTest.cpp

Index: llvm/trunk/lib/Support/Regex.cpp
===================================================================
--- llvm/trunk/lib/Support/Regex.cpp
+++ llvm/trunk/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();
Index: llvm/trunk/unittests/Support/RegexTest.cpp
===================================================================
--- llvm/trunk/unittests/Support/RegexTest.cpp
+++ llvm/trunk/unittests/Support/RegexTest.cpp
@@ -153,4 +153,13 @@
   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));
+}
+
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24101.69955.patch
Type: text/x-patch
Size: 897 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160901/70dd40c9/attachment.bin>


More information about the llvm-commits mailing list