]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Driver/SanitizerArgs.h
Merge ACPICA 20170728.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / Driver / SanitizerArgs.h
1 //===--- SanitizerArgs.h - Arguments for sanitizer tools  -------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_DRIVER_SANITIZERARGS_H
10 #define LLVM_CLANG_DRIVER_SANITIZERARGS_H
11
12 #include "clang/Basic/Sanitizers.h"
13 #include "clang/Driver/Types.h"
14 #include "llvm/Option/Arg.h"
15 #include "llvm/Option/ArgList.h"
16 #include <string>
17 #include <vector>
18
19 namespace clang {
20 namespace driver {
21
22 class ToolChain;
23
24 class SanitizerArgs {
25   SanitizerSet Sanitizers;
26   SanitizerSet RecoverableSanitizers;
27   SanitizerSet TrapSanitizers;
28
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 = true;
38   bool AsanGlobalsDeadStripping = false;
39   bool LinkCXXRuntimes = false;
40   bool NeedPIE = false;
41   bool Stats = false;
42   bool TsanMemoryAccess = true;
43   bool TsanFuncEntryExit = true;
44   bool TsanAtomics = true;
45
46  public:
47   /// Parses the sanitizer arguments from an argument list.
48   SanitizerArgs(const ToolChain &TC, const llvm::opt::ArgList &Args);
49
50   bool needsAsanRt() const { return Sanitizers.has(SanitizerKind::Address); }
51   bool needsSharedAsanRt() const { return AsanSharedRuntime; }
52   bool needsTsanRt() const { return Sanitizers.has(SanitizerKind::Thread); }
53   bool needsMsanRt() const { return Sanitizers.has(SanitizerKind::Memory); }
54   bool needsFuzzer() const { return Sanitizers.has(SanitizerKind::Fuzzer); }
55   bool needsLsanRt() const {
56     return Sanitizers.has(SanitizerKind::Leak) &&
57            !Sanitizers.has(SanitizerKind::Address);
58   }
59   bool needsUbsanRt() const;
60   bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); }
61   bool needsSafeStackRt() const {
62     return Sanitizers.has(SanitizerKind::SafeStack);
63   }
64   bool needsCfiRt() const;
65   bool needsCfiDiagRt() const;
66   bool needsStatsRt() const { return Stats; }
67   bool needsEsanRt() const {
68     return Sanitizers.hasOneOf(SanitizerKind::Efficiency);
69   }
70
71   bool requiresPIE() const;
72   bool needsUnwindTables() const;
73   bool linkCXXRuntimes() const { return LinkCXXRuntimes; }
74   bool hasCrossDsoCfi() const { return CfiCrossDso; }
75   void addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
76                llvm::opt::ArgStringList &CmdArgs, types::ID InputType) const;
77 };
78
79 }  // namespace driver
80 }  // namespace clang
81
82 #endif