clang  14.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"
15 #include "clang/Driver/Options.h"
16 #include "clang/Driver/Phases.h"
17 #include "clang/Driver/ToolChain.h"
18 #include "clang/Driver/Types.h"
19 #include "clang/Driver/Util.h"
20 #include "llvm/ADT/StringMap.h"
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/Option/Arg.h"
23 #include "llvm/Option/ArgList.h"
24 #include "llvm/Support/StringSaver.h"
25 
26 #include <list>
27 #include <map>
28 #include <string>
29 
30 namespace llvm {
31 class Triple;
32 namespace vfs {
33 class FileSystem;
34 }
35 } // namespace llvm
36 
37 namespace clang {
38 
39 namespace driver {
40 
41  class Command;
42  class Compilation;
43  class InputInfo;
44  class JobList;
45  class JobAction;
46  class SanitizerArgs;
47  class ToolChain;
48 
49 /// Describes the kind of LTO mode selected via -f(no-)?lto(=.*)? options.
50 enum LTOKind {
55 };
56 
57 /// Driver - Encapsulate logic for constructing compilation processes
58 /// from a set of gcc-driver-like command line arguments.
59 class Driver {
60  DiagnosticsEngine &Diags;
61 
63 
64  enum DriverMode {
65  GCCMode,
66  GXXMode,
67  CPPMode,
68  CLMode,
69  FlangMode
70  } Mode;
71 
72  enum SaveTempsMode {
73  SaveTempsNone,
74  SaveTempsCwd,
75  SaveTempsObj
76  } SaveTemps;
77 
78  enum BitcodeEmbedMode {
79  EmbedNone,
80  EmbedMarker,
81  EmbedBitcode
82  } BitcodeEmbed;
83 
84  /// LTO mode selected via -f(no-)?lto(=.*)? options.
85  LTOKind LTOMode;
86 
87  /// LTO mode selected via -f(no-offload-)?lto(=.*)? options.
88  LTOKind OffloadLTOMode;
89 
90 public:
92  /// An unknown OpenMP runtime. We can't generate effective OpenMP code
93  /// without knowing what runtime to target.
95 
96  /// The LLVM OpenMP runtime. When completed and integrated, this will become
97  /// the default for Clang.
99 
100  /// The GNU OpenMP runtime. Clang doesn't support generating OpenMP code for
101  /// this runtime but can swallow the pragmas, and find and link against the
102  /// runtime library itself.
104 
105  /// The legacy name for the LLVM OpenMP runtime from when it was the Intel
106  /// OpenMP runtime. We support this mode for users with existing
107  /// dependencies on this runtime library name.
109  };
110 
111  // Diag - Forwarding function for diagnostics.
112  DiagnosticBuilder Diag(unsigned DiagID) const {
113  return Diags.Report(DiagID);
114  }
115 
116  // FIXME: Privatize once interface is stable.
117 public:
118  /// The name the driver was invoked as.
120 
121  /// The path the driver executable was in, as invoked from the
122  /// command line.
124 
125  /// The original path to the clang executable.
127 
128  /// Target and driver mode components extracted from clang executable name.
130 
131  /// The path to the installed clang directory, if any.
133 
134  /// The path to the compiler resource directory.
136 
137  /// System directory for config files.
139 
140  /// User directory for config files.
142 
143  /// A prefix directory used to emulate a limited subset of GCC's '-Bprefix'
144  /// functionality.
145  /// FIXME: This type of customization should be removed in favor of the
146  /// universal driver when it is ready.
149 
150  /// sysroot, if present
152 
153  /// Dynamic loader prefix, if present
155 
156  /// Driver title to use with help.
158 
159  /// Information about the host which can be overridden by the user.
161 
162  /// The file to log CC_PRINT_PROC_STAT_FILE output to, if enabled.
164 
165  /// The file to log CC_PRINT_OPTIONS output to, if enabled.
167 
168  /// The file to log CC_PRINT_HEADERS output to, if enabled.
170 
171  /// The file to log CC_LOG_DIAGNOSTICS output to, if enabled.
173 
174  /// A list of inputs and their types for the given arguments.
177 
178  /// Whether the driver should follow g++ like behavior.
179  bool CCCIsCXX() const { return Mode == GXXMode; }
180 
181  /// Whether the driver is just the preprocessor.
182  bool CCCIsCPP() const { return Mode == CPPMode; }
183 
184  /// Whether the driver should follow gcc like behavior.
185  bool CCCIsCC() const { return Mode == GCCMode; }
186 
187  /// Whether the driver should follow cl.exe like behavior.
188  bool IsCLMode() const { return Mode == CLMode; }
189 
190  /// Whether the driver should invoke flang for fortran inputs.
191  /// Other modes fall back to calling gcc which in turn calls gfortran.
192  bool IsFlangMode() const { return Mode == FlangMode; }
193 
194  /// Only print tool bindings, don't build any jobs.
195  unsigned CCCPrintBindings : 1;
196 
197  /// Set CC_PRINT_OPTIONS mode, which is like -v but logs the commands to
198  /// CCPrintOptionsFilename or to stderr.
199  unsigned CCPrintOptions : 1;
200 
201  /// Set CC_PRINT_HEADERS mode, which causes the frontend to log header include
202  /// information to CCPrintHeadersFilename or to stderr.
203  unsigned CCPrintHeaders : 1;
204 
205  /// Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics
206  /// to CCLogDiagnosticsFilename or to stderr, in a stable machine readable
207  /// format.
208  unsigned CCLogDiagnostics : 1;
209 
210  /// Whether the driver is generating diagnostics for debugging purposes.
211  unsigned CCGenDiagnostics : 1;
212 
213  /// Set CC_PRINT_PROC_STAT mode, which causes the driver to dump
214  /// performance report to CC_PRINT_PROC_STAT_FILE or to stdout.
215  unsigned CCPrintProcessStats : 1;
216 
217  /// Pointer to the ExecuteCC1Tool function, if available.
218  /// When the clangDriver lib is used through clang.exe, this provides a
219  /// shortcut for executing the -cc1 command-line directly, in the same
220  /// process.
222  CC1ToolFunc CC1Main = nullptr;
223 
224 private:
225  /// Raw target triple.
226  std::string TargetTriple;
227 
228  /// Name to use when invoking gcc/g++.
229  std::string CCCGenericGCCName;
230 
231  /// Name of configuration file if used.
232  std::string ConfigFile;
233 
234  /// Allocator for string saver.
235  llvm::BumpPtrAllocator Alloc;
236 
237  /// Object that stores strings read from configuration file.
238  llvm::StringSaver Saver;
239 
240  /// Arguments originated from configuration file.
241  std::unique_ptr<llvm::opt::InputArgList> CfgOptions;
242 
243  /// Arguments originated from command line.
244  std::unique_ptr<llvm::opt::InputArgList> CLOptions;
245 
246  /// Whether to check that input files exist when constructing compilation
247  /// jobs.
248  unsigned CheckInputsExist : 1;
249 
250 public:
251  /// Force clang to emit reproducer for driver invocation. This is enabled
252  /// indirectly by setting FORCE_CLANG_DIAGNOSTICS_CRASH environment variable
253  /// or when using the -gen-reproducer driver flag.
254  unsigned GenReproducer : 1;
255 
256  // getFinalPhase - Determine which compilation mode we are in and record
257  // which option we used to determine the final phase.
258  // TODO: Much of what getFinalPhase returns are not actually true compiler
259  // modes. Fold this functionality into Types::getCompilationPhases and
260  // handleArguments.
261  phases::ID getFinalPhase(const llvm::opt::DerivedArgList &DAL,
262  llvm::opt::Arg **FinalPhaseArg = nullptr) const;
263 
264 private:
265  /// Certain options suppress the 'no input files' warning.
266  unsigned SuppressMissingInputWarning : 1;
267 
268  /// Cache of all the ToolChains in use by the driver.
269  ///
270  /// This maps from the string representation of a triple to a ToolChain
271  /// created targeting that triple. The driver owns all the ToolChain objects
272  /// stored in it, and will clean them up when torn down.
273  mutable llvm::StringMap<std::unique_ptr<ToolChain>> ToolChains;
274 
275 private:
276  /// TranslateInputArgs - Create a new derived argument list from the input
277  /// arguments, after applying the standard argument translations.
278  llvm::opt::DerivedArgList *
279  TranslateInputArgs(const llvm::opt::InputArgList &Args) const;
280 
281  // handleArguments - All code related to claiming and printing diagnostics
282  // related to arguments to the driver are done here.
283  void handleArguments(Compilation &C, llvm::opt::DerivedArgList &Args,
284  const InputList &Inputs, ActionList &Actions) const;
285 
286  // Before executing jobs, sets up response files for commands that need them.
287  void setUpResponseFiles(Compilation &C, Command &Cmd);
288 
289  void generatePrefixedToolNames(StringRef Tool, const ToolChain &TC,
290  SmallVectorImpl<std::string> &Names) const;
291 
292  /// Find the appropriate .crash diagonostic file for the child crash
293  /// under this driver and copy it out to a temporary destination with the
294  /// other reproducer related files (.sh, .cache, etc). If not found, suggest a
295  /// directory for the user to look at.
296  ///
297  /// \param ReproCrashFilename The file path to copy the .crash to.
298  /// \param CrashDiagDir The suggested directory for the user to look at
299  /// in case the search or copy fails.
300  ///
301  /// \returns If the .crash is found and successfully copied return true,
302  /// otherwise false and return the suggested directory in \p CrashDiagDir.
303  bool getCrashDiagnosticFile(StringRef ReproCrashFilename,
304  SmallString<128> &CrashDiagDir);
305 
306 public:
307 
308  /// Takes the path to a binary that's either in bin/ or lib/ and returns
309  /// the path to clang's resource directory.
310  static std::string GetResourcesPath(StringRef BinaryPath,
311  StringRef CustomResourceDir = "");
312 
313  Driver(StringRef ClangExecutable, StringRef TargetTriple,
314  DiagnosticsEngine &Diags, std::string Title = "clang LLVM compiler",
316 
317  /// @name Accessors
318  /// @{
319 
320  /// Name to use when invoking gcc/g++.
321  const std::string &getCCCGenericGCCName() const { return CCCGenericGCCName; }
322 
323  const std::string &getConfigFile() const { return ConfigFile; }
324 
325  const llvm::opt::OptTable &getOpts() const { return getDriverOptTable(); }
326 
327  DiagnosticsEngine &getDiags() const { return Diags; }
328 
329  llvm::vfs::FileSystem &getVFS() const { return *VFS; }
330 
331  bool getCheckInputsExist() const { return CheckInputsExist; }
332 
333  void setCheckInputsExist(bool Value) { CheckInputsExist = Value; }
334 
336 
337  const std::string &getTitle() { return DriverTitle; }
338  void setTitle(std::string Value) { DriverTitle = std::move(Value); }
339 
340  std::string getTargetTriple() const { return TargetTriple; }
341 
342  /// Get the path to the main clang executable.
343  const char *getClangProgramPath() const {
344  return ClangExecutable.c_str();
345  }
346 
347  /// Get the path to where the clang executable was installed.
348  const char *getInstalledDir() const {
349  if (!InstalledDir.empty())
350  return InstalledDir.c_str();
351  return Dir.c_str();
352  }
354 
355  bool isSaveTempsEnabled() const { return SaveTemps != SaveTempsNone; }
356  bool isSaveTempsObj() const { return SaveTemps == SaveTempsObj; }
357 
358  bool embedBitcodeEnabled() const { return BitcodeEmbed != EmbedNone; }
359  bool embedBitcodeInObject() const { return (BitcodeEmbed == EmbedBitcode); }
360  bool embedBitcodeMarkerOnly() const { return (BitcodeEmbed == EmbedMarker); }
361 
362  /// Compute the desired OpenMP runtime from the flags provided.
363  OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList &Args) const;
364 
365  /// @}
366  /// @name Primary Functionality
367  /// @{
368 
369  /// CreateOffloadingDeviceToolChains - create all the toolchains required to
370  /// support offloading devices given the programming models specified in the
371  /// current compilation. Also, update the host tool chain kind accordingly.
373 
374  /// BuildCompilation - Construct a compilation object for a command
375  /// line argument vector.
376  ///
377  /// \return A compilation, or 0 if none was built for the given
378  /// argument vector. A null return value does not necessarily
379  /// indicate an error condition, the diagnostics should be queried
380  /// to determine if an error occurred.
382 
383  /// ParseArgStrings - Parse the given list of strings into an
384  /// ArgList.
385  llvm::opt::InputArgList ParseArgStrings(ArrayRef<const char *> Args,
386  bool IsClCompatMode,
387  bool &ContainsError);
388 
389  /// BuildInputs - Construct the list of inputs and their types from
390  /// the given arguments.
391  ///
392  /// \param TC - The default host tool chain.
393  /// \param Args - The input arguments.
394  /// \param Inputs - The list to store the resulting compilation
395  /// inputs onto.
396  void BuildInputs(const ToolChain &TC, llvm::opt::DerivedArgList &Args,
397  InputList &Inputs) const;
398 
399  /// BuildActions - Construct the list of actions to perform for the
400  /// given arguments, which are only done for a single architecture.
401  ///
402  /// \param C - The compilation that is being built.
403  /// \param Args - The input arguments.
404  /// \param Actions - The list to store the resulting actions onto.
405  void BuildActions(Compilation &C, llvm::opt::DerivedArgList &Args,
406  const InputList &Inputs, ActionList &Actions) const;
407 
408  /// BuildUniversalActions - Construct the list of actions to perform
409  /// for the given arguments, which may require a universal build.
410  ///
411  /// \param C - The compilation that is being built.
412  /// \param TC - The default host tool chain.
413  void BuildUniversalActions(Compilation &C, const ToolChain &TC,
414  const InputList &BAInputs) const;
415 
416  /// Check that the file referenced by Value exists. If it doesn't,
417  /// issue a diagnostic and return false.
418  /// If TypoCorrect is true and the file does not exist, see if it looks
419  /// like a likely typo for a flag and if so print a "did you mean" blurb.
420  bool DiagnoseInputExistence(const llvm::opt::DerivedArgList &Args,
421  StringRef Value, types::ID Ty,
422  bool TypoCorrect) const;
423 
424  /// BuildJobs - Bind actions to concrete tools and translate
425  /// arguments to form the list of jobs to run.
426  ///
427  /// \param C - The compilation that is being built.
428  void BuildJobs(Compilation &C) const;
429 
430  /// ExecuteCompilation - Execute the compilation according to the command line
431  /// arguments and return an appropriate exit code.
432  ///
433  /// This routine handles additional processing that must be done in addition
434  /// to just running the subprocesses, for example reporting errors, setting
435  /// up response files, removing temporary files, etc.
437  SmallVectorImpl< std::pair<int, const Command *> > &FailingCommands);
438 
439  /// Contains the files in the compilation diagnostic report generated by
440  /// generateCompilationDiagnostics.
443  };
444 
445  /// generateCompilationDiagnostics - Generate diagnostics information
446  /// including preprocessed source file(s).
447  ///
449  Compilation &C, const Command &FailingCommand,
450  StringRef AdditionalInformation = "",
451  CompilationDiagnosticReport *GeneratedReport = nullptr);
452 
453  /// @}
454  /// @name Helper Methods
455  /// @{
456 
457  /// PrintActions - Print the list of actions.
458  void PrintActions(const Compilation &C) const;
459 
460  /// PrintHelp - Print the help text.
461  ///
462  /// \param ShowHidden - Show hidden options.
463  void PrintHelp(bool ShowHidden) const;
464 
465  /// PrintVersion - Print the driver version.
466  void PrintVersion(const Compilation &C, raw_ostream &OS) const;
467 
468  /// GetFilePath - Lookup \p Name in the list of file search paths.
469  ///
470  /// \param TC - The tool chain for additional information on
471  /// directories to search.
472  //
473  // FIXME: This should be in CompilationInfo.
474  std::string GetFilePath(StringRef Name, const ToolChain &TC) const;
475 
476  /// GetProgramPath - Lookup \p Name in the list of program search paths.
477  ///
478  /// \param TC - The provided tool chain for additional information on
479  /// directories to search.
480  //
481  // FIXME: This should be in CompilationInfo.
482  std::string GetProgramPath(StringRef Name, const ToolChain &TC) const;
483 
484  /// HandleAutocompletions - Handle --autocomplete by searching and printing
485  /// possible flags, descriptions, and its arguments.
486  void HandleAutocompletions(StringRef PassedFlags) const;
487 
488  /// HandleImmediateArgs - Handle any arguments which should be
489  /// treated before building actions or binding tools.
490  ///
491  /// \return Whether any compilation should be built for this
492  /// invocation.
493  bool HandleImmediateArgs(const Compilation &C);
494 
495  /// ConstructAction - Construct the appropriate action to do for
496  /// \p Phase on the \p Input, taking in to account arguments
497  /// like -fsyntax-only or --analyze.
499  Compilation &C, const llvm::opt::ArgList &Args, phases::ID Phase,
500  Action *Input,
501  Action::OffloadKind TargetDeviceOffloadKind = Action::OFK_None) const;
502 
503  /// BuildJobsForAction - Construct the jobs to perform for the action \p A and
504  /// return an InputInfo for the result of running \p A. Will only construct
505  /// jobs for a given (Action, ToolChain, BoundArch, DeviceKind) tuple once.
506  InputInfo
507  BuildJobsForAction(Compilation &C, const Action *A, const ToolChain *TC,
508  StringRef BoundArch, bool AtTopLevel, bool MultipleArchs,
509  const char *LinkingOutput,
510  std::map<std::pair<const Action *, std::string>, InputInfo>
511  &CachedResults,
512  Action::OffloadKind TargetDeviceOffloadKind) const;
513 
514  /// Returns the default name for linked images (e.g., "a.out").
515  const char *getDefaultImageName() const;
516 
517  /// GetNamedOutputPath - Return the name to use for the output of
518  /// the action \p JA. The result is appended to the compilation's
519  /// list of temporary or result files, as appropriate.
520  ///
521  /// \param C - The compilation.
522  /// \param JA - The action of interest.
523  /// \param BaseInput - The original input file that this action was
524  /// triggered by.
525  /// \param BoundArch - The bound architecture.
526  /// \param AtTopLevel - Whether this is a "top-level" action.
527  /// \param MultipleArchs - Whether multiple -arch options were supplied.
528  /// \param NormalizedTriple - The normalized triple of the relevant target.
529  const char *GetNamedOutputPath(Compilation &C, const JobAction &JA,
530  const char *BaseInput, StringRef BoundArch,
531  bool AtTopLevel, bool MultipleArchs,
532  StringRef NormalizedTriple) const;
533 
534  /// GetTemporaryPath - Return the pathname of a temporary file to use
535  /// as part of compilation; the file will have the given prefix and suffix.
536  ///
537  /// GCC goes to extra lengths here to be a bit more robust.
538  std::string GetTemporaryPath(StringRef Prefix, StringRef Suffix) const;
539 
540  /// GetTemporaryDirectory - Return the pathname of a temporary directory to
541  /// use as part of compilation; the directory will have the given prefix.
542  std::string GetTemporaryDirectory(StringRef Prefix) const;
543 
544  /// Return the pathname of the pch file in clang-cl mode.
545  std::string GetClPchPath(Compilation &C, StringRef BaseName) const;
546 
547  /// ShouldUseClangCompiler - Should the clang compiler be used to
548  /// handle this action.
549  bool ShouldUseClangCompiler(const JobAction &JA) const;
550 
551  /// ShouldUseFlangCompiler - Should the flang compiler be used to
552  /// handle this action.
553  bool ShouldUseFlangCompiler(const JobAction &JA) const;
554 
555  /// ShouldEmitStaticLibrary - Should the linker emit a static library.
556  bool ShouldEmitStaticLibrary(const llvm::opt::ArgList &Args) const;
557 
558  /// Returns true if we are performing any kind of LTO.
559  bool isUsingLTO(bool IsOffload = false) const {
560  return getLTOMode(IsOffload) != LTOK_None;
561  }
562 
563  /// Get the specific kind of LTO being performed.
564  LTOKind getLTOMode(bool IsOffload = false) const {
565  return IsOffload ? OffloadLTOMode : LTOMode;
566  }
567 
568 private:
569 
570  /// Tries to load options from configuration file.
571  ///
572  /// \returns true if error occurred.
573  bool loadConfigFile();
574 
575  /// Read options from the specified file.
576  ///
577  /// \param [in] FileName File to read.
578  /// \returns true, if error occurred while reading.
579  bool readConfigFile(StringRef FileName);
580 
581  /// Set the driver mode (cl, gcc, etc) from the value of the `--driver-mode`
582  /// option.
583  void setDriverMode(StringRef DriverModeValue);
584 
585  /// Parse the \p Args list for LTO options and record the type of LTO
586  /// compilation based on which -f(no-)?lto(=.*)? option occurs last.
587  void setLTOMode(const llvm::opt::ArgList &Args);
588 
589  /// Retrieves a ToolChain for a particular \p Target triple.
590  ///
591  /// Will cache ToolChains for the life of the driver object, and create them
592  /// on-demand.
593  const ToolChain &getToolChain(const llvm::opt::ArgList &Args,
594  const llvm::Triple &Target) const;
595 
596  /// @}
597 
598  /// Get bitmasks for which option flags to include and exclude based on
599  /// the driver mode.
600  std::pair<unsigned, unsigned> getIncludeExcludeOptionFlagMasks(bool IsClCompatMode) const;
601 
602  /// Helper used in BuildJobsForAction. Doesn't use the cache when building
603  /// jobs specifically for the given action, but will use the cache when
604  /// building jobs for the Action's inputs.
605  InputInfo BuildJobsForActionNoCache(
606  Compilation &C, const Action *A, const ToolChain *TC, StringRef BoundArch,
607  bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
608  std::map<std::pair<const Action *, std::string>, InputInfo>
609  &CachedResults,
610  Action::OffloadKind TargetDeviceOffloadKind) const;
611 
612 public:
613  /// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and
614  /// return the grouped values as integers. Numbers which are not
615  /// provided are set to 0.
616  ///
617  /// \return True if the entire string was parsed (9.2), or all
618  /// groups were parsed (10.3.5extrastuff). HadExtra is true if all
619  /// groups were parsed but extra characters remain at the end.
620  static bool GetReleaseVersion(StringRef Str, unsigned &Major, unsigned &Minor,
621  unsigned &Micro, bool &HadExtra);
622 
623  /// Parse digits from a string \p Str and fulfill \p Digits with
624  /// the parsed numbers. This method assumes that the max number of
625  /// digits to look for is equal to Digits.size().
626  ///
627  /// \return True if the entire string was parsed and there are
628  /// no extra characters remaining at the end.
629  static bool GetReleaseVersion(StringRef Str,
631  /// Compute the default -fmodule-cache-path.
632  /// \return True if the system provides a default cache directory.
634 };
635 
636 /// \return True if the last defined optimization level is -Ofast.
637 /// And False otherwise.
638 bool isOptimizationLevelFast(const llvm::opt::ArgList &Args);
639 
640 /// \return True if the argument combination will end up generating remarks.
641 bool willEmitRemarks(const llvm::opt::ArgList &Args);
642 
643 /// Returns the driver mode option's value, i.e. `X` in `--driver-mode=X`. If \p
644 /// Args doesn't mention one explicitly, tries to deduce from `ProgName`.
645 /// Returns empty on failure.
646 /// Common values are "gcc", "g++", "cpp", "cl" and "flang". Returned value need
647 /// not be one of these.
648 llvm::StringRef getDriverMode(StringRef ProgName, ArrayRef<const char *> Args);
649 
650 /// Checks whether the value produced by getDriverMode is for CL mode.
651 bool IsClangCL(StringRef DriverMode);
652 
653 } // end namespace driver
654 } // end namespace clang
655 
656 #endif
clang::driver::Driver::embedBitcodeEnabled
bool embedBitcodeEnabled() const
Definition: Driver.h:358
Util.h
clang::driver::Driver::InputList
SmallVector< std::pair< types::ID, const llvm::opt::Arg * >, 16 > InputList
A list of inputs and their types for the given arguments.
Definition: Driver.h:176
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:5179
clang::driver::Driver::HostRelease
std::string HostRelease
Definition: Driver.h:160
llvm
Definition: Dominators.h:30
clang::driver::isOptimizationLevelFast
bool isOptimizationLevelFast(const llvm::opt::ArgList &Args)
clang::driver::Driver::PrefixDirs
prefix_list PrefixDirs
Definition: Driver.h:148
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:4888
clang::DiagnosticBuilder
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:1264
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:331
clang::driver::Driver::CompilationDiagnosticReport
Contains the files in the compilation diagnostic report generated by generateCompilationDiagnostics.
Definition: Driver.h:441
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:123
clang::driver::LTOK_None
@ LTOK_None
Definition: Driver.h:51
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:2135
clang::driver::Driver::PrintVersion
void PrintVersion(const Compilation &C, raw_ostream &OS) const
PrintVersion - Print the driver version.
Definition: Driver.cpp:1624
clang::driver::Driver::IsCLMode
bool IsCLMode() const
Whether the driver should follow cl.exe like behavior.
Definition: Driver.h:188
llvm::SmallVector< std::string, 4 >
clang::driver::Action
Action - Represent an abstract compilation step to perform.
Definition: Action.h:47
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:1331
clang::DiagnosticsEngine
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:191
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:359
int
__device__ int
Definition: __clang_hip_libdevice_declares.h:63
clang::driver::Driver::CCPrintOptionsFilename
std::string CCPrintOptionsFilename
The file to log CC_PRINT_OPTIONS output to, if enabled.
Definition: Driver.h:166
clang::driver::Driver::OpenMPRuntimeKind
OpenMPRuntimeKind
Definition: Driver.h:91
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:3680
clang::driver::Driver::getConfigFile
const std::string & getConfigFile() const
Definition: Driver.h:323
clang::driver::Driver::getDefaultModuleCachePath
static bool getDefaultModuleCachePath(SmallVectorImpl< char > &Result)
Compute the default -fmodule-cache-path.
Definition: Clang.cpp:3417
clang::driver::Driver::getOpenMPRuntime
OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList &Args) const
Compute the desired OpenMP runtime from the flags provided.
Definition: Driver.cpp:622
clang::driver::Driver::getOpts
const llvm::opt::OptTable & getOpts() const
Definition: Driver.h:325
clang::driver::InputInfo
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
clang::driver::Driver::getDiags
DiagnosticsEngine & getDiags() const
Definition: Driver.h:327
clang::driver::Driver::PrintActions
void PrintActions(const Compilation &C) const
PrintActions - Print the list of actions.
Definition: Driver.cpp:2027
clang::driver::Driver::InstalledDir
std::string InstalledDir
The path to the installed clang directory, if any.
Definition: Driver.h:132
Action.h
clang::driver::Driver::DriverTitle
std::string DriverTitle
Driver title to use with help.
Definition: Driver.h:157
llvm::MutableArrayRef
Definition: LLVM.h:35
clang::driver::Driver::isSaveTempsEnabled
bool isSaveTempsEnabled() const
Definition: Driver.h:355
clang::driver::Driver::getLTOMode
LTOKind getLTOMode(bool IsOffload=false) const
Get the specific kind of LTO being performed.
Definition: Driver.h:564
clang::driver::Driver::Diag
DiagnosticBuilder Diag(unsigned DiagID) const
Definition: Driver.h:112
clang::driver::Driver::CCCPrintBindings
unsigned CCCPrintBindings
Only print tool bindings, don't build any jobs.
Definition: Driver.h:195
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:185
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:3921
clang::driver::Driver::CCCIsCPP
bool CCCIsCPP() const
Whether the driver is just the preprocessor.
Definition: Driver.h:182
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:199
clang::driver::LTOK_Thin
@ LTOK_Thin
Definition: Driver.h:53
clang::driver::Driver::Name
std::string Name
The name the driver was invoked as.
Definition: Driver.h:119
Diagnostic.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:187
clang::driver::Driver::HostBits
std::string HostBits
Information about the host which can be overridden by the user.
Definition: Driver.h:160
clang::driver::Driver::SystemConfigDir
std::string SystemConfigDir
System directory for config files.
Definition: Driver.h:138
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:203
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:133
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:108
llvm::SmallString< 128 >
clang::driver::Driver::SysRoot
std::string SysRoot
sysroot, if present
Definition: Driver.h:151
clang::driver::Driver::ShouldEmitStaticLibrary
bool ShouldEmitStaticLibrary(const llvm::opt::ArgList &Args) const
ShouldEmitStaticLibrary - Should the linker emit a static library.
Definition: Driver.cpp:5473
clang::driver::Driver::CCCIsCXX
bool CCCIsCXX() const
Whether the driver should follow g++ like behavior.
Definition: Driver.h:179
clang::driver::Driver::OMPRT_OMP
@ OMPRT_OMP
The LLVM OpenMP runtime.
Definition: Driver.h:98
clang::driver::Driver::getCCCGenericGCCName
const std::string & getCCCGenericGCCName() const
Name to use when invoking gcc/g++.
Definition: Driver.h:321
clang::driver::Driver::getTitle
const std::string & getTitle()
Definition: Driver.h:337
clang::driver::Action::OFK_None
@ OFK_None
Definition: Action.h:86
clang::driver::LTOK_Full
@ LTOK_Full
Definition: Driver.h:52
Phases.h
clang::driver::Driver::CCLogDiagnostics
unsigned CCLogDiagnostics
Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics to CCLogDiagnosticsFilename...
Definition: Driver.h:208
clang::driver::Driver::CC1ToolFunc
int(* CC1ToolFunc)(SmallVectorImpl< const char * > &ArgV)
Pointer to the ExecuteCC1Tool function, if available.
Definition: Driver.h:221
Cmd
CompileCommand Cmd
Definition: InterpolatingCompilationDatabase.cpp:130
clang::driver::Driver::ResourceDir
std::string ResourceDir
The path to the compiler resource directory.
Definition: Driver.h:135
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:1532
clang::driver::Driver::getClangProgramPath
const char * getClangProgramPath() const
Get the path to the main clang executable.
Definition: Driver.h:343
clang::driver::Driver::CC1Main
CC1ToolFunc CC1Main
Definition: Driver.h:222
clang::driver::Driver::getFinalPhase
phases::ID getFinalPhase(const llvm::opt::DerivedArgList &DAL, llvm::opt::Arg **FinalPhaseArg=nullptr) const
Definition: Driver.cpp:271
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:647
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:360
clang::driver::LTOKind
LTOKind
Describes the kind of LTO mode selected via -f(no-)?lto(=.*)? options.
Definition: Driver.h:50
clang::driver::Driver::CCPrintStatReportFilename
std::string CCPrintStatReportFilename
The file to log CC_PRINT_PROC_STAT_FILE output to, if enabled.
Definition: Driver.h:163
clang::driver::Driver::isUsingLTO
bool isUsingLTO(bool IsOffload=false) const
Returns true if we are performing any kind of LTO.
Definition: Driver.h:559
clang::driver::Driver::BuildJobsForAction
InputInfo 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 >, InputInfo > &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:4525
clang::driver::Driver::ClangNameParts
ParsedClangName ClangNameParts
Target and driver mode components extracted from clang executable name.
Definition: Driver.h:129
clang::driver::Driver::ShouldUseFlangCompiler
bool ShouldUseFlangCompiler(const JobAction &JA) const
ShouldUseFlangCompiler - Should the flang compiler be used to handle this action.
Definition: Driver.cpp:5460
clang::driver::Driver::isSaveTempsObj
bool isSaveTempsObj() const
Definition: Driver.h:356
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:5243
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:5221
clang::driver::ToolChain
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:91
llvm::ArrayRef< const char * >
clang::driver::Driver::getDefaultImageName
const char * getDefaultImageName() const
Returns the default name for linked images (e.g., "a.out").
Definition: Driver.cpp:4839
Value
Value
Definition: UninitializedValues.cpp:102
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:147
clang::driver::Driver::UserConfigDir
std::string UserConfigDir
User directory for config files.
Definition: Driver.h:141
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:107
clang::driver::Driver::setTargetAndMode
void setTargetAndMode(const ParsedClangName &TM)
Definition: Driver.h:335
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:4026
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:54
clang::driver::Driver::CCLogDiagnosticsFilename
std::string CCLogDiagnosticsFilename
The file to log CC_LOG_DIAGNOSTICS output to, if enabled.
Definition: Driver.h:172
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:5119
clang::driver::willEmitRemarks
bool willEmitRemarks(const llvm::opt::ArgList &Args)
clang::driver::Driver::CompilationDiagnosticReport::TemporaryFiles
llvm::SmallVector< std::string, 4 > TemporaryFiles
Definition: Driver.h:442
clang::driver::Driver::setInstalledDir
void setInstalledDir(StringRef Value)
Definition: Driver.h:353
clang
Definition: CalledOnceCheck.h:17
clang::driver::Driver
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:59
clang::driver::Driver::getTargetTriple
std::string getTargetTriple() const
Definition: Driver.h:340
clang::driver::Driver::ShouldUseClangCompiler
bool ShouldUseClangCompiler(const JobAction &JA) const
ShouldUseClangCompiler - Should the clang compiler be used to handle this action.
Definition: Driver.cpp:5446
clang::driver::Driver::CCPrintHeadersFilename
std::string CCPrintHeadersFilename
The file to log CC_PRINT_HEADERS output to, if enabled.
Definition: Driver.h:169
clang::driver::Driver::OMPRT_Unknown
@ OMPRT_Unknown
An unknown OpenMP runtime.
Definition: Driver.h:94
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:5232
clang::driver::IsClangCL
bool IsClangCL(StringRef DriverMode)
Checks whether the value produced by getDriverMode is for CL mode.
Definition: Driver.cpp:5604
clang::driver::Driver::GenReproducer
unsigned GenReproducer
Force clang to emit reproducer for driver invocation.
Definition: Driver.h:254
clang::driver::Driver::HostSystem
std::string HostSystem
Definition: Driver.h:160
clang::driver::Driver::getVFS
llvm::vfs::FileSystem & getVFS() const
Definition: Driver.h:329
Types.h
clang::driver::Driver::setTitle
void setTitle(std::string Value)
Definition: Driver.h:338
clang::driver::Action::OffloadKind
OffloadKind
Definition: Action.h:85
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:1747
clang::driver::getDriverMode
llvm::StringRef getDriverMode(StringRef ProgName, ArrayRef< const char * > Args)
Returns the driver mode option's value, i.e.
Definition: Driver.cpp:5589
llvm::SmallVectorImpl
Definition: LLVM.h:39
clang::driver::Driver::PrintHelp
void PrintHelp(bool ShowHidden) const
PrintHelp - Print the help text.
Definition: Driver.cpp:1603
clang::driver::Driver::OMPRT_GOMP
@ OMPRT_GOMP
The GNU OpenMP runtime.
Definition: Driver.h:103
clang::driver::JobAction
Definition: Action.h:380
clang::driver::Driver::DyldPrefix
std::string DyldPrefix
Dynamic loader prefix, if present.
Definition: Driver.h:154
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:2208
clang::driver::Driver::GetReleaseVersion
static bool GetReleaseVersion(StringRef Str, unsigned &Major, unsigned &Minor, unsigned &Micro, bool &HadExtra)
GetReleaseVersion - Parse (([0-9]+)(.
Definition: Driver.cpp:5485
clang::driver::Driver::ClangExecutable
std::string ClangExecutable
The original path to the clang executable.
Definition: Driver.h:126
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:215
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:1661
clang::driver::Driver::getInstalledDir
const char * getInstalledDir() const
Get the path to where the clang executable was installed.
Definition: Driver.h:348
clang::driver::Driver::IsFlangMode
bool IsFlangMode() const
Whether the driver should invoke flang for fortran inputs.
Definition: Driver.h:192
clang::driver::Driver::setCheckInputsExist
void setCheckInputsExist(bool Value)
Definition: Driver.h:333
clang::driver::Driver::HostMachine
std::string HostMachine
Definition: Driver.h:160
clang::DiagnosticsEngine::Report
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1523
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:2047
clang::driver::Driver::BuildCompilation
Compilation * BuildCompilation(ArrayRef< const char * > Args)
BuildCompilation - Construct a compilation object for a command line argument vector.
Definition: Driver.cpp:998
clang::driver::Driver::CCGenDiagnostics
unsigned CCGenDiagnostics
Whether the driver is generating diagnostics for debugging purposes.
Definition: Driver.h:211