clang  3.8.0
SanitizerArgs.h
Go to the documentation of this file.
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 
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;
32  int MsanTrackOrigins;
33  bool MsanUseAfterDtor;
34  bool CfiCrossDso;
35  int AsanFieldPadding;
36  bool AsanSharedRuntime;
37  bool LinkCXXRuntimes;
38  bool NeedPIE;
39 
40  public:
41  /// Parses the sanitizer arguments from an argument list.
42  SanitizerArgs(const ToolChain &TC, const llvm::opt::ArgList &Args);
43 
44  bool needsAsanRt() const { return Sanitizers.has(SanitizerKind::Address); }
45  bool needsSharedAsanRt() const { return AsanSharedRuntime; }
46  bool needsTsanRt() const { return Sanitizers.has(SanitizerKind::Thread); }
47  bool needsMsanRt() const { return Sanitizers.has(SanitizerKind::Memory); }
48  bool needsLsanRt() const {
49  return Sanitizers.has(SanitizerKind::Leak) &&
50  !Sanitizers.has(SanitizerKind::Address);
51  }
52  bool needsUbsanRt() const;
53  bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); }
54  bool needsSafeStackRt() const {
55  return Sanitizers.has(SanitizerKind::SafeStack);
56  }
57  bool needsCfiRt() const;
58  bool needsCfiDiagRt() const;
59 
60  bool requiresPIE() const;
61  bool needsUnwindTables() const;
62  bool linkCXXRuntimes() const { return LinkCXXRuntimes; }
63  void addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
64  llvm::opt::ArgStringList &CmdArgs, types::ID InputType) const;
65 
66  private:
67  void clear();
68 };
69 
70 } // namespace driver
71 } // namespace clang
72 
73 #endif
Defines the clang::SanitizerKind enum.
void addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, types::ID InputType) const
bool has(SanitizerMask K) const
Check if a certain (single) sanitizer is enabled.
Definition: Sanitizers.h:52
SanitizerArgs(const ToolChain &TC, const llvm::opt::ArgList &Args)
Parses the sanitizer arguments from an argument list.
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:47