|
clang 24.0.0git
|
#include "clang/Driver/Driver.h"#include "ClangCLArgs.h"#include "ToolChains/AIX.h"#include "ToolChains/AMDGPU.h"#include "ToolChains/AVR.h"#include "ToolChains/Arch/RISCV.h"#include "ToolChains/BareMetal.h"#include "ToolChains/Clang.h"#include "ToolChains/CrossWindows.h"#include "ToolChains/Cuda.h"#include "ToolChains/Cygwin.h"#include "ToolChains/Darwin.h"#include "ToolChains/DragonFly.h"#include "ToolChains/FreeBSD.h"#include "ToolChains/Fuchsia.h"#include "ToolChains/Gnu.h"#include "ToolChains/HIPAMD.h"#include "ToolChains/HIPSPV.h"#include "ToolChains/HLSL.h"#include "ToolChains/Haiku.h"#include "ToolChains/Hexagon.h"#include "ToolChains/Hurd.h"#include "ToolChains/LFILinux.h"#include "ToolChains/Lanai.h"#include "ToolChains/Linux.h"#include "ToolChains/MSP430.h"#include "ToolChains/MSVC.h"#include "ToolChains/Managarm.h"#include "ToolChains/MinGW.h"#include "ToolChains/MipsLinux.h"#include "ToolChains/NetBSD.h"#include "ToolChains/OHOS.h"#include "ToolChains/OpenBSD.h"#include "ToolChains/PPCFreeBSD.h"#include "ToolChains/PPCLinux.h"#include "ToolChains/PS4CPU.h"#include "ToolChains/SPIRV.h"#include "ToolChains/SPIRVOpenMP.h"#include "ToolChains/SYCL.h"#include "ToolChains/Serenity.h"#include "ToolChains/Solaris.h"#include "ToolChains/TCE.h"#include "ToolChains/UEFI.h"#include "ToolChains/VEToolchain.h"#include "ToolChains/WebAssembly.h"#include "ToolChains/XCore.h"#include "ToolChains/ZOS.h"#include "clang/Basic/DiagnosticDriver.h"#include "clang/Basic/TargetID.h"#include "clang/Basic/Version.h"#include "clang/Config/config.h"#include "clang/Driver/Action.h"#include "clang/Driver/CommonArgs.h"#include "clang/Driver/Compilation.h"#include "clang/Driver/InputInfo.h"#include "clang/Driver/Job.h"#include "clang/Driver/ModulesDriver.h"#include "clang/Driver/Phases.h"#include "clang/Driver/SanitizerArgs.h"#include "clang/Driver/Tool.h"#include "clang/Driver/ToolChain.h"#include "clang/Driver/Types.h"#include "clang/Frontend/CompilerInvocation.h"#include "clang/Options/OptionUtils.h"#include "clang/Options/Options.h"#include "clang/ScalableStaticAnalysis/Core/Serialization/SerializationFormatRegistry.h"#include "clang/ScalableStaticAnalysis/Core/TUSummary/ExtractorRegistry.h"#include "clang/ScalableStaticAnalysis/SSAFForceLinker.h"#include "llvm/ADT/ArrayRef.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/ScopeExit.h"#include "llvm/ADT/SmallSet.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/StringExtras.h"#include "llvm/ADT/StringRef.h"#include "llvm/ADT/StringSet.h"#include "llvm/ADT/StringSwitch.h"#include "llvm/Config/llvm-config.h"#include "llvm/MC/TargetRegistry.h"#include "llvm/Option/Arg.h"#include "llvm/Option/ArgList.h"#include "llvm/Option/OptSpecifier.h"#include "llvm/Option/OptTable.h"#include "llvm/Option/Option.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/ErrorHandling.h"#include "llvm/Support/ExitCodes.h"#include "llvm/Support/FileSystem.h"#include "llvm/Support/FileUtilities.h"#include "llvm/Support/FormatVariadic.h"#include "llvm/Support/IOSandbox.h"#include "llvm/Support/JSON.h"#include "llvm/Support/MD5.h"#include "llvm/Support/MemoryBuffer.h"#include "llvm/Support/Path.h"#include "llvm/Support/PrettyStackTrace.h"#include "llvm/Support/Process.h"#include "llvm/Support/Program.h"#include "llvm/Support/Regex.h"#include "llvm/Support/StringSaver.h"#include "llvm/Support/TarWriter.h"#include "llvm/Support/VirtualFileSystem.h"#include "llvm/Support/raw_ostream.h"#include "llvm/TargetParser/Host.h"#include "llvm/TargetParser/RISCVISAInfo.h"#include <cstdlib>#include <map>#include <memory>#include <optional>#include <set>#include <string>#include <utility>Go to the source code of this file.
Typedefs | |
| using | TripleSet = std::multiset<llvm::Triple> |
Enumerations | |
| enum | { TopLevelAction = 0 , HeadSibAction = 1 , OtherSibAction = 2 } |
Functions | |
| template<typename F> | |
| static bool | usesInput (const ArgList &Args, F &&Fn) |
| static bool | isIncludeDirArg (StringRef Arg) |
| static void | printCXXStdlibIncludeDirs (const ToolChain &TC, const ArgList &Args) |
| static void | setZosTargetVersion (const Driver &D, llvm::Triple &Target, StringRef ArgTarget) |
| static llvm::Triple | computeTargetTriple (const Driver &D, StringRef TargetTriple, const ArgList &Args, StringRef ArchName="") |
| Compute target triple from args. | |
| static llvm::SmallVector< std::string > | getSystemOffloadArchs (Compilation &C, Action::OffloadKind Kind) |
| static llvm::Triple | getSYCLDefaultTriple (const llvm::Triple &HostTriple) |
| static TripleSet | inferOffloadToolchains (Compilation &C, Action::OffloadKind Kind) |
| static void | appendOneArg (InputArgList &Args, const Arg *Opt) |
| static bool | findTripleConfigFile (llvm::cl::ExpansionContext &ExpCtx, SmallString< 128 > &ConfigFilePath, llvm::Triple Triple, std::string Suffix) |
| static void | printArgList (raw_ostream &OS, const llvm::opt::ArgList &Args) |
| static void | PrintDiagnosticCategories (raw_ostream &OS) |
| PrintDiagnosticCategories - Implement the –print-diagnostic-categories option. | |
| static unsigned | PrintActions1 (const Compilation &C, Action *A, std::map< Action *, unsigned > &Ids, Twine Indent={}, int Kind=TopLevelAction) |
| static bool | ContainsCompileOrAssembleAction (const Action *A) |
| Check whether the given input tree contains any compilation or assembly actions. | |
| static types::ID | CXXHeaderUnitType (ModuleHeaderMode HM) |
| static bool | shouldBundleHIPAsm (const Compilation &C, const llvm::opt::DerivedArgList &Args, const Driver &D) |
HIP non-RDC -S for AMDGCN: emit host and device assembly separately and bundle with clang-offload-bundler, instead of llvm-offload-binary / clang-linker-wrapper fatbin embedding. | |
| static bool | isPlainSPIRV (const llvm::Triple &Triple) |
| static StringRef | getCanonicalArchString (Compilation &C, const llvm::opt::DerivedArgList &Args, StringRef ArchStr, const llvm::Triple &Triple, Action::OffloadKind Kind) |
Returns the canonical name for the offloading architecture ArchStr on Triple, or an empty string after diagnosing an architecture that Triple does not support. | |
| static std::optional< std::pair< llvm::StringRef, llvm::StringRef > > | getConflictOffloadArchCombination (const llvm::DenseSet< StringRef > &Archs, llvm::Triple Triple) |
| Checks if the set offloading architectures does not conflict. | |
| static bool | isOffloadDeviceCC1JobCandidate (Command &Job) |
| static std::string | getOffloadDeviceCC1ParallelJobGroup (const Command &Job) |
| static void | claimAndDiagnoseOffloadJobs (const Driver &D, const ArgList &Args) |
| static void | markOffloadDeviceCC1JobsForParallelExecution (Compilation &C) |
| static std::string | GetTriplePlusArchString (const ToolChain *TC, BoundArch BA, Action::OffloadKind OffloadKind) |
| Return a string that uniquely identifies the result of a job. | |
| static void | handleTimeTrace (Compilation &C, const ArgList &Args, const JobAction *JA, const char *BaseInput, const InputInfo &Result) |
| static const char * | MakeCLOutputFilename (const ArgList &Args, StringRef ArgValue, StringRef BaseName, types::ID FileType) |
| Create output filename based on ArgValue, which could either be a full filename, filename without extension, or a directory. | |
| static bool | HasPreprocessOutput (const Action &JA) |
| static const char * | GetModuleOutputPath (Compilation &C, const JobAction &JA, const char *BaseInput) |
| static bool | ScanDirForExecutable (SmallString< 128 > &Dir, StringRef Name) |
| static const char * | GetStableCStr (llvm::StringSet<> &SavedStrings, StringRef S) |
| static void | applyOneOverrideOption (raw_ostream &OS, SmallVectorImpl< const char * > &Args, StringRef Edit, llvm::StringSet<> &SavedStrings) |
| Apply a list of edits to the input argument lists. | |
Variables | |
| static const char | BugReportMsg [] |
| using TripleSet = std::multiset<llvm::Triple> |
Definition at line 990 of file Driver.cpp.
| anonymous enum |
| Enumerator | |
|---|---|
| TopLevelAction | |
| HeadSibAction | |
| OtherSibAction | |
Definition at line 2930 of file Driver.cpp.
|
static |
Definition at line 1276 of file Driver.cpp.
References clang::Copy.
Referenced by clang::driver::Driver::BuildCompilation().
|
static |
Apply a list of edits to the input argument lists.
The input string is a space separated list of edits to perform, they are applied in order to the input argument lists. Edits should be one of the following forms:
'#': Silence information about the changes to the command line arguments.
'^FOO': Add FOO as a new argument at the beginning of the command line right after the name of the compiler executable.
'+FOO': Add FOO as a new argument at the end of the command line.
's/XXX/YYY/': Substitute the regular expression XXX with YYY in the command line.
'xOPTION': Removes all instances of the literal argument OPTION.
'XOPTION': Removes all instances of the literal argument OPTION, and the following argument.
'Ox': Removes all flags matching 'O' or 'O[sz0-9]' and adds 'Ox' at the end of the command line.
| OS | - The stream to write edit information to. |
| Args | - The vector of command line arguments. |
| Edit | - The override command to perform. |
| SavedStrings | - Set to use for storing string representations. |
Definition at line 6763 of file Driver.cpp.
References GetStableCStr().
Referenced by clang::driver::applyOverrideOptions().
|
static |
Definition at line 4675 of file Driver.cpp.
References clang::driver::Driver::Diag(), and clang::driver::tools::parseOffloadJobs().
Referenced by clang::driver::Driver::BuildJobs().
|
static |
Compute target triple from args.
This routine provides the logic to compute a target triple from various args passed to the driver and the default triple string.
Definition at line 661 of file Driver.cpp.
References clang::driver::Driver::Diag(), clang::driver::toolchains::MinGW::fixTripleArch(), clang::driver::tools::riscv::getRISCVArch(), clang::driver::Driver::IsFlangMode(), clang::driver::tools::darwin::setTripleTypeForMachOArchName(), setZosTargetVersion(), and clang::Target.
Referenced by clang::driver::Driver::BuildCompilation().
Check whether the given input tree contains any compilation or assembly actions.
Definition at line 3033 of file Driver.cpp.
References ContainsCompileOrAssembleAction(), clang::driver::Action::inputs(), and clang::isa().
Referenced by clang::driver::Driver::BuildUniversalActions(), and ContainsCompileOrAssembleAction().
|
static |
Definition at line 3212 of file Driver.cpp.
References clang::driver::HeaderMode_Default, clang::driver::HeaderMode_None, clang::driver::HeaderMode_System, and clang::driver::HeaderMode_User.
Referenced by clang::driver::Driver::BuildInputs().
|
static |
Definition at line 1442 of file Driver.cpp.
|
static |
Returns the canonical name for the offloading architecture ArchStr on Triple, or an empty string after diagnosing an architecture that Triple does not support.
Definition at line 3966 of file Driver.cpp.
References Arch, clang::C, clang::getCanonicalTargetID(), clang::getOffloadArchSubArch(), clang::getProcessorFromTargetID(), clang::OffloadArch::getUnknown(), isPlainSPIRV(), clang::OffloadArchToString(), clang::driver::Action::OFK_SYCL, and clang::StringToOffloadArch().
Referenced by clang::driver::Driver::getOffloadArchs().
|
static |
Checks if the set offloading architectures does not conflict.
Returns the incompatible pair if a conflict occurs.
Definition at line 4041 of file Driver.cpp.
References clang::getConflictTargetIDCombination().
Referenced by clang::driver::Driver::getOffloadArchs().
|
static |
Definition at line 5669 of file Driver.cpp.
References clang::C, clang::driver::tools::getCXX20NamedModuleOutputPath(), clang::driver::Action::getType(), and clang::isa().
Referenced by clang::driver::Driver::GetNamedOutputPath().
|
static |
Definition at line 4663 of file Driver.cpp.
References clang::driver::Command::getCreator(), clang::driver::Action::GetOffloadKindName(), clang::driver::Command::getSource(), clang::driver::Tool::getToolChain(), clang::driver::ToolChain::getTripleString(), and clang::driver::types::getTypeName().
Referenced by markOffloadDeviceCC1JobsForParallelExecution().
|
static |
Definition at line 6731 of file Driver.cpp.
Referenced by applyOneOverrideOption().
|
static |
HostTriple: spirv64 on a 64-bit host, spirv32 otherwise. Definition at line 994 of file Driver.cpp.
Referenced by inferOffloadToolchains().
|
static |
Definition at line 947 of file Driver.cpp.
References Arch, clang::C, clang::driver::Action::GetOffloadKindName(), clang::driver::Action::OFK_Cuda, clang::driver::Action::OFK_HIP, and clang::driver::Action::OFK_SYCL.
Referenced by inferOffloadToolchains().
|
static |
Return a string that uniquely identifies the result of a job.
The bound arch is not necessarily represented in the toolchain's triple – for example, armv7 and armv7s both map to the same triple – so we need both in our map. Also, we need to add the offloading device kind, as the same tool chain can be used for host and device for some programming models, e.g. OpenMP.
Definition at line 5237 of file Driver.cpp.
References clang::BoundArch::ArchName, clang::BoundArch::empty(), clang::driver::Action::GetOffloadKindName(), and clang::driver::ToolChain::getTriple().
Referenced by clang::driver::Driver::BuildJobsForAction().
|
static |
Definition at line 5268 of file Driver.cpp.
References Arch, clang::C, clang::driver::ToolChain::getEffectiveTriple(), clang::driver::Action::getOffloadingArch(), clang::driver::Action::getOffloadingDeviceKind(), clang::driver::Action::GetOffloadingFileNamePrefix(), clang::driver::Action::getOffloadingHostActiveKinds(), clang::driver::Action::getOffloadingToolChain(), and clang::driver::Action::OFK_None.
Definition at line 5608 of file Driver.cpp.
References clang::driver::Action::getInputs(), HasPreprocessOutput(), and clang::isa().
Referenced by clang::driver::Driver::GetNamedOutputPath(), and HasPreprocessOutput().
|
static |
Definition at line 1001 of file Driver.cpp.
References Arch, clang::C, clang::getProcessorFromTargetID(), getSYCLDefaultTriple(), getSystemOffloadArchs(), clang::OffloadArchToTriple(), clang::driver::Action::OFK_Cuda, clang::driver::Action::OFK_HIP, clang::driver::Action::OFK_OpenMP, clang::driver::Action::OFK_SYCL, and clang::StringToOffloadArch().
Referenced by clang::driver::Driver::CreateOffloadingDeviceToolChains().
|
static |
Definition at line 140 of file Driver.cpp.
Referenced by printCXXStdlibIncludeDirs().
Definition at line 4640 of file Driver.cpp.
References clang::BoundArch::empty(), clang::driver::Command::getBoundArch(), clang::driver::Command::getCreator(), clang::driver::Tool::getName(), clang::driver::Command::getSource(), clang::driver::Tool::getToolChain(), clang::driver::ToolChain::getTriple(), clang::isa(), clang::driver::Action::OFK_Host, clang::driver::Action::OFK_None, and clang::driver::Command::setBoundArch().
Referenced by markOffloadDeviceCC1JobsForParallelExecution().
|
static |
Triple is a SPIR-V target with no vendor or OS, such as spirv64-unknown-unknown. Definition at line 3957 of file Driver.cpp.
Referenced by getCanonicalArchString().
|
static |
Create output filename based on ArgValue, which could either be a full filename, filename without extension, or a directory.
If ArgValue does not provide a filename, then use BaseName, and use the extension suitable for FileType.
Definition at line 5579 of file Driver.cpp.
References clang::driver::types::getTypeTempSuffix().
Referenced by clang::driver::Driver::GetNamedOutputPath().
|
static |
Definition at line 4687 of file Driver.cpp.
References clang::C, getOffloadDeviceCC1ParallelJobGroup(), and isOffloadDeviceCC1JobCandidate().
Referenced by clang::driver::Driver::BuildJobs().
|
static |
Definition at line 2939 of file Driver.cpp.
References clang::C, and clang::Indent().
Referenced by clang::driver::Driver::PrintActions().
|
static |
Definition at line 1979 of file Driver.cpp.
Referenced by clang::driver::Driver::generateCompilationDiagnostics().
|
static |
Definition at line 145 of file Driver.cpp.
References clang::driver::ToolChain::AddClangCXXStdlibIncludeArgs(), clang::driver::ToolChain::AddClangCXXStdlibIsystemArgs(), and isIncludeDirArg().
Referenced by clang::driver::Driver::HandleImmediateArgs().
|
static |
PrintDiagnosticCategories - Implement the –print-diagnostic-categories option.
Definition at line 2589 of file Driver.cpp.
References clang::DiagnosticIDs::getCategoryNameFromID(), clang::DiagnosticIDs::getNumberOfCategories(), and max().
Referenced by clang::driver::Driver::HandleImmediateArgs().
|
static |
Definition at line 6047 of file Driver.cpp.
Referenced by clang::driver::Driver::GetProgramPath().
|
static |
Definition at line 593 of file Driver.cpp.
References clang::driver::Driver::Diag(), and V.
Referenced by computeTargetTriple().
|
static |
HIP non-RDC -S for AMDGCN: emit host and device assembly separately and bundle with clang-offload-bundler, instead of llvm-offload-binary / clang-linker-wrapper fatbin embedding.
Definition at line 3623 of file Driver.cpp.
References clang::C, clang::driver::ToolChain::getTriple(), clang::driver::Driver::offloadDeviceOnly(), and clang::driver::Action::OFK_HIP.
Referenced by clang::driver::Driver::BuildOffloadingActions().
|
static |
Definition at line 129 of file Driver.cpp.
References getKind(), clang::driver::types::lookupTypeForExtension(), and clang::driver::types::lookupTypeForTypeSpecifier().
|
static |
Definition at line 2089 of file Driver.cpp.
Referenced by clang::driver::Driver::generateCompilationDiagnostics().