diff options
| author | 2019-01-27 16:42:12 +0000 | |
|---|---|---|
| committer | 2019-01-27 16:42:12 +0000 | |
| commit | b773203fb58f3ef282fb69c832d8710cab5bc82d (patch) | |
| tree | e75913f147570fbd75169647b144df85b88a038c /gnu/llvm/lib/Support/Regex.cpp | |
| parent | tweak errno in previous (diff) | |
| download | wireguard-openbsd-b773203fb58f3ef282fb69c832d8710cab5bc82d.tar.xz wireguard-openbsd-b773203fb58f3ef282fb69c832d8710cab5bc82d.zip | |
Import LLVM 7.0.1 release including clang, lld and lldb.
Diffstat (limited to 'gnu/llvm/lib/Support/Regex.cpp')
| -rw-r--r-- | gnu/llvm/lib/Support/Regex.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/gnu/llvm/lib/Support/Regex.cpp b/gnu/llvm/lib/Support/Regex.cpp index b1087fd8853..48caab13152 100644 --- a/gnu/llvm/lib/Support/Regex.cpp +++ b/gnu/llvm/lib/Support/Regex.cpp @@ -12,11 +12,16 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/Regex.h" -#include "regex_impl.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" #include <string> + +// Important this comes last because it defines "_REGEX_H_". At least on +// Darwin, if included before any header that (transitively) includes +// xlocale.h, this will cause trouble, because of missing regex-related types. +#include "regex_impl.h" + using namespace llvm; Regex::Regex() : preg(nullptr), error(REG_BADPAT) {} @@ -25,7 +30,7 @@ Regex::Regex(StringRef regex, unsigned Flags) { unsigned flags = 0; preg = new llvm_regex(); preg->re_endp = regex.end(); - if (Flags & IgnoreCase) + if (Flags & IgnoreCase) flags |= REG_ICASE; if (Flags & Newline) flags |= REG_NEWLINE; @@ -51,9 +56,9 @@ Regex::~Regex() { bool Regex::isValid(std::string &Error) const { if (!error) return true; - + size_t len = llvm_regerror(error, preg, nullptr, 0); - + Error.resize(len - 1); llvm_regerror(error, preg, &Error[0], len); return false; @@ -91,7 +96,7 @@ bool Regex::match(StringRef String, SmallVectorImpl<StringRef> *Matches){ if (Matches) { // match position requested Matches->clear(); - + for (unsigned i = 0; i != nmatch; ++i) { if (pm[i].rm_so == -1) { // this group didn't match |
