clang  16.0.0git
Driver.h
Go to the documentation of this file.
1 //===--- Driver.h - Clang GCC Compatible Driver -----------------*- 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_DRIVER_H
10 #define LLVM_CLANG_DRIVER_DRIVER_H
11 
12 #include "clang/Basic/Diagnostic.h"
13 #include "clang/Basic/LLVM.h"
14 #include "clang/Driver/Action.h"
16 #include "clang/Driver/InputInfo.h"
17 #include "clang/Driver/Options.h"
18 #include "clang/Driver/Phases.h"
19 #include "clang/Driver/ToolChain.h"
20 #include "clang/Driver/Types.h"
21 #include "clang/Driver/Util.h"
22 #include "llvm/ADT/ArrayRef.h"
23 #include "llvm/ADT/StringMap.h"
24 #include "llvm/ADT/StringRef.h"
25 #include "llvm/Option/Arg.h"
26 #include "llvm/Option/ArgList.h"
27 #include "llvm/Support/StringSaver.h"
28 
29 #include <list>
30 #include <map>
31 #include <string>
32 #include <vector>
33 
34 namespace llvm {
35 class Triple;
36 namespace vfs {
37 class FileSystem;
38 }
39 } // namespace llvm
40 
41 namespace clang {
42 
43 namespace driver {
44 
46 
47 class Command;
48 class Compilation;
49 class JobAction;
50 class ToolChain;
51 
52 /// Describes the kind of LTO mode selected via -f(no-)?lto(=.*)? options.
53 enum LTOKind {
58 };
59 
60 /// Whether headers used to construct C++20 module units should be looked
61 /// up by the path supplied on the command line, or in the user or system
62 /// search paths.
68 };
69 
70 /// Driver - Encapsulate logic for constructing compilation processes
71 /// from a set of gcc-driver-like command line arguments.
72 class Driver {
73  DiagnosticsEngine &Diags;
74 
76 
77  enum DriverMode {
78  GCCMode,
79  GXXMode,
80  CPPMode,
81  CLMode,
82  FlangMode,
83  DXCMode
84  } Mode;
85 
86  enum SaveTempsMode {
87  SaveTempsNone,
88  SaveTempsCwd,
89  SaveTempsObj
90  } SaveTemps;
91 
92  enum BitcodeEmbedMode {
93  EmbedNone,
94  EmbedMarker,
95  EmbedBitcode
96  } BitcodeEmbed;
97 
98  enum OffloadMode {
99  OffloadHostDevice,
100  OffloadHost,
101  OffloadDevice,
102  } Offload;
103 
104  /// Header unit mode set by -fmodule-header={user,system}.
105  ModuleHeaderMode CXX20HeaderType;
106 
107  /// Set if we should process inputs and jobs with C++20 module
108  /// interpretation.
109  bool ModulesModeCXX20;
110 
111  /// LTO mode selected via -f(no-)?lto(=.*)? options.
112  LTOKind LTOMode;
113 
114  /// LTO mode selected via -f(no-offload-)?lto(=.*)? options.
115  LTOKind OffloadLTOMode;
116 
117 public:
119  /// An unknown OpenMP runtime. We can't generate effective OpenMP code
120  /// without knowing what runtime to target.
122 
123  /// The LLVM OpenMP runtime. When completed and integrated, this will become
124  /// the default for Clang.
126 
127  /// The GNU OpenMP runtime. Clang doesn't support generating OpenMP code for
128  /// this runtime but can swallow the pragmas, and find and link against the
129  /// runtime library itself.
131 
132  /// The legacy name for the LLVM OpenMP runtime from when it was the Intel
133  /// OpenMP runtime. We support this mode for users with existing
134  /// dependencies on this runtime library name.
136  };
137 
138  // Diag - Forwarding function for diagnostics.
139  DiagnosticBuilder Diag(unsigned DiagID) const {
140  return Diags.Report(DiagID);
141  }
142 
143  // FIXME: Privatize once interface is stable.
144 public:
145  /// The name the driver was invoked as.
147 
148  /// The path the driver executable was in, as invoked from the
149  /// command line.
151 
152  /// The original path to the clang executable.
154 
155  /// Target and driver mode components extracted from clang executable name.
157 
158  /// The path to the installed clang directory, if any.
160 
161  /// The path to the compiler resource directory.
163 
164  /// System directory for config files.
166 
167  /// User directory for config files.
169 
170  /// A prefix directory used to emulate a limited subset of GCC's '-Bprefix'
171  /// functionality.
172  /// FIXME: This type of customization should be removed in favor of the
173  /// universal driver when it is ready.
176 
177  /// sysroot, if present
179 
180  /// Dynamic loader prefix, if present
182 
183  /// Driver title to use with help.
185 
186  /// Information about the host which can be overridden by the user.
188 
189  /// The file to log CC_PRINT_PROC_STAT_FILE output to, if enabled.
191 
192  /// The file to log CC_PRINT_OPTIONS output to, if enabled.
194 
195  /// The file to log CC_PRINT_HEADERS output to, if enabled.
197 
198  /// The file to log CC_LOG_DIAGNOSTICS output to, if enabled.
200 
201  /// An input type and its arguments.
202  using InputTy = std::pair<types::ID, const llvm::opt::Arg *>;
203 
204  /// A list of inputs and their types for the given arguments.
206 
207  /// Whether the driver should follow g++ like behavior.
208  bool CCCIsCXX() const { return Mode == GXXMode; }
209 
210  /// Whether the driver is just the preprocessor.
211  bool CCCIsCPP() const { return Mode == CPPMode; }
212 
213  /// Whether the driver should follow gcc like behavior.
214  bool CCCIsCC() const { return Mode == GCCMode; }
215 
216  /// Whether the driver should follow cl.exe like behavior.
217  bool IsCLMode() const { return Mode == CLMode; }
218 
219  /// Whether the driver should invoke flang for fortran inputs.
220  /// Other modes fall back to calling gcc which in turn calls gfortran.
221  bool IsFlangMode() const { return Mode == FlangMode; }
222 
223  /// Whether the driver should follow dxc.exe like behavior.
224  bool IsDXCMode() const { return Mode == DXCMode; }
225 
226  /// Only print tool bindings, don't build any jobs.
227  unsigned CCCPrintBindings : 1;
228 
229  /// Set CC_PRINT_OPTIONS mode, which is like -v but logs the commands to
230  /// CCPrintOptionsFilename or to stderr.
231  unsigned CCPrintOptions : 1;
232 
233  /// Set CC_PRINT_HEADERS mode, which causes the frontend to log header include
234  /// information to CCPrintHeadersFilename or to stderr.
235  unsigned CCPrintHeaders : 1;
236 
237  /// Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics
238  /// to CCLogDiagnosticsFilename or to stderr, in a stable machine readable
239  /// format.
240  unsigned CCLogDiagnostics : 1;
241 
242  /// Whether the driver is generating diagnostics for debugging purposes.
243  unsigned CCGenDiagnostics : 1;
244 
245  /// Set CC_PRINT_PROC_STAT mode, which causes the driver to dump
246  /// performance report to CC_PRINT_PROC_STAT_FILE or to stdout.
247  unsigned CCPrintProcessStats : 1;
248 
249  /// Pointer to the ExecuteCC1Tool function, if available.
250  /// When the clangDriver lib is used through clang.exe, this provides a
251  /// shortcut for executing the -cc1 command-line directly, in the same
252  /// process.
254  CC1ToolFunc CC1Main = nullptr;
255 
256 private:
257  /// Raw target triple.
258  std::string TargetTriple;
259 
260  /// Name to use when invoking gcc/g++.
261  std::string CCCGenericGCCName;
262 
263  /// Paths to configuration files used.
264  std::vector<std::string> ConfigFiles;
265 
266  /// Allocator for string saver.
267  llvm::BumpPtrAllocator Alloc;
268 
269  /// Object that stores strings read from configuration file.
270  llvm::StringSaver Saver;
271 
272  /// Arguments originated from configuration file.
273  std::unique_ptr<llvm::opt::InputArgList> CfgOptions;
274 
275  /// Arguments originated from command line.
276  std::unique_ptr<llvm::opt::InputArgList> CLOptions;
277 
278  /// Whether to check that input files exist when constructing compilation
279  /// jobs.
280  unsigned CheckInputsExist : 1;
281  /// Whether to probe for PCH files on disk, in order to upgrade
282  /// -include foo.h to -include-pch foo.h.pch.
283  unsigned ProbePrecompiled : 1;
284 
285 public:
286  // getFinalPhase - Determine which compilation mode we are in and record
287  // which option we used to determine the final phase.
288  // TODO: Much of what getFinalPhase returns are not actually true compiler
289  // modes. Fold this functionality into Types::getCompilationPhases and
290  // handleArguments.
291  phases::ID getFinalPhase(const llvm::opt::DerivedArgList &DAL,
292  llvm::opt::Arg **FinalPhaseArg = nullptr) const;
293 
294 private:
295  /// Certain options suppress the 'no input files' warning.
296  unsigned SuppressMissingInputWarning : 1;
297 
298  /// Cache of all the ToolChains in use by the driver.
299  ///
300  /// This maps from the string representation of a triple to a ToolChain
301  /// created targeting that triple. The driver owns all the ToolChain objects
302  /// stored in it, and will clean them up when torn down.
303  mutable llvm::StringMap<std::unique_ptr<ToolChain>> ToolChains;
304 
305  /// Cache of known offloading architectures for the ToolChain already derived.
306  /// This should only be modified when we first initialize the offloading
307  /// toolchains.
308  llvm::DenseMap<const ToolChain *, llvm::DenseSet<llvm::StringRef>> KnownArchs;
309 
310 private:
311  /// TranslateInputArgs - Create a new derived argument list from the input
312  /// arguments, after applying the standard argument translations.
313  llvm::opt::DerivedArgList *
314  TranslateInputArgs(const llvm::opt::InputArgList &Args) const;
315 
316  // handleArguments - All code related to claiming and printing diagnostics
317  // related to arguments to the driver are done here.
318  void handleArguments(Compilation &C, llvm::opt::DerivedArgList &Args,
319  const InputList &Inputs, ActionList &Actions) const;
320 
321  // Before executing jobs, sets up response files for commands that need them.
322  void setUpResponseFiles(Compilation &C, Command &Cmd);
323 
324  void generatePrefixedToolNames(StringRef Tool, const ToolChain &TC,
325  SmallVectorImpl<std::string> &Names) const;
326 
327  /// Find the appropriate .crash diagonostic file for the child crash
328  /// under this driver and copy it out to a temporary destination with the
329  /// other reproducer related files (.sh, .cache, etc). If not found, suggest a
330  /// directory for the user to look at.
331  ///
332  /// \param ReproCrashFilename The file path to copy the .crash to.
333  /// \param CrashDiagDir The suggested directory for the user to look at
334  /// in case the search or copy fails.
335  ///
336  /// \returns If the .crash is found and successfully copied return true,
337  /// otherwise false and return the suggested directory in \p CrashDiagDir.
338  bool getCrashDiagnosticFile(StringRef ReproCrashFilename,
339  SmallString<128> &CrashDiagDir);
340 
341 public:
342 
343  /// Takes the path to a binary that's either in bin/ or lib/ and returns
344  /// the path to clang's resource directory.
345  static std::string GetResourcesPath(StringRef BinaryPath,
346  StringRef CustomResourceDir = "");
347 
348  Driver(StringRef ClangExecutable, StringRef TargetTriple,
349  DiagnosticsEngine &Diags, std::string Title = "clang LLVM compiler",
351 
352  /// @name Accessors
353  /// @{
354 
355  /// Name to use when invoking gcc/g++.
356  const std::string &getCCCGenericGCCName() const { return CCCGenericGCCName; }
357 
359  return ConfigFiles;
360  }
361 
362  const llvm::opt::OptTable &getOpts() const { return getDriverOptTable(); }
363 
364  DiagnosticsEngine &getDiags() const { return Diags; }
365 
366  llvm::vfs::FileSystem &getVFS() const { return *VFS; }
367 
368  bool getCheckInputsExist() const { return CheckInputsExist; }
369 
370  void setCheckInputsExist(bool Value) { CheckInputsExist = Value; }
371 
372  bool getProbePrecompiled() const { return ProbePrecompiled; }
373  void setProbePrecompiled(bool Value) { ProbePrecompiled = Value; }
374 
376 
377  const std::string &getTitle() { return DriverTitle; }
378  void setTitle(std::string Value) { DriverTitle = std::move(Value); }
379 
380  std::string getTargetTriple() const { return TargetTriple; }
381 
382  /// Get the path to the main clang executable.
383  const char *getClangProgramPath() const {
384  return ClangExecutable.c_str();
385  }
386 
387  /// Get the path to where the clang executable was installed.
388  const char *getInstalledDir() const {
389  if (!InstalledDir.empty())
390  return InstalledDir.c_str();
391  return Dir.c_str();
392  }
394 
395  bool isSaveTempsEnabled() const { return SaveTemps != SaveTempsNone; }
396  bool isSaveTempsObj() const { return SaveTemps == SaveTempsObj; }
397 
398  bool embedBitcodeEnabled() const { return BitcodeEmbed != EmbedNone; }
399  bool embedBitcodeInObject() const { return (BitcodeEmbed == EmbedBitcode); }
400  bool embedBitcodeMarkerOnly() const { return (BitcodeEmbed == EmbedMarker); }
401 
402  bool offloadHostOnly() const { return Offload == OffloadHost; }
403  bool offloadDeviceOnly() const { return Offload == OffloadDevice; }
404 
405  /// Compute the desired OpenMP runtime from the flags provided.
406  OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList &Args) const;
407 
408  /// @}
409  /// @name Primary Functionality
410  /// @{
411 
412  /// CreateOffloadingDeviceToolChains - create all the toolchains required to
413  /// support offloading devices given the programming models specified in the
414  /// current compilation. Also, update the host tool chain kind accordingly.
416 
417  /// BuildCompilation - Construct a compilation object for a command
418  /// line argument vector.
419  ///
420  /// \return A compilation, or 0 if none was built for the given
421  /// argument vector. A null return value does not necessarily
422  /// indicate an error condition, the diagnostics should be queried
423  /// to determine if an error occurred.
425 
426  /// ParseArgStrings - Parse the given list of strings into an
427  /// ArgList.
428  llvm::opt::InputArgList ParseArgStrings(ArrayRef<const char *> Args,
429  bool IsClCompatMode,
430  bool &ContainsError);
431 
432  /// BuildInputs - Construct the list of inputs and their types from
433  /// the given arguments.
434  ///
435  /// \param TC - The default host tool chain.
436  /// \param Args - The input arguments.
437  /// \param Inputs - The list to store the resulting compilation
438  /// inputs onto.
439  void BuildInputs(const ToolChain &TC, llvm::opt::DerivedArgList &Args,
440  InputList &Inputs) const;
441 
442  /// BuildActions - Construct the list of actions to perform for the
443  /// given arguments, which are only done for a single architecture.
444  ///
445  /// \param C - The compilation that is being built.
446  /// \param Args - The input arguments.
447  /// \param Actions - The list to store the resulting actions onto.
448  void BuildActions(Compilation &C, llvm::opt::DerivedArgList &Args,
449  const InputList &Inputs, ActionList &Actions) const;
450 
451  /// BuildUniversalActions - Construct the list of actions to perform
452  /// for the given arguments, which may require a universal build.
453  ///
454  /// \param C - The compilation that is being built.
455  /// \param TC - The default host tool chain.
456  void BuildUniversalActions(Compilation &C, const ToolChain &TC,
457  const InputList &BAInputs) const;
458 
459  /// BuildOffloadingActions - Construct the list of actions to perform for the
460  /// offloading toolchain that will be embedded in the host.
461  ///
462  /// \param C - The compilation that is being built.
463  /// \param Args - The input arguments.
464  /// \param Input - The input type and arguments
465  /// \param HostAction - The host action used in the offloading toolchain.
467  llvm::opt::DerivedArgList &Args,
468  const InputTy &Input,
469  Action *HostAction) const;
470 
471  /// Returns the set of bound architectures active for this offload kind.
472  /// If there are no bound architctures we return a set containing only the
473  /// empty string.
475  getOffloadArchs(Compilation &C, const llvm::opt::DerivedArgList &Args,
476  Action::OffloadKind Kind, const ToolChain *TC) const;
477 
478  /// Check that the file referenced by Value exists. If it doesn't,
479  /// issue a diagnostic and return false.
480  /// If TypoCorrect is true and the file does not exist, see if it looks
481  /// like a likely typo for a flag and if so print a "did you mean" blurb.
482  bool DiagnoseInputExistence(const llvm::opt::DerivedArgList &Args,
483  StringRef Value, types::ID Ty,
484  bool TypoCorrect) const;
485 
486  /// BuildJobs - Bind actions to concrete tools and translate
487  /// arguments to form the list of jobs to run.
488  ///
489  /// \param C - The compilation that is being built.
490  void BuildJobs(Compilation &C) const;
491 
492  /// ExecuteCompilation - Execute the compilation according to the command line
493  /// arguments and return an appropriate exit code.
494  ///
495  /// This routine handles additional processing that must be done in addition
496  /// to just running the subprocesses, for example reporting errors, setting
497  /// up response files, removing temporary files, etc.
499  SmallVectorImpl< std::pair<int, const Command *> > &FailingCommands);
500 
501  /// Contains the files in the compilation diagnostic report generated by
502  /// generateCompilationDiagnostics.
505  };
506 
507  /// generateCompilationDiagnostics - Generate diagnostics information
508  /// including preprocessed source file(s).
509  ///
511  Compilation &C, const Command &FailingCommand,
512  StringRef AdditionalInformation = "",
513  CompilationDiagnosticReport *GeneratedReport = nullptr);
514 
515  enum class CommandStatus {
516  Crash = 1,
517  Error,
518  Ok,
519  };
520 
521  enum class ReproLevel {
522  Off = 0,
523  OnCrash = static_cast<int>(CommandStatus::Crash),
524  OnError = static_cast<int>(CommandStatus::Error),
525  Always = static_cast<int>(CommandStatus::Ok),
526  };
527 
530  const Command &FailingCommand, StringRef AdditionalInformation = "",
531  CompilationDiagnosticReport *GeneratedReport = nullptr) {
532  if (static_cast<int>(CS) > static_cast<int>(Level))
533  return false;
534  if (CS != CommandStatus::Crash)
535  Diags.Report(diag::err_drv_force_crash)
536  << !::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH");
537  // Hack to ensure that diagnostic notes get emitted.
538  Diags.setLastDiagnosticIgnored(false);
539  generateCompilationDiagnostics(C, FailingCommand, AdditionalInformation,
540  GeneratedReport);
541  return true;
542  }
543 
544  /// @}
545  /// @name Helper Methods
546  /// @{
547 
548  /// PrintActions - Print the list of actions.
549  void PrintActions(const Compilation &C) const;
550 
551  /// PrintHelp - Print the help text.
552  ///
553  /// \param ShowHidden - Show hidden options.
554  void PrintHelp(bool ShowHidden) const;
555 
556  /// PrintVersion - Print the driver version.
557  void PrintVersion(const Compilation &C, raw_ostream &OS) const;
558 
559  /// GetFilePath - Lookup \p Name in the list of file search paths.
560  ///
561  /// \param TC - The tool chain for additional information on
562  /// directories to search.
563  //
564  // FIXME: This should be in CompilationInfo.
565  std::string GetFilePath(StringRef Name, const ToolChain &TC) const;
566 
567  /// GetProgramPath - Lookup \p Name in the list of program search paths.
568  ///
569  /// \param TC - The provided tool chain for additional information on
570  /// directories to search.
571  //
572  // FIXME: This should be in CompilationInfo.
573  std::string GetProgramPath(StringRef Name, const ToolChain &TC) const;
574 
575  /// HandleAutocompletions - Handle --autocomplete by searching and printing
576  /// possible flags, descriptions, and its arguments.
577  void HandleAutocompletions(StringRef PassedFlags) const;
578 
579  /// HandleImmediateArgs - Handle any arguments which should be
580  /// treated before building actions or binding tools.
581  ///
582  /// \return Whether any compilation should be built for this
583  /// invocation.
584  bool HandleImmediateArgs(const Compilation &C);
585 
586  /// ConstructAction - Construct the appropriate action to do for
587  /// \p Phase on the \p Input, taking in to account arguments
588  /// like -fsyntax-only or --analyze.
590  Compilation &C, const llvm::opt::ArgList &Args, phases::ID Phase,
591  Action *Input,
592  Action::OffloadKind TargetDeviceOffloadKind = Action::OFK_None) const;
593 
594  /// BuildJobsForAction - Construct the jobs to perform for the action \p A and
595  /// return an InputInfo for the result of running \p A. Will only construct
596  /// jobs for a given (Action, ToolChain, BoundArch, DeviceKind) tuple once.
598  Compilation &C, const Action *A, const ToolChain *TC, StringRef BoundArch,
599  bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
600  std::map<std::pair<const Action *, std::string>, InputInfoList>
601  &CachedResults,
602  Action::OffloadKind TargetDeviceOffloadKind) const;
603 
604  /// Returns the default name for linked images (e.g., "a.out").
605  const char *getDefaultImageName() const;
606 
607  // Creates a temp file with $Prefix-%%%%%%.$Suffix
608  const char *CreateTempFile(Compilation &C, StringRef Prefix, StringRef Suffix,
609  bool MultipleArchs = false,
610  StringRef BoundArch = {}) const;
611 
612  /// GetNamedOutputPath - Return the name to use for the output of
613  /// the action \p JA. The result is appended to the compilation's
614  /// list of temporary or result files, as appropriate.
615  ///
616  /// \param C - The compilation.
617  /// \param JA - The action of interest.
618  /// \param BaseInput - The original input file that this action was
619  /// triggered by.
620  /// \param BoundArch - The bound architecture.
621  /// \param AtTopLevel - Whether this is a "top-level" action.
622  /// \param MultipleArchs - Whether multiple -arch options were supplied.
623  /// \param NormalizedTriple - The normalized triple of the relevant target.
624  const char *GetNamedOutputPath(Compilation &C, const JobAction &JA,
625  const char *BaseInput, StringRef BoundArch,
626  bool AtTopLevel, bool MultipleArchs,
627  StringRef NormalizedTriple) const;
628 
629  /// GetTemporaryPath - Return the pathname of a temporary file to use
630  /// as part of compilation; the file will have the given prefix and suffix.
631  ///
632  /// GCC goes to extra lengths here to be a bit more robust.
633  std::string GetTemporaryPath(StringRef Prefix, StringRef Suffix) const;
634 
635  /// GetTemporaryDirectory - Return the pathname of a temporary directory to
636  /// use as part of compilation; the directory will have the given prefix.
637  std::string GetTemporaryDirectory(StringRef Prefix) const;
638 
639  /// Return the pathname of the pch file in clang-cl mode.
640  std::string GetClPchPath(Compilation &C, StringRef BaseName) const;
641 
642  /// ShouldUseClangCompiler - Should the clang compiler be used to
643  /// handle this action.
644  bool ShouldUseClangCompiler(const JobAction &JA) const;
645 
646  /// ShouldUseFlangCompiler - Should the flang compiler be used to
647  /// handle this action.
648  bool ShouldUseFlangCompiler(const JobAction &JA) const;
649 
650  /// ShouldEmitStaticLibrary - Should the linker emit a static library.
651  bool ShouldEmitStaticLibrary(const llvm::opt::ArgList &Args) const;
652 
653  /// Returns true if the user has indicated a C++20 header unit mode.
654  bool hasHeaderMode() const { return CXX20HeaderType != HeaderMode_None; }
655 
656  /// Get the mode for handling headers as set by fmodule-header{=}.
657  ModuleHeaderMode getModuleHeaderMode() const { return CXX20HeaderType; }
658 
659  /// Returns true if we are performing any kind of LTO.
660  bool isUsingLTO(bool IsOffload = false) const {
661  return getLTOMode(IsOffload) != LTOK_None;
662  }
663 
664  /// Get the specific kind of LTO being performed.
665  LTOKind getLTOMode(bool IsOffload = false) const {
666  return IsOffload ? OffloadLTOMode : LTOMode;
667  }
668 
669 private:
670 
671  /// Tries to load options from configuration files.
672  ///
673  /// \returns true if error occurred.
674  bool loadConfigFiles();
675 
676  /// Tries to load options from default configuration files (deduced from
677  /// executable filename).
678  ///
679  /// \returns true if error occurred.
680  bool loadDefaultConfigFiles(ArrayRef<StringRef> CfgFileSearchDirs);
681 
682  /// Read options from the specified file.
683  ///
684  /// \param [in] FileName File to read.
685  /// \returns true, if error occurred while reading.
686  bool readConfigFile(StringRef FileName);
687 
688  /// Set the driver mode (cl, gcc, etc) from the value of the `--driver-mode`
689  /// option.
690  void setDriverMode(StringRef DriverModeValue);
691 
692  /// Parse the \p Args list for LTO options and record the type of LTO
693  /// compilation based on which -f(no-)?lto(=.*)? option occurs last.
694  void setLTOMode(const llvm::opt::ArgList &Args);
695 
696  /// Retrieves a ToolChain for a particular \p Target triple.
697  ///
698  /// Will cache ToolChains for the life of the driver object, and create them
699  /// on-demand.
700  const ToolChain &getToolChain(const llvm::opt::ArgList &Args,
701  const llvm::Triple &Target) const;
702 
703  /// @}
704 
705  /// Retrieves a ToolChain for a particular device \p Target triple
706  ///
707  /// \param[in] HostTC is the host ToolChain paired with the device
708  ///
709  /// \param[in] TargetDeviceOffloadKind (e.g. OFK_Cuda/OFK_OpenMP/OFK_SYCL) is
710  /// an Offloading action that is optionally passed to a ToolChain (used by
711  /// CUDA, to specify if it's used in conjunction with OpenMP)
712  ///
713  /// Will cache ToolChains for the life of the driver object, and create them
714  /// on-demand.
715  const ToolChain &getOffloadingDeviceToolChain(
716  const llvm::opt::ArgList &Args, const llvm::Triple &Target,
717  const ToolChain &HostTC,
718  const Action::OffloadKind &TargetDeviceOffloadKind) const;
719 
720  /// Get bitmasks for which option flags to include and exclude based on
721  /// the driver mode.
722  std::pair<unsigned, unsigned> getIncludeExcludeOptionFlagMasks(bool IsClCompatMode) const;
723 
724  /// Helper used in BuildJobsForAction. Doesn't use the cache when building
725  /// jobs specifically for the given action, but will use the cache when
726  /// building jobs for the Action's inputs.
727  InputInfoList BuildJobsForActionNoCache(
728  Compilation &C, const Action *A, const ToolChain *TC, StringRef BoundArch,
729  bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
730  std::map<std::pair<const Action *, std::string>, InputInfoList>
731  &CachedResults,
732  Action::OffloadKind TargetDeviceOffloadKind) const;
733 
734  /// Return the typical executable name for the specified driver \p Mode.
735  static const char *getExecutableForDriverMode(DriverMode Mode);
736 
737 public:
738  /// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and
739  /// return the grouped values as integers. Numbers which are not
740  /// provided are set to 0.
741  ///
742  /// \return True if the entire string was parsed (9.2), or all
743  /// groups were parsed (10.3.5extrastuff). HadExtra is true if all
744  /// groups were parsed but extra characters remain at the end.
745  static bool GetReleaseVersion(StringRef Str, unsigned &Major, unsigned &Minor,
746  unsigned &Micro, bool &HadExtra);
747 
748  /// Parse digits from a string \p Str and fulfill \p Digits with
749  /// the parsed numbers. This method assumes that the max number of
750  /// digits to look for is equal to Digits.size().
751  ///
752  /// \return True if the entire string was parsed and there are
753  /// no extra characters remaining at the end.
754  static bool GetReleaseVersion(StringRef Str,
756  /// Compute the default -fmodule-cache-path.
757  /// \return True if the system provides a default cache directory.
759 };
760 
761 /// \return True if the last defined optimization level is -Ofast.
762 /// And False otherwise.
763 bool isOptimizationLevelFast(const llvm::opt::ArgList &Args);
764 
765 /// \return True if the argument combination will end up generating remarks.
766 bool willEmitRemarks(const llvm::opt::ArgList &Args);
767 
768 /// Returns the driver mode option's value, i.e. `X` in `--driver-mode=X`. If \p
769 /// Args doesn't mention one explicitly, tries to deduce from `ProgName`.
770 /// Returns empty on failure.
771 /// Common values are "gcc", "g++", "cpp", "cl" and "flang". Returned value need
772 /// not be one of these.
773 llvm::StringRef getDriverMode(StringRef ProgName, ArrayRef<const char *> Args);
774 
775 /// Checks whether the value produced by getDriverMode is for CL mode.
776 bool IsClangCL(StringRef DriverMode);
777 
778 } // end namespace driver
779 } // end namespace clang
780 
781 #endif
clang::driver::Driver::InputList
SmallVector< InputTy, 16 > InputList
A list of inputs and their types for the given arguments.
Definition: Driver.h:205
clang::driver::Driver::embedBitcodeEnabled
bool embedBitcodeEnabled() const
Definition: Driver.h:398
clang::driver::Driver::BuildJobsForAction
InputInfoList BuildJobsForAction(Compilation &C, const Action *A, const ToolChain *TC, StringRef BoundArch, bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput, std::map< std::pair< const Action *, std::string >, InputInfoList > &CachedResults, Action::OffloadKind TargetDeviceOffloadKind) const
BuildJobsForAction - Construct the jobs to perform for the action A and return an InputInfo for the r...
Definition: Driver.cpp:5082
Util.h
clang::driver::Driver::GetProgramPath
std::string GetProgramPath(StringRef Name, const ToolChain &TC) const
GetProgramPath - Lookup Name in the list of program search paths.
Definition: Driver.cpp:5770
clang::driver::Driver::HostRelease
std::string HostRelease
Definition: Driver.h:187
llvm
YAML serialization mapping.
Definition: Dominators.h:30
clang::driver::isOptimizationLevelFast
bool isOptimizationLevelFast(const llvm::opt::ArgList &Args)
clang::driver::Driver::PrefixDirs
prefix_list PrefixDirs
Definition: Driver.h:175
clang::driver::Driver::GetNamedOutputPath
const char * GetNamedOutputPath(Compilation &C, const JobAction &JA, const char *BaseInput, StringRef BoundArch, bool AtTopLevel, bool MultipleArchs, StringRef NormalizedTriple) const
GetNamedOutputPath - Return the name to use for the output of the action JA.
Definition: Driver.cpp:5490
clang::DiagnosticBuilder
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:1266
clang::driver::ParsedClangName
Helper structure used to pass information extracted from clang executable name such as i686-linux-and...
Definition: ToolChain.h:64
clang::driver::Driver::getCheckInputsExist
bool getCheckInputsExist() const
Definition: Driver.h:368
clang::driver::Driver::CompilationDiagnosticReport
Contains the files in the compilation diagnostic report generated by generateCompilationDiagnostics.
Definition: Driver.h:503
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::driver::Driver::Dir
std::string Dir
The path the driver executable was in, as invoked from the command line.
Definition: Driver.h:150
clang::driver::LTOK_None
@ LTOK_None
Definition: Driver.h:54
clang::driver::Driver::DiagnoseInputExistence
bool DiagnoseInputExistence(const llvm::opt::DerivedArgList &Args, StringRef Value, types::ID Ty, bool TypoCorrect) const
Check that the file referenced by Value exists.
Definition: Driver.cpp:2400
clang::driver::Driver::PrintVersion
void PrintVersion(const Compilation &C, raw_ostream &OS) const
PrintVersion - Print the driver version.
Definition: Driver.cpp:1885
clang::driver::Driver::IsCLMode
bool IsCLMode() const
Whether the driver should follow cl.exe like behavior.
Definition: Driver.h:217
llvm::SmallVector
Definition: LLVM.h:38
clang::driver::Driver::hasHeaderMode
bool hasHeaderMode() const
Returns true if the user has indicated a C++20 header unit mode.
Definition: Driver.h:654
clang::driver::Action
Action - Represent an abstract compilation step to perform.
Definition: Action.h:47
clang::driver::Driver::maybeGenerateCompilationDiagnostics
bool maybeGenerateCompilationDiagnostics(CommandStatus CS, ReproLevel Level, Compilation &C, const Command &FailingCommand, StringRef AdditionalInformation="", CompilationDiagnosticReport *GeneratedReport=nullptr)
Definition: Driver.h:528
clang::driver::Driver::getOffloadArchs
llvm::DenseSet< StringRef > getOffloadArchs(Compilation &C, const llvm::opt::DerivedArgList &Args, Action::OffloadKind Kind, const ToolChain *TC) const
Returns the set of bound architectures active for this offload kind.
Definition: Driver.cpp:4229
clang::driver::HeaderMode_User
@ HeaderMode_User
Definition: Driver.h:66
clang::driver::Driver::generateCompilationDiagnostics
void generateCompilationDiagnostics(Compilation &C, const Command &FailingCommand, StringRef AdditionalInformation="", CompilationDiagnosticReport *GeneratedReport=nullptr)
generateCompilationDiagnostics - Generate diagnostics information including preprocessed source file(...
Definition: Driver.cpp:1535
clang::driver::Driver::getModuleHeaderMode
ModuleHeaderMode getModuleHeaderMode() const
Get the mode for handling headers as set by fmodule-header{=}.
Definition: Driver.h:657
clang::DiagnosticsEngine
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:192
clang::driver::phases::ID
ID
ID - Ordered values for successive stages in the compilation process which interact with user options...
Definition: Phases.h:17
clang::driver::Driver::embedBitcodeInObject
bool embedBitcodeInObject() const
Definition: Driver.h:399
int
__device__ int
Definition: __clang_hip_libdevice_declares.h:63
clang::driver::Driver::InputTy
std::pair< types::ID, const llvm::opt::Arg * > InputTy
An input type and its arguments.
Definition: Driver.h:202
clang::driver::InputInfoList
SmallVector< InputInfo, 4 > InputInfoList
Definition: Driver.h:45
clang::driver::Driver::CCPrintOptionsFilename
std::string CCPrintOptionsFilename
The file to log CC_PRINT_OPTIONS output to, if enabled.
Definition: Driver.h:193
clang::driver::Driver::OpenMPRuntimeKind
OpenMPRuntimeKind
Definition: Driver.h:118
clang::driver::Driver::BuildActions
void BuildActions(Compilation &C, llvm::opt::DerivedArgList &Args, const InputList &Inputs, ActionList &Actions) const
BuildActions - Construct the list of actions to perform for the given arguments, which are only done ...
Definition: Driver.cpp:3898
clang::driver::Driver::getDefaultModuleCachePath
static bool getDefaultModuleCachePath(SmallVectorImpl< char > &Result)
Compute the default -fmodule-cache-path.
Definition: Clang.cpp:3645
clang::driver::Driver::CommandStatus
CommandStatus
Definition: Driver.h:515
clang::DiagnosticsEngine::setLastDiagnosticIgnored
void setLastDiagnosticIgnored(bool Ignored)
Pretend that the last diagnostic issued was ignored, so any subsequent notes will be suppressed,...
Definition: Diagnostic.h:756
clang::driver::Driver::getOpenMPRuntime
OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList &Args) const
Compute the desired OpenMP runtime from the flags provided.
Definition: Driver.cpp:709
clang::driver::Driver::getOpts
const llvm::opt::OptTable & getOpts() const
Definition: Driver.h:362
clang::driver::Driver::getDiags
DiagnosticsEngine & getDiags() const
Definition: Driver.h:364
clang::driver::Driver::PrintActions
void PrintActions(const Compilation &C) const
PrintActions - Print the list of actions.
Definition: Driver.cpp:2296
InputInfo.h
clang::driver::Driver::InstalledDir
std::string InstalledDir
The path to the installed clang directory, if any.
Definition: Driver.h:159
Action.h
clang::driver::Driver::DriverTitle
std::string DriverTitle
Driver title to use with help.
Definition: Driver.h:184
llvm::MutableArrayRef
Definition: LLVM.h:35
clang::driver::Driver::isSaveTempsEnabled
bool isSaveTempsEnabled() const
Definition: Driver.h:395
clang::driver::Driver::getLTOMode
LTOKind getLTOMode(bool IsOffload=false) const
Get the specific kind of LTO being performed.
Definition: Driver.h:665
clang::driver::Driver::Diag
DiagnosticBuilder Diag(unsigned DiagID) const
Definition: Driver.h:139
clang::driver::Driver::getConfigFiles
llvm::ArrayRef< std::string > getConfigFiles() const
Definition: Driver.h:358
clang::driver::Driver::CCCPrintBindings
unsigned CCCPrintBindings
Only print tool bindings, don't build any jobs.
Definition: Driver.h:227
clang::driver::Tool
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
clang::driver::getDriverOptTable
const llvm::opt::OptTable & getDriverOptTable()
Definition: DriverOptions.cpp:42
clang::driver::Driver::CCCIsCC
bool CCCIsCC() const
Whether the driver should follow gcc like behavior.
Definition: Driver.h:214
Options.h
clang::driver::Driver::ConstructPhaseAction
Action * ConstructPhaseAction(Compilation &C, const llvm::opt::ArgList &Args, phases::ID Phase, Action *Input, Action::OffloadKind TargetDeviceOffloadKind=Action::OFK_None) const
ConstructAction - Construct the appropriate action to do for Phase on the Input, taking in to account...
Definition: Driver.cpp:4439
clang::driver::Driver::CCCIsCPP
bool CCCIsCPP() const
Whether the driver is just the preprocessor.
Definition: Driver.h:211
clang::driver::Driver::CCPrintOptions
unsigned CCPrintOptions
Set CC_PRINT_OPTIONS mode, which is like -v but logs the commands to CCPrintOptionsFilename or to std...
Definition: Driver.h:231
clang::driver::Driver::CommandStatus::Ok
@ Ok
clang::driver::Driver::ReproLevel::OnError
@ OnError
clang::driver::LTOK_Thin
@ LTOK_Thin
Definition: Driver.h:56
clang::driver::Driver::Name
std::string Name
The name the driver was invoked as.
Definition: Driver.h:146
Diagnostic.h
DriverDiagnostic.h
clang::driver::Driver::ParseArgStrings
llvm::opt::InputArgList ParseArgStrings(ArrayRef< const char * > Args, bool IsClCompatMode, bool &ContainsError)
ParseArgStrings - Parse the given list of strings into an ArgList.
Definition: Driver.cpp:246
clang::driver::Driver::HostBits
std::string HostBits
Information about the host which can be overridden by the user.
Definition: Driver.h:187
clang::driver::Driver::SystemConfigDir
std::string SystemConfigDir
System directory for config files.
Definition: Driver.h:165
clang::driver::Driver::CCPrintHeaders
unsigned CCPrintHeaders
Set CC_PRINT_HEADERS mode, which causes the frontend to log header include information to CCPrintHead...
Definition: Driver.h:235
clang::driver::Driver::Driver
Driver(StringRef ClangExecutable, StringRef TargetTriple, DiagnosticsEngine &Diags, std::string Title="clang LLVM compiler", IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS=nullptr)
Definition: Driver.cpp:191
clang::driver::Driver::BuildOffloadingActions
Action * BuildOffloadingActions(Compilation &C, llvm::opt::DerivedArgList &Args, const InputTy &Input, Action *HostAction) const
BuildOffloadingActions - Construct the list of actions to perform for the offloading toolchain that w...
Definition: Driver.cpp:4294
clang::driver::Driver::OMPRT_IOMP5
@ OMPRT_IOMP5
The legacy name for the LLVM OpenMP runtime from when it was the Intel OpenMP runtime.
Definition: Driver.h:135
llvm::SmallString< 128 >
clang::driver::Driver::CommandStatus::Crash
@ Crash
clang::driver::HeaderMode_System
@ HeaderMode_System
Definition: Driver.h:67
clang::driver::Driver::SysRoot
std::string SysRoot
sysroot, if present
Definition: Driver.h:178
clang::driver::Driver::ReproLevel::Off
@ Off
clang::driver::Driver::ShouldEmitStaticLibrary
bool ShouldEmitStaticLibrary(const llvm::opt::ArgList &Args) const
ShouldEmitStaticLibrary - Should the linker emit a static library.
Definition: Driver.cpp:6116
llvm::DenseSet
Definition: Sema.h:77
clang::driver::Driver::CCCIsCXX
bool CCCIsCXX() const
Whether the driver should follow g++ like behavior.
Definition: Driver.h:208
clang::driver::Driver::OMPRT_OMP
@ OMPRT_OMP
The LLVM OpenMP runtime.
Definition: Driver.h:125
clang::driver::Driver::getCCCGenericGCCName
const std::string & getCCCGenericGCCName() const
Name to use when invoking gcc/g++.
Definition: Driver.h:356
clang::driver::Driver::getTitle
const std::string & getTitle()
Definition: Driver.h:377
clang::driver::Action::OFK_None
@ OFK_None
Definition: Action.h:88
clang::driver::LTOK_Full
@ LTOK_Full
Definition: Driver.h:55
Phases.h
clang::driver::Driver::offloadDeviceOnly
bool offloadDeviceOnly() const
Definition: Driver.h:403
clang::driver::Driver::CCLogDiagnostics
unsigned CCLogDiagnostics
Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics to CCLogDiagnosticsFilename...
Definition: Driver.h:240
clang::driver::Driver::CC1ToolFunc
int(* CC1ToolFunc)(SmallVectorImpl< const char * > &ArgV)
Pointer to the ExecuteCC1Tool function, if available.
Definition: Driver.h:253
Cmd
CompileCommand Cmd
Definition: InterpolatingCompilationDatabase.cpp:129
clang::driver::Driver::ResourceDir
std::string ResourceDir
The path to the compiler resource directory.
Definition: Driver.h:162
clang::driver::Driver::ExecuteCompilation
int ExecuteCompilation(Compilation &C, SmallVectorImpl< std::pair< int, const Command * > > &FailingCommands)
ExecuteCompilation - Execute the compilation according to the command line arguments and return an ap...
Definition: Driver.cpp:1780
clang::driver::Driver::getClangProgramPath
const char * getClangProgramPath() const
Get the path to the main clang executable.
Definition: Driver.h:383
clang::driver::Driver::CC1Main
CC1ToolFunc CC1Main
Definition: Driver.h:254
clang::driver::Driver::ReproLevel
ReproLevel
Definition: Driver.h:521
clang::driver::Driver::getFinalPhase
phases::ID getFinalPhase(const llvm::opt::DerivedArgList &DAL, llvm::opt::Arg **FinalPhaseArg=nullptr) const
Definition: Driver.cpp:336
ToolChain.h
clang::driver::Driver::CreateOffloadingDeviceToolChains
void CreateOffloadingDeviceToolChains(Compilation &C, InputList &Inputs)
CreateOffloadingDeviceToolChains - create all the toolchains required to support offloading devices g...
Definition: Driver.cpp:734
clang::driver::Command
Command - An executable path/name and argument vector to execute.
Definition: Job.h:106
clang::driver::Driver::embedBitcodeMarkerOnly
bool embedBitcodeMarkerOnly() const
Definition: Driver.h:400
clang::driver::LTOKind
LTOKind
Describes the kind of LTO mode selected via -f(no-)?lto(=.*)? options.
Definition: Driver.h:53
clang::driver::Driver::ReproLevel::Always
@ Always
clang::driver::Driver::CCPrintStatReportFilename
std::string CCPrintStatReportFilename
The file to log CC_PRINT_PROC_STAT_FILE output to, if enabled.
Definition: Driver.h:190
clang::driver::Driver::isUsingLTO
bool isUsingLTO(bool IsOffload=false) const
Returns true if we are performing any kind of LTO.
Definition: Driver.h:660
clang::driver::Driver::ClangNameParts
ParsedClangName ClangNameParts
Target and driver mode components extracted from clang executable name.
Definition: Driver.h:156
clang::driver::Driver::ShouldUseFlangCompiler
bool ShouldUseFlangCompiler(const JobAction &JA) const
ShouldUseFlangCompiler - Should the flang compiler be used to handle this action.
Definition: Driver.cpp:6102
clang::driver::Driver::isSaveTempsObj
bool isSaveTempsObj() const
Definition: Driver.h:396
clang::driver::Driver::GetClPchPath
std::string GetClPchPath(Compilation &C, StringRef BaseName) const
Return the pathname of the pch file in clang-cl mode.
Definition: Driver.cpp:5834
clang::driver::Driver::GetTemporaryPath
std::string GetTemporaryPath(StringRef Prefix, StringRef Suffix) const
GetTemporaryPath - Return the pathname of a temporary file to use as part of compilation; the file wi...
Definition: Driver.cpp:5812
clang::driver::ToolChain
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:91
clang::driver::Driver::IsDXCMode
bool IsDXCMode() const
Whether the driver should follow dxc.exe like behavior.
Definition: Driver.h:224
llvm::ArrayRef< std::string >
clang::driver::Driver::getDefaultImageName
const char * getDefaultImageName() const
Returns the default name for linked images (e.g., "a.out").
Definition: Driver.cpp:5409
Value
Value
Definition: UninitializedValues.cpp:102
clang::driver::Driver::CreateTempFile
const char * CreateTempFile(Compilation &C, StringRef Prefix, StringRef Suffix, bool MultipleArchs=false, StringRef BoundArch={}) const
Definition: Driver.cpp:5458
clang::driver::Driver::prefix_list
SmallVector< std::string, 4 > prefix_list
A prefix directory used to emulate a limited subset of GCC's '-Bprefix' functionality.
Definition: Driver.h:174
clang::driver::Driver::UserConfigDir
std::string UserConfigDir
User directory for config files.
Definition: Driver.h:168
LLVM.h
clang::driver::Driver::GetResourcesPath
static std::string GetResourcesPath(StringRef BinaryPath, StringRef CustomResourceDir="")
Takes the path to a binary that's either in bin/ or lib/ and returns the path to clang's resource dir...
Definition: Driver.cpp:165
clang::driver::Driver::setTargetAndMode
void setTargetAndMode(const ParsedClangName &TM)
Definition: Driver.h:375
clang::driver::Driver::BuildJobs
void BuildJobs(Compilation &C) const
BuildJobs - Bind actions to concrete tools and translate arguments to form the list of jobs to run.
Definition: Driver.cpp:4560
clang::driver::types::ID
ID
Definition: Types.h:23
clang::driver::Compilation
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
clang::driver::LTOK_Unknown
@ LTOK_Unknown
Definition: Driver.h:57
clang::driver::Driver::CCLogDiagnosticsFilename
std::string CCLogDiagnosticsFilename
The file to log CC_LOG_DIAGNOSTICS output to, if enabled.
Definition: Driver.h:199
clang::driver::Driver::GetFilePath
std::string GetFilePath(StringRef Name, const ToolChain &TC) const
GetFilePath - Lookup Name in the list of file search paths.
Definition: Driver.cpp:5710
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::driver::willEmitRemarks
bool willEmitRemarks(const llvm::opt::ArgList &Args)
clang::driver::Driver::setProbePrecompiled
void setProbePrecompiled(bool Value)
Definition: Driver.h:373
clang::driver::Driver::CompilationDiagnosticReport::TemporaryFiles
llvm::SmallVector< std::string, 4 > TemporaryFiles
Definition: Driver.h:504
clang::driver::Driver::setInstalledDir
void setInstalledDir(StringRef Value)
Definition: Driver.h:393
clang::driver::ModuleHeaderMode
ModuleHeaderMode
Whether headers used to construct C++20 module units should be looked up by the path supplied on the ...
Definition: Driver.h:63
clang
Definition: CalledOnceCheck.h:17
clang::driver::Driver::offloadHostOnly
bool offloadHostOnly() const
Definition: Driver.h:402
clang::driver::Driver
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:72
clang::driver::Driver::getTargetTriple
std::string getTargetTriple() const
Definition: Driver.h:380
clang::driver::Driver::ShouldUseClangCompiler
bool ShouldUseClangCompiler(const JobAction &JA) const
ShouldUseClangCompiler - Should the clang compiler be used to handle this action.
Definition: Driver.cpp:6087
clang::driver::Driver::CCPrintHeadersFilename
std::string CCPrintHeadersFilename
The file to log CC_PRINT_HEADERS output to, if enabled.
Definition: Driver.h:196
clang::driver::HeaderMode_None
@ HeaderMode_None
Definition: Driver.h:64
clang::driver::Driver::OMPRT_Unknown
@ OMPRT_Unknown
An unknown OpenMP runtime.
Definition: Driver.h:121
clang::prec::Level
Level
Definition: OperatorPrecedence.h:26
clang::driver::Driver::GetTemporaryDirectory
std::string GetTemporaryDirectory(StringRef Prefix) const
GetTemporaryDirectory - Return the pathname of a temporary directory to use as part of compilation; t...
Definition: Driver.cpp:5823
clang::driver::IsClangCL
bool IsClangCL(StringRef DriverMode)
Checks whether the value produced by getDriverMode is for CL mode.
Definition: Driver.cpp:6277
clang::driver::Driver::HostSystem
std::string HostSystem
Definition: Driver.h:187
clang::driver::Driver::getVFS
llvm::vfs::FileSystem & getVFS() const
Definition: Driver.h:366
Types.h
clang::driver::HeaderMode_Default
@ HeaderMode_Default
Definition: Driver.h:65
clang::driver::Driver::setTitle
void setTitle(std::string Value)
Definition: Driver.h:378
clang::driver::Action::OffloadKind
OffloadKind
Definition: Action.h:87
clang::driver::Driver::HandleImmediateArgs
bool HandleImmediateArgs(const Compilation &C)
HandleImmediateArgs - Handle any arguments which should be treated before building actions or binding...
Definition: Driver.cpp:2008
clang::driver::getDriverMode
llvm::StringRef getDriverMode(StringRef ProgName, ArrayRef< const char * > Args)
Returns the driver mode option's value, i.e.
Definition: Driver.cpp:6262
llvm::SmallVectorImpl
Definition: Randstruct.h:18
clang::driver::Driver::PrintHelp
void PrintHelp(bool ShowHidden) const
PrintHelp - Print the help text.
Definition: Driver.cpp:1864
clang::driver::Driver::OMPRT_GOMP
@ OMPRT_GOMP
The GNU OpenMP runtime.
Definition: Driver.h:130
clang::driver::JobAction
Definition: Action.h:399
clang::driver::Driver::DyldPrefix
std::string DyldPrefix
Dynamic loader prefix, if present.
Definition: Driver.h:181
clang::driver::Driver::getProbePrecompiled
bool getProbePrecompiled() const
Definition: Driver.h:372
clang::driver::Driver::ReproLevel::OnCrash
@ OnCrash
clang::driver::Driver::BuildInputs
void BuildInputs(const ToolChain &TC, llvm::opt::DerivedArgList &Args, InputList &Inputs) const
BuildInputs - Construct the list of inputs and their types from the given arguments.
Definition: Driver.cpp:2496
clang::driver::Driver::GetReleaseVersion
static bool GetReleaseVersion(StringRef Str, unsigned &Major, unsigned &Minor, unsigned &Micro, bool &HadExtra)
GetReleaseVersion - Parse (([0-9]+)(.
Definition: Driver.cpp:6128
clang::driver::Driver::ClangExecutable
std::string ClangExecutable
The original path to the clang executable.
Definition: Driver.h:153
clang::driver::Driver::CCPrintProcessStats
unsigned CCPrintProcessStats
Set CC_PRINT_PROC_STAT mode, which causes the driver to dump performance report to CC_PRINT_PROC_STAT...
Definition: Driver.h:247
llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem >
clang::driver::Driver::HandleAutocompletions
void HandleAutocompletions(StringRef PassedFlags) const
HandleAutocompletions - Handle –autocomplete by searching and printing possible flags,...
Definition: Driver.cpp:1922
clang::driver::Driver::getInstalledDir
const char * getInstalledDir() const
Get the path to where the clang executable was installed.
Definition: Driver.h:388
clang::driver::Driver::IsFlangMode
bool IsFlangMode() const
Whether the driver should invoke flang for fortran inputs.
Definition: Driver.h:221
clang::driver::Driver::setCheckInputsExist
void setCheckInputsExist(bool Value)
Definition: Driver.h:370
clang::driver::Driver::HostMachine
std::string HostMachine
Definition: Driver.h:187
clang::DiagnosticsEngine::Report
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1537
clang::driver::Driver::CommandStatus::Error
@ Error
clang::driver::Driver::BuildUniversalActions
void BuildUniversalActions(Compilation &C, const ToolChain &TC, const InputList &BAInputs) const
BuildUniversalActions - Construct the list of actions to perform for the given arguments,...
Definition: Driver.cpp:2312
clang::driver::Driver::BuildCompilation
Compilation * BuildCompilation(ArrayRef< const char * > Args)
BuildCompilation - Construct a compilation object for a command line argument vector.
Definition: Driver.cpp:1149
clang::driver::Driver::CCGenDiagnostics
unsigned CCGenDiagnostics
Whether the driver is generating diagnostics for debugging purposes.
Definition: Driver.h:243