Coverage Report

Created: 2019-03-22 08:08

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Driver/ToolChain.h
Line
Count
Source (jump to first uncovered line)
1
//===- ToolChain.h - Collections of tools for one platform ------*- 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
9
#ifndef LLVM_CLANG_DRIVER_TOOLCHAIN_H
10
#define LLVM_CLANG_DRIVER_TOOLCHAIN_H
11
12
#include "clang/Basic/DebugInfoOptions.h"
13
#include "clang/Basic/LLVM.h"
14
#include "clang/Basic/LangOptions.h"
15
#include "clang/Basic/Sanitizers.h"
16
#include "clang/Driver/Action.h"
17
#include "clang/Driver/Multilib.h"
18
#include "clang/Driver/Types.h"
19
#include "llvm/ADT/ArrayRef.h"
20
#include "llvm/ADT/SmallVector.h"
21
#include "llvm/ADT/StringRef.h"
22
#include "llvm/ADT/Triple.h"
23
#include "llvm/MC/MCTargetOptions.h"
24
#include "llvm/Option/Option.h"
25
#include "llvm/Support/VersionTuple.h"
26
#include "llvm/Target/TargetOptions.h"
27
#include <cassert>
28
#include <memory>
29
#include <string>
30
#include <utility>
31
32
namespace llvm {
33
namespace opt {
34
35
class Arg;
36
class ArgList;
37
class DerivedArgList;
38
39
} // namespace opt
40
namespace vfs {
41
42
class FileSystem;
43
44
} // namespace vfs
45
} // namespace llvm
46
47
namespace clang {
48
49
class ObjCRuntime;
50
51
namespace driver {
52
53
class Driver;
54
class InputInfo;
55
class SanitizerArgs;
56
class Tool;
57
class XRayArgs;
58
59
/// Helper structure used to pass information extracted from clang executable
60
/// name such as `i686-linux-android-g++`.
61
0
struct ParsedClangName {
62
  /// Target part of the executable name, as `i686-linux-android`.
63
  std::string TargetPrefix;
64
65
  /// Driver mode part of the executable name, as `g++`.
66
  std::string ModeSuffix;
67
68
  /// Corresponding driver mode argument, as '--driver-mode=g++'
69
  const char *DriverMode = nullptr;
70
71
  /// True if TargetPrefix is recognized as a registered target name.
72
  bool TargetIsValid = false;
73
74
29.3k
  ParsedClangName() = default;
75
  ParsedClangName(std::string Suffix, const char *Mode)
76
65.9k
      : ModeSuffix(Suffix), DriverMode(Mode) {}
77
  ParsedClangName(std::string Target, std::string Suffix, const char *Mode,
78
                  bool IsRegistered)
79
      : TargetPrefix(Target), ModeSuffix(Suffix), DriverMode(Mode),
80
32
        TargetIsValid(IsRegistered) {}
81
82
29.2k
  bool isEmpty() const {
83
29.2k
    return TargetPrefix.empty() && 
ModeSuffix.empty()29.1k
&&
DriverMode == nullptr7.56k
;
84
29.2k
  }
85
};
86
87
/// ToolChain - Access to tools for a single platform.
88
class ToolChain {
89
public:
90
  using path_list = SmallVector<std::string, 16>;
91
92
  enum CXXStdlibType {
93
    CST_Libcxx,
94
    CST_Libstdcxx
95
  };
96
97
  enum RuntimeLibType {
98
    RLT_CompilerRT,
99
    RLT_Libgcc
100
  };
101
102
  enum UnwindLibType {
103
    UNW_None,
104
    UNW_CompilerRT,
105
    UNW_Libgcc
106
  };
107
108
  enum RTTIMode {
109
    RM_Enabled,
110
    RM_Disabled,
111
  };
112
113
  enum FileType { FT_Object, FT_Static, FT_Shared };
114
115
private:
116
  friend class RegisterEffectiveTriple;
117
118
  const Driver &D;
119
  llvm::Triple Triple;
120
  const llvm::opt::ArgList &Args;
121
122
  // We need to initialize CachedRTTIArg before CachedRTTIMode
123
  const llvm::opt::Arg *const CachedRTTIArg;
124
125
  const RTTIMode CachedRTTIMode;
126
127
  /// The list of toolchain specific path prefixes to search for libraries.
128
  path_list LibraryPaths;
129
130
  /// The list of toolchain specific path prefixes to search for files.
131
  path_list FilePaths;
132
133
  /// The list of toolchain specific path prefixes to search for programs.
134
  path_list ProgramPaths;
135
136
  mutable std::unique_ptr<Tool> Clang;
137
  mutable std::unique_ptr<Tool> Assemble;
138
  mutable std::unique_ptr<Tool> Link;
139
  mutable std::unique_ptr<Tool> OffloadBundler;
140
141
  Tool *getClang() const;
142
  Tool *getAssemble() const;
143
  Tool *getLink() const;
144
  Tool *getClangAs() const;
145
  Tool *getOffloadBundler() const;
146
147
  mutable std::unique_ptr<SanitizerArgs> SanitizerArguments;
148
  mutable std::unique_ptr<XRayArgs> XRayArguments;
149
150
  /// The effective clang triple for the current Job.
151
  mutable llvm::Triple EffectiveTriple;
152
153
  /// Set the toolchain's effective clang triple.
154
73.0k
  void setEffectiveTriple(llvm::Triple ET) const {
155
73.0k
    EffectiveTriple = std::move(ET);
156
73.0k
  }
157
158
protected:
159
  MultilibSet Multilibs;
160
  Multilib SelectedMultilib;
161
162
  ToolChain(const Driver &D, const llvm::Triple &T,
163
            const llvm::opt::ArgList &Args);
164
165
  void setTripleEnvironment(llvm::Triple::EnvironmentType Env);
166
167
  virtual Tool *buildAssembler() const;
168
  virtual Tool *buildLinker() const;
169
  virtual Tool *getTool(Action::ActionClass AC) const;
170
171
  /// \name Utilities for implementing subclasses.
172
  ///@{
173
  static void addSystemInclude(const llvm::opt::ArgList &DriverArgs,
174
                               llvm::opt::ArgStringList &CC1Args,
175
                               const Twine &Path);
176
  static void addExternCSystemInclude(const llvm::opt::ArgList &DriverArgs,
177
                                      llvm::opt::ArgStringList &CC1Args,
178
                                      const Twine &Path);
179
  static void
180
      addExternCSystemIncludeIfExists(const llvm::opt::ArgList &DriverArgs,
181
                                      llvm::opt::ArgStringList &CC1Args,
182
                                      const Twine &Path);
183
  static void addSystemIncludes(const llvm::opt::ArgList &DriverArgs,
184
                                llvm::opt::ArgStringList &CC1Args,
185
                                ArrayRef<StringRef> Paths);
186
  ///@}
187
188
public:
189
  virtual ~ToolChain();
190
191
  // Accessors
192
193
679k
  const Driver &getDriver() const { return D; }
194
  llvm::vfs::FileSystem &getVFS() const;
195
1.34M
  const llvm::Triple &getTriple() const { return Triple; }
196
197
  /// Get the toolchain's aux triple, if it has one.
198
  ///
199
  /// Exactly what the aux triple represents depends on the toolchain, but for
200
  /// example when compiling CUDA code for the GPU, the triple might be NVPTX,
201
  /// while the aux triple is the host (CPU) toolchain, e.g. x86-linux-gnu.
202
202
  virtual const llvm::Triple *getAuxTriple() const { return nullptr; }
203
204
  /// Some toolchains need to modify the file name, for example to replace the
205
  /// extension for object files with .cubin for OpenMP offloading to Nvidia
206
  /// GPUs.
207
  virtual std::string getInputFilename(const InputInfo &Input) const;
208
209
371k
  llvm::Triple::ArchType getArch() const { return Triple.getArch(); }
210
2
  StringRef getArchName() const { return Triple.getArchName(); }
211
0
  StringRef getPlatform() const { return Triple.getVendorName(); }
212
37.3k
  StringRef getOS() const { return Triple.getOSName(); }
213
214
  /// Provide the default architecture name (as expected by -arch) for
215
  /// this toolchain.
216
  StringRef getDefaultUniversalArchName() const;
217
218
17.6k
  std::string getTripleString() const {
219
17.6k
    return Triple.getTriple();
220
17.6k
  }
221
222
  /// Get the toolchain's effective clang triple.
223
107k
  const llvm::Triple &getEffectiveTriple() const {
224
107k
    assert(!EffectiveTriple.getTriple().empty() && "No effective triple");
225
107k
    return EffectiveTriple;
226
107k
  }
227
228
20
  path_list &getLibraryPaths() { return LibraryPaths; }
229
10.3k
  const path_list &getLibraryPaths() const { return LibraryPaths; }
230
231
4.32k
  path_list &getFilePaths() { return FilePaths; }
232
9.60k
  const path_list &getFilePaths() const { return FilePaths; }
233
234
39.3k
  path_list &getProgramPaths() { return ProgramPaths; }
235
4.64k
  const path_list &getProgramPaths() const { return ProgramPaths; }
236
237
1
  const MultilibSet &getMultilibs() const { return Multilibs; }
238
239
3
  const Multilib &getMultilib() const { return SelectedMultilib; }
240
241
  const SanitizerArgs& getSanitizerArgs() const;
242
243
  const XRayArgs& getXRayArgs() const;
244
245
  // Returns the Arg * that explicitly turned on/off rtti, or nullptr.
246
4
  const llvm::opt::Arg *getRTTIArg() const { return CachedRTTIArg; }
247
248
  // Returns the RTTIMode for the toolchain with the current arguments.
249
58.4k
  RTTIMode getRTTIMode() const { return CachedRTTIMode; }
250
251
  /// Return any implicit target and/or mode flag for an invocation of
252
  /// the compiler driver as `ProgName`.
253
  ///
254
  /// For example, when called with i686-linux-android-g++, the first element
255
  /// of the return value will be set to `"i686-linux-android"` and the second
256
  /// will be set to "--driver-mode=g++"`.
257
  /// It is OK if the target name is not registered. In this case the return
258
  /// value contains false in the field TargetIsValid.
259
  ///
260
  /// \pre `llvm::InitializeAllTargets()` has been called.
261
  /// \param ProgName The name the Clang driver was invoked with (from,
262
  /// e.g., argv[0]).
263
  /// \return A structure of type ParsedClangName that contains the executable
264
  /// name parts.
265
  static ParsedClangName getTargetAndModeFromProgramName(StringRef ProgName);
266
267
  // Tool access.
268
269
  /// TranslateArgs - Create a new derived argument list for any argument
270
  /// translations this ToolChain may wish to perform, or 0 if no tool chain
271
  /// specific translations are needed. If \p DeviceOffloadKind is specified
272
  /// the translation specific for that offload kind is performed.
273
  ///
274
  /// \param BoundArch - The bound architecture name, or 0.
275
  /// \param DeviceOffloadKind - The device offload kind used for the
276
  /// translation.
277
  virtual llvm::opt::DerivedArgList *
278
  TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
279
426
                Action::OffloadKind DeviceOffloadKind) const {
280
426
    return nullptr;
281
426
  }
282
283
  /// TranslateOpenMPTargetArgs - Create a new derived argument list for
284
  /// that contains the OpenMP target specific flags passed via
285
  /// -Xopenmp-target -opt=val OR -Xopenmp-target=<triple> -opt=val
286
  virtual llvm::opt::DerivedArgList *TranslateOpenMPTargetArgs(
287
      const llvm::opt::DerivedArgList &Args, bool SameTripleAsHost,
288
      SmallVectorImpl<llvm::opt::Arg *> &AllocatedArgs) const;
289
290
  /// Choose a tool to use to handle the action \p JA.
291
  ///
292
  /// This can be overridden when a particular ToolChain needs to use
293
  /// a compiler other than Clang.
294
  virtual Tool *SelectTool(const JobAction &JA) const;
295
296
  // Helper methods
297
298
  std::string GetFilePath(const char *Name) const;
299
  std::string GetProgramPath(const char *Name) const;
300
301
  /// Returns the linker path, respecting the -fuse-ld= argument to determine
302
  /// the linker suffix or name.
303
  std::string GetLinkerPath() const;
304
305
  /// Dispatch to the specific toolchain for verbose printing.
306
  ///
307
  /// This is used when handling the verbose option to print detailed,
308
  /// toolchain-specific information useful for understanding the behavior of
309
  /// the driver on a specific platform.
310
14
  virtual void printVerboseInfo(raw_ostream &OS) const {}
311
312
  // Platform defaults information
313
314
  /// Returns true if the toolchain is targeting a non-native
315
  /// architecture.
316
  virtual bool isCrossCompiling() const;
317
318
  /// HasNativeLTOLinker - Check whether the linker and related tools have
319
  /// native LLVM support.
320
  virtual bool HasNativeLLVMSupport() const;
321
322
  /// LookupTypeForExtension - Return the default language type to use for the
323
  /// given extension.
324
  virtual types::ID LookupTypeForExtension(StringRef Ext) const;
325
326
  /// IsBlocksDefault - Does this tool chain enable -fblocks by default.
327
8.36k
  virtual bool IsBlocksDefault() const { return false; }
328
329
  /// IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as
330
  /// by default.
331
628
  virtual bool IsIntegratedAssemblerDefault() const { return false; }
332
333
  /// Check if the toolchain should use the integrated assembler.
334
  virtual bool useIntegratedAs() const;
335
336
  /// IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
337
7.26k
  virtual bool IsMathErrnoDefault() const { return true; }
338
339
  /// IsEncodeExtendedBlockSignatureDefault - Does this tool chain enable
340
  /// -fencode-extended-block-signature by default.
341
8.36k
  virtual bool IsEncodeExtendedBlockSignatureDefault() const { return false; }
342
343
  /// IsObjCNonFragileABIDefault - Does this tool chain set
344
  /// -fobjc-nonfragile-abi by default.
345
7.80k
  virtual bool IsObjCNonFragileABIDefault() const { return false; }
346
347
  /// UseObjCMixedDispatchDefault - When using non-legacy dispatch, should the
348
  /// mixed dispatch method be used?
349
0
  virtual bool UseObjCMixedDispatch() const { return false; }
350
351
  /// Check whether to enable x86 relax relocations by default.
352
  virtual bool useRelaxRelocations() const;
353
354
  /// GetDefaultStackProtectorLevel - Get the default stack protector level for
355
  /// this tool chain (0=off, 1=on, 2=strong, 3=all).
356
8.58k
  virtual unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const {
357
8.58k
    return 0;
358
8.58k
  }
359
360
  /// Get the default trivial automatic variable initialization.
361
  virtual LangOptions::TrivialAutoVarInitKind
362
28.4k
  GetDefaultTrivialAutoVarInit() const {
363
28.4k
    return LangOptions::TrivialAutoVarInitKind::Uninitialized;
364
28.4k
  }
365
366
  /// GetDefaultLinker - Get the default linker to use.
367
4.25k
  virtual const char *getDefaultLinker() const { return "ld"; }
368
369
  /// GetDefaultRuntimeLibType - Get the default runtime library variant to use.
370
5.66k
  virtual RuntimeLibType GetDefaultRuntimeLibType() const {
371
5.66k
    return ToolChain::RLT_Libgcc;
372
5.66k
  }
373
374
1.91k
  virtual CXXStdlibType GetDefaultCXXStdlibType() const {
375
1.91k
    return ToolChain::CST_Libstdcxx;
376
1.91k
  }
377
378
0
  virtual UnwindLibType GetDefaultUnwindLibType() const {
379
0
    return ToolChain::UNW_None;
380
0
  }
381
382
  virtual std::string getCompilerRTPath() const;
383
384
  virtual std::string getCompilerRT(const llvm::opt::ArgList &Args,
385
                                    StringRef Component,
386
                                    FileType Type = ToolChain::FT_Static) const;
387
388
  const char *
389
  getCompilerRTArgString(const llvm::opt::ArgList &Args, StringRef Component,
390
                         FileType Type = ToolChain::FT_Static) const;
391
392
  // Returns <ResourceDir>/lib/<OSName>/<arch>.  This is used by runtimes (such
393
  // as OpenMP) to find arch-specific libraries.
394
  std::string getArchSpecificLibPath() const;
395
396
  // Returns <OSname> part of above.
397
  StringRef getOSLibName() const;
398
399
  /// needsProfileRT - returns true if instrumentation profile is on.
400
  static bool needsProfileRT(const llvm::opt::ArgList &Args);
401
402
  /// Returns true if gcov instrumentation (-fprofile-arcs or --coverage) is on.
403
  static bool needsGCovInstrumentation(const llvm::opt::ArgList &Args);
404
405
  /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables
406
  /// by default.
407
  virtual bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const;
408
409
  /// Test whether this toolchain defaults to PIC.
410
  virtual bool isPICDefault() const = 0;
411
412
  /// Test whether this toolchain defaults to PIE.
413
  virtual bool isPIEDefault() const = 0;
414
415
  /// Tests whether this toolchain forces its default for PIC, PIE or
416
  /// non-PIC.  If this returns true, any PIC related flags should be ignored
417
  /// and instead the results of \c isPICDefault() and \c isPIEDefault() are
418
  /// used exclusively.
419
  virtual bool isPICDefaultForced() const = 0;
420
421
  /// SupportsProfiling - Does this tool chain support -pg.
422
15.4k
  virtual bool SupportsProfiling() const { return true; }
423
424
  /// Complain if this tool chain doesn't support Objective-C ARC.
425
0
  virtual void CheckObjCARC() const {}
426
427
  /// Get the default debug info format. Typically, this is DWARF.
428
2.46k
  virtual codegenoptions::DebugInfoFormat getDefaultDebugFormat() const {
429
2.46k
    return codegenoptions::DIF_DWARF;
430
2.46k
  }
431
432
  /// UseDwarfDebugFlags - Embed the compile options to clang into the Dwarf
433
  /// compile unit information.
434
8.57k
  virtual bool UseDwarfDebugFlags() const { return false; }
435
436
  // Return the DWARF version to emit, in the absence of arguments
437
  // to the contrary.
438
413
  virtual unsigned GetDefaultDwarfVersion() const { return 4; }
439
440
  // True if the driver should assume "-fstandalone-debug"
441
  // in the absence of an option specifying otherwise,
442
  // provided that debugging was requested in the first place.
443
  // i.e. a value of 'true' does not imply that debugging is wanted.
444
9.07k
  virtual bool GetDefaultStandaloneDebug() const { return false; }
445
446
  // Return the default debugger "tuning."
447
8.39k
  virtual llvm::DebuggerKind getDefaultDebuggerTuning() const {
448
8.39k
    return llvm::DebuggerKind::GDB;
449
8.39k
  }
450
451
  /// Does this toolchain supports given debug info option or not.
452
2.67k
  virtual bool supportsDebugInfoOption(const llvm::opt::Arg *) const {
453
2.67k
    return true;
454
2.67k
  }
455
456
  /// Adjust debug information kind considering all passed options.
457
  virtual void adjustDebugInfoKind(codegenoptions::DebugInfoKind &DebugInfoKind,
458
28.1k
                                   const llvm::opt::ArgList &Args) const {}
459
460
  /// GetExceptionModel - Return the tool chain exception model.
461
  virtual llvm::ExceptionHandling
462
  GetExceptionModel(const llvm::opt::ArgList &Args) const;
463
464
  /// SupportsEmbeddedBitcode - Does this tool chain support embedded bitcode.
465
0
  virtual bool SupportsEmbeddedBitcode() const { return false; }
466
467
  /// getThreadModel() - Which thread model does this target use?
468
35.0k
  virtual std::string getThreadModel() const { return "posix"; }
469
470
  /// isThreadModelSupported() - Does this target support a thread model?
471
  virtual bool isThreadModelSupported(const StringRef Model) const;
472
473
  /// ComputeLLVMTriple - Return the LLVM target triple to use, after taking
474
  /// command line arguments into account.
475
  virtual std::string
476
  ComputeLLVMTriple(const llvm::opt::ArgList &Args,
477
                    types::ID InputType = types::TY_INVALID) const;
478
479
  /// ComputeEffectiveClangTriple - Return the Clang triple to use for this
480
  /// target, which may take into account the command line arguments. For
481
  /// example, on Darwin the -mmacosx-version-min= command line argument (which
482
  /// sets the deployment target) determines the version in the triple passed to
483
  /// Clang.
484
  virtual std::string ComputeEffectiveClangTriple(
485
      const llvm::opt::ArgList &Args,
486
      types::ID InputType = types::TY_INVALID) const;
487
488
  /// getDefaultObjCRuntime - Return the default Objective-C runtime
489
  /// for this platform.
490
  ///
491
  /// FIXME: this really belongs on some sort of DeploymentTarget abstraction
492
  virtual ObjCRuntime getDefaultObjCRuntime(bool isNonFragile) const;
493
494
  /// hasBlocksRuntime - Given that the user is compiling with
495
  /// -fblocks, does this tool chain guarantee the existence of a
496
  /// blocks runtime?
497
  ///
498
  /// FIXME: this really belongs on some sort of DeploymentTarget abstraction
499
856
  virtual bool hasBlocksRuntime() const { return true; }
500
501
  /// Add the clang cc1 arguments for system include paths.
502
  ///
503
  /// This routine is responsible for adding the necessary cc1 arguments to
504
  /// include headers from standard system header directories.
505
  virtual void
506
  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
507
                            llvm::opt::ArgStringList &CC1Args) const;
508
509
  /// Add options that need to be passed to cc1 for this target.
510
  virtual void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
511
                                     llvm::opt::ArgStringList &CC1Args,
512
                                     Action::OffloadKind DeviceOffloadKind) const;
