]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Driver/SanitizerArgs.h
Update LLDB snapshot to upstream r225923 (git 2b588ecd)
[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 "llvm/Option/Arg.h"
14 #include "llvm/Option/ArgList.h"
15 #include <string>
16
17 namespace clang {
18 namespace driver {
19
20 class Driver;
21 class ToolChain;
22
23 class SanitizerArgs {
24   SanitizerSet Sanitizers;
25   SanitizerSet RecoverableSanitizers;
26
27   std::string BlacklistFile;
28   int SanitizeCoverage;
29   int MsanTrackOrigins;
30   int AsanFieldPadding;
31   bool AsanZeroBaseShadow;
32   bool UbsanTrapOnError;
33   bool AsanSharedRuntime;
34   bool LinkCXXRuntimes;
35
36  public:
37   /// Parses the sanitizer arguments from an argument list.
38   SanitizerArgs(const ToolChain &TC, const llvm::opt::ArgList &Args);
39
40   bool needsAsanRt() const { return Sanitizers.has(SanitizerKind::Address); }
41   bool needsSharedAsanRt() const { return AsanSharedRuntime; }
42   bool needsTsanRt() const { return Sanitizers.has(SanitizerKind::Thread); }
43   bool needsMsanRt() const { return Sanitizers.has(SanitizerKind::Memory); }
44   bool needsLsanRt() const {
45     return Sanitizers.has(SanitizerKind::Leak) &&
46            !Sanitizers.has(SanitizerKind::Address);
47   }
48   bool needsUbsanRt() const;
49   bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); }
50
51   bool sanitizesVptr() const { return Sanitizers.has(SanitizerKind::Vptr); }
52   bool requiresPIE() const;
53   bool needsUnwindTables() const;
54   bool linkCXXRuntimes() const { return LinkCXXRuntimes; }
55   void addArgs(const llvm::opt::ArgList &Args,
56                llvm::opt::ArgStringList &CmdArgs) const;
57
58  private:
59   void clear();
60   bool getDefaultBlacklist(const Driver &D, std::string &BLPath);
61 };
62
63 }  // namespace driver
64 }  // namespace clang
65
66 #endif