Coverage Report

Created: 2020-11-24 06:42

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Basic/SanitizerSpecialCaseList.cpp
Line
Count
Source
1
//===--- SanitizerSpecialCaseList.cpp - SCL 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
// An extension of SpecialCaseList to allowing querying sections by
10
// SanitizerMask.
11
//
12
//===----------------------------------------------------------------------===//
13
#include "clang/Basic/SanitizerSpecialCaseList.h"
14
15
using namespace clang;
16
17
std::unique_ptr<SanitizerSpecialCaseList>
18
SanitizerSpecialCaseList::create(const std::vector<std::string> &Paths,
19
                                 llvm::vfs::FileSystem &VFS,
20
85.9k
                                 std::string &Error) {
21
85.9k
  std::unique_ptr<clang::SanitizerSpecialCaseList> SSCL(
22
85.9k
      new SanitizerSpecialCaseList());
23
85.9k
  if (SSCL->createInternal(Paths, VFS, Error)) {
24
85.9k
    SSCL->createSanitizerSections();
25
85.9k
    return SSCL;
26
85.9k
  }
27
3
  return nullptr;
28
3
}
29
30
std::unique_ptr<SanitizerSpecialCaseList>
31
SanitizerSpecialCaseList::createOrDie(const std::vector<std::string> &Paths,
32
85.9k
                                      llvm::vfs::FileSystem &VFS) {
33
85.9k
  std::string Error;
34
85.9k
  if (auto SSCL = create(Paths, VFS, Error))
35
85.9k
    return SSCL;
36
2
  llvm::report_fatal_error(Error);
37
2
}
38
39
85.9k
void SanitizerSpecialCaseList::createSanitizerSections() {
40
34
  for (auto &S : Sections) {
41
34
    SanitizerMask Mask;
42
43
34
#define SANITIZER(NAME, ID)                                                    \
44
2.24k
  if (S.SectionMatcher->match(NAME))                                           \
45
1.34k
    Mask |= SanitizerKind::ID;
46
374
#define SANITIZER_GROUP(NAME, ID, ALIAS) SANITIZER(NAME, ID)
47
48
34
#include "clang/Basic/Sanitizers.def"
49
34
#undef SANITIZER
50
34
#undef SANITIZER_GROUP
51
52
34
    SanitizerSections.emplace_back(Mask, S.Entries);
53
34
  }
54
85.9k
}
55
56
bool SanitizerSpecialCaseList::inSection(SanitizerMask Mask, StringRef Prefix,
57
                                         StringRef Query,
58
16.3k
                                         StringRef Category) const {
59
16.3k
  for (auto &S : SanitizerSections)
60
1.36k
    if ((S.Mask & Mask) &&
61
1.33k
        SpecialCaseList::inSectionBlame(S.Entries, Prefix, Query, Category))
62
143
      return true;
63
64
16.2k
  return false;
65
16.3k
}