clang  3.9.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 //===----------------------------------------------------------------------===//
15 
16 using namespace clang;
17 
19  const std::vector<std::string> &BlacklistPaths, SourceManager &SM)
20  : SCL(llvm::SpecialCaseList::createOrDie(BlacklistPaths)), SM(SM) {}
21 
22 bool SanitizerBlacklist::isBlacklistedGlobal(StringRef GlobalName,
23  StringRef Category) const {
24  return SCL->inSection("global", GlobalName, Category);
25 }
26 
27 bool SanitizerBlacklist::isBlacklistedType(StringRef MangledTypeName,
28  StringRef Category) const {
29  return SCL->inSection("type", MangledTypeName, Category);
30 }
31 
32 bool SanitizerBlacklist::isBlacklistedFunction(StringRef FunctionName) const {
33  return SCL->inSection("fun", FunctionName);
34 }
35 
37  StringRef Category) const {
38  return SCL->inSection("src", FileName, Category);
39 }
40 
42  StringRef Category) const {
43  return Loc.isValid() &&
44  isBlacklistedFile(SM.getFilename(SM.getFileLoc(Loc)), Category);
45 }
46 
bool isBlacklistedFile(StringRef FileName, StringRef Category=StringRef()) const
int Category
Definition: Format.cpp:1197
bool isBlacklistedLocation(SourceLocation Loc, StringRef Category=StringRef()) const
SourceLocation getFileLoc(SourceLocation Loc) const
Given Loc, if it is a macro location return the expansion location or the spelling location...
StringRef getFilename(SourceLocation SpellingLoc) const
Return the filename of the file containing a SourceLocation.
const SourceManager & SM
Definition: Format.cpp:1184
StringRef FileName
Definition: Format.cpp:1313
Encodes a location in the source.
bool isBlacklistedType(StringRef MangledTypeName, StringRef Category=StringRef()) const
bool isValid() const
Return true if this is a valid SourceLocation object.
bool isBlacklistedGlobal(StringRef GlobalName, StringRef Category=StringRef()) const
bool isBlacklistedFunction(StringRef FunctionName) const
SanitizerBlacklist(const std::vector< std::string > &BlacklistPaths, SourceManager &SM)
This class handles loading and caching of source files into memory.