Coverage Report

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