1 //===--- SanitizerArgs.h - Arguments for sanitizer tools -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_DRIVER_SANITIZERARGS_H
10 #define LLVM_CLANG_DRIVER_SANITIZERARGS_H
12 #include "clang/Basic/Sanitizers.h"
13 #include "clang/Driver/Types.h"
14 #include "llvm/Option/Arg.h"
15 #include "llvm/Option/ArgList.h"
25 SanitizerSet Sanitizers;
26 SanitizerSet RecoverableSanitizers;
27 SanitizerSet TrapSanitizers;
29 std::vector<std::string> BlacklistFiles;
30 std::vector<std::string> ExtraDeps;
31 int CoverageFeatures = 0;
32 int MsanTrackOrigins = 0;
33 bool MsanUseAfterDtor = false;
34 bool CfiCrossDso = false;
35 int AsanFieldPadding = 0;
36 bool AsanSharedRuntime = false;
37 bool AsanUseAfterScope = false;
38 bool LinkCXXRuntimes = false;
41 bool TsanMemoryAccess = true;
42 bool TsanFuncEntryExit = true;
43 bool TsanAtomics = true;
46 /// Parses the sanitizer arguments from an argument list.
47 SanitizerArgs(const ToolChain &TC, const llvm::opt::ArgList &Args);
49 bool needsAsanRt() const { return Sanitizers.has(SanitizerKind::Address); }
50 bool needsSharedAsanRt() const { return AsanSharedRuntime; }
51 bool needsTsanRt() const { return Sanitizers.has(SanitizerKind::Thread); }
52 bool needsMsanRt() const { return Sanitizers.has(SanitizerKind::Memory); }
53 bool needsLsanRt() const {
54 return Sanitizers.has(SanitizerKind::Leak) &&
55 !Sanitizers.has(SanitizerKind::Address);
57 bool needsUbsanRt() const;
58 bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); }
59 bool needsSafeStackRt() const {
60 return Sanitizers.has(SanitizerKind::SafeStack);
62 bool needsCfiRt() const;
63 bool needsCfiDiagRt() const;
64 bool needsStatsRt() const { return Stats; }
65 bool needsEsanRt() const {
66 return Sanitizers.hasOneOf(SanitizerKind::Efficiency);
69 bool requiresPIE() const;
70 bool needsUnwindTables() const;
71 bool linkCXXRuntimes() const { return LinkCXXRuntimes; }
72 bool hasCrossDsoCfi() const { return CfiCrossDso; }
73 void addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
74 llvm::opt::ArgStringList &CmdArgs, types::ID InputType) const;