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 //===----------------------------------------------------------------------===//
14 
15 using namespace clang;
16 
18  const std::vector<std::string> &BlacklistPaths, SourceManager &SM)
19  : SSCL(SanitizerSpecialCaseList::createOrDie(
20  BlacklistPaths, SM.getFileManager().getVirtualFileSystem())),
21  SM(SM) {}
22 
24  StringRef GlobalName,
25  StringRef Category) const {
26  return SSCL->inSection(Mask, "global", GlobalName, Category);
27 }
28 
30  StringRef MangledTypeName,
31  StringRef Category) const {
32  return SSCL->inSection(Mask, "type", MangledTypeName, Category);
33 }
34 
36  StringRef FunctionName) const {
37  return SSCL->inSection(Mask, "fun", FunctionName);
38 }
39 
41  StringRef FileName,
42  StringRef Category) const {
43  return SSCL->inSection(Mask, "src", FileName, Category);
44 }
45 
47  SourceLocation Loc,
48  StringRef Category) const {
49  return Loc.isValid() &&
50  isBlacklistedFile(Mask, SM.getFilename(SM.getFileLoc(Loc)), Category);
51 }
52 
bool isBlacklistedType(SanitizerMask Mask, StringRef MangledTypeName, StringRef Category=StringRef()) const
bool isBlacklistedLocation(SanitizerMask Mask, SourceLocation Loc, StringRef Category=StringRef()) const
int Category
Definition: Format.cpp:1828
bool isBlacklistedFile(SanitizerMask Mask, StringRef FileName, StringRef Category=StringRef()) const
bool isBlacklistedFunction(SanitizerMask Mask, StringRef FunctionName) const
const SourceManager & SM
Definition: Format.cpp:1685
StringRef getFilename(SourceLocation SpellingLoc) const
Return the filename of the file containing a SourceLocation.
Encodes a location in the source.
SourceLocation getFileLoc(SourceLocation Loc) const
Given Loc, if it is a macro location return the expansion location or the spelling location...
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
bool isBlacklistedGlobal(SanitizerMask Mask, StringRef GlobalName, StringRef Category=StringRef()) const
SanitizerBlacklist(const std::vector< std::string > &BlacklistPaths, SourceManager &SM)
This class handles loading and caching of source files into memory.