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 18 SanitizerBlacklist::SanitizerBlacklist( 19 const std::vector<std::string> &BlacklistPaths, SourceManager &SM) 20 : SCL(llvm::SpecialCaseList::createOrDie(BlacklistPaths)), SM(SM) {} 21 22 bool SanitizerBlacklist::isBlacklistedGlobal(StringRef GlobalName, 23 StringRef Category) const { 24 return SCL->inSection("global", GlobalName, Category); 25 } 26 27 bool SanitizerBlacklist::isBlacklistedType(StringRef MangledTypeName, 28 StringRef Category) const { 29 return SCL->inSection("type", MangledTypeName, Category); 30 } 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 } 40 41 bool SanitizerBlacklist::isBlacklistedLocation(SourceLocation Loc, 42 StringRef Category) const { 43 return Loc.isValid() && 44 isBlacklistedFile(SM.getFilename(SM.getFileLoc(Loc)), Category); 45 } 46 47