Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/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
41.7k
                                 std::string &Error) {
20
41.7k
  std::unique_ptr<clang::SanitizerSpecialCaseList> SSCL(
21
41.7k
      new SanitizerSpecialCaseList());
22
41.7k
  if (
SSCL->createInternal(Paths, Error)41.7k
) {
23
41.7k
    SSCL->createSanitizerSections();
24
41.7k
    return SSCL;
25
41.7k
  }
26
18.4E
  return nullptr;
27
18.4E
}
28
29
std::unique_ptr<SanitizerSpecialCaseList>
30
41.7k
SanitizerSpecialCaseList::createOrDie(const std::vector<std::string> &Paths) {
31
41.7k
  std::string Error;
32
41.7k
  if (auto SSCL = create(Paths, Error))
33
41.7k
    return SSCL;
34
18.4E
  llvm::report_fatal_error(Error);
35
18.4E
}
36
37
41.7k
void SanitizerSpecialCaseList::createSanitizerSections() {
38
41.7k
  for (auto &S : Sections) {
39
34
    SanitizerMask Mask;
40
34
41
34
#define SANITIZER(NAME, ID)                                                    \
42
2.17k
  if (S.SectionMatcher->match(NAME))                                           \
43
2.17k
    
Mask |= SanitizerKind::ID1.43k
;
44
374
#define SANITIZER_GROUP(NAME, ID, ALIAS) SANITIZER(NAME, ID)
45
34
46
34
#include "clang/Basic/Sanitizers.def"
47
34
#undef SANITIZER
48
34
#undef SANITIZER_GROUP
49
34
50
34
    SanitizerSections.emplace_back(Mask, S.Entries);
51
34
  }
52
41.7k
}
53
54
bool SanitizerSpecialCaseList::inSection(SanitizerMask Mask, StringRef Prefix,
55
                                         StringRef Query,
56
13.0k
                                         StringRef Category) const {
57
13.0k
  for (auto &S : SanitizerSections)
58
1.25k
    if ((S.Mask & Mask) &&
59
1.25k
        
SpecialCaseList::inSectionBlame(S.Entries, Prefix, Query, Category)1.23k
)
60
123
      return true;
61
13.0k
62
13.0k
  
return false12.9k
;
63
13.0k
}