]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Driver/SanitizerArgs.h
MFV r294491: ntp 4.2.8p6.
[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   int CoverageFeatures;
31   int MsanTrackOrigins;
32   bool MsanUseAfterDtor;
33   int AsanFieldPadding;
34   bool AsanZeroBaseShadow;
35   bool AsanSharedRuntime;
36   bool LinkCXXRuntimes;
37
38  public:
39   /// Parses the sanitizer arguments from an argument list.
40   SanitizerArgs(const ToolChain &TC, const llvm::opt::ArgList &Args);
41
42   bool needsAsanRt() const { return Sanitizers.has(SanitizerKind::Address); }
43   bool needsSharedAsanRt() const { return AsanSharedRuntime; }
44   bool needsTsanRt() const { return Sanitizers.has(SanitizerKind::Thread); }
45   bool needsMsanRt() const { return Sanitizers.has(SanitizerKind::Memory); }
46   bool needsLsanRt() const {
47     return Sanitizers.has(SanitizerKind::Leak) &&
48            !Sanitizers.has(SanitizerKind::Address);
49   }
50   bool needsUbsanRt() const;
51   bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); }
52   bool needsSafeStackRt() const {
53     return Sanitizers.has(SanitizerKind::SafeStack);
54   }
55
56   bool requiresPIE() const;
57   bool needsUnwindTables() const;
58   bool linkCXXRuntimes() const { return LinkCXXRuntimes; }
59   void addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
60                llvm::opt::ArgStringList &CmdArgs, types::ID InputType) const;
61
62  private:
63   void clear();
64 };
65
66 }  // namespace driver
67 }  // namespace clang
68
69 #endif