clang  3.9.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 = 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;
39  bool NeedPIE = false;
40  bool Stats = false;
41 
42  public:
43  /// Parses the sanitizer arguments from an argument list.
44  SanitizerArgs(const ToolChain &TC, const llvm::opt::ArgList &Args);
45 
46  bool needsAsanRt() const { return Sanitizers.has(SanitizerKind::Address); }
47  bool needsSharedAsanRt() const { return AsanSharedRuntime; }
48  bool needsTsanRt() const { return Sanitizers.has(SanitizerKind::Thread); }
49  bool needsMsanRt() const { return Sanitizers.has(SanitizerKind::Memory); }
50  bool needsLsanRt() const {
51  return Sanitizers.has(SanitizerKind::Leak) &&
52  !Sanitizers.has(SanitizerKind::Address);
53  }
54  bool needsUbsanRt() const;
55  bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); }
56  bool needsSafeStackRt() const {
57  return Sanitizers.has(SanitizerKind::SafeStack);
58  }
59  bool needsCfiRt() const;
60  bool needsCfiDiagRt() const;
61  bool needsStatsRt() const { return Stats; }
62  bool needsEsanRt() const {
63  return Sanitizers.hasOneOf(SanitizerKind::Efficiency);
64  }
65 
66  bool requiresPIE() const;
67  bool needsUnwindTables() const;
68  bool linkCXXRuntimes() const { return LinkCXXRuntimes; }
69  void addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
70  llvm::opt::ArgStringList &CmdArgs, types::ID InputType) const;
71 };
72 
73 } // namespace driver
74 } // namespace clang
75 
76 #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 hasOneOf(SanitizerMask K) const
Check if one or more sanitizers are enabled.
Definition: Sanitizers.h:56
bool has(SanitizerMask K) const
Check if a certain (single) sanitizer is enabled.
Definition: Sanitizers.h:50
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:48