Coverage Report

Created: 2020-09-15 12:33

/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
83.6k
                                 std::string &Error) {
21
83.6k
  std::unique_ptr<clang::SanitizerSpecialCaseList> SSCL(
22
83.6k
      new SanitizerSpecialCaseList());
23
83.6k
  if (SSCL->createInternal(Paths, VFS, Error)) {
24
83.6k
    SSCL->createSanitizerSections();
25
83.6k
    return SSCL;
26
83.6k
  }
27
2
  return nullptr;
28
2
}
29
30
std::unique_ptr<SanitizerSpecialCaseList>
31
SanitizerSpecialCaseList::createOrDie(const std::vector<std::string> &Paths,
32
83.6k
                                      llvm::vfs::FileSystem &VFS) {
33
83.6k
  std::string Error;
34
83.6k
  if (auto SSCL = create(Paths, VFS, Error))
35
83.6k
    return SSCL;
36
4
  llvm::report_fatal_error(Error);
37
4
}
38
39
83.6k
void SanitizerSpecialCaseList::createSanitizerSections() {
40
32
  for (auto &S : Sections) {
41
32
    SanitizerMask Mask;
42
32
43
32
#define SANITIZER(NAME, ID)                                                    \
44
2.11k
  if (S.SectionMatcher->match(NAME))                                           \
45
1.34k
    Mask |= SanitizerKind::ID;
46
352
#define SANITIZER_GROUP(NAME, ID, ALIAS) SANITIZER(NAME, ID)
47
32
48
32
#include "clang/Basic/Sanitizers.def"
49
32
#undef SANITIZER
50
32
#undef SANITIZER_GROUP
51
32
52
32
    SanitizerSections.emplace_back(Mask, S.Entries);
53
32
  }
54
83.6k
}
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.35k
    if ((S.Mask & Mask) &&
61
1.33k
        SpecialCaseList::inSectionBlame(S.Entries, Prefix, Query, Category))
62
140
      return true;
63
16.3k
64
16.2k
  return false;
65
16.3k
}