/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.7k | bool needsSharedRt() const { return SharedRuntime; } |
65 | | |
66 | 1.83k | bool needsMemProfRt() const { return NeedsMemProfRt; } |
67 | 19.6k | bool needsAsanRt() const { return Sanitizers.has(SanitizerKind::Address); } |
68 | 15.2k | bool needsHwasanRt() const { |
69 | 15.2k | return Sanitizers.has(SanitizerKind::HWAddress); |
70 | 15.2k | } |
71 | 62.4k | bool needsTsanRt() const { return Sanitizers.has(SanitizerKind::Thread); } |
72 | 15.2k | bool needsMsanRt() const { return Sanitizers.has(SanitizerKind::Memory); } |
73 | 5.73k | bool needsFuzzer() const { return Sanitizers.has(SanitizerKind::Fuzzer); } |
74 | 18.6k | bool needsLsanRt() const { |
75 | 18.6k | return Sanitizers.has(SanitizerKind::Leak) && |
76 | 70 | !Sanitizers.has(SanitizerKind::Address) && |
77 | 69 | !Sanitizers.has(SanitizerKind::HWAddress); |
78 | 18.6k | } |
79 | | bool needsFuzzerInterceptors() const; |
80 | | bool needsUbsanRt() const; |
81 | 203 | bool requiresMinimalRuntime() const { return MinimalRuntime; } |
82 | 15.1k | bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); } |
83 | 1.80k | bool needsSafeStackRt() const { return SafeStackRuntime; } |
84 | | bool needsCfiRt() const; |
85 | | bool needsCfiDiagRt() const; |
86 | 15.0k | bool needsStatsRt() const { return Stats; } |
87 | 15.1k | bool needsScudoRt() const { return Sanitizers.has(SanitizerKind::Scudo); } |
88 | | |
89 | | bool requiresPIE() const; |
90 | | bool needsUnwindTables() const; |
91 | | bool needsLTO() const; |
92 | 365 | bool linkRuntimes() const { return LinkRuntimes; } |
93 | 257 | bool linkCXXRuntimes() const { return LinkCXXRuntimes; } |
94 | 1.87k | 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 |