Coverage Report

Created: 2022-07-16 07:03

/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
96.6k
                                 std::string &Error) {
21
96.6k
  std::unique_ptr<clang::SanitizerSpecialCaseList> SSCL(
22
96.6k
      new SanitizerSpecialCaseList());
23
96.6k
  if (SSCL->createInternal(Paths, VFS, Error)) {
24
96.6k
    SSCL->createSanitizerSections();
25
96.6k
    return SSCL;
26
96.6k
  }
27
1
  return nullptr;
28
96.6k
}
29
30
std::unique_ptr<SanitizerSpecialCaseList>
31
SanitizerSpecialCaseList::createOrDie(const std::vector<std::string> &Paths,
32
96.6k
                                      llvm::vfs::FileSystem &VFS) {
33
96.6k
  std::string Error;
34
96.6k
  if (auto SSCL = create(Paths, VFS, Error))
35
96.6k
    return SSCL;
36
1
  llvm::report_fatal_error(Error);
37
1
}
38
39
96.6k
void SanitizerSpecialCaseList::createSanitizerSections() {
40
96.6k
  for (auto &S : Sections) {
41
81
    SanitizerMask Mask;
42
43
81
#define SANITIZER(NAME, ID)                                                    \
44
5.58k
  if (S.SectionMatcher->match(NAME))                                           \
45
5.58k
    
Mask |= SanitizerKind::ID2.34k
;
46
972
#define SANITIZER_GROUP(NAME, ID, ALIAS) SANITIZER(NAME, ID)
47
48
81
#include "clang/Basic/Sanitizers.def"
49
81
#undef SANITIZER
50
81
#undef SANITIZER_GROUP
51
52
81
    SanitizerSections.emplace_back(Mask, S.Entries);
53
81
  }
54
96.6k
}
55
56
bool SanitizerSpecialCaseList::inSection(SanitizerMask Mask, StringRef Prefix,
57
                                         StringRef Query,
58
28.4k
                                         StringRef Category) const {
59
28.4k
  for (auto &S : SanitizerSections)
60
5.88k
    if ((S.Mask & Mask) &&
61
5.88k
        
SpecialCaseList::inSectionBlame(S.Entries, Prefix, Query, Category)2.41k
)
62
227
      return true;
63
64
28.2k
  return false;
65
28.4k
}