Alexey Samsonov | b7dd329 | 2014-07-09 19:40:08 +0000 | [diff] [blame] | 1 | //===--- SanitizerBlacklist.cpp - Blacklist for sanitizers ----------------===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Alexey Samsonov | b7dd329 | 2014-07-09 19:40:08 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // User-provided blacklist used to disable/alter instrumentation done in |
| 10 | // sanitizers. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
Alexey Samsonov | 8d043e8 | 2014-10-15 19:57:45 +0000 | [diff] [blame] | 13 | #include "clang/Basic/SanitizerBlacklist.h" |
Alexey Samsonov | b7dd329 | 2014-07-09 19:40:08 +0000 | [diff] [blame] | 14 | |
| 15 | using namespace clang; |
Alexey Samsonov | b7dd329 | 2014-07-09 19:40:08 +0000 | [diff] [blame] | 16 | |
Alexey Samsonov | a511cdd | 2015-02-04 17:40:08 +0000 | [diff] [blame] | 17 | SanitizerBlacklist::SanitizerBlacklist( |
| 18 | const std::vector<std::string> &BlacklistPaths, SourceManager &SM) |
Vlad Tsyrklevich | 2eccdab | 2017-09-25 22:11:12 +0000 | [diff] [blame] | 19 | : SSCL(SanitizerSpecialCaseList::createOrDie(BlacklistPaths)), SM(SM) {} |
Alexey Samsonov | 0b15e34 | 2014-10-15 22:17:27 +0000 | [diff] [blame] | 20 | |
Vlad Tsyrklevich | 2eccdab | 2017-09-25 22:11:12 +0000 | [diff] [blame] | 21 | bool SanitizerBlacklist::isBlacklistedGlobal(SanitizerMask Mask, |
| 22 | StringRef GlobalName, |
Alexey Samsonov | a0ac3c2 | 2014-10-17 22:37:33 +0000 | [diff] [blame] | 23 | StringRef Category) const { |
Vlad Tsyrklevich | 2eccdab | 2017-09-25 22:11:12 +0000 | [diff] [blame] | 24 | return SSCL->inSection(Mask, "global", GlobalName, Category); |
Alexey Samsonov | b7dd329 | 2014-07-09 19:40:08 +0000 | [diff] [blame] | 25 | } |
Alexey Samsonov | 8485601 | 2014-07-10 22:34:19 +0000 | [diff] [blame] | 26 | |
Vlad Tsyrklevich | 2eccdab | 2017-09-25 22:11:12 +0000 | [diff] [blame] | 27 | bool SanitizerBlacklist::isBlacklistedType(SanitizerMask Mask, |
| 28 | StringRef MangledTypeName, |
Kostya Serebryany | 293dc9b | 2014-10-16 20:54:52 +0000 | [diff] [blame] | 29 | StringRef Category) const { |
Vlad Tsyrklevich | 2eccdab | 2017-09-25 22:11:12 +0000 | [diff] [blame] | 30 | return SSCL->inSection(Mask, "type", MangledTypeName, Category); |
Alexey Samsonov | 8485601 | 2014-07-10 22:34:19 +0000 | [diff] [blame] | 31 | } |
Alexey Samsonov | 74246aa | 2014-10-16 17:10:38 +0000 | [diff] [blame] | 32 | |
Vlad Tsyrklevich | 2eccdab | 2017-09-25 22:11:12 +0000 | [diff] [blame] | 33 | bool SanitizerBlacklist::isBlacklistedFunction(SanitizerMask Mask, |
| 34 | StringRef FunctionName) const { |
| 35 | return SSCL->inSection(Mask, "fun", FunctionName); |
Alexey Samsonov | 74246aa | 2014-10-16 17:10:38 +0000 | [diff] [blame] | 36 | } |
| 37 | |
Vlad Tsyrklevich | 2eccdab | 2017-09-25 22:11:12 +0000 | [diff] [blame] | 38 | bool SanitizerBlacklist::isBlacklistedFile(SanitizerMask Mask, |
| 39 | StringRef FileName, |
Alexey Samsonov | 74246aa | 2014-10-16 17:10:38 +0000 | [diff] [blame] | 40 | StringRef Category) const { |
Vlad Tsyrklevich | 2eccdab | 2017-09-25 22:11:12 +0000 | [diff] [blame] | 41 | return SSCL->inSection(Mask, "src", FileName, Category); |
Alexey Samsonov | 74246aa | 2014-10-16 17:10:38 +0000 | [diff] [blame] | 42 | } |
Alexey Samsonov | 33e00e2 | 2014-10-16 23:50:26 +0000 | [diff] [blame] | 43 | |
Vlad Tsyrklevich | 2eccdab | 2017-09-25 22:11:12 +0000 | [diff] [blame] | 44 | bool SanitizerBlacklist::isBlacklistedLocation(SanitizerMask Mask, |
| 45 | SourceLocation Loc, |
Alexey Samsonov | 33e00e2 | 2014-10-16 23:50:26 +0000 | [diff] [blame] | 46 | StringRef Category) const { |
Yaron Keren | ed1fe5d | 2015-10-03 05:15:57 +0000 | [diff] [blame] | 47 | return Loc.isValid() && |
Vlad Tsyrklevich | 2eccdab | 2017-09-25 22:11:12 +0000 | [diff] [blame] | 48 | isBlacklistedFile(Mask, SM.getFilename(SM.getFileLoc(Loc)), Category); |
Alexey Samsonov | 33e00e2 | 2014-10-16 23:50:26 +0000 | [diff] [blame] | 49 | } |
| 50 | |