clang  12.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 
17 #include "clang/Basic/Sanitizers.h"
19 
20 using namespace clang;
21 
23  const std::vector<std::string> &BlacklistPaths, SourceManager &SM)
24  : SSCL(SanitizerSpecialCaseList::createOrDie(
25  BlacklistPaths, SM.getFileManager().getVirtualFileSystem())),
26  SM(SM) {}
27 
29 
31  StringRef GlobalName,
32  StringRef Category) const {
33  return SSCL->inSection(Mask, "global", GlobalName, Category);
34 }
35 
37  StringRef MangledTypeName,
38  StringRef Category) const {
39  return SSCL->inSection(Mask, "type", MangledTypeName, Category);
40 }
41 
43  StringRef FunctionName) const {
44  return SSCL->inSection(Mask, "fun", FunctionName);
45 }
46 
48  StringRef FileName,
49  StringRef Category) const {
50  return SSCL->inSection(Mask, "src", FileName, Category);
51 }
52 
54  SourceLocation Loc,
55  StringRef Category) const {
56  return Loc.isValid() &&
57  isBlacklistedFile(Mask, SM.getFilename(SM.getFileLoc(Loc)), Category);
58 }
59 
Defines the clang::FileManager interface and associated types.
bool isBlacklistedType(SanitizerMask Mask, StringRef MangledTypeName, StringRef Category=StringRef()) const
Defines the SourceManager interface.
bool isBlacklistedLocation(SanitizerMask Mask, SourceLocation Loc, StringRef Category=StringRef()) const
Defines the clang::SanitizerKind enum.
int Category
Definition: Format.cpp:2065
bool isBlacklistedFile(SanitizerMask Mask, StringRef FileName, StringRef Category=StringRef()) const
StringRef getFilename(SourceLocation SpellingLoc) const
Return the filename of the file containing a SourceLocation.
bool isBlacklistedFunction(SanitizerMask Mask, StringRef FunctionName) const
#define SM(sm)
Definition: Cuda.cpp:62
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.