clang 8.0.0

SanitizerBlacklist.cpp
Go to the documentation of this file.
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 : SSCL(SanitizerSpecialCaseList::createOrDie(BlacklistPaths)), SM(SM) {}
21
22 bool SanitizerBlacklist::isBlacklistedGlobal(SanitizerMask Mask,
23 StringRef GlobalName,
24 StringRef Category) const {
25 return SSCL->inSection(Mask, "global", GlobalName, Category);
26 }
27
28 bool SanitizerBlacklist::isBlacklistedType(SanitizerMask Mask,
29 StringRef MangledTypeName,
30 StringRef Category) const {
31 return SSCL->inSection(Mask, "type", MangledTypeName, Category);
32 }
33
34 bool SanitizerBlacklist::isBlacklistedFunction(SanitizerMask Mask,
35 StringRef FunctionName) const {
36 return SSCL->inSection(Mask, "fun", FunctionName);
37 }
38
39 bool SanitizerBlacklist::isBlacklistedFile(SanitizerMask Mask,
40 StringRef FileName,
41 StringRef Category) const {
42 return SSCL->inSection(Mask, "src", FileName, Category);
43 }
44
45 bool SanitizerBlacklist::isBlacklistedLocation(SanitizerMask Mask,
46 SourceLocation Loc,
47 StringRef Category) const {
48 return Loc.isValid() &&
49 isBlacklistedFile(Mask, SM.getFilename(SM.getFileLoc(Loc)), Category);
50 }
51
clang::SanitizerBlacklist::isBlacklistedType
bool isBlacklistedType(SanitizerMask Mask, StringRef MangledTypeName, StringRef Category=StringRef()) const
Definition: SanitizerBlacklist.cpp:28
clang::SanitizerSpecialCaseList
Definition: SanitizerSpecialCaseList.h:25
clang::SanitizerBlacklist::isBlacklistedLocation
bool isBlacklistedLocation(SanitizerMask Mask, SourceLocation Loc, StringRef Category=StringRef()) const
Definition: SanitizerBlacklist.cpp:45
Category
int Category
Definition: Format.cpp:1632
clang::SanitizerBlacklist::isBlacklistedFile
bool isBlacklistedFile(SanitizerMask Mask, StringRef FileName, StringRef Category=StringRef()) const
Definition: SanitizerBlacklist.cpp:39
clang::SanitizerBlacklist::isBlacklistedFunction
bool isBlacklistedFunction(SanitizerMask Mask, StringRef FunctionName) const
Definition: SanitizerBlacklist.cpp:34
SanitizerBlacklist.h
SM
const SourceManager & SM
Definition: Format.cpp:1490
clang::SourceManager::getFilename
StringRef getFilename(SourceLocation SpellingLoc) const
Return the filename of the file containing a SourceLocation.
Definition: SourceManager.h:1059
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:88
clang::SourceManager::getFileLoc
SourceLocation getFileLoc(SourceLocation Loc) const
Given Loc, if it is a macro location return the expansion location or the spelling location...
Definition: SourceManager.h:1127
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::SourceLocation::isValid
bool isValid() const
Return true if this is a valid SourceLocation object.
Definition: SourceLocation.h:108
clang::SanitizerMask
uint64_t SanitizerMask
Definition: Sanitizers.h:26
clang::SanitizerBlacklist::isBlacklistedGlobal
bool isBlacklistedGlobal(SanitizerMask Mask, StringRef GlobalName, StringRef Category=StringRef()) const
Definition: SanitizerBlacklist.cpp:22
clang::SanitizerBlacklist::SanitizerBlacklist
SanitizerBlacklist(const std::vector< std::string > &BlacklistPaths, SourceManager &SM)
Definition: SanitizerBlacklist.cpp:18
clang::SourceManager
This class handles loading and caching of source files into memory.
Definition: SourceManager.h:582