Alexey Samsonov | b7dd329 | 2014-07-09 19:40:08 +0000 | [diff] [blame] | 1 | //===--- SanitizerBlacklist.cpp - Blacklist for sanitizers ----------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // User-provided blacklist used to disable/alter instrumentation done in |
| 11 | // sanitizers. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
Alexey Samsonov | 8d043e8 | 2014-10-15 19:57:45 +0000 | [diff] [blame] | 14 | #include "clang/Basic/SanitizerBlacklist.h" |
Alexey Samsonov | b7dd329 | 2014-07-09 19:40:08 +0000 | [diff] [blame] | 15 | |
| 16 | using namespace clang; |
Alexey Samsonov | b7dd329 | 2014-07-09 19:40:08 +0000 | [diff] [blame] | 17 | |
Alexey Samsonov | 33e00e2 | 2014-10-16 23:50:26 +0000 | [diff] [blame] | 18 | SanitizerBlacklist::SanitizerBlacklist(StringRef BlacklistPath, |
| 19 | SourceManager &SM) |
| 20 | : SCL(llvm::SpecialCaseList::createOrDie(BlacklistPath)), SM(SM) {} |
Alexey Samsonov | 0b15e34 | 2014-10-15 22:17:27 +0000 | [diff] [blame] | 21 | |
Alexey Samsonov | a0ac3c2 | 2014-10-17 22:37:33 +0000 | [diff] [blame] | 22 | bool SanitizerBlacklist::isBlacklistedGlobal(StringRef GlobalName, |
| 23 | StringRef Category) const { |
| 24 | return SCL->inSection("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 | |
Kostya Serebryany | 293dc9b | 2014-10-16 20:54:52 +0000 | [diff] [blame] | 27 | bool SanitizerBlacklist::isBlacklistedType(StringRef MangledTypeName, |
| 28 | StringRef Category) const { |
| 29 | return SCL->inSection("type", MangledTypeName, Category); |
Alexey Samsonov | 8485601 | 2014-07-10 22:34:19 +0000 | [diff] [blame] | 30 | } |
Alexey Samsonov | 74246aa | 2014-10-16 17:10:38 +0000 | [diff] [blame] | 31 | |
| 32 | bool SanitizerBlacklist::isBlacklistedFunction(StringRef FunctionName) const { |
| 33 | return SCL->inSection("fun", FunctionName); |
| 34 | } |
| 35 | |
| 36 | bool SanitizerBlacklist::isBlacklistedFile(StringRef FileName, |
| 37 | StringRef Category) const { |
| 38 | return SCL->inSection("src", FileName, Category); |
| 39 | } |
Alexey Samsonov | 33e00e2 | 2014-10-16 23:50:26 +0000 | [diff] [blame] | 40 | |
| 41 | bool SanitizerBlacklist::isBlacklistedLocation(SourceLocation Loc, |
| 42 | StringRef Category) const { |
Alexey Samsonov | fa7a856 | 2014-10-22 18:26:07 +0000 | [diff] [blame] | 43 | return !Loc.isInvalid() && |
Alexey Samsonov | 6d87ce8 | 2014-10-22 19:34:25 +0000 | [diff] [blame^] | 44 | isBlacklistedFile(SM.getFilename(SM.getFileLoc(Loc)), Category); |
Alexey Samsonov | 33e00e2 | 2014-10-16 23:50:26 +0000 | [diff] [blame] | 45 | } |
| 46 | |