diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/ObjCopy/CommonConfig.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/ObjCopy/CommonConfig.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/contrib/llvm-project/llvm/lib/ObjCopy/CommonConfig.cpp b/contrib/llvm-project/llvm/lib/ObjCopy/CommonConfig.cpp index e85715d0c44c..f44e70d996b2 100644 --- a/contrib/llvm-project/llvm/lib/ObjCopy/CommonConfig.cpp +++ b/contrib/llvm-project/llvm/lib/ObjCopy/CommonConfig.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "llvm/ObjCopy/CommonConfig.h" +#include "llvm/Support/Errc.h" namespace llvm { namespace objcopy { @@ -38,6 +39,12 @@ NameOrPattern::create(StringRef Pattern, MatchStyle MS, IsPositiveMatch); } case MatchStyle::Regex: { + Regex RegEx(Pattern); + std::string Err; + if (!RegEx.isValid(Err)) + return createStringError(errc::invalid_argument, + "cannot compile regular expression \'" + + Pattern + "\': " + Err); SmallVector<char, 32> Data; return NameOrPattern(std::make_shared<Regex>( ("^" + Pattern.ltrim('^').rtrim('$') + "$").toStringRef(Data))); |