clang  14.0.0git
Enumerations | Functions
Driver.cpp File Reference
#include "clang/Driver/Driver.h"
#include "ToolChains/AIX.h"
#include "ToolChains/AMDGPU.h"
#include "ToolChains/AMDGPUOpenMP.h"
#include "ToolChains/AVR.h"
#include "ToolChains/Ananas.h"
#include "ToolChains/BareMetal.h"
#include "ToolChains/Clang.h"
#include "ToolChains/CloudABI.h"
#include "ToolChains/Contiki.h"
#include "ToolChains/CrossWindows.h"
#include "ToolChains/Cuda.h"
#include "ToolChains/Darwin.h"
#include "ToolChains/DragonFly.h"
#include "ToolChains/FreeBSD.h"
#include "ToolChains/Fuchsia.h"
#include "ToolChains/Gnu.h"
#include "ToolChains/HIP.h"
#include "ToolChains/Haiku.h"
#include "ToolChains/Hexagon.h"
#include "ToolChains/Hurd.h"
#include "ToolChains/Lanai.h"
#include "ToolChains/Linux.h"
#include "ToolChains/MSP430.h"
#include "ToolChains/MSVC.h"
#include "ToolChains/MinGW.h"
#include "ToolChains/Minix.h"
#include "ToolChains/MipsLinux.h"
#include "ToolChains/Myriad.h"
#include "ToolChains/NaCl.h"
#include "ToolChains/NetBSD.h"
#include "ToolChains/OpenBSD.h"
#include "ToolChains/PPCLinux.h"
#include "ToolChains/PS4CPU.h"
#include "ToolChains/RISCVToolchain.h"
#include "ToolChains/Solaris.h"
#include "ToolChains/TCE.h"
#include "ToolChains/VEToolchain.h"
#include "ToolChains/WebAssembly.h"
#include "ToolChains/XCore.h"
#include "ToolChains/ZOS.h"
#include "clang/Basic/TargetID.h"
#include "clang/Basic/Version.h"
#include "clang/Config/config.h"
#include "clang/Driver/Action.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Job.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallSet.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/FormatVariadic.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/MD5.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/StringSaver.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include <map>
#include <memory>
#include <utility>

Go to the source code of this file.


enum  { TopLevelAction = 0, HeadSibAction = 1, OtherSibAction = 2 }


static llvm::Triple getHIPOffloadTargetTriple ()
static Arg * MakeInputArg (DerivedArgList &Args, const OptTable &Opts, StringRef Value, bool Claim=true)
static llvm::Triple computeTargetTriple (const Driver &D, StringRef TargetTriple, const ArgList &Args, StringRef DarwinArchName="")
 Compute target triple from args. More...
static driver::LTOKind parseLTOMode (Driver &D, const llvm::opt::ArgList &Args, OptSpecifier OptEq, OptSpecifier OptNeg)
static bool searchForFile (SmallVectorImpl< char > &FilePath, ArrayRef< StringRef > Dirs, StringRef FileName)
 Looks the given directories for the specified file. More...
static void printArgList (raw_ostream &OS, const llvm::opt::ArgList &Args)
static void PrintDiagnosticCategories (raw_ostream &OS)
 PrintDiagnosticCategories - Implement the –print-diagnostic-categories option. More...
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. More...
static std::string GetTriplePlusArchString (const ToolChain *TC, StringRef BoundArch, Action::OffloadKind OffloadKind)
 Return a string that uniquely identifies the result of a job. More...
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. More...
static bool HasPreprocessOutput (const Action &JA)
static bool ScanDirForExecutable (SmallString< 128 > &Dir, StringRef Name)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Definition at line 1931 of file Driver.cpp.

Function Documentation

◆ computeTargetTriple()

static llvm::Triple computeTargetTriple ( const Driver D,
StringRef  TargetTriple,
const ArgList &  Args,
StringRef  DarwinArchName = "" 

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 426 of file Driver.cpp.

References clang::driver::Driver::Diag(), clang::interp::LE(), normalize(), clang::driver::tools::darwin::setTripleTypeForMachOArchName(), and clang::Target.

◆ ContainsCompileOrAssembleAction()

static bool ContainsCompileOrAssembleAction ( const Action A)

Check whether the given input tree contains any compilation or assembly actions.

Definition at line 2035 of file Driver.cpp.

References clang::driver::Action::inputs().

Referenced by clang::driver::Driver::BuildUniversalActions().

◆ getHIPOffloadTargetTriple()

static llvm::Triple getHIPOffloadTargetTriple ( )

Definition at line 101 of file Driver.cpp.

Referenced by clang::driver::Driver::CreateOffloadingDeviceToolChains().

◆ GetTriplePlusArchString()

static std::string GetTriplePlusArchString ( const ToolChain TC,
StringRef  BoundArch,
Action::OffloadKind  OffloadKind 

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 4512 of file Driver.cpp.

References clang::driver::Action::GetOffloadKindName(), clang::driver::ToolChain::getTriple(), and string().

Referenced by clang::driver::Driver::BuildJobsForAction().

◆ HasPreprocessOutput()

static bool HasPreprocessOutput ( const Action JA)

◆ MakeCLOutputFilename()

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.

If ArgValue does not provide a filename, then use BaseName, and use the extension suitable for FileType.

Definition at line 4848 of file Driver.cpp.

References Filename, and clang::driver::types::getTypeTempSuffix().

Referenced by clang::driver::Driver::GetNamedOutputPath().

◆ MakeInputArg()

static Arg* MakeInputArg ( DerivedArgList &  Args,
const OptTable &  Opts,
StringRef  Value,
bool  Claim = true 

Definition at line 321 of file Driver.cpp.

Referenced by clang::driver::Driver::BuildInputs().

◆ parseLTOMode()

static driver::LTOKind parseLTOMode ( Driver D,
const llvm::opt::ArgList &  Args,
OptSpecifier  OptEq,
OptSpecifier  OptNeg 

◆ PrintActions1()

static unsigned PrintActions1 ( const Compilation C,
Action A,
std::map< Action *, unsigned > &  Ids,
Twine  Indent = {},
int  Kind = TopLevelAction 

Definition at line 1940 of file Driver.cpp.

Referenced by clang::driver::Driver::PrintActions().

◆ printArgList()

static void printArgList ( raw_ostream &  OS,
const llvm::opt::ArgList &  Args 

Definition at line 1220 of file Driver.cpp.

Referenced by clang::driver::Driver::generateCompilationDiagnostics().

◆ PrintDiagnosticCategories()

static void PrintDiagnosticCategories ( raw_ostream &  OS)

PrintDiagnosticCategories - Implement the –print-diagnostic-categories option.

Definition at line 1654 of file Driver.cpp.

References clang::DiagnosticIDs::getCategoryNameFromID(), clang::DiagnosticIDs::getNumberOfCategories(), and max().

Referenced by clang::driver::Driver::HandleImmediateArgs().

◆ ScanDirForExecutable()

static bool ScanDirForExecutable ( SmallString< 128 > &  Dir,
StringRef  Name 

Definition at line 5171 of file Driver.cpp.

◆ searchForFile()

static bool searchForFile ( SmallVectorImpl< char > &  FilePath,
ArrayRef< StringRef >  Dirs,
StringRef  FileName 

Looks the given directories for the specified file.

[out]FilePathFile path, if the file was found.
[in]DirsDirectories used for the search.
[in]FileNameName of the file to search for.
True if file was found.

Looks for file specified by FileName sequentially in directories specified by Dirs.

Definition at line 797 of file Driver.cpp.