Coverage Report

Created: 2021-06-15 06:44

/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
101k
                                 std::string &Error) {
21
101k
  std::unique_ptr<clang::SanitizerSpecialCaseList> SSCL(
22
101k
      new SanitizerSpecialCaseList());
23
101k
  if (SSCL->createInternal(Paths, VFS, Error)) {
24
101k
    SSCL->createSanitizerSections();
25
101k
    return SSCL;
26
101k
  }
27
6
  return nullptr;
28
101k
}
29
30
std::unique_ptr<SanitizerSpecialCaseList>
31
SanitizerSpecialCaseList::createOrDie(const std::vector<std::string> &Paths,
32
101k
                                      llvm::vfs::FileSystem &VFS) {
33
101k
  std::string Error;
34
101k
  if (auto SSCL = create(Paths, VFS, Error))
35
101k
    return SSCL;
36
14
  llvm::report_fatal_error(Error);
37
101k
}
38
39
101k
void SanitizerSpecialCaseList::createSanitizerSections() {
40
101k
  for (auto &S : Sections) {
41
34
    SanitizerMask Mask;
42
43
34
#define SANITIZER(NAME, ID)                                                    \
44
2.24k
  if (S.SectionMatcher->match(NAME))                                           \
45
2.24k
    
Mask |= SanitizerKind::ID1.34k
;
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
101k
}
55
56
bool SanitizerSpecialCaseList::inSection(SanitizerMask Mask, StringRef Prefix,
57
                                         StringRef Query,
58
17.5k
                                         StringRef Category) const {
59
17.5k
  for (auto &S : SanitizerSections)
60
1.36k
    if ((S.Mask & Mask) &&
61
1.36k
        
SpecialCaseList::inSectionBlame(S.Entries, Prefix, Query, Category)1.33k
)
62
143
      return true;
63
64
17.4k
  return false;
65
17.5k
}