llvm.org GIT mirror llvm / 68642e9
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 Jonas Devlieghere 2 years ago
1 changed file(s) with 10 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/Support/Regex.h"
14 #include "regex_impl.h"
1514 #include "llvm/ADT/SmallVector.h"
1615 #include "llvm/ADT/StringRef.h"
1716 #include "llvm/ADT/Twine.h"
1817 #include
18
19 // Important this comes last because it defines "_REGEX_H_". At least on
20 // Darwin, if included before any header that (transitively) includes
21 // xlocale.h, this will cause trouble, because of missing regex-related types.
22 #include "regex_impl.h"
23
1924 using namespace llvm;
2025
2126 Regex::Regex() : preg(nullptr), error(REG_BADPAT) {}
2429 unsigned flags = 0;
2530 preg = new llvm_regex();
2631 preg->re_endp = regex.end();
27 if (Flags & IgnoreCase)
32 if (Flags & IgnoreCase)
2833 flags |= REG_ICASE;
2934 if (Flags & Newline)
3035 flags |= REG_NEWLINE;
5055 bool Regex::isValid(std::string &Error) const {
5156 if (!error)
5257 return true;
53
58
5459 size_t len = llvm_regerror(error, preg, nullptr, 0);
55
60
5661 Error.resize(len - 1);
5762 llvm_regerror(error, preg, &Error[0], len);
5863 return false;
9095
9196 if (Matches) { // match position requested
9297 Matches->clear();
93
98
9499 for (unsigned i = 0; i != nmatch; ++i) {
95100 if (pm[i].rm_so == -1) {
96101 // this group didn't match