clang 10.0.0git

SanitizerBlacklist.cpp
Go to the documentation of this file.
1 //===--- SanitizerBlacklist.cpp - Blacklist for sanitizers ----------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // User-provided blacklist used to disable/alter instrumentation done in
10 // sanitizers.
11 //
12 //===----------------------------------------------------------------------===//
13 #include "clang/Basic/SanitizerBlacklist.h"
14
15 using namespace clang;
16
17 SanitizerBlacklist::SanitizerBlacklist(
18 const std::vector<std::string> &BlacklistPaths, SourceManager &SM)
19 : SSCL(SanitizerSpecialCaseList::createOrDie(
20 BlacklistPaths, SM.getFileManager().getVirtualFileSystem())),
21 SM(SM) {}
22
23 bool SanitizerBlacklist::isBlacklistedGlobal(SanitizerMask Mask,
24 StringRef GlobalName,
25 StringRef Category) const {
26 return SSCL->inSection(Mask, "global", GlobalName, Category);
27 }
28
29 bool SanitizerBlacklist::isBlacklistedType(SanitizerMask Mask,
30 StringRef MangledTypeName,
31 StringRef Category) const {
32 return SSCL->inSection(Mask, "type", MangledTypeName, Category);
33 }
34
35 bool SanitizerBlacklist::isBlacklistedFunction(SanitizerMask Mask,
36 StringRef FunctionName) const {
37 return SSCL->inSection(Mask, "fun", FunctionName);
38 }
39
40 bool SanitizerBlacklist::isBlacklistedFile(SanitizerMask Mask,
41 StringRef FileName,
42 StringRef Category) const {
43 return SSCL->inSection(Mask, "src", FileName, Category);
44 }
45
46 bool SanitizerBlacklist::isBlacklistedLocation(SanitizerMask Mask,
47 SourceLocation Loc,
48 StringRef Category) const {
49 return Loc.isValid() &&
50 isBlacklistedFile(Mask, SM.getFilename(SM.getFileLoc(Loc)), Category);
51 }
52
clang::SanitizerBlacklist::isBlacklistedType
bool isBlacklistedType(SanitizerMask Mask, StringRef MangledTypeName, StringRef Category=StringRef()) const
Definition: SanitizerBlacklist.cpp:29
clang::SanitizerSpecialCaseList
Definition: SanitizerSpecialCaseList.h:25
clang::SanitizerBlacklist::isBlacklistedLocation
bool isBlacklistedLocation(SanitizerMask Mask, SourceLocation Loc, StringRef Category=StringRef()) const
Definition: SanitizerBlacklist.cpp:46
Category
int Category
Definition: Format.cpp:1828
clang::SanitizerBlacklist::isBlacklistedFile
bool isBlacklistedFile(SanitizerMask Mask, StringRef FileName, StringRef Category=StringRef()) const
Definition: SanitizerBlacklist.cpp:40
clang::SanitizerBlacklist::isBlacklistedFunction
bool isBlacklistedFunction(SanitizerMask Mask, StringRef FunctionName) const
Definition: SanitizerBlacklist.cpp:35
SanitizerBlacklist.h
SM
const SourceManager & SM
Definition: Format.cpp:1685
clang::SourceManager::getFilename
StringRef getFilename(SourceLocation SpellingLoc) const
Return the filename of the file containing a SourceLocation.
Definition: SourceManager.h:1101
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
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:1169
clang::SanitizerMask
Definition: Sanitizers.h:29
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
clang::SourceLocation::isValid
bool isValid() const
Return true if this is a valid SourceLocation object.
Definition: SourceLocation.h:106
clang::SanitizerBlacklist::isBlacklistedGlobal
bool isBlacklistedGlobal(SanitizerMask Mask, StringRef GlobalName, StringRef Category=StringRef()) const
Definition: SanitizerBlacklist.cpp:23
clang::SanitizerBlacklist::SanitizerBlacklist
SanitizerBlacklist(const std::vector< std::string > &BlacklistPaths, SourceManager &SM)
Definition: SanitizerBlacklist.cpp:17
clang::SourceManager
This class handles loading and caching of source files into memory.
Definition: SourceManager.h:596