clang 22.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"
19#include "clang/Driver/Phases.h"
21#include "clang/Driver/Types.h"
22#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.
58enum LTOKind {
63};
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.
73};
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 /// An input type and its arguments.
232 using InputTy = std::pair<types::ID, const llvm::opt::Arg *>;
233
234 /// A list of inputs and their types for the given arguments.
236
237 /// Whether the driver should follow g++ like behavior.
238 bool CCCIsCXX() const { return Mode == GXXMode; }
239
240 /// Whether the driver is just the preprocessor.
241 bool CCCIsCPP() const { return Mode == CPPMode; }
242
243 /// Whether the driver should follow gcc like behavior.
244 bool CCCIsCC() const { return Mode == GCCMode; }
245
246 /// Whether the driver should follow cl.exe like behavior.
247 bool IsCLMode() const { return Mode == CLMode; }
248
249 /// Whether the driver should invoke flang for fortran inputs.
250 /// Other modes fall back to calling gcc which in turn calls gfortran.
251 bool IsFlangMode() const { return Mode == FlangMode; }
252
253 /// Whether the driver should follow dxc.exe like behavior.
254 bool IsDXCMode() const { return Mode == DXCMode; }
255
256 /// Only print tool bindings, don't build any jobs.
257 LLVM_PREFERRED_TYPE(bool)
259
260 /// Set CC_PRINT_OPTIONS mode, which is like -v but logs the commands to
261 /// CCPrintOptionsFilename or to stderr.
262 LLVM_PREFERRED_TYPE(bool)
263 unsigned CCPrintOptions : 1;
264
265 /// The format of the header information that is emitted. If CC_PRINT_HEADERS
266 /// is set, the format is textual. Otherwise, the format is determined by the
267 /// enviroment variable CC_PRINT_HEADERS_FORMAT.
269
270 /// This flag determines whether clang should filter the header information
271 /// that is emitted. If enviroment variable CC_PRINT_HEADERS_FILTERING is set
272 /// to "only-direct-system", only system headers that are directly included
273 /// from non-system headers are emitted.
275
276 /// Name of the library that provides implementations of
277 /// IEEE-754 128-bit float math functions used by Fortran F128
278 /// runtime library. It should be linked as needed by the linker job.
280
281 /// Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics
282 /// to CCLogDiagnosticsFilename or to stderr, in a stable machine readable
283 /// format.
284 LLVM_PREFERRED_TYPE(bool)
285 unsigned CCLogDiagnostics : 1;
286
287 /// Whether the driver is generating diagnostics for debugging purposes.
288 LLVM_PREFERRED_TYPE(bool)
289 unsigned CCGenDiagnostics : 1;
290
291 /// Set CC_PRINT_PROC_STAT mode, which causes the driver to dump
292 /// performance report to CC_PRINT_PROC_STAT_FILE or to stdout.
293 LLVM_PREFERRED_TYPE(bool)
295
296 /// Set CC_PRINT_INTERNAL_STAT mode, which causes the driver to dump internal
297 /// performance report to CC_PRINT_INTERNAL_STAT_FILE or to stdout.
298 LLVM_PREFERRED_TYPE(bool)
300
301 /// Pointer to the ExecuteCC1Tool function, if available.
302 /// When the clangDriver lib is used through clang.exe, this provides a
303 /// shortcut for executing the -cc1 command-line directly, in the same
304 /// process.
306 llvm::function_ref<int(SmallVectorImpl<const char *> &ArgV)>;
308
309private:
310 /// Raw target triple.
311 std::string TargetTriple;
312
313 /// Name to use when invoking gcc/g++.
314 std::string CCCGenericGCCName;
315
316 /// Paths to configuration files used.
317 std::vector<std::string> ConfigFiles;
318
319 /// Allocator for string saver.
320 llvm::BumpPtrAllocator Alloc;
321
322 /// Object that stores strings read from configuration file.
323 llvm::StringSaver Saver;
324
325 /// Arguments originated from configuration file (head part).
326 std::unique_ptr<llvm::opt::InputArgList> CfgOptionsHead;
327
328 /// Arguments originated from configuration file (tail part).
329 std::unique_ptr<llvm::opt::InputArgList> CfgOptionsTail;
330
331 /// Arguments originated from command line.
332 std::unique_ptr<llvm::opt::InputArgList> CLOptions;
333
334 /// If this is non-null, the driver will prepend this argument before
335 /// reinvoking clang. This is useful for the llvm-driver where clang's
336 /// realpath will be to the llvm binary and not clang, so it must pass
337 /// "clang" as it's first argument.
338 const char *PrependArg;
339
340 /// The default value of -fuse-ld= option. An empty string means the default
341 /// system linker.
342 std::string PreferredLinker;
343
344 /// Whether to check that input files exist when constructing compilation
345 /// jobs.
346 LLVM_PREFERRED_TYPE(bool)
347 unsigned CheckInputsExist : 1;
348 /// Whether to probe for PCH files on disk, in order to upgrade
349 /// -include foo.h to -include-pch foo.h.pch.
350 LLVM_PREFERRED_TYPE(bool)
351 unsigned ProbePrecompiled : 1;
352
353public:
354 // getFinalPhase - Determine which compilation mode we are in and record
355 // which option we used to determine the final phase.
356 // TODO: Much of what getFinalPhase returns are not actually true compiler
357 // modes. Fold this functionality into Types::getCompilationPhases and
358 // handleArguments.
359 phases::ID getFinalPhase(const llvm::opt::DerivedArgList &DAL,
360 llvm::opt::Arg **FinalPhaseArg = nullptr) const;
361
362 llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
363 executeProgram(llvm::ArrayRef<llvm::StringRef> Args) const;
364
365private:
366 /// Certain options suppress the 'no input files' warning.
367 LLVM_PREFERRED_TYPE(bool)
368 unsigned SuppressMissingInputWarning : 1;
369
370 /// Cache of all the ToolChains in use by the driver.
371 ///
372 /// This maps from the string representation of a triple to a ToolChain
373 /// created targeting that triple. The driver owns all the ToolChain objects
374 /// stored in it, and will clean them up when torn down.
375 mutable llvm::StringMap<std::unique_ptr<ToolChain>> ToolChains;
376
377private:
378 /// TranslateInputArgs - Create a new derived argument list from the input
379 /// arguments, after applying the standard argument translations.
380 llvm::opt::DerivedArgList *
381 TranslateInputArgs(const llvm::opt::InputArgList &Args) const;
382
383 // handleArguments - All code related to claiming and printing diagnostics
384 // related to arguments to the driver are done here.
385 void handleArguments(Compilation &C, llvm::opt::DerivedArgList &Args,
386 const InputList &Inputs, ActionList &Actions) const;
387
388 // Before executing jobs, sets up response files for commands that need them.
389 void setUpResponseFiles(Compilation &C, Command &Cmd);
390
391 void generatePrefixedToolNames(StringRef Tool, const ToolChain &TC,
392 SmallVectorImpl<std::string> &Names) const;
393
394 /// Find the appropriate .crash diagonostic file for the child crash
395 /// under this driver and copy it out to a temporary destination with the
396 /// other reproducer related files (.sh, .cache, etc). If not found, suggest a
397 /// directory for the user to look at.
398 ///
399 /// \param ReproCrashFilename The file path to copy the .crash to.
400 /// \param CrashDiagDir The suggested directory for the user to look at
401 /// in case the search or copy fails.
402 ///
403 /// \returns If the .crash is found and successfully copied return true,
404 /// otherwise false and return the suggested directory in \p CrashDiagDir.
405 bool getCrashDiagnosticFile(StringRef ReproCrashFilename,
406 SmallString<128> &CrashDiagDir);
407
408public:
409
410 /// Takes the path to a binary that's either in bin/ or lib/ and returns
411 /// the path to clang's resource directory.
412 static std::string GetResourcesPath(StringRef BinaryPath);
413
414 Driver(StringRef ClangExecutable, StringRef TargetTriple,
415 DiagnosticsEngine &Diags, std::string Title = "clang LLVM compiler",
416 IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);
417
418 /// @name Accessors
419 /// @{
420
421 /// Name to use when invoking gcc/g++.
422 const std::string &getCCCGenericGCCName() const { return CCCGenericGCCName; }
423
425 return ConfigFiles;
426 }
427
428 const llvm::opt::OptTable &getOpts() const { return getDriverOptTable(); }
429
430 DiagnosticsEngine &getDiags() const { return Diags; }
431
432 llvm::vfs::FileSystem &getVFS() const { return *VFS; }
433
434 bool getCheckInputsExist() const { return CheckInputsExist; }
435
436 void setCheckInputsExist(bool Value) { CheckInputsExist = Value; }
437
438 bool getProbePrecompiled() const { return ProbePrecompiled; }
439 void setProbePrecompiled(bool Value) { ProbePrecompiled = Value; }
440
441 const char *getPrependArg() const { return PrependArg; }
442 void setPrependArg(const char *Value) { PrependArg = Value; }
443
445
446 const std::string &getTitle() { return DriverTitle; }
447 void setTitle(std::string Value) { DriverTitle = std::move(Value); }
448
449 std::string getTargetTriple() const { return TargetTriple; }
450
451 /// Get the path to the main clang executable.
452 const char *getClangProgramPath() const {
453 return ClangExecutable.c_str();
454 }
455
456 StringRef getPreferredLinker() const { return PreferredLinker; }
457 void setPreferredLinker(std::string Value) {
458 PreferredLinker = std::move(Value);
459 }
460
461 bool isSaveTempsEnabled() const { return SaveTemps != SaveTempsNone; }
462 bool isSaveTempsObj() const { return SaveTemps == SaveTempsObj; }
463
464 bool embedBitcodeEnabled() const { return BitcodeEmbed != EmbedNone; }
465 bool embedBitcodeInObject() const { return (BitcodeEmbed == EmbedBitcode); }
466 bool embedBitcodeMarkerOnly() const { return (BitcodeEmbed == EmbedMarker); }
467
468 bool offloadHostOnly() const { return Offload == OffloadHost; }
469 bool offloadDeviceOnly() const { return Offload == OffloadDevice; }
470
471 void setFlangF128MathLibrary(std::string name) {
472 FlangF128MathLibrary = std::move(name);
473 }
474 StringRef getFlangF128MathLibrary() const { return FlangF128MathLibrary; }
475
476 /// Compute the desired OpenMP runtime from the flags provided.
477 OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList &Args) const;
478
479 /// @}
480 /// @name Primary Functionality
481 /// @{
482
483 /// CreateOffloadingDeviceToolChains - create all the toolchains required to
484 /// support offloading devices given the programming models specified in the
485 /// current compilation. Also, update the host tool chain kind accordingly.
487
488 /// BuildCompilation - Construct a compilation object for a command
489 /// line argument vector.
490 ///
491 /// \return A compilation, or 0 if none was built for the given
492 /// argument vector. A null return value does not necessarily
493 /// indicate an error condition, the diagnostics should be queried
494 /// to determine if an error occurred.
496
497 /// ParseArgStrings - Parse the given list of strings into an
498 /// ArgList.
499 llvm::opt::InputArgList ParseArgStrings(ArrayRef<const char *> Args,
500 bool UseDriverMode,
501 bool &ContainsError) const;
502
503 /// BuildInputs - Construct the list of inputs and their types from
504 /// the given arguments.
505 ///
506 /// \param TC - The default host tool chain.
507 /// \param Args - The input arguments.
508 /// \param Inputs - The list to store the resulting compilation
509 /// inputs onto.
510 void BuildInputs(const ToolChain &TC, llvm::opt::DerivedArgList &Args,
511 InputList &Inputs) const;
512
513 /// BuildActions - Construct the list of actions to perform for the
514 /// given arguments, which are only done for a single architecture.
515 /// If the compilation is an explicit module build, delegates to
516 /// BuildDriverManagedModuleBuildActions. Otherwise, BuildDefaultActions is
517 /// used.
518 ///
519 /// \param C - The compilation that is being built.
520 /// \param Args - The input arguments.
521 /// \param Actions - The list to store the resulting actions onto.
522 void BuildActions(Compilation &C, llvm::opt::DerivedArgList &Args,
523 const InputList &Inputs, ActionList &Actions) const;
524
525 /// BuildUniversalActions - Construct the list of actions to perform
526 /// for the given arguments, which may require a universal build.
527 ///
528 /// \param C - The compilation that is being built.
529 /// \param TC - The default host tool chain.
531 const InputList &BAInputs) const;
532
533 /// BuildOffloadingActions - Construct the list of actions to perform for the
534 /// offloading toolchain that will be embedded in the host.
535 ///
536 /// \param C - The compilation that is being built.
537 /// \param Args - The input arguments.
538 /// \param Input - The input type and arguments
539 /// \param CUID - The CUID for \p Input
540 /// \param HostAction - The host action used in the offloading toolchain.
542 llvm::opt::DerivedArgList &Args,
543 const InputTy &Input, StringRef CUID,
544 Action *HostAction) const;
545
546 /// Returns the set of bound architectures active for this offload kind.
547 /// If there are no bound architctures we return a set containing only the
548 /// empty string.
550 getOffloadArchs(Compilation &C, const llvm::opt::DerivedArgList &Args,
551 Action::OffloadKind Kind, const ToolChain &TC) const;
552
553 /// Check that the file referenced by Value exists. If it doesn't,
554 /// issue a diagnostic and return false.
555 /// If TypoCorrect is true and the file does not exist, see if it looks
556 /// like a likely typo for a flag and if so print a "did you mean" blurb.
557 bool DiagnoseInputExistence(const llvm::opt::DerivedArgList &Args,
558 StringRef Value, types::ID Ty,
559 bool TypoCorrect) const;
560
561 /// BuildJobs - Bind actions to concrete tools and translate
562 /// arguments to form the list of jobs to run.
563 ///
564 /// \param C - The compilation that is being built.
565 void BuildJobs(Compilation &C) const;
566
567 /// ExecuteCompilation - Execute the compilation according to the command line
568 /// arguments and return an appropriate exit code.
569 ///
570 /// This routine handles additional processing that must be done in addition
571 /// to just running the subprocesses, for example reporting errors, setting
572 /// up response files, removing temporary files, etc.
574 SmallVectorImpl< std::pair<int, const Command *> > &FailingCommands);
575
576 /// Contains the files in the compilation diagnostic report generated by
577 /// generateCompilationDiagnostics.
580 };
581
582 /// generateCompilationDiagnostics - Generate diagnostics information
583 /// including preprocessed source file(s).
584 ///
586 Compilation &C, const Command &FailingCommand,
587 StringRef AdditionalInformation = "",
588 CompilationDiagnosticReport *GeneratedReport = nullptr);
589
590 enum class CommandStatus {
591 Crash = 1,
592 Error,
593 Ok,
594 };
595
596 enum class ReproLevel {
597 Off = 0,
598 OnCrash = static_cast<int>(CommandStatus::Crash),
599 OnError = static_cast<int>(CommandStatus::Error),
600 Always = static_cast<int>(CommandStatus::Ok),
601 };
602
605 const Command &FailingCommand, StringRef AdditionalInformation = "",
606 CompilationDiagnosticReport *GeneratedReport = nullptr) {
607 if (static_cast<int>(CS) > static_cast<int>(Level))
608 return false;
609 if (CS != CommandStatus::Crash)
610 Diags.Report(diag::err_drv_force_crash)
611 << !::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH");
612 // Hack to ensure that diagnostic notes get emitted.
613 Diags.setLastDiagnosticIgnored(false);
614 generateCompilationDiagnostics(C, FailingCommand, AdditionalInformation,
615 GeneratedReport);
616 return true;
617 }
618
619 /// @}
620 /// @name Helper Methods
621 /// @{
622
623 /// PrintActions - Print the list of actions.
624 void PrintActions(const Compilation &C) const;
625
626 /// PrintHelp - Print the help text.
627 ///
628 /// \param ShowHidden - Show hidden options.
629 void PrintHelp(bool ShowHidden) const;
630
631 /// PrintVersion - Print the driver version.
632 void PrintVersion(const Compilation &C, raw_ostream &OS) const;
633
634 /// GetFilePath - Lookup \p Name in the list of file search paths.
635 ///
636 /// \param TC - The tool chain for additional information on
637 /// directories to search.
638 //
639 // FIXME: This should be in CompilationInfo.
640 std::string GetFilePath(StringRef Name, const ToolChain &TC) const;
641
642 /// GetProgramPath - Lookup \p Name in the list of program search paths.
643 ///
644 /// \param TC - The provided tool chain for additional information on
645 /// directories to search.
646 //
647 // FIXME: This should be in CompilationInfo.
648 std::string GetProgramPath(StringRef Name, const ToolChain &TC) const;
649
650 /// Lookup the path to the Standard library module manifest.
651 ///
652 /// \param C - The compilation.
653 /// \param TC - The tool chain for additional information on
654 /// directories to search.
655 //
656 // FIXME: This should be in CompilationInfo.
657 std::string GetStdModuleManifestPath(const Compilation &C,
658 const ToolChain &TC) const;
659
660 /// HandleAutocompletions - Handle --autocomplete by searching and printing
661 /// possible flags, descriptions, and its arguments.
662 void HandleAutocompletions(StringRef PassedFlags) const;
663
664 /// HandleImmediateArgs - Handle any arguments which should be
665 /// treated before building actions or binding tools.
666 ///
667 /// \return Whether any compilation should be built for this
668 /// invocation. The compilation can only be modified when
669 /// this function returns false.
671
672 /// ConstructAction - Construct the appropriate action to do for
673 /// \p Phase on the \p Input, taking in to account arguments
674 /// like -fsyntax-only or --analyze.
676 Compilation &C, const llvm::opt::ArgList &Args, phases::ID Phase,
677 Action *Input,
678 Action::OffloadKind TargetDeviceOffloadKind = Action::OFK_None) const;
679
680 /// BuildJobsForAction - Construct the jobs to perform for the action \p A and
681 /// return an InputInfo for the result of running \p A. Will only construct
682 /// jobs for a given (Action, ToolChain, BoundArch, DeviceKind) tuple once.
684 Compilation &C, const Action *A, const ToolChain *TC, StringRef BoundArch,
685 bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
686 std::map<std::pair<const Action *, std::string>, InputInfoList>
687 &CachedResults,
688 Action::OffloadKind TargetDeviceOffloadKind) const;
689
690 /// Returns the default name for linked images (e.g., "a.out").
691 const char *getDefaultImageName() const;
692
693 /// Creates a temp file.
694 /// 1. If \p MultipleArch is false or \p BoundArch is empty, the temp file is
695 /// in the temporary directory with name $Prefix-%%%%%%.$Suffix.
696 /// 2. If \p MultipleArch is true and \p BoundArch is not empty,
697 /// 2a. If \p NeedUniqueDirectory is false, the temp file is in the
698 /// temporary directory with name $Prefix-$BoundArch-%%%%%.$Suffix.
699 /// 2b. If \p NeedUniqueDirectory is true, the temp file is in a unique
700 /// subdiretory with random name under the temporary directory, and
701 /// the temp file itself has name $Prefix-$BoundArch.$Suffix.
702 const char *CreateTempFile(Compilation &C, StringRef Prefix, StringRef Suffix,
703 bool MultipleArchs = false,
704 StringRef BoundArch = {},
705 bool NeedUniqueDirectory = false) const;
706
707 /// GetNamedOutputPath - Return the name to use for the output of
708 /// the action \p JA. The result is appended to the compilation's
709 /// list of temporary or result files, as appropriate.
710 ///
711 /// \param C - The compilation.
712 /// \param JA - The action of interest.
713 /// \param BaseInput - The original input file that this action was
714 /// triggered by.
715 /// \param BoundArch - The bound architecture.
716 /// \param AtTopLevel - Whether this is a "top-level" action.
717 /// \param MultipleArchs - Whether multiple -arch options were supplied.
718 /// \param NormalizedTriple - The normalized triple of the relevant target.
719 const char *GetNamedOutputPath(Compilation &C, const JobAction &JA,
720 const char *BaseInput, StringRef BoundArch,
721 bool AtTopLevel, bool MultipleArchs,
722 StringRef NormalizedTriple) const;
723
724 /// GetTemporaryPath - Return the pathname of a temporary file to use
725 /// as part of compilation; the file will have the given prefix and suffix.
726 ///
727 /// GCC goes to extra lengths here to be a bit more robust.
728 std::string GetTemporaryPath(StringRef Prefix, StringRef Suffix) const;
729
730 /// GetTemporaryDirectory - Return the pathname of a temporary directory to
731 /// use as part of compilation; the directory will have the given prefix.
732 std::string GetTemporaryDirectory(StringRef Prefix) const;
733
734 /// Return the pathname of the pch file in clang-cl mode.
735 std::string GetClPchPath(Compilation &C, StringRef BaseName) const;
736
737 /// ShouldUseClangCompiler - Should the clang compiler be used to
738 /// handle this action.
739 bool ShouldUseClangCompiler(const JobAction &JA) const;
740
741 /// ShouldUseFlangCompiler - Should the flang compiler be used to
742 /// handle this action.
743 bool ShouldUseFlangCompiler(const JobAction &JA) const;
744
745 /// ShouldEmitStaticLibrary - Should the linker emit a static library.
746 bool ShouldEmitStaticLibrary(const llvm::opt::ArgList &Args) const;
747
748 /// Returns true if the user has indicated a C++20 header unit mode.
749 bool hasHeaderMode() const { return CXX20HeaderType != HeaderMode_None; }
750
751 /// Get the mode for handling headers as set by fmodule-header{=}.
752 ModuleHeaderMode getModuleHeaderMode() const { return CXX20HeaderType; }
753
754 /// Returns true if we are performing any kind of LTO.
755 bool isUsingLTO() const { return getLTOMode() != LTOK_None; }
756
757 /// Get the specific kind of LTO being performed.
758 LTOKind getLTOMode() const { return LTOMode; }
759
760 /// Returns true if we are performing any kind of offload LTO.
761 bool isUsingOffloadLTO() const { return getOffloadLTOMode() != LTOK_None; }
762
763 /// Get the specific kind of offload LTO being performed.
764 LTOKind getOffloadLTOMode() const { return OffloadLTOMode; }
765
766 /// Get the CUID option.
767 const CUIDOptions &getCUIDOpts() const { return CUIDOpts; }
768
769private:
770
771 /// Tries to load options from configuration files.
772 ///
773 /// \returns true if error occurred.
774 bool loadConfigFiles();
775
776 /// Tries to load options from default configuration files (deduced from
777 /// executable filename).
778 ///
779 /// \returns true if error occurred.
780 bool loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx);
781
782 /// Tries to load options from customization file.
783 ///
784 /// \returns true if error occurred.
785 bool loadZOSCustomizationFile(llvm::cl::ExpansionContext &);
786
787 /// Read options from the specified file.
788 ///
789 /// \param [in] FileName File to read.
790 /// \param [in] Search and expansion options.
791 /// \returns true, if error occurred while reading.
792 bool readConfigFile(StringRef FileName, llvm::cl::ExpansionContext &ExpCtx);
793
794 /// Set the driver mode (cl, gcc, etc) from the value of the `--driver-mode`
795 /// option.
796 void setDriverMode(StringRef DriverModeValue);
797
798 /// Parse the \p Args list for LTO options and record the type of LTO
799 /// compilation based on which -f(no-)?lto(=.*)? option occurs last.
800 void setLTOMode(const llvm::opt::ArgList &Args);
801
802 /// BuildDefaultActions - Constructs the list of actions to perform
803 /// for the provided arguments, which are only done for a single architecture.
804 ///
805 /// \param C - The compilation that is being built.
806 /// \param Args - The input arguments.
807 /// \param Actions - The list to store the resulting actions onto.
808 void BuildDefaultActions(Compilation &C, llvm::opt::DerivedArgList &Args,
809 const InputList &Inputs, ActionList &Actions) const;
810
811 /// BuildDriverManagedModuleBuildActions - Performs a dependency
812 /// scan and constructs the list of actions to perform for dependency order
813 /// and the provided arguments. This is only done for a single a architecture.
814 ///
815 /// \param C - The compilation that is being built.
816 /// \param Args - The input arguments.
817 /// \param Actions - The list to store the resulting actions onto.
818 void BuildDriverManagedModuleBuildActions(Compilation &C,
819 llvm::opt::DerivedArgList &Args,
820 const InputList &Inputs,
821 ActionList &Actions) const;
822
823 /// Scans the leading lines of the C++ source inputs to detect C++20 module
824 /// usage.
825 ///
826 /// \returns True if module usage is detected, false otherwise, or an error on
827 /// read failure.
828 llvm::ErrorOr<bool>
829 ScanInputsForCXX20ModulesUsage(const InputList &Inputs) const;
830
831 /// Retrieves a ToolChain for a particular \p Target triple.
832 ///
833 /// Will cache ToolChains for the life of the driver object, and create them
834 /// on-demand.
835 const ToolChain &getToolChain(const llvm::opt::ArgList &Args,
836 const llvm::Triple &Target) const;
837
838 /// Retrieves a ToolChain for a particular \p Target triple for offloading.
839 ///
840 /// Will cache ToolChains for the life of the driver object, and create them
841 /// on-demand.
842 const ToolChain &getOffloadToolChain(const llvm::opt::ArgList &Args,
844 const llvm::Triple &Target,
845 const llvm::Triple &AuxTarget) const;
846
847 /// Get bitmasks for which option flags to include and exclude based on
848 /// the driver mode.
849 llvm::opt::Visibility
850 getOptionVisibilityMask(bool UseDriverMode = true) const;
851
852 /// Helper used in BuildJobsForAction. Doesn't use the cache when building
853 /// jobs specifically for the given action, but will use the cache when
854 /// building jobs for the Action's inputs.
855 InputInfoList BuildJobsForActionNoCache(
856 Compilation &C, const Action *A, const ToolChain *TC, StringRef BoundArch,
857 bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
858 std::map<std::pair<const Action *, std::string>, InputInfoList>
859 &CachedResults,
860 Action::OffloadKind TargetDeviceOffloadKind) const;
861
862 /// Return the typical executable name for the specified driver \p Mode.
863 static const char *getExecutableForDriverMode(DriverMode Mode);
864
865public:
866 /// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and
867 /// return the grouped values as integers. Numbers which are not
868 /// provided are set to 0.
869 ///
870 /// \return True if the entire string was parsed (9.2), or all
871 /// groups were parsed (10.3.5extrastuff). HadExtra is true if all
872 /// groups were parsed but extra characters remain at the end.
873 static bool GetReleaseVersion(StringRef Str, unsigned &Major, unsigned &Minor,
874 unsigned &Micro, bool &HadExtra);
875
876 /// Parse digits from a string \p Str and fulfill \p Digits with
877 /// the parsed numbers. This method assumes that the max number of
878 /// digits to look for is equal to Digits.size().
879 ///
880 /// \return True if the entire string was parsed and there are
881 /// no extra characters remaining at the end.
882 static bool GetReleaseVersion(StringRef Str,
884 /// Compute the default -fmodule-cache-path.
885 /// \return True if the system provides a default cache directory.
887};
888
889/// \return True if the last defined optimization level is -Ofast.
890/// And False otherwise.
891bool isOptimizationLevelFast(const llvm::opt::ArgList &Args);
892
893/// \return True if the argument combination will end up generating remarks.
894bool willEmitRemarks(const llvm::opt::ArgList &Args);
895
896/// Returns the driver mode option's value, i.e. `X` in `--driver-mode=X`. If \p
897/// Args doesn't mention one explicitly, tries to deduce from `ProgName`.
898/// Returns empty on failure.
899/// Common values are "gcc", "g++", "cpp", "cl" and "flang". Returned value need
900/// not be one of these.
901llvm::StringRef getDriverMode(StringRef ProgName, ArrayRef<const char *> Args);
902
903/// Checks whether the value produced by getDriverMode is for CL mode.
904bool IsClangCL(StringRef DriverMode);
905
906/// Expand response files from a clang driver or cc1 invocation.
907///
908/// \param Args The arguments that will be expanded.
909/// \param ClangCLMode Whether clang is in CL mode.
910/// \param Alloc Allocator for new arguments.
911/// \param FS Filesystem to use when expanding files.
913 bool ClangCLMode, llvm::BumpPtrAllocator &Alloc,
914 llvm::vfs::FileSystem *FS = nullptr);
915
916/// Apply a space separated list of edits to the input argument lists.
917/// See applyOneOverrideOption.
919 const char *OverrideOpts,
920 llvm::StringSet<> &SavedStrings, StringRef EnvVar,
921 raw_ostream *OS = nullptr);
922
923} // end namespace driver
924} // end namespace clang
925
926#endif
static char ID
Definition: Arena.cpp:183
Defines the Diagnostic-related interfaces.
const Decl * D
enum clang::sema::@1840::IndirectLocalPathEntry::EntryKind Kind
Defines enums used when emitting included header information.
CompileCommand Cmd
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
llvm::MachO::Target Target
Definition: MachO.h:51
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:1233
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:231
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1529
void setLastDiagnosticIgnored(bool IsIgnored)
Pretend that the last diagnostic issued was ignored, so any subsequent notes will be suppressed,...
Definition: Diagnostic.h:791
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:179
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:767
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
SmallVector< InputTy, 16 > InputList
A list of inputs and their types for the given arguments.
Definition: Driver.h:235
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:5073
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:2757
void PrintHelp(bool ShowHidden) const
PrintHelp - Print the help text.
Definition: Driver.cpp:2293
bool offloadDeviceOnly() const
Definition: Driver.h:469
bool isSaveTempsEnabled() const
Definition: Driver.h:461
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:5229
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:5771
std::string GetFilePath(StringRef Name, const ToolChain &TC) const
GetFilePath - Lookup Name in the list of file search paths.
Definition: Driver.cpp:6505
void setPreferredLinker(std::string Value)
Definition: Driver.h:457
void setCheckInputsExist(bool Value)
Definition: Driver.h:436
unsigned CCPrintProcessStats
Set CC_PRINT_PROC_STAT mode, which causes the driver to dump performance report to CC_PRINT_PROC_STAT...
Definition: Driver.h:294
DiagnosticsEngine & getDiags() const
Definition: Driver.h:430
void PrintActions(const Compilation &C) const
PrintActions - Print the list of actions.
Definition: Driver.cpp:2741
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:6215
void setFlangF128MathLibrary(std::string name)
Definition: Driver.h:471
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:406
const char * getPrependArg() const
Definition: Driver.h:441
CC1ToolFunc CC1Main
Definition: Driver.h:307
OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList &Args) const
Compute the desired OpenMP runtime from the flags provided.
Definition: Driver.cpp:881
std::string GetTemporaryDirectory(StringRef Prefix) const
GetTemporaryDirectory - Return the pathname of a temporary directory to use as part of compilation; t...
Definition: Driver.cpp:6683
bool IsDXCMode() const
Whether the driver should follow dxc.exe like behavior.
Definition: Driver.h:254
const char * getDefaultImageName() const
Returns the default name for linked images (e.g., "a.out").
Definition: Driver.cpp:6104
bool IsCLMode() const
Whether the driver should follow cl.exe like behavior.
Definition: Driver.h:247
static std::string GetResourcesPath(StringRef BinaryPath)
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:127
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:7014
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:258
unsigned CCLogDiagnostics
Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics to CCLogDiagnosticsFilename...
Definition: Driver.h:285
llvm::ArrayRef< std::string > getConfigFiles() const
Definition: Driver.h:424
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:2935
static bool getDefaultModuleCachePath(SmallVectorImpl< char > &Result)
Compute the default -fmodule-cache-path.
Definition: Clang.cpp:3850
unsigned CCGenDiagnostics
Whether the driver is generating diagnostics for debugging purposes.
Definition: Driver.h:289
bool HandleImmediateArgs(Compilation &C)
HandleImmediateArgs - Handle any arguments which should be treated before building actions or binding...
Definition: Driver.cpp:2432
const char * getClangProgramPath() const
Get the path to the main clang executable.
Definition: Driver.h:452
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:2211
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:299
static bool GetReleaseVersion(StringRef Str, unsigned &Major, unsigned &Minor, unsigned &Micro, bool &HadExtra)
GetReleaseVersion - Parse (([0-9]+)(.
Definition: Driver.cpp:7026
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:4742
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:349
std::string GetClPchPath(Compilation &C, StringRef BaseName) const
Return the pathname of the pch file in clang-cl mode.
Definition: Driver.cpp:6694
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:6153
void setPrependArg(const char *Value)
Definition: Driver.h:442
StringRef getFlangF128MathLibrary() const
Definition: Driver.h:474
const llvm::opt::OptTable & getOpts() const
Definition: Driver.h:428
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:4350
bool offloadHostOnly() const
Definition: Driver.h:468
ModuleHeaderMode getModuleHeaderMode() const
Get the mode for handling headers as set by fmodule-header{=}.
Definition: Driver.h:752
void generateCompilationDiagnostics(Compilation &C, const Command &FailingCommand, StringRef AdditionalInformation="", CompilationDiagnosticReport *GeneratedReport=nullptr)
generateCompilationDiagnostics - Generate diagnostics information including preprocessed source file(...
Definition: Driver.cpp:1965
bool hasHeaderMode() const
Returns true if the user has indicated a C++20 header unit mode.
Definition: Driver.h:749
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:2302
Action * BuildOffloadingActions(Compilation &C, llvm::opt::DerivedArgList &Args, const InputTy &Input, StringRef CUID, Action *HostAction) const
BuildOffloadingActions - Construct the list of actions to perform for the offloading toolchain that w...
Definition: Driver.cpp:4843
bool ShouldUseFlangCompiler(const JobAction &JA) const
ShouldUseFlangCompiler - Should the flang compiler be used to handle this action.
Definition: Driver.cpp:7000
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:2844
const std::string & getTitle()
Definition: Driver.h:446
std::pair< types::ID, const llvm::opt::Arg * > InputTy
An input type and its arguments.
Definition: Driver.h:232
LTOKind getOffloadLTOMode() const
Get the specific kind of offload LTO being performed.
Definition: Driver.h:764
bool isUsingOffloadLTO() const
Returns true if we are performing any kind of offload LTO.
Definition: Driver.h:761
bool embedBitcodeEnabled() const
Definition: Driver.h:464
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:6570
std::string CCLogDiagnosticsFilename
The file to log CC_LOG_DIAGNOSTICS output to, if enabled.
Definition: Driver.h:229
bool isSaveTempsObj() const
Definition: Driver.h:462
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:2345
std::string ResourceDir
The path to the compiler resource directory.
Definition: Driver.h:189
llvm::vfs::FileSystem & getVFS() const
Definition: Driver.h:432
unsigned CCPrintOptions
Set CC_PRINT_OPTIONS mode, which is like -v but logs the commands to CCPrintOptionsFilename or to std...
Definition: Driver.h:263
bool ShouldUseClangCompiler(const JobAction &JA) const
ShouldUseClangCompiler - Should the clang compiler be used to handle this action.
Definition: Driver.cpp:6985
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:6672
void setProbePrecompiled(bool Value)
Definition: Driver.h:439
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:603
@ 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:755
std::string HostBits
Information about the host which can be overridden by the user.
Definition: Driver.h:214
HeaderIncludeFormatKind CCPrintHeadersFormat
The format of the header information that is emitted.
Definition: Driver.h:268
std::string getTargetTriple() const
Definition: Driver.h:449
bool getCheckInputsExist() const
Definition: Driver.h:434
bool CCCIsCC() const
Whether the driver should follow gcc like behavior.
Definition: Driver.h:244
void setTargetAndMode(const ParsedClangName &TM)
Definition: Driver.h:444
std::string GetStdModuleManifestPath(const Compilation &C, const ToolChain &TC) const
Lookup the path to the Standard library module manifest.
Definition: Driver.cpp:6612
bool IsFlangMode() const
Whether the driver should invoke flang for fortran inputs.
Definition: Driver.h:251
bool embedBitcodeMarkerOnly() const
Definition: Driver.h:466
void setTitle(std::string Value)
Definition: Driver.h:447
llvm::function_ref< int(SmallVectorImpl< const char * > &ArgV)> CC1ToolFunc
Pointer to the ExecuteCC1Tool function, if available.
Definition: Driver.h:306
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:1476
HeaderIncludeFilteringKind CCPrintHeadersFiltering
This flag determines whether clang should filter the header information that is emitted.
Definition: Driver.h:274
const std::string & getCCCGenericGCCName() const
Name to use when invoking gcc/g++.
Definition: Driver.h:422
LTOKind getLTOMode() const
Get the specific kind of LTO being performed.
Definition: Driver.h:758
std::string HostMachine
Definition: Driver.h:214
bool embedBitcodeInObject() const
Definition: Driver.h:465
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:267
bool CCCIsCPP() const
Whether the driver is just the preprocessor.
Definition: Driver.h:241
StringRef getPreferredLinker() const
Definition: Driver.h:456
std::string HostSystem
Definition: Driver.h:214
bool CCCIsCXX() const
Whether the driver should follow g++ like behavior.
Definition: Driver.h:238
bool getProbePrecompiled() const
Definition: Driver.h:438
std::string FlangF128MathLibrary
Name of the library that provides implementations of IEEE-754 128-bit float math functions used by Fo...
Definition: Driver.h:279
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:7315
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
LTOKind
Describes the kind of LTO mode selected via -f(no-)?lto(=.*)? options.
Definition: Driver.h:58
@ LTOK_Unknown
Definition: Driver.h:62
SmallVector< InputInfo, 4 > InputInfoList
Definition: Driver.h:50
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:7143
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:7160
const llvm::opt::OptTable & getDriverOptTable()
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:7158
The JSON file list parser is used to communicate input to InstallAPI.
HeaderIncludeFilteringKind
Whether header information is filtered or not.
Definition: HeaderInclude.h:29
@ HIFIL_None
Definition: HeaderInclude.h:30
@ Result
The result type of a method or function.
HeaderIncludeFormatKind
The format in which header information is emitted.
Definition: HeaderInclude.h:22
@ HIFMT_None
Definition: HeaderInclude.h:22
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:578
llvm::SmallVector< std::string, 4 > TemporaryFiles
Definition: Driver.h:579
Helper structure used to pass information extracted from clang executable name such as i686-linux-and...
Definition: ToolChain.h:65