clang 23.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
14#include "clang/Basic/LLVM.h"
15#include "clang/Driver/Action.h"
18#include "clang/Driver/Phases.h"
20#include "clang/Driver/Types.h"
21#include "clang/Driver/Util.h"
23#include "llvm/ADT/ArrayRef.h"
24#include "llvm/ADT/STLFunctionalExtras.h"
25#include "llvm/ADT/StringMap.h"
26#include "llvm/ADT/StringRef.h"
27#include "llvm/Option/Arg.h"
28#include "llvm/Option/ArgList.h"
29#include "llvm/Support/StringSaver.h"
30
31#include <map>
32#include <set>
33#include <string>
34#include <vector>
35
36namespace llvm {
37class Triple;
38namespace vfs {
39class FileSystem;
40}
41namespace cl {
42class ExpansionContext;
43}
44} // namespace llvm
45
46namespace clang {
47
48namespace driver {
49
51
52class Command;
53class Compilation;
54class JobAction;
55class ToolChain;
56
57/// Describes the kind of LTO mode selected via -f(no-)?lto(=.*)? options.
64
65/// Whether headers used to construct C++20 module units should be looked
66/// up by the path supplied on the command line, or in the user or system
67/// search paths.
74
75/// Options for specifying CUID used by CUDA/HIP for uniquely identifying
76/// compilation units.
78public:
79 enum class Kind { Hash, Random, Fixed, None, Invalid };
80
81 CUIDOptions() = default;
82 CUIDOptions(llvm::opt::DerivedArgList &Args, const Driver &D);
83
84 // Get the CUID for an input string
85 std::string getCUID(StringRef InputFile,
86 llvm::opt::DerivedArgList &Args) const;
87
88 bool isEnabled() const {
89 return UseCUID != Kind::None && UseCUID != Kind::Invalid;
90 }
91
92private:
93 Kind UseCUID = Kind::None;
94 StringRef FixedCUID;
95};
96
97/// Driver - Encapsulate logic for constructing compilation processes
98/// from a set of gcc-driver-like command line arguments.
99class Driver {
100 DiagnosticsEngine &Diags;
101
103
104 enum DriverMode {
105 GCCMode,
106 GXXMode,
107 CPPMode,
108 CLMode,
109 FlangMode,
110 DXCMode
111 } Mode;
112
113 enum SaveTempsMode {
114 SaveTempsNone,
115 SaveTempsCwd,
116 SaveTempsObj
117 } SaveTemps;
118
119 enum BitcodeEmbedMode {
120 EmbedNone,
121 EmbedMarker,
122 EmbedBitcode
123 } BitcodeEmbed;
124
125 enum OffloadMode {
126 OffloadHostDevice,
127 OffloadHost,
128 OffloadDevice,
129 } Offload;
130
131 /// Header unit mode set by -fmodule-header={user,system}.
132 ModuleHeaderMode CXX20HeaderType;
133
134 /// Set if we should process inputs and jobs with C++20 module
135 /// interpretation.
136 bool ModulesModeCXX20;
137
138 /// LTO mode selected via -f(no-)?lto(=.*)? options.
139 LTOKind LTOMode;
140
141 /// LTO mode selected via -f(no-offload-)?lto(=.*)? options.
142 LTOKind OffloadLTOMode;
143
144 /// Options for CUID
145 CUIDOptions CUIDOpts;
146
147public:
149 /// An unknown OpenMP runtime. We can't generate effective OpenMP code
150 /// without knowing what runtime to target.
152
153 /// The LLVM OpenMP runtime. When completed and integrated, this will become
154 /// the default for Clang.
156
157 /// The GNU OpenMP runtime. Clang doesn't support generating OpenMP code for
158 /// this runtime but can swallow the pragmas, and find and link against the
159 /// runtime library itself.
161
162 /// The legacy name for the LLVM OpenMP runtime from when it was the Intel
163 /// OpenMP runtime. We support this mode for users with existing
164 /// dependencies on this runtime library name.
166 };
167
168 // Diag - Forwarding function for diagnostics.
169 DiagnosticBuilder Diag(unsigned DiagID) const {
170 return Diags.Report(DiagID);
171 }
172
173 // FIXME: Privatize once interface is stable.
174public:
175 /// The name the driver was invoked as.
176 std::string Name;
177
178 /// The path the driver executable was in, as invoked from the
179 /// command line.
180 std::string Dir;
181
182 /// The original path to the clang executable.
183 std::string ClangExecutable;
184
185 /// Target and driver mode components extracted from clang executable name.
187
188 /// The path to the compiler resource directory.
189 std::string ResourceDir;
190
191 /// System directory for config files.
192 std::string SystemConfigDir;
193
194 /// User directory for config files.
195 std::string UserConfigDir;
196
197 /// A prefix directory used to emulate a limited subset of GCC's '-Bprefix'
198 /// functionality.
199 /// FIXME: This type of customization should be removed in favor of the
200 /// universal driver when it is ready.
203
204 /// sysroot, if present
205 std::string SysRoot;
206
207 /// Dynamic loader prefix, if present
208 std::string DyldPrefix;
209
210 /// Driver title to use with help.
211 std::string DriverTitle;
212
213 /// Information about the host which can be overridden by the user.
215
216 /// The file to log CC_PRINT_PROC_STAT_FILE output to, if enabled.
218
219 /// The file to log CC_PRINT_INTERNAL_STAT_FILE output to, if enabled.
221
222 /// The file to log CC_PRINT_OPTIONS output to, if enabled.
224
225 /// The file to log CC_PRINT_HEADERS output to, if enabled.
227
228 /// The file to log CC_LOG_DIAGNOSTICS output to, if enabled.
230
231 /// Whether the driver should follow g++ like behavior.
232 bool CCCIsCXX() const { return Mode == GXXMode; }
233
234 /// Whether the driver is just the preprocessor.
235 bool CCCIsCPP() const { return Mode == CPPMode; }
236
237 /// Whether the driver should follow gcc like behavior.
238 bool CCCIsCC() const { return Mode == GCCMode; }
239
240 /// Whether the driver should follow cl.exe like behavior.
241 bool IsCLMode() const { return Mode == CLMode; }
242
243 /// Whether the driver should invoke flang for fortran inputs.
244 /// Other modes fall back to calling gcc which in turn calls gfortran.
245 bool IsFlangMode() const { return Mode == FlangMode; }
246
247 /// Whether the driver should follow dxc.exe like behavior.
248 bool IsDXCMode() const { return Mode == DXCMode; }
249
250 /// Only print tool bindings, don't build any jobs.
251 LLVM_PREFERRED_TYPE(bool)
253
254 /// Set CC_PRINT_OPTIONS mode, which is like -v but logs the commands to
255 /// CCPrintOptionsFilename or to stderr.
256 LLVM_PREFERRED_TYPE(bool)
257 unsigned CCPrintOptions : 1;
258
259 /// The format of the header information that is emitted. If CC_PRINT_HEADERS
260 /// is set, the format is textual. Otherwise, the format is determined by the
261 /// enviroment variable CC_PRINT_HEADERS_FORMAT.
263
264 /// This flag determines whether clang should filter the header information
265 /// that is emitted. If enviroment variable CC_PRINT_HEADERS_FILTERING is set
266 /// to "only-direct-system", only system headers that are directly included
267 /// from non-system headers are emitted.
269
270 /// Name of the library that provides implementations of
271 /// IEEE-754 128-bit float math functions used by Fortran F128
272 /// runtime library. It should be linked as needed by the linker job.
274
275 /// Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics
276 /// to CCLogDiagnosticsFilename or to stderr, in a stable machine readable
277 /// format.
278 LLVM_PREFERRED_TYPE(bool)
279 unsigned CCLogDiagnostics : 1;
280
281 /// Whether the driver is generating diagnostics for debugging purposes.
282 LLVM_PREFERRED_TYPE(bool)
283 unsigned CCGenDiagnostics : 1;
284
285 /// Set CC_PRINT_PROC_STAT mode, which causes the driver to dump
286 /// performance report to CC_PRINT_PROC_STAT_FILE or to stdout.
287 LLVM_PREFERRED_TYPE(bool)
289
290 /// Set CC_PRINT_INTERNAL_STAT mode, which causes the driver to dump internal
291 /// performance report to CC_PRINT_INTERNAL_STAT_FILE or to stdout.
292 LLVM_PREFERRED_TYPE(bool)
294
295 /// Pointer to the ExecuteCC1Tool function, if available.
296 /// When the clangDriver lib is used through clang.exe, this provides a
297 /// shortcut for executing the -cc1 command-line directly, in the same
298 /// process.
300 llvm::function_ref<int(SmallVectorImpl<const char *> &ArgV)>;
302
303private:
304 /// Raw target triple.
305 std::string TargetTriple;
306
307 /// Name to use when invoking gcc/g++.
308 std::string CCCGenericGCCName;
309
310 /// Paths to configuration files used.
311 std::vector<std::string> ConfigFiles;
312
313 /// Allocator for string saver.
314 llvm::BumpPtrAllocator Alloc;
315
316 /// Object that stores strings read from configuration file.
317 llvm::StringSaver Saver;
318
319 /// Arguments originated from configuration file (head part).
320 std::unique_ptr<llvm::opt::InputArgList> CfgOptionsHead;
321
322 /// Arguments originated from configuration file (tail part).
323 std::unique_ptr<llvm::opt::InputArgList> CfgOptionsTail;
324
325 /// Arguments originated from command line.
326 std::unique_ptr<llvm::opt::InputArgList> CLOptions;
327
328 /// If this is non-null, the driver will prepend this argument before
329 /// reinvoking clang. This is useful for the llvm-driver where clang's
330 /// realpath will be to the llvm binary and not clang, so it must pass
331 /// "clang" as it's first argument.
332 const char *PrependArg;
333
334 /// The default value of -fuse-ld= option. An empty string means the default
335 /// system linker.
336 std::string PreferredLinker;
337
338 /// Whether to check that input files exist when constructing compilation
339 /// jobs.
340 LLVM_PREFERRED_TYPE(bool)
341 unsigned CheckInputsExist : 1;
342 /// Whether to probe for PCH files on disk, in order to upgrade
343 /// -include foo.h to -include-pch foo.h.pch.
344 LLVM_PREFERRED_TYPE(bool)
345 unsigned ProbePrecompiled : 1;
346
347public:
348 // getFinalPhase - Determine which compilation mode we are in and record
349 // which option we used to determine the final phase.
350 // TODO: Much of what getFinalPhase returns are not actually true compiler
351 // modes. Fold this functionality into Types::getCompilationPhases and
352 // handleArguments.
353 phases::ID getFinalPhase(const llvm::opt::DerivedArgList &DAL,
354 llvm::opt::Arg **FinalPhaseArg = nullptr) const;
355
356 llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
357 executeProgram(llvm::ArrayRef<llvm::StringRef> Args) const;
358
359private:
360 /// Certain options suppress the 'no input files' warning.
361 LLVM_PREFERRED_TYPE(bool)
362 unsigned SuppressMissingInputWarning : 1;
363
364 /// Cache of all the ToolChains in use by the driver.
365 ///
366 /// This maps from the string representation of a triple to a ToolChain
367 /// created targeting that triple. The driver owns all the ToolChain objects
368 /// stored in it, and will clean them up when torn down.
369 mutable llvm::StringMap<std::unique_ptr<ToolChain>> ToolChains;
370
371private:
372 /// TranslateInputArgs - Create a new derived argument list from the input
373 /// arguments, after applying the standard argument translations.
374 llvm::opt::DerivedArgList *
375 TranslateInputArgs(const llvm::opt::InputArgList &Args) const;
376
377 // handleArguments - All code related to claiming and printing diagnostics
378 // related to arguments to the driver are done here.
379 void handleArguments(Compilation &C, llvm::opt::DerivedArgList &Args,
380 const InputList &Inputs, ActionList &Actions) const;
381
382 // Before executing jobs, sets up response files for commands that need them.
383 void setUpResponseFiles(Compilation &C, Command &Cmd);
384
385 void generatePrefixedToolNames(StringRef Tool, const ToolChain &TC,
386 SmallVectorImpl<std::string> &Names) const;
387
388 /// Find the appropriate .crash diagonostic file for the child crash
389 /// under this driver and copy it out to a temporary destination with the
390 /// other reproducer related files (.sh, .cache, etc). If not found, suggest a
391 /// directory for the user to look at.
392 ///
393 /// \param ReproCrashFilename The file path to copy the .crash to.
394 /// \param CrashDiagDir The suggested directory for the user to look at
395 /// in case the search or copy fails.
396 ///
397 /// \returns If the .crash is found and successfully copied return true,
398 /// otherwise false and return the suggested directory in \p CrashDiagDir.
399 bool getCrashDiagnosticFile(StringRef ReproCrashFilename,
400 SmallString<128> &CrashDiagDir);
401
402public:
403 Driver(StringRef ClangExecutable, StringRef TargetTriple,
404 DiagnosticsEngine &Diags, std::string Title = "clang LLVM compiler",
405 IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);
406
407 /// @name Accessors
408 /// @{
409
410 /// Name to use when invoking gcc/g++.
411 const std::string &getCCCGenericGCCName() const { return CCCGenericGCCName; }
412
414 return ConfigFiles;
415 }
416
417 const llvm::opt::OptTable &getOpts() const { return getDriverOptTable(); }
418
419 DiagnosticsEngine &getDiags() const { return Diags; }
420
421 llvm::vfs::FileSystem &getVFS() const { return *VFS; }
422
423 bool getCheckInputsExist() const { return CheckInputsExist; }
424
425 void setCheckInputsExist(bool Value) { CheckInputsExist = Value; }
426
427 bool getProbePrecompiled() const { return ProbePrecompiled; }
428 void setProbePrecompiled(bool Value) { ProbePrecompiled = Value; }
429
430 const char *getPrependArg() const { return PrependArg; }
431 void setPrependArg(const char *Value) { PrependArg = Value; }
432
434
435 const std::string &getTitle() { return DriverTitle; }
436 void setTitle(std::string Value) { DriverTitle = std::move(Value); }
437
438 std::string getTargetTriple() const { return TargetTriple; }
439
440 /// Get the path to the main clang executable.
441 const char *getClangProgramPath() const {
442 return ClangExecutable.c_str();
443 }
444
445 StringRef getPreferredLinker() const { return PreferredLinker; }
446 void setPreferredLinker(std::string Value) {
447 PreferredLinker = std::move(Value);
448 }
449
450 bool isSaveTempsEnabled() const { return SaveTemps != SaveTempsNone; }
451 bool isSaveTempsObj() const { return SaveTemps == SaveTempsObj; }
452
453 bool embedBitcodeEnabled() const { return BitcodeEmbed != EmbedNone; }
454 bool embedBitcodeInObject() const { return (BitcodeEmbed == EmbedBitcode); }
455 bool embedBitcodeMarkerOnly() const { return (BitcodeEmbed == EmbedMarker); }
456
457 bool offloadHostOnly() const { return Offload == OffloadHost; }
458 bool offloadDeviceOnly() const { return Offload == OffloadDevice; }
459
460 void setFlangF128MathLibrary(std::string name) {
461 FlangF128MathLibrary = std::move(name);
462 }
463 StringRef getFlangF128MathLibrary() const { return FlangF128MathLibrary; }
464
465 /// Compute the desired OpenMP runtime from the flags provided.
466 OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList &Args) const;
467
468 /// @}
469 /// @name Primary Functionality
470 /// @{
471
472 /// CreateOffloadingDeviceToolChains - create all the toolchains required to
473 /// support offloading devices given the programming models specified in the
474 /// current compilation. Also, update the host tool chain kind accordingly.
476
477 /// BuildCompilation - Construct a compilation object for a command
478 /// line argument vector.
479 ///
480 /// \return A compilation, or 0 if none was built for the given
481 /// argument vector. A null return value does not necessarily
482 /// indicate an error condition, the diagnostics should be queried
483 /// to determine if an error occurred.
485
486 /// ParseArgStrings - Parse the given list of strings into an
487 /// ArgList.
488 llvm::opt::InputArgList ParseArgStrings(ArrayRef<const char *> Args,
489 bool UseDriverMode,
490 bool &ContainsError) const;
491
492 /// BuildInputs - Construct the list of inputs and their types from
493 /// the given arguments.
494 ///
495 /// \param TC - The default host tool chain.
496 /// \param Args - The input arguments.
497 /// \param Inputs - The list to store the resulting compilation
498 /// inputs onto.
499 void BuildInputs(const ToolChain &TC, llvm::opt::DerivedArgList &Args,
500 InputList &Inputs) const;
501
502 /// BuildActions - Construct the list of actions to perform for the
503 /// given arguments, which are only done for a single architecture.
504 ///
505 /// \param C - The compilation that is being built.
506 /// \param Args - The input arguments.
507 /// \param Actions - The list to store the resulting actions onto.
508 void BuildActions(Compilation &C, llvm::opt::DerivedArgList &Args,
509 const InputList &Inputs, ActionList &Actions) const;
510
511 /// BuildUniversalActions - Construct the list of actions to perform
512 /// for the given arguments, which may require a universal build.
513 ///
514 /// \param C - The compilation that is being built.
515 /// \param TC - The default host tool chain.
517 const InputList &BAInputs) const;
518
519 /// BuildOffloadingActions - Construct the list of actions to perform for the
520 /// offloading toolchain that will be embedded in the host.
521 ///
522 /// \param C - The compilation that is being built.
523 /// \param Args - The input arguments.
524 /// \param Input - The input type and arguments
525 /// \param CUID - The CUID for \p Input
526 /// \param HostAction - The host action used in the offloading toolchain.
527 /// \param HIPAsmBundleDeviceOut - If non-null, HIP non-RDC \c -S (AMDGCN)
528 /// device actions are appended here and \p HostAction is returned unchanged
529 /// so the caller can emit a bundled \c .s via \c OffloadBundlingJobAction.
530 Action *
531 BuildOffloadingActions(Compilation &C, llvm::opt::DerivedArgList &Args,
532 const InputTy &Input, StringRef CUID,
533 Action *HostAction,
534 ActionList *HIPAsmBundleDeviceOut = nullptr) const;
535
536 /// Returns the set of bound architectures active for this offload kind.
537 /// If there are no bound architctures we return a set containing only the
538 /// empty string.
540 getOffloadArchs(Compilation &C, const llvm::opt::DerivedArgList &Args,
541 Action::OffloadKind Kind, const ToolChain &TC) const;
542
543 /// Check that the file referenced by Value exists. If it doesn't,
544 /// issue a diagnostic and return false.
545 /// If TypoCorrect is true and the file does not exist, see if it looks
546 /// like a likely typo for a flag and if so print a "did you mean" blurb.
547 bool DiagnoseInputExistence(StringRef Value, types::ID Ty,
548 bool TypoCorrect) const;
549
550 /// BuildJobs - Bind actions to concrete tools and translate
551 /// arguments to form the list of jobs to run.
552 ///
553 /// \param C - The compilation that is being built.
554 void BuildJobs(Compilation &C) const;
555
556 /// ExecuteCompilation - Execute the compilation according to the command line
557 /// arguments and return an appropriate exit code.
558 ///
559 /// This routine handles additional processing that must be done in addition
560 /// to just running the subprocesses, for example reporting errors, setting
561 /// up response files, removing temporary files, etc.
563 SmallVectorImpl< std::pair<int, const Command *> > &FailingCommands);
564
565 /// Contains the files in the compilation diagnostic report generated by
566 /// generateCompilationDiagnostics.
570
571 /// generateCompilationDiagnostics - Generate diagnostics information
572 /// including preprocessed source file(s).
573 ///
575 Compilation &C, const Command &FailingCommand,
576 StringRef AdditionalInformation = "",
577 CompilationDiagnosticReport *GeneratedReport = nullptr);
578
579 enum class CommandStatus {
580 Crash = 1,
583 };
584
585 enum class ReproLevel {
586 Off = 0,
587 OnCrash = static_cast<int>(CommandStatus::Crash),
588 OnError = static_cast<int>(CommandStatus::Error),
589 Always = static_cast<int>(CommandStatus::Ok),
590 };
591
594 const Command &FailingCommand, StringRef AdditionalInformation = "",
595 CompilationDiagnosticReport *GeneratedReport = nullptr) {
596 if (static_cast<int>(CS) > static_cast<int>(Level))
597 return false;
598 if (CS != CommandStatus::Crash)
599 Diags.Report(diag::err_drv_force_crash)
600 << !::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH");
601 // Hack to ensure that diagnostic notes get emitted.
602 Diags.setLastDiagnosticIgnored(false);
603 generateCompilationDiagnostics(C, FailingCommand, AdditionalInformation,
604 GeneratedReport);
605 return true;
606 }
607
608 /// @}
609 /// @name Helper Methods
610 /// @{
611
612 /// PrintActions - Print the list of actions.
613 void PrintActions(const Compilation &C) const;
614
615 /// PrintHelp - Print the help text.
616 ///
617 /// \param ShowHidden - Show hidden options.
618 void PrintHelp(bool ShowHidden) const;
619
620 /// PrintVersion - Print the driver version.
621 void PrintVersion(const Compilation &C, raw_ostream &OS) const;
622
623 /// GetFilePath - Lookup \p Name in the list of file search paths.
624 ///
625 /// \param TC - The tool chain for additional information on
626 /// directories to search.
627 //
628 // FIXME: This should be in CompilationInfo.
629 std::string GetFilePath(StringRef Name, const ToolChain &TC) const;
630
631 /// GetProgramPath - Lookup \p Name in the list of program search paths.
632 ///
633 /// \param TC - The provided tool chain for additional information on
634 /// directories to search.
635 //
636 // FIXME: This should be in CompilationInfo.
637 std::string GetProgramPath(StringRef Name, const ToolChain &TC) const;
638
639 /// Lookup the path to the Standard library module manifest.
640 ///
641 /// \param C - The compilation.
642 /// \param TC - The tool chain for additional information on
643 /// directories to search.
644 //
645 // FIXME: This should be in CompilationInfo.
646 std::string GetStdModuleManifestPath(const Compilation &C,
647 const ToolChain &TC) const;
648
649 /// HandleAutocompletions - Handle --autocomplete by searching and printing
650 /// possible flags, descriptions, and its arguments.
651 void HandleAutocompletions(StringRef PassedFlags) const;
652
653 /// HandleImmediateArgs - Handle any arguments which should be
654 /// treated before building actions or binding tools.
655 ///
656 /// \return Whether any compilation should be built for this
657 /// invocation. The compilation can only be modified when
658 /// this function returns false.
660
661 /// ConstructAction - Construct the appropriate action to do for
662 /// \p Phase on the \p Input, taking in to account arguments
663 /// like -fsyntax-only or --analyze.
665 Compilation &C, const llvm::opt::ArgList &Args, phases::ID Phase,
666 Action *Input,
667 Action::OffloadKind TargetDeviceOffloadKind = Action::OFK_None) const;
668
669 /// BuildJobsForAction - Construct the jobs to perform for the action \p A and
670 /// return an InputInfo for the result of running \p A. Will only construct
671 /// jobs for a given (Action, ToolChain, BoundArch, DeviceKind) tuple once.
673 Compilation &C, const Action *A, const ToolChain *TC, StringRef BoundArch,
674 bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
675 std::map<std::pair<const Action *, std::string>, InputInfoList>
676 &CachedResults,
677 Action::OffloadKind TargetDeviceOffloadKind) const;
678
679 /// Returns the default name for linked images (e.g., "a.out").
680 const char *getDefaultImageName() const;
681
682 /// Creates a temp file.
683 /// 1. If \p MultipleArch is false or \p BoundArch is empty, the temp file is
684 /// in the temporary directory with name $Prefix-%%%%%%.$Suffix.
685 /// 2. If \p MultipleArch is true and \p BoundArch is not empty,
686 /// 2a. If \p NeedUniqueDirectory is false, the temp file is in the
687 /// temporary directory with name $Prefix-$BoundArch-%%%%%.$Suffix.
688 /// 2b. If \p NeedUniqueDirectory is true, the temp file is in a unique
689 /// subdiretory with random name under the temporary directory, and
690 /// the temp file itself has name $Prefix-$BoundArch.$Suffix.
691 const char *CreateTempFile(Compilation &C, StringRef Prefix, StringRef Suffix,
692 bool MultipleArchs = false,
693 StringRef BoundArch = {},
694 bool NeedUniqueDirectory = false) const;
695
696 /// GetNamedOutputPath - Return the name to use for the output of
697 /// the action \p JA. The result is appended to the compilation's
698 /// list of temporary or result files, as appropriate.
699 ///
700 /// \param C - The compilation.
701 /// \param JA - The action of interest.
702 /// \param BaseInput - The original input file that this action was
703 /// triggered by.
704 /// \param BoundArch - The bound architecture.
705 /// \param AtTopLevel - Whether this is a "top-level" action.
706 /// \param MultipleArchs - Whether multiple -arch options were supplied.
707 /// \param NormalizedTriple - The normalized triple of the relevant target.
708 const char *GetNamedOutputPath(Compilation &C, const JobAction &JA,
709 const char *BaseInput, StringRef BoundArch,
710 bool AtTopLevel, bool MultipleArchs,
711 StringRef NormalizedTriple) const;
712
713 /// GetTemporaryPath - Return the pathname of a temporary file to use
714 /// as part of compilation; the file will have the given prefix and suffix.
715 ///
716 /// GCC goes to extra lengths here to be a bit more robust.
717 std::string GetTemporaryPath(StringRef Prefix, StringRef Suffix) const;
718
719 /// GetTemporaryDirectory - Return the pathname of a temporary directory to
720 /// use as part of compilation; the directory will have the given prefix.
721 std::string GetTemporaryDirectory(StringRef Prefix) const;
722
723 /// Return the pathname of the pch file in clang-cl mode.
724 std::string GetClPchPath(Compilation &C, StringRef BaseName) const;
725
726 /// ShouldUseClangCompiler - Should the clang compiler be used to
727 /// handle this action.
728 bool ShouldUseClangCompiler(const JobAction &JA) const;
729
730 /// ShouldUseFlangCompiler - Should the flang compiler be used to
731 /// handle this action.
732 bool ShouldUseFlangCompiler(const JobAction &JA) const;
733
734 /// ShouldEmitStaticLibrary - Should the linker emit a static library.
735 bool ShouldEmitStaticLibrary(const llvm::opt::ArgList &Args) const;
736
737 /// Returns true if the user has indicated a C++20 header unit mode.
738 bool hasHeaderMode() const { return CXX20HeaderType != HeaderMode_None; }
739
740 /// Get the mode for handling headers as set by fmodule-header{=}.
741 ModuleHeaderMode getModuleHeaderMode() const { return CXX20HeaderType; }
742
743 /// Returns true if we are performing any kind of LTO.
744 bool isUsingLTO() const { return getLTOMode() != LTOK_None; }
745
746 /// Get the specific kind of LTO being performed.
747 LTOKind getLTOMode() const { return LTOMode; }
748
749 /// Returns true if we are performing any kind of offload LTO.
750 bool isUsingOffloadLTO() const { return getOffloadLTOMode() != LTOK_None; }
751
752 /// Get the specific kind of offload LTO being performed.
753 LTOKind getOffloadLTOMode() const { return OffloadLTOMode; }
754
755 /// Get the CUID option.
756 const CUIDOptions &getCUIDOpts() const { return CUIDOpts; }
757
758private:
759
760 /// Tries to load options from configuration files.
761 ///
762 /// \returns true if error occurred.
763 bool loadConfigFiles();
764
765 /// Tries to load options from default configuration files (deduced from
766 /// executable filename).
767 ///
768 /// \returns true if error occurred.
769 bool loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx);
770
771 /// Tries to load options from customization file.
772 ///
773 /// \returns true if error occurred.
774 bool loadZOSCustomizationFile(llvm::cl::ExpansionContext &);
775
776 /// Read options from the specified file.
777 ///
778 /// \param [in] FileName File to read.
779 /// \param [in] Search and expansion options.
780 /// \returns true, if error occurred while reading.
781 bool readConfigFile(StringRef FileName, llvm::cl::ExpansionContext &ExpCtx);
782
783 /// Set the driver mode (cl, gcc, etc) from the value of the `--driver-mode`
784 /// option.
785 void setDriverMode(StringRef DriverModeValue);
786
787 /// Parse the \p Args list for LTO options and record the type of LTO
788 /// compilation based on which -f(no-)?lto(=.*)? option occurs last.
789 void setLTOMode(const llvm::opt::ArgList &Args);
790
791 /// Retrieves a ToolChain for a particular \p Target triple.
792 ///
793 /// Will cache ToolChains for the life of the driver object, and create them
794 /// on-demand.
795 const ToolChain &getToolChain(const llvm::opt::ArgList &Args,
796 const llvm::Triple &Target) const;
797
798 /// Retrieves a ToolChain for a particular \p Target triple for offloading.
799 ///
800 /// Will cache ToolChains for the life of the driver object, and create them
801 /// on-demand.
802 const ToolChain &getOffloadToolChain(const llvm::opt::ArgList &Args,
803 const Action::OffloadKind Kind,
804 const llvm::Triple &Target,
805 const llvm::Triple &AuxTarget) const;
806
807 /// Get bitmasks for which option flags to include and exclude based on
808 /// the driver mode.
809 llvm::opt::Visibility
810 getOptionVisibilityMask(bool UseDriverMode = true) const;
811
812 /// Helper used in BuildJobsForAction. Doesn't use the cache when building
813 /// jobs specifically for the given action, but will use the cache when
814 /// building jobs for the Action's inputs.
815 InputInfoList BuildJobsForActionNoCache(
816 Compilation &C, const Action *A, const ToolChain *TC, StringRef BoundArch,
817 bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
818 std::map<std::pair<const Action *, std::string>, InputInfoList>
819 &CachedResults,
820 Action::OffloadKind TargetDeviceOffloadKind) const;
821
822 /// Return the typical executable name for the specified driver \p Mode.
823 static const char *getExecutableForDriverMode(DriverMode Mode);
824
825public:
826 /// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and
827 /// return the grouped values as integers. Numbers which are not
828 /// provided are set to 0.
829 ///
830 /// \return True if the entire string was parsed (9.2), or all
831 /// groups were parsed (10.3.5extrastuff). HadExtra is true if all
832 /// groups were parsed but extra characters remain at the end.
833 static bool GetReleaseVersion(StringRef Str, unsigned &Major, unsigned &Minor,
834 unsigned &Micro, bool &HadExtra);
835
836 /// Parse digits from a string \p Str and fulfill \p Digits with
837 /// the parsed numbers. This method assumes that the max number of
838 /// digits to look for is equal to Digits.size().
839 ///
840 /// \return True if the entire string was parsed and there are
841 /// no extra characters remaining at the end.
842 static bool GetReleaseVersion(StringRef Str,
844 /// Compute the default -fmodule-cache-path.
845 /// \return True if the system provides a default cache directory.
847};
848
849/// \return True if the last defined optimization level is -Ofast.
850/// And False otherwise.
851bool isOptimizationLevelFast(const llvm::opt::ArgList &Args);
852
853/// \return True if the argument combination will end up generating remarks.
854bool willEmitRemarks(const llvm::opt::ArgList &Args);
855
856/// Returns the driver mode option's value, i.e. `X` in `--driver-mode=X`. If \p
857/// Args doesn't mention one explicitly, tries to deduce from `ProgName`.
858/// Returns empty on failure.
859/// Common values are "gcc", "g++", "cpp", "cl" and "flang". Returned value need
860/// not be one of these.
861llvm::StringRef getDriverMode(StringRef ProgName, ArrayRef<const char *> Args);
862
863/// Checks whether the value produced by getDriverMode is for CL mode.
864bool IsClangCL(StringRef DriverMode);
865
866/// Expand response files from a clang driver or cc1 invocation.
867///
868/// \param Args The arguments that will be expanded.
869/// \param ClangCLMode Whether clang is in CL mode.
870/// \param Alloc Allocator for new arguments.
871/// \param FS Filesystem to use when expanding files.
873 bool ClangCLMode, llvm::BumpPtrAllocator &Alloc,
874 llvm::vfs::FileSystem *FS = nullptr);
875
876/// Apply a space separated list of edits to the input argument lists.
877/// See applyOneOverrideOption.
879 const char *OverrideOpts,
880 llvm::StringSet<> &SavedStrings, StringRef EnvVar,
881 raw_ostream *OS = nullptr);
882
883/// Creates and adds a synthesized input argument.
884///
885/// \param Args The argument list to append the input argument to.
886/// \param Opts The option table used to look up OPT_INPUT.
887/// \param Value The input to add, typically a filename.
888/// \param Claim Whether the newly created argument should be claimed.
889///
890/// \return The newly created input argument.
891llvm::opt::Arg *makeInputArg(llvm::opt::DerivedArgList &Args,
892 const llvm::opt::OptTable &Opts, StringRef Value,
893 bool Claim = true);
894
895} // end namespace driver
896} // end namespace clang
897
898#endif
Defines the Diagnostic-related interfaces.
Defines enums used when emitting included header information.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
A little helper class used to produce diagnostics.
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:232
Action - Represent an abstract compilation step to perform.
Definition Action.h:47
Options for specifying CUID used by CUDA/HIP for uniquely identifying compilation units.
Definition Driver.h:77
std::string getCUID(StringRef InputFile, llvm::opt::DerivedArgList &Args) const
Definition Driver.cpp:154
bool isEnabled() const
Definition Driver.h:88
Command - An executable path/name and argument vector to execute.
Definition Job.h:106
Compilation - A set of tasks to perform for a single driver invocation.
Definition Compilation.h:45
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition Driver.h:99
const CUIDOptions & getCUIDOpts() const
Get the CUID option.
Definition Driver.h:756
std::string SysRoot
sysroot, if present
Definition Driver.h:205
std::string CCPrintInternalStatReportFilename
The file to log CC_PRINT_INTERNAL_STAT_FILE output to, if enabled.
Definition Driver.h:220
std::string UserConfigDir
User directory for config files.
Definition Driver.h:195
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:5197
std::string HostRelease
Definition Driver.h:214
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:2868
void PrintHelp(bool ShowHidden) const
PrintHelp - Print the help text.
Definition Driver.cpp:2384
bool offloadDeviceOnly() const
Definition Driver.h:458
bool isSaveTempsEnabled() const
Definition Driver.h:450
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:5413
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:5955
std::string GetFilePath(StringRef Name, const ToolChain &TC) const
GetFilePath - Lookup Name in the list of file search paths.
Definition Driver.cpp:6723
void setPreferredLinker(std::string Value)
Definition Driver.h:446
void setCheckInputsExist(bool Value)
Definition Driver.h:425
unsigned CCPrintProcessStats
Set CC_PRINT_PROC_STAT mode, which causes the driver to dump performance report to CC_PRINT_PROC_STAT...
Definition Driver.h:288
DiagnosticsEngine & getDiags() const
Definition Driver.h:419
void PrintActions(const Compilation &C) const
PrintActions - Print the list of actions.
Definition Driver.cpp:2852
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:6429
void setFlangF128MathLibrary(std::string name)
Definition Driver.h:460
std::string CCPrintOptionsFilename
The file to log CC_PRINT_OPTIONS output to, if enabled.
Definition Driver.h:223
llvm::Expected< std::unique_ptr< llvm::MemoryBuffer > > executeProgram(llvm::ArrayRef< llvm::StringRef > Args) const
Definition Driver.cpp:392
const char * getPrependArg() const
Definition Driver.h:430
Action * BuildOffloadingActions(Compilation &C, llvm::opt::DerivedArgList &Args, const InputTy &Input, StringRef CUID, Action *HostAction, ActionList *HIPAsmBundleDeviceOut=nullptr) const
BuildOffloadingActions - Construct the list of actions to perform for the offloading toolchain that w...
Definition Driver.cpp:4944
CC1ToolFunc CC1Main
Definition Driver.h:301
OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList &Args) const
Compute the desired OpenMP runtime from the flags provided.
Definition Driver.cpp:883
std::string GetTemporaryDirectory(StringRef Prefix) const
GetTemporaryDirectory - Return the pathname of a temporary directory to use as part of compilation; t...
Definition Driver.cpp:6904
bool IsDXCMode() const
Whether the driver should follow dxc.exe like behavior.
Definition Driver.h:248
const char * getDefaultImageName() const
Returns the default name for linked images (e.g., "a.out").
Definition Driver.cpp:6318
llvm::function_ref< int(SmallVectorImpl< const char * > &ArgV)> CC1ToolFunc
Pointer to the ExecuteCC1Tool function, if available.
Definition Driver.h:299
bool IsCLMode() const
Whether the driver should follow cl.exe like behavior.
Definition Driver.h:241
std::string DyldPrefix
Dynamic loader prefix, if present.
Definition Driver.h:208
bool ShouldEmitStaticLibrary(const llvm::opt::ArgList &Args) const
ShouldEmitStaticLibrary - Should the linker emit a static library.
Definition Driver.cpp:7246
std::string DriverTitle
Driver title to use with help.
Definition Driver.h:211
unsigned CCCPrintBindings
Only print tool bindings, don't build any jobs.
Definition Driver.h:252
unsigned CCLogDiagnostics
Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics to CCLogDiagnosticsFilename...
Definition Driver.h:279
llvm::ArrayRef< std::string > getConfigFiles() const
Definition Driver.h:413
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:3054
static bool getDefaultModuleCachePath(SmallVectorImpl< char > &Result)
Compute the default -fmodule-cache-path.
Definition Clang.cpp:3826
unsigned CCGenDiagnostics
Whether the driver is generating diagnostics for debugging purposes.
Definition Driver.h:283
bool HandleImmediateArgs(Compilation &C)
HandleImmediateArgs - Handle any arguments which should be treated before building actions or binding...
Definition Driver.cpp:2523
const char * getClangProgramPath() const
Get the path to the main clang executable.
Definition Driver.h:441
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:2295
DiagnosticBuilder Diag(unsigned DiagID) const
Definition Driver.h:169
std::string SystemConfigDir
System directory for config files.
Definition Driver.h:192
ParsedClangName ClangNameParts
Target and driver mode components extracted from clang executable name.
Definition Driver.h:186
unsigned CCPrintInternalStats
Set CC_PRINT_INTERNAL_STAT mode, which causes the driver to dump internal performance report to CC_PR...
Definition Driver.h:293
static bool GetReleaseVersion(StringRef Str, unsigned &Major, unsigned &Minor, unsigned &Micro, bool &HadExtra)
GetReleaseVersion - Parse (([0-9]+)(.
Definition Driver.cpp:7258
llvm::SmallVector< 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:4842
std::string Name
The name the driver was invoked as.
Definition Driver.h:176
phases::ID getFinalPhase(const llvm::opt::DerivedArgList &DAL, llvm::opt::Arg **FinalPhaseArg=nullptr) const
Definition Driver.cpp:333
std::string GetClPchPath(Compilation &C, StringRef BaseName) const
Return the pathname of the pch file in clang-cl mode.
Definition Driver.cpp:6915
std::string ClangExecutable
The original path to the clang executable.
Definition Driver.h:183
const char * CreateTempFile(Compilation &C, StringRef Prefix, StringRef Suffix, bool MultipleArchs=false, StringRef BoundArch={}, bool NeedUniqueDirectory=false) const
Creates a temp file.
Definition Driver.cpp:6367
void setPrependArg(const char *Value)
Definition Driver.h:431
StringRef getFlangF128MathLibrary() const
Definition Driver.h:463
const llvm::opt::OptTable & getOpts() const
Definition Driver.h:417
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:4472
bool offloadHostOnly() const
Definition Driver.h:457
ModuleHeaderMode getModuleHeaderMode() const
Get the mode for handling headers as set by fmodule-header{=}.
Definition Driver.h:741
void generateCompilationDiagnostics(Compilation &C, const Command &FailingCommand, StringRef AdditionalInformation="", CompilationDiagnosticReport *GeneratedReport=nullptr)
generateCompilationDiagnostics - Generate diagnostics information including preprocessed source file(...
Definition Driver.cpp:2008
bool hasHeaderMode() const
Returns true if the user has indicated a C++20 header unit mode.
Definition Driver.h:738
SmallVector< std::string, 4 > prefix_list
A prefix directory used to emulate a limited subset of GCC's '-Bprefix' functionality.
Definition Driver.h:201
void PrintVersion(const Compilation &C, raw_ostream &OS) const
PrintVersion - Print the driver version.
Definition Driver.cpp:2393
bool ShouldUseFlangCompiler(const JobAction &JA) const
ShouldUseFlangCompiler - Should the flang compiler be used to handle this action.
Definition Driver.cpp:7232
const std::string & getTitle()
Definition Driver.h:435
bool DiagnoseInputExistence(StringRef Value, types::ID Ty, bool TypoCorrect) const
Check that the file referenced by Value exists.
Definition Driver.cpp:2963
LTOKind getOffloadLTOMode() const
Get the specific kind of offload LTO being performed.
Definition Driver.h:753
bool isUsingOffloadLTO() const
Returns true if we are performing any kind of offload LTO.
Definition Driver.h:750
bool embedBitcodeEnabled() const
Definition Driver.h:453
void CreateOffloadingDeviceToolChains(Compilation &C, InputList &Inputs)
CreateOffloadingDeviceToolChains - create all the toolchains required to support offloading devices g...
Definition Driver.cpp:1041
std::string GetProgramPath(StringRef Name, const ToolChain &TC) const
GetProgramPath - Lookup Name in the list of program search paths.
Definition Driver.cpp:6788
std::string CCLogDiagnosticsFilename
The file to log CC_LOG_DIAGNOSTICS output to, if enabled.
Definition Driver.h:229
bool isSaveTempsObj() const
Definition Driver.h:451
std::string CCPrintHeadersFilename
The file to log CC_PRINT_HEADERS output to, if enabled.
Definition Driver.h:226
void HandleAutocompletions(StringRef PassedFlags) const
HandleAutocompletions - Handle –autocomplete by searching and printing possible flags,...
Definition Driver.cpp:2436
std::string ResourceDir
The path to the compiler resource directory.
Definition Driver.h:189
llvm::vfs::FileSystem & getVFS() const
Definition Driver.h:421
unsigned CCPrintOptions
Set CC_PRINT_OPTIONS mode, which is like -v but logs the commands to CCPrintOptionsFilename or to std...
Definition Driver.h:257
bool ShouldUseClangCompiler(const JobAction &JA) const
ShouldUseClangCompiler - Should the clang compiler be used to handle this action.
Definition Driver.cpp:7217
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:6893
void setProbePrecompiled(bool Value)
Definition Driver.h:428
std::string Dir
The path the driver executable was in, as invoked from the command line.
Definition Driver.h:180
bool maybeGenerateCompilationDiagnostics(CommandStatus CS, ReproLevel Level, Compilation &C, const Command &FailingCommand, StringRef AdditionalInformation="", CompilationDiagnosticReport *GeneratedReport=nullptr)
Definition Driver.h:592
@ OMPRT_IOMP5
The legacy name for the LLVM OpenMP runtime from when it was the Intel OpenMP runtime.
Definition Driver.h:165
@ OMPRT_OMP
The LLVM OpenMP runtime.
Definition Driver.h:155
@ OMPRT_Unknown
An unknown OpenMP runtime.
Definition Driver.h:151
@ OMPRT_GOMP
The GNU OpenMP runtime.
Definition Driver.h:160
bool isUsingLTO() const
Returns true if we are performing any kind of LTO.
Definition Driver.h:744
std::string HostBits
Information about the host which can be overridden by the user.
Definition Driver.h:214
Driver(StringRef ClangExecutable, StringRef TargetTriple, DiagnosticsEngine &Diags, std::string Title="clang LLVM compiler", IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS=nullptr)
Definition Driver.cpp:176
HeaderIncludeFormatKind CCPrintHeadersFormat
The format of the header information that is emitted.
Definition Driver.h:262
std::string getTargetTriple() const
Definition Driver.h:438
bool getCheckInputsExist() const
Definition Driver.h:423
bool CCCIsCC() const
Whether the driver should follow gcc like behavior.
Definition Driver.h:238
void setTargetAndMode(const ParsedClangName &TM)
Definition Driver.h:433
std::string GetStdModuleManifestPath(const Compilation &C, const ToolChain &TC) const
Lookup the path to the Standard library module manifest.
Definition Driver.cpp:6830
bool IsFlangMode() const
Whether the driver should invoke flang for fortran inputs.
Definition Driver.h:245
bool embedBitcodeMarkerOnly() const
Definition Driver.h:455
void setTitle(std::string Value)
Definition Driver.h:436
prefix_list PrefixDirs
Definition Driver.h:202
Compilation * BuildCompilation(ArrayRef< const char * > Args)
BuildCompilation - Construct a compilation object for a command line argument vector.
Definition Driver.cpp:1472
HeaderIncludeFilteringKind CCPrintHeadersFiltering
This flag determines whether clang should filter the header information that is emitted.
Definition Driver.h:268
const std::string & getCCCGenericGCCName() const
Name to use when invoking gcc/g++.
Definition Driver.h:411
LTOKind getLTOMode() const
Get the specific kind of LTO being performed.
Definition Driver.h:747
std::string HostMachine
Definition Driver.h:214
bool embedBitcodeInObject() const
Definition Driver.h:454
std::string CCPrintStatReportFilename
The file to log CC_PRINT_PROC_STAT_FILE output to, if enabled.
Definition Driver.h:217
llvm::opt::InputArgList ParseArgStrings(ArrayRef< const char * > Args, bool UseDriverMode, bool &ContainsError) const
ParseArgStrings - Parse the given list of strings into an ArgList.
Definition Driver.cpp:242
bool CCCIsCPP() const
Whether the driver is just the preprocessor.
Definition Driver.h:235
StringRef getPreferredLinker() const
Definition Driver.h:445
std::string HostSystem
Definition Driver.h:214
bool CCCIsCXX() const
Whether the driver should follow g++ like behavior.
Definition Driver.h:232
bool getProbePrecompiled() const
Definition Driver.h:427
std::string FlangF128MathLibrary
Name of the library that provides implementations of IEEE-754 128-bit float math functions used by Fo...
Definition Driver.h:273
ToolChain - Access to tools for a single platform.
Definition ToolChain.h:92
Tool - Information on a specific compilation tool.
Definition Tool.h:32
ID
ID - Ordered values for successive stages in the compilation process which interact with user options...
Definition Phases.h:17
void applyOverrideOptions(SmallVectorImpl< const char * > &Args, const char *OverrideOpts, llvm::StringSet<> &SavedStrings, StringRef EnvVar, raw_ostream *OS=nullptr)
Apply a space separated list of edits to the input argument lists.
Definition Driver.cpp:7547
ModuleHeaderMode
Whether headers used to construct C++20 module units should be looked up by the path supplied on the ...
Definition Driver.h:68
@ HeaderMode_System
Definition Driver.h:72
@ HeaderMode_None
Definition Driver.h:69
@ HeaderMode_Default
Definition Driver.h:70
@ HeaderMode_User
Definition Driver.h:71
llvm::opt::Arg * makeInputArg(llvm::opt::DerivedArgList &Args, const llvm::opt::OptTable &Opts, StringRef Value, bool Claim=true)
Creates and adds a synthesized input argument.
LTOKind
Describes the kind of LTO mode selected via -f(no-)?lto(=.*)? options.
Definition Driver.h:58
SmallVector< InputInfo, 4 > InputInfoList
Definition Driver.h:50
std::pair< types::ID, const llvm::opt::Arg * > InputTy
A list of inputs and their types for the given arguments.
Definition Types.h:133
SmallVector< Action *, 3 > ActionList
ActionList - Type used for lists of actions.
Definition Util.h:25
bool isOptimizationLevelFast(const llvm::opt::ArgList &Args)
llvm::StringRef getDriverMode(StringRef ProgName, ArrayRef< const char * > Args)
Returns the driver mode option's value, i.e.
Definition Driver.cpp:7375
llvm::Error expandResponseFiles(SmallVectorImpl< const char * > &Args, bool ClangCLMode, llvm::BumpPtrAllocator &Alloc, llvm::vfs::FileSystem *FS=nullptr)
Expand response files from a clang driver or cc1 invocation.
Definition Driver.cpp:7392
llvm::SmallVector< InputTy, 16 > InputList
A list of inputs and their types for the given arguments.
Definition Types.h:136
bool willEmitRemarks(const llvm::opt::ArgList &Args)
bool IsClangCL(StringRef DriverMode)
Checks whether the value produced by getDriverMode is for CL mode.
Definition Driver.cpp:7390
The JSON file list parser is used to communicate input to InstallAPI.
HeaderIncludeFilteringKind
Whether header information is filtered or not.
@ Result
The result type of a method or function.
Definition TypeBase.h:905
const llvm::opt::OptTable & getDriverOptTable()
HeaderIncludeFormatKind
The format in which header information is emitted.
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
Contains the files in the compilation diagnostic report generated by generateCompilationDiagnostics.
Definition Driver.h:567
llvm::SmallVector< std::string, 4 > TemporaryFiles
Definition Driver.h:568
Helper structure used to pass information extracted from clang executable name such as i686-linux-and...
Definition ToolChain.h:65