Coverage Report

Created: 2022-05-17 06:19

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