/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Basic/NoSanitizeList.cpp
Line | Count | Source |
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 | | |
14 | | #include "clang/Basic/NoSanitizeList.h" |
15 | | #include "clang/Basic/FileManager.h" |
16 | | #include "clang/Basic/SanitizerSpecialCaseList.h" |
17 | | #include "clang/Basic/Sanitizers.h" |
18 | | #include "clang/Basic/SourceManager.h" |
19 | | |
20 | | using namespace clang; |
21 | | |
22 | | NoSanitizeList::NoSanitizeList(const std::vector<std::string> &NoSanitizePaths, |
23 | | SourceManager &SM) |
24 | | : SSCL(SanitizerSpecialCaseList::createOrDie( |
25 | | NoSanitizePaths, SM.getFileManager().getVirtualFileSystem())), |
26 | 96.6k | SM(SM) {} |
27 | | |
28 | 91.5k | NoSanitizeList::~NoSanitizeList() = default; |
29 | | |
30 | | bool NoSanitizeList::containsGlobal(SanitizerMask Mask, StringRef GlobalName, |
31 | 1.70k | StringRef Category) const { |
32 | 1.70k | return SSCL->inSection(Mask, "global", GlobalName, Category); |
33 | 1.70k | } |
34 | | |
35 | | bool NoSanitizeList::containsType(SanitizerMask Mask, StringRef MangledTypeName, |
36 | 774 | StringRef Category) const { |
37 | 774 | return SSCL->inSection(Mask, "type", MangledTypeName, Category); |
38 | 774 | } |
39 | | |
40 | | bool NoSanitizeList::containsFunction(SanitizerMask Mask, |
41 | 7.54k | StringRef FunctionName) const { |
42 | 7.54k | return SSCL->inSection(Mask, "fun", FunctionName); |
43 | 7.54k | } |
44 | | |
45 | | bool NoSanitizeList::containsFile(SanitizerMask Mask, StringRef FileName, |
46 | 9.20k | StringRef Category) const { |
47 | 9.20k | return SSCL->inSection(Mask, "src", FileName, Category); |
48 | 9.20k | } |
49 | | |
50 | | bool NoSanitizeList::containsMainFile(SanitizerMask Mask, StringRef FileName, |
51 | 9.20k | StringRef Category) const { |
52 | 9.20k | return SSCL->inSection(Mask, "mainfile", FileName, Category); |
53 | 9.20k | } |
54 | | |
55 | | bool NoSanitizeList::containsLocation(SanitizerMask Mask, SourceLocation Loc, |
56 | 9.01k | StringRef Category) const { |
57 | 9.01k | return Loc.isValid() && |
58 | 9.01k | containsFile(Mask, SM.getFilename(SM.getFileLoc(Loc)), Category)8.92k ; |
59 | 9.01k | } |