mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-28 14:10:55 +00:00
Fix compilation on Darwin with expensive checks.
After r327219 was landed, the bot with expensive checks on GreenDragon started failing. The problem was missing symbols `regex_t` and `regmatch_t` in `xlocale/_regex.h`. The latter was included because after the change in r327219, `random` is needed, which transitively includes `xlocale.h.` which in turn conditionally includes `xlocale/_regex.h` when _REGEX_H_ is defined. Because this is the header guard in `regex_impl.h` and because `regex_impl.h` was included before the other LLVM includes, `xlocale/_regex.h` was included without the necessary types being available. This commit fixes this by moving the include of `regex_impl.h` all the way down. I also added a comment to stress the significance of its position. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327256 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d7e41ba27b
commit
68642e9a89
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user