clang  9.0.0svn
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(BlacklistPaths)), SM(SM) {}
20 
22  StringRef GlobalName,
23  StringRef Category) const {
24  return SSCL->inSection(Mask, "global", GlobalName, Category);
25 }
26 
28  StringRef MangledTypeName,
29  StringRef Category) const {
30  return SSCL->inSection(Mask, "type", MangledTypeName, Category);
31 }
32 
34  StringRef FunctionName) const {
35  return SSCL->inSection(Mask, "fun", FunctionName);
36 }
37 
39  StringRef FileName,
40  StringRef Category) const {
41  return SSCL->inSection(Mask, "src", FileName, Category);
42 }
43 
45  SourceLocation Loc,
46  StringRef Category) const {
47  return Loc.isValid() &&
48  isBlacklistedFile(Mask, SM.getFilename(SM.getFileLoc(Loc)), Category);
49 }
50 
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:1710
bool isBlacklistedFile(SanitizerMask Mask, StringRef FileName, StringRef Category=StringRef()) const
bool isBlacklistedFunction(SanitizerMask Mask, StringRef FunctionName) const
const SourceManager & SM
Definition: Format.cpp:1568
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.