[PATCH] D27463: Change llvm::Regex to expose a fallible constructor.

Chandler Carruth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 9 17:31:06 PST 2017


chandlerc added inline comments.


================
Comment at: include/llvm/Support/YAMLTraits.h:437-438
+  }
+  // Regex constant failed to compile -- this crashes with asserts enabled.
   return false;
 }
----------------
chandlerc wrote:
> In addition to what Richard said, I would also try to use a pattern that ends up working more like:
> 
>   if (auto MyMatcher = Regex::compile(...))
>     return MyMatcher->match(...);
>   else
>     llvm_unreachable("boom");
> 
> This will give us nice assert like behavior in assert builds and will actually kill the other edge in optimized builds.
I would just re-use compileKnownValid everywhere instead of having to inline the llvm_unreachable.


https://reviews.llvm.org/D27463





More information about the llvm-commits mailing list