Coverage Report

Created: 2020-02-25 14:32

/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
  int CoverageFeatures = 0;
31
  int MsanTrackOrigins = 0;
32
  bool MsanUseAfterDtor = true;
33
  bool CfiCrossDso = false;
34
  bool CfiICallGeneralizePointers = false;
35
  bool CfiCanonicalJumpTables = false;
36
  int AsanFieldPadding = 0;
37
  bool SharedRuntime = false;
38
  bool AsanUseAfterScope = true;
39
  bool AsanPoisonCustomArrayCookie = false;
40
  bool AsanGlobalsDeadStripping = false;
41
  bool AsanUseOdrIndicator = false;
42
  bool AsanInvalidPointerCmp = false;
43
  bool AsanInvalidPointerSub = false;
44
  std::string HwasanAbi;
45
  bool LinkRuntimes = true;
46
  bool LinkCXXRuntimes = false;
47
  bool NeedPIE = false;
48
  bool SafeStackRuntime = false;
49
  bool Stats = false;
50
  bool TsanMemoryAccess = true;
51
  bool TsanFuncEntryExit = true;
52
  bool TsanAtomics = true;
53
  bool MinimalRuntime = false;
54
  // True if cross-dso CFI support if provided by the system (i.e. Android).
55
  bool ImplicitCfiRuntime = false;
56
57
 public:
58
  /// Parses the sanitizer arguments from an argument list.
59
  SanitizerArgs(const ToolChain &TC, const llvm::opt::ArgList &Args);
60
61
10.1k
  bool needsSharedRt() const { return SharedRuntime; }
62
63
11.5k
  bool needsAsanRt() const { return Sanitizers.has(SanitizerKind::Address); }
64
7.47k
  bool needsHwasanRt() const {
65
7.47k
    return Sanitizers.has(SanitizerKind::HWAddress);
66
7.47k
  }
67
10.6k
  bool needsTsanRt() const { return Sanitizers.has(SanitizerKind::Thread); }
68
7.48k
  bool needsMsanRt() const { return Sanitizers.has(SanitizerKind::Memory); }
69
5.25k
  bool needsFuzzer() const { return Sanitizers.has(SanitizerKind::Fuzzer); }
70
10.5k
  bool needsLsanRt() const {
71
10.5k
    return Sanitizers.has(SanitizerKind::Leak) &&
72
10.5k
           
!Sanitizers.has(SanitizerKind::Address)70
&&
73
10.5k
           
!Sanitizers.has(SanitizerKind::HWAddress)69
;
74
10.5k
  }
75
  bool needsUbsanRt() const;
76
193
  bool requiresMinimalRuntime() const { return MinimalRuntime; }
77
7.38k
  bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); }
78
1.63k
  bool needsSafeStackRt() const { return SafeStackRuntime; }
79
  bool needsCfiRt() const;
80
  bool needsCfiDiagRt() const;
81
7.36k
  bool needsStatsRt() const { return Stats; }
82
7.36k
  bool needsScudoRt() const { return Sanitizers.has(SanitizerKind::Scudo); }
83
84
  bool requiresPIE() const;
85
  bool needsUnwindTables() const;
86
  bool needsLTO() const;
87
345
  bool linkRuntimes() const { return LinkRuntimes; }
88
242
  bool linkCXXRuntimes() const { return LinkCXXRuntimes; }
89
1.70k
  bool hasCrossDsoCfi() const { return CfiCrossDso; }
90
192
  bool hasAnySanitizer() const { return !Sanitizers.empty(); }
91
  void addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
92
               llvm::opt::ArgStringList &CmdArgs, types::ID InputType) const;
93
};
94
95
}  // namespace driver
96
}  // namespace clang
97
98
#endif