Coverage Report

Created: 2020-02-25 14:32

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Basic/Sanitizers.cpp
Line
Count
Source
1
//===- Sanitizers.cpp - C Language Family Language Options ----------------===//
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
//  This file defines the classes from Sanitizers.h
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "clang/Basic/Sanitizers.h"
14
#include "llvm/ADT/Hashing.h"
15
#include "llvm/ADT/StringSwitch.h"
16
17
using namespace clang;
18
19
// Once LLVM switches to C++17, the constexpr variables can be inline and we
20
// won't need this.
21
#define SANITIZER(NAME, ID) constexpr SanitizerMask SanitizerKind::ID;
22
#define SANITIZER_GROUP(NAME, ID, ALIAS)                                       \
23
  constexpr SanitizerMask SanitizerKind::ID;                                   \
24
  constexpr SanitizerMask SanitizerKind::ID##Group;
25
#include "clang/Basic/Sanitizers.def"
26
27
9.15k
SanitizerMask clang::parseSanitizerValue(StringRef Value, bool AllowGroups) {
28
9.15k
  SanitizerMask ParsedKind = llvm::StringSwitch<SanitizerMask>(Value)
29
485k
#define SANITIZER(NAME, ID) .Case(NAME, SanitizerKind::ID)
30
9.15k
#define SANITIZER_GROUP(NAME, ID, ALIAS)                                       \
31
100k
  .Case(NAME, AllowGroups ? 
SanitizerKind::ID86.9k
##Group :
SanitizerMask()13.8k
)
32
9.15k
#include "clang/Basic/Sanitizers.def"
33
9.15k
    .Default(SanitizerMask());
34
9.15k
  return ParsedKind;
35
9.15k
}
36
37
2.70k
SanitizerMask clang::expandSanitizerGroups(SanitizerMask Kinds) {
38
2.70k
#define SANITIZER(NAME, ID)
39
2.70k
#define SANITIZER_GROUP(NAME, ID, ALIAS)                                       \
40
29.7k
  if (Kinds & SanitizerKind::ID##Group)                                        \
41
29.7k
    
Kinds |= SanitizerKind::ID1.12k
;
42
2.70k
#include "clang/Basic/Sanitizers.def"
43
2.70k
  return Kinds;
44
2.70k
}
45
46
5
llvm::hash_code SanitizerMask::hash_value() const {
47
5
  return llvm::hash_combine_range(&maskLoToHigh[0], &maskLoToHigh[kNumElem]);
48
5
}
49
50
namespace clang {
51
5
llvm::hash_code hash_value(const clang::SanitizerMask &Arg) {
52
5
  return Arg.hash_value();
53
5
}
54
} // namespace clang