513
514
  /// Add warning options that need to be passed to cc1 for this target.
515
  virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const;
516
517
  // GetRuntimeLibType - Determine the runtime library type to use with the
518
  // given compilation arguments.
519
  virtual RuntimeLibType
520
  GetRuntimeLibType(const llvm::opt::ArgList &Args) const;
521
522
  // GetCXXStdlibType - Determine the C++ standard library type to use with the
523
  // given compilation arguments.
524
  virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const;
525
526
  // GetUnwindLibType - Determine the unwind library type to use with the
527
  // given compilation arguments.
528
  virtual UnwindLibType GetUnwindLibType(const llvm::opt::ArgList &Args) const;
529
530
  /// AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set
531
  /// the include paths to use for the given C++ standard library type.
532
  virtual void
533
  AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
534
                               llvm::opt::ArgStringList &CC1Args) const;
535
536
  /// Returns if the C++ standard library should be linked in.
537
  /// Note that e.g. -lm should still be linked even if this returns false.
538
  bool ShouldLinkCXXStdlib(const llvm::opt::ArgList &Args) const;
539
540
  /// AddCXXStdlibLibArgs - Add the system specific linker arguments to use
541
  /// for the given C++ standard library type.
542
  virtual void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
543
                                   llvm::opt::ArgStringList &CmdArgs) const;
