Coverage Report

Created: 2020-09-22 08:39

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Basic/SanitizerBlacklist.cpp
Line
Count
Source
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
14
#include "clang/Basic/SanitizerBlacklist.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
SanitizerBlacklist::SanitizerBlacklist(
23
    const std::vector<std::string> &BlacklistPaths, SourceManager &SM)
24
    : SSCL(SanitizerSpecialCaseList::createOrDie(
25
          BlacklistPaths, SM.getFileManager().getVirtualFileSystem())),
26
83.9k
      SM(SM) {}
27
28
78.9k
SanitizerBlacklist::~SanitizerBlacklist() = default;
29
30
bool SanitizerBlacklist::isBlacklistedGlobal(SanitizerMask Mask,
31
                                             StringRef GlobalName,
32
430
                                             StringRef Category) const {
33
430
  return SSCL->inSection(Mask, "global", GlobalName, Category);
34
430
}
35
36
bool SanitizerBlacklist::isBlacklistedType(SanitizerMask Mask,
37
                                           StringRef MangledTypeName,
38
371
                                           StringRef Category) const {
39
371
  return SSCL->inSection(Mask, "type", MangledTypeName, Category);
40
371
}
41
42
bool SanitizerBlacklist::isBlacklistedFunction(SanitizerMask Mask,
43
7.54k
                                               StringRef FunctionName) const {
44
7.54k
  return SSCL->inSection(Mask, "fun", FunctionName);
45
7.54k
}
46
47
bool SanitizerBlacklist::isBlacklistedFile(SanitizerMask Mask,
48
                                           StringRef FileName,
49
8.02k
                                           StringRef Category) const {
50
8.02k
  return SSCL->inSection(Mask, "src", FileName, Category);
51
8.02k
}
52
53
bool SanitizerBlacklist::isBlacklistedLocation(SanitizerMask Mask,
54
                                               SourceLocation Loc,
55
7.97k
                                               StringRef Category) const {
56
7.97k
  return Loc.isValid() &&
57
7.91k
         isBlacklistedFile(Mask, SM.getFilename(SM.getFileLoc(Loc)), Category);
58
7.97k
}
59