| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | #include "clang/Basic/SanitizerSpecialCaseList.h" |
| 14 | |
| 15 | using namespace clang; |
| 16 | |
| 17 | std::unique_ptr<SanitizerSpecialCaseList> |
| 18 | SanitizerSpecialCaseList::create(const std::vector<std::string> &Paths, |
| 19 | std::string &Error) { |
| 20 | std::unique_ptr<clang::SanitizerSpecialCaseList> SSCL( |
| 21 | new SanitizerSpecialCaseList()); |
| 22 | if (SSCL->createInternal(Paths, Error)) { |
| 23 | SSCL->createSanitizerSections(); |
| 24 | return SSCL; |
| 25 | } |
| 26 | return nullptr; |
| 27 | } |
| 28 | |
| 29 | std::unique_ptr<SanitizerSpecialCaseList> |
| 30 | SanitizerSpecialCaseList::createOrDie(const std::vector<std::string> &Paths) { |
| 31 | std::string Error; |
| 32 | if (auto SSCL = create(Paths, Error)) |
| 33 | return SSCL; |
| 34 | llvm::report_fatal_error(Error); |
| 35 | } |
| 36 | |
| 37 | void SanitizerSpecialCaseList::createSanitizerSections() { |
| 38 | for (auto &S : Sections) { |
| 39 | SanitizerMask Mask; |
| 40 | |
| 41 | #define SANITIZER(NAME, ID) \ |
| 42 | if (S.SectionMatcher->match(NAME)) \ |
| 43 | Mask |= SanitizerKind::ID; |
| 44 | #define SANITIZER_GROUP(NAME, ID, ALIAS) SANITIZER(NAME, ID) |
| 45 | |
| 46 | #include "clang/Basic/Sanitizers.def" |
| 47 | #undef SANITIZER |
| 48 | #undef SANITIZER_GROUP |
| 49 | |
| 50 | SanitizerSections.emplace_back(Mask, S.Entries); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | bool SanitizerSpecialCaseList::inSection(SanitizerMask Mask, StringRef Prefix, |
| 55 | StringRef Query, |
| 56 | StringRef Category) const { |
| 57 | for (auto &S : SanitizerSections) |
| 58 | if ((S.Mask & Mask) && |
| 59 | SpecialCaseList::inSectionBlame(S.Entries, Prefix, Query, Category)) |
| 60 | return true; |
| 61 | |
| 62 | return false; |
| 63 | } |
| 64 | |