544
545
  /// AddFilePathLibArgs - Add each thing in getFilePaths() as a "-L" option.
546
  void AddFilePathLibArgs(const llvm::opt::ArgList &Args,
547
                          llvm::opt::ArgStringList &CmdArgs) const;
548
549
  /// AddCCKextLibArgs - Add the system specific linker arguments to use
550
  /// for kernel extensions (Darwin-specific).
551
  virtual void AddCCKextLibArgs(const llvm::opt::ArgList &Args,
552
                                llvm::opt::ArgStringList &CmdArgs) const;
553
554
  /// AddFastMathRuntimeIfAvailable - If a runtime library exists that sets
555
  /// global flags for unsafe floating point math, add it and return true.
556
  ///
557
  /// This checks for presence of the -Ofast, -ffast-math or -funsafe-math flags.
558
  virtual bool AddFastMathRuntimeIfAvailable(
559
      const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const;
560
561
  /// addProfileRTLibs - When -fprofile-instr-profile is specified, try to pass
562
  /// a suitable profile runtime library to the linker.
563
  virtual void addProfileRTLibs(const llvm::opt::ArgList &Args,
564
                                llvm::opt::ArgStringList &CmdArgs) const;
565
566
  /// Add arguments to use system-specific CUDA includes.
567
  virtual void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
568
                                  llvm::opt::ArgStringList &CC1Args) const;
569
570
  /// Add arguments to use MCU GCC toolchain includes.
571
  virtual void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
572
                                   llvm::opt::ArgStringList &CC1Args) const;
573
574
  /// On Windows, returns the MSVC compatibility version.
575
  virtual VersionTuple computeMSVCVersion(const Driver *D,
576
                                          const llvm::opt::ArgList &Args) const;
577
578
  /// Return sanitizers which are available in this toolchain.
579
  virtual SanitizerMask getSupportedSanitizers() const;
580
581
  /// Return sanitizers which are enabled by default.
582
29.8k
  virtual SanitizerMask getDefaultSanitizers() const {
583
29.8k
    return SanitizerMask();
584
29.8k
  }
585
};
586
587
/// Set a ToolChain's effective triple. Reset it when the registration object
588
/// is destroyed.
589
class RegisterEffectiveTriple {
590
  const ToolChain &TC;
591
592
public:
593
36.5k
  RegisterEffectiveTriple(const ToolChain &TC, llvm::Triple T) : TC(TC) {
594
36.5k
    TC.setEffectiveTriple(std::move(T));
595
36.5k
  }
596
597
36.5k
  ~RegisterEffectiveTriple() { TC.setEffectiveTriple(llvm::Triple()); }
598
};
599
600
} // namespace driver
601
602
} // namespace clang
603
604
#endif // LLVM_CLANG_DRIVER_TOOLCHAIN_H