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 //===----------------------------------------------------------------------===//
14 #include "clang/Basic/SanitizerBlacklist.h"
15
16 using namespace clang;
17
SanitizerBlacklist(const std::vector<std::string> & BlacklistPaths,SourceManager & SM)18 SanitizerBlacklist::SanitizerBlacklist(
19 const std::vector<std::string> &BlacklistPaths, SourceManager &SM)
20 : SCL(llvm::SpecialCaseList::createOrDie(BlacklistPaths)), SM(SM) {}
21
isBlacklistedGlobal(StringRef GlobalName,StringRef Category) const22 bool SanitizerBlacklist::isBlacklistedGlobal(StringRef GlobalName,
23 StringRef Category) const {
24 return SCL->inSection("global", GlobalName, Category);
25 }
26
isBlacklistedType(StringRef MangledTypeName,StringRef Category) const27 bool SanitizerBlacklist::isBlacklistedType(StringRef MangledTypeName,
28 StringRef Category) const {
29 return SCL->inSection("type", MangledTypeName, Category);
30 }
31
isBlacklistedFunction(StringRef FunctionName) const32 bool SanitizerBlacklist::isBlacklistedFunction(StringRef FunctionName) const {
33 return SCL->inSection("fun", FunctionName);
34 }
35
isBlacklistedFile(StringRef FileName,StringRef Category) const36 bool SanitizerBlacklist::isBlacklistedFile(StringRef FileName,
37 StringRef Category) const {
38 return SCL->inSection("src", FileName, Category);
39 }
40
isBlacklistedLocation(SourceLocation Loc,StringRef Category) const41 bool SanitizerBlacklist::isBlacklistedLocation(SourceLocation Loc,
42 StringRef Category) const {
43 return Loc.isValid() &&
44 isBlacklistedFile(SM.getFilename(SM.getFileLoc(Loc)), Category);
45 }
46
47