Coverage Report

Created: 2019-02-23 12:57

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Driver/SanitizerArgs.h
Line
Count
Source
1
//===--- SanitizerArgs.h - Arguments for sanitizer tools  -------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
#ifndef LLVM_CLANG_DRIVER_SANITIZERARGS_H
9
#define LLVM_CLANG_DRIVER_SANITIZERARGS_H
10
11
#include "clang/Basic/Sanitizers.h"
12
#include "clang/Driver/Types.h"
13
#include "llvm/Option/Arg.h"
14
#include "llvm/Option/ArgList.h"
15
#include <string>
16
#include <vector>
17
18
namespace clang {
19
namespace driver {
20
21
class ToolChain;
22
23
class SanitizerArgs {
24
  SanitizerSet Sanitizers;
25
  SanitizerSet RecoverableSanitizers;
26
  SanitizerSet TrapSanitizers;
27
28
  std::vector<std::string> BlacklistFiles;
29
  std::vector<std::string> ExtraDeps;
30
  int CoverageFeatures = 0;
31
  int MsanTrackOrigins = 0;
32
  bool MsanUseAfterDtor = true;
33
  bool CfiCrossDso = false;
34
  bool CfiICallGeneralizePointers = false;
35
  int AsanFieldPadding = 0;
36
  bool SharedRuntime = false;
37
  bool AsanUseAfterScope = true;
38
  bool AsanPoisonCustomArrayCookie = false;
39
  bool AsanGlobalsDeadStripping = false;
40
  bool AsanUseOdrIndicator = false;
41
  std::string HwasanAbi;
42
  bool LinkCXXRuntimes = false;
43
  bool NeedPIE = false;
44
  bool SafeStackRuntime = false;
45
  bool Stats = false;
46
  bool TsanMemoryAccess = true;
47
  bool TsanFuncEntryExit = true;
48
  bool TsanAtomics = true;
49
  bool MinimalRuntime = false;
50
  // True if cross-dso CFI support if provided by the system (i.e. Android).
51
  bool ImplicitCfiRuntime = false;
52
53
 public:
54
  /// Parses the sanitizer arguments from an argument list.
55
  SanitizerArgs(const ToolChain &TC, const llvm::opt::ArgList &Args);
56
57
3.34k
  bool needsSharedRt() const { return SharedRuntime; }
58
59
9.70k
  bool needsAsanRt() const { return Sanitizers.has(SanitizerKind::Address); }
60
6.43k
  bool needsHwasanRt() const { return Sanitizers.has(SanitizerKind::HWAddress); }
61
8.72k
  bool needsTsanRt() const { return Sanitizers.has(SanitizerKind::Thread); }
62
6.27k
  bool needsMsanRt() const { return Sanitizers.has(SanitizerKind::Memory); }
63
4.46k
  bool needsFuzzer() const { return Sanitizers.has(SanitizerKind::Fuzzer); }
64
8.69k
  bool needsLsanRt() const {
65
8.69k
    return Sanitizers.has(SanitizerKind::Leak) &&
66
8.69k
           
!Sanitizers.has(SanitizerKind::Address)61
&&
67
8.69k
           
!Sanitizers.has(SanitizerKind::HWAddress)60
;
68
8.69k
  }
69
  bool needsUbsanRt() const;
70
169
  bool requiresMinimalRuntime() const { return MinimalRuntime; }
71
6.16k
  bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); }
72
1.37k
  bool needsSafeStackRt() const { return SafeStackRuntime; }
73
  bool needsCfiRt() const;
74
  bool needsCfiDiagRt() const;
75
6.28k
  bool needsStatsRt() const { return Stats; }
76
3.88k
  bool needsEsanRt() const {
77
3.88k
    return Sanitizers.hasOneOf(SanitizerKind::Efficiency);
78
3.88k
  }
79
6.32k
  bool needsScudoRt() const { return Sanitizers.has(SanitizerKind::Scudo); }
80
81
  bool requiresPIE() const;
82
  bool needsUnwindTables() const;
83
  bool needsLTO() const;
84
248
  bool linkCXXRuntimes() const { return LinkCXXRuntimes; }
85
1.61k
  bool hasCrossDsoCfi() const { return CfiCrossDso; }
86
187
  bool hasAnySanitizer() const { return !Sanitizers.empty(); }
87
  void addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
88
               llvm::opt::ArgStringList &CmdArgs, types::ID InputType) const;
89
};
90
91
}  // namespace driver
92
}  // namespace clang
93
94
#endif