clang  14.0.0git
NoSanitizeList.cpp
Go to the documentation of this file.
1 //===--- NoSanitizeList.cpp - Ignored list 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 ignore-list used to disable/alter instrumentation done in
10 // sanitizers.
11 //
12 //===----------------------------------------------------------------------===//
13 
17 #include "clang/Basic/Sanitizers.h"
19 
20 using namespace clang;
21 
22 NoSanitizeList::NoSanitizeList(const std::vector<std::string> &NoSanitizePaths,
24  : SSCL(SanitizerSpecialCaseList::createOrDie(
25  NoSanitizePaths, SM.getFileManager().getVirtualFileSystem())),
26  SM(SM) {}
27 
29 
30 bool NoSanitizeList::containsGlobal(SanitizerMask Mask, StringRef GlobalName,
31  StringRef Category) const {
32  return SSCL->inSection(Mask, "global", GlobalName, Category);
33 }
34 
35 bool NoSanitizeList::containsType(SanitizerMask Mask, StringRef MangledTypeName,
36  StringRef Category) const {
37  return SSCL->inSection(Mask, "type", MangledTypeName, Category);
38 }
39 
41  StringRef FunctionName) const {
42  return SSCL->inSection(Mask, "fun", FunctionName);
43 }
44 
45 bool NoSanitizeList::containsFile(SanitizerMask Mask, StringRef FileName,
46  StringRef Category) const {
47  return SSCL->inSection(Mask, "src", FileName, Category);
48 }
49 
51  StringRef Category) const {
52  return Loc.isValid() &&
53  containsFile(Mask, SM.getFilename(SM.getFileLoc(Loc)), Category);
54 }
clang::SourceManager::getFilename
StringRef getFilename(SourceLocation SpellingLoc) const
Return the filename of the file containing a SourceLocation.
Definition: SourceManager.cpp:1018
clang::NoSanitizeList::~NoSanitizeList
~NoSanitizeList()
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:88
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:1168
SourceManager.h
clang::SourceManager
This class handles loading and caching of source files into memory.
Definition: SourceManager.h:626
clang::NoSanitizeList::containsFunction
bool containsFunction(SanitizerMask Mask, StringRef FunctionName) const
Definition: NoSanitizeList.cpp:40
clang::NoSanitizeList::NoSanitizeList
NoSanitizeList(const std::vector< std::string > &NoSanitizeListPaths, SourceManager &SM)
Definition: NoSanitizeList.cpp:22
SanitizerSpecialCaseList.h
Category
int Category
Definition: Format.cpp:2336
NoSanitizeList.h
clang::NoSanitizeList::containsGlobal
bool containsGlobal(SanitizerMask Mask, StringRef GlobalName, StringRef Category=StringRef()) const
Definition: NoSanitizeList.cpp:30
clang::NoSanitizeList::containsFile
bool containsFile(SanitizerMask Mask, StringRef FileName, StringRef Category=StringRef()) const
Definition: NoSanitizeList.cpp:45
Sanitizers.h
clang
Definition: CalledOnceCheck.h:17
clang::NoSanitizeList::containsLocation
bool containsLocation(SanitizerMask Mask, SourceLocation Loc, StringRef Category=StringRef()) const
Definition: NoSanitizeList.cpp:50
clang::SourceLocation::isValid
bool isValid() const
Return true if this is a valid SourceLocation object.
Definition: SourceLocation.h:112
clang::NoSanitizeList::containsType
bool containsType(SanitizerMask Mask, StringRef MangledTypeName, StringRef Category=StringRef()) const
Definition: NoSanitizeList.cpp:35
clang::SanitizerSpecialCaseList
Definition: SanitizerSpecialCaseList.h:32
FileManager.h
SM
#define SM(sm)
Definition: Cuda.cpp:78
clang::SanitizerMask
Definition: Sanitizers.h:30