Coverage Report

Created: 2020-09-19 12:23

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/Driver/SanitizerArgs.h
Line
Count
Source
1
//===--- SanitizerArgs.h - Arguments for sanitizer tools  -------*- C++ -*-===//
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
#ifndef LLVM_CLANG_DRIVER_SANITIZERARGS_H
9
#define LLVM_CLANG_DRIVER_SANITIZERARGS_H
10
11
#include "clang/Basic/Sanitizers.h"
12
#include "clang/Driver/Types.h"
13
#include "llvm/Option/Arg.h"
14
#include "llvm/Option/ArgList.h"
15
#include <string>
16
#include <vector>
17
18
namespace clang {
19
namespace driver {
20
21
class ToolChain;
22
23
class SanitizerArgs {
24
  SanitizerSet Sanitizers;
25
  SanitizerSet RecoverableSanitizers;
26
  SanitizerSet TrapSanitizers;
27
28
  std::vector<std::string> UserBlacklistFiles;
29
  std::vector<std::string> SystemBlacklistFiles;
30
  std::vector<std::string> CoverageAllowlistFiles;
31
  std::vector<std::string> CoverageBlocklistFiles;
32
  int CoverageFeatures = 0;
33
  int MsanTrackOrigins = 0;
34
  bool MsanUseAfterDtor = true;
35
  bool CfiCrossDso = false;
36
  bool CfiICallGeneralizePointers = false;
37
  bool CfiCanonicalJumpTables = false;
38
  int AsanFieldPadding = 0;
39
  bool SharedRuntime = false;
40
  bool AsanUseAfterScope = true;
41
  bool AsanPoisonCustomArrayCookie = false;
42
  bool AsanGlobalsDeadStripping = false;
43
  bool AsanUseOdrIndicator = false;
44
  bool AsanInvalidPointerCmp = false;
45
  bool AsanInvalidPointerSub = false;
46
  std::string HwasanAbi;
47
  bool LinkRuntimes = true;
48
  bool LinkCXXRuntimes = false;
49
  bool NeedPIE = false;
50
  bool SafeStackRuntime = false;
51
  bool Stats = false;
52
  bool TsanMemoryAccess = true;
53
  bool TsanFuncEntryExit = true;
54
  bool TsanAtomics = true;
55
  bool MinimalRuntime = false;
56
  // True if cross-dso CFI support if provided by the system (i.e. Android).
57
  bool ImplicitCfiRuntime = false;
58
  bool NeedsMemProfRt = false;
59
60
public:
61
  /// Parses the sanitizer arguments from an argument list.
62
  SanitizerArgs(const ToolChain &TC, const llvm::opt::ArgList &Args);
63
64
14.3k
  bool needsSharedRt() const { return SharedRuntime; }
65
66
1.78k
  bool needsMemProfRt() const { return NeedsMemProfRt; }
67
19.1k
  bool needsAsanRt() const { return Sanitizers.has(SanitizerKind::Address); }
68
14.8k
  bool needsHwasanRt() const {
69
14.8k
    return Sanitizers.has(SanitizerKind::HWAddress);
70
14.8k
  }
71
18.2k
  bool needsTsanRt() const { return Sanitizers.has(SanitizerKind::Thread); }
72
14.8k
  bool needsMsanRt() const { return Sanitizers.has(SanitizerKind::Memory); }
73
5.60k
  bool needsFuzzer() const { return Sanitizers.has(SanitizerKind::Fuzzer); }
74
18.1k
  bool needsLsanRt() const {
75
18.1k
    return Sanitizers.has(SanitizerKind::Leak) &&
76
70
           !Sanitizers.has(SanitizerKind::Address) &&
77
69
           !Sanitizers.has(SanitizerKind::HWAddress);
78
18.1k
  }
79
  bool needsFuzzerInterceptors() const;
80
  bool needsUbsanRt() const;
81
198
  bool requiresMinimalRuntime() const { return MinimalRuntime; }
82
14.7k
  bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); }
83
1.75k
  bool needsSafeStackRt() const { return SafeStackRuntime; }
84
  bool needsCfiRt() const;
85
  bool needsCfiDiagRt() const;
86
14.7k
  bool needsStatsRt() const { return Stats; }
87
14.7k
  bool needsScudoRt() const { return Sanitizers.has(SanitizerKind::Scudo); }
88
89
  bool requiresPIE() const;
90
  bool needsUnwindTables() const;
91
  bool needsLTO() const;
92
355
  bool linkRuntimes() const { return LinkRuntimes; }
93
252
  bool linkCXXRuntimes() const { return LinkCXXRuntimes; }
94
1.82k
  bool hasCrossDsoCfi() const { return CfiCrossDso; }
95
192
  bool hasAnySanitizer() const { return !Sanitizers.empty(); }
96
  void addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
97
               llvm::opt::ArgStringList &CmdArgs, types::ID InputType) const;
98
};
99
100
}  // namespace driver
101
}  // namespace clang
102
103
#endif