clang  5.0.0
Functions
Clang.cpp File Reference
#include "Clang.h"
#include "Arch/AArch64.h"
#include "Arch/ARM.h"
#include "Arch/Mips.h"
#include "Arch/PPC.h"
#include "Arch/Sparc.h"
#include "Arch/SystemZ.h"
#include "Arch/X86.h"
#include "CommonArgs.h"
#include "Hexagon.h"
#include "InputInfo.h"
#include "PS4CPU.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/ObjCRuntime.h"
#include "clang/Basic/Version.h"
#include "clang/Config/config.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Driver/XRayArgs.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/TargetParser.h"
#include "llvm/Support/YAMLParser.h"
Include dependency graph for Clang.cpp:

Go to the source code of this file.

Functions

static void CheckPreprocessingOptions (const Driver &D, const ArgList &Args)
 
static void CheckCodeGenerationOptions (const Driver &D, const ArgList &Args)
 
static void EscapeSpacesAndBackslashes (const char *Arg, SmallVectorImpl< char > &Res)
 
static void QuoteTarget (StringRef Target, SmallVectorImpl< char > &Res)
 
static void forAllAssociatedToolChains (Compilation &C, const JobAction &JA, const ToolChain &RegularToolChain, llvm::function_ref< void(const ToolChain &)> Work)
 Apply Work on the current tool chain RegularToolChain and any other offloading tool chain that is associated with the current action JA. More...
 
static bool getRefinementStep (StringRef In, const Driver &D, const Arg &A, size_t &Position)
 This is a helper function for validating the optional refinement step parameter in reciprocal argument strings. More...
 
static void ParseMRecip (const Driver &D, const ArgList &Args, ArgStringList &OutStrings)
 The -mrecip flag requires processing of many optional parameters. More...
 
static void getHexagonTargetFeatures (const ArgList &Args, std::vector< StringRef > &Features)
 
static void getWebAssemblyTargetFeatures (const ArgList &Args, std::vector< StringRef > &Features)
 
static void getAMDGPUTargetFeatures (const Driver &D, const ArgList &Args, std::vector< StringRef > &Features)
 
static void getTargetFeatures (const ToolChain &TC, const llvm::Triple &Triple, const ArgList &Args, ArgStringList &CmdArgs, bool ForAS)
 
static bool shouldUseExceptionTablesForObjCExceptions (const ObjCRuntime &runtime, const llvm::Triple &Triple)
 
static void addExceptionArgs (const ArgList &Args, types::ID InputType, const ToolChain &TC, bool KernelOrKext, const ObjCRuntime &objcRuntime, ArgStringList &CmdArgs)
 Adds exception related arguments to the driver command arguments. More...
 
static bool ShouldDisableAutolink (const ArgList &Args, const ToolChain &TC)
 
static bool ShouldDisableDwarfDirectory (const ArgList &Args, const ToolChain &TC)
 
static
codegenoptions::DebugInfoKind 
DebugLevelToInfoKind (const Arg &A)
 
static bool mustUseNonLeafFramePointerForTarget (const llvm::Triple &Triple)
 
static bool useFramePointerForTargetByDefault (const ArgList &Args, const llvm::Triple &Triple)
 
static bool shouldUseFramePointer (const ArgList &Args, const llvm::Triple &Triple)
 
static bool shouldUseLeafFramePointer (const ArgList &Args, const llvm::Triple &Triple)
 
static void addDebugCompDirArg (const ArgList &Args, ArgStringList &CmdArgs)
 Add a CC1 option to specify the debug compilation directory. More...
 
static bool shouldEnableVectorizerAtOLevel (const ArgList &Args, bool isSlpVec)
 Vectorize at all optimization levels greater than 1 except for -Oz. More...
 
static void addDashXForInput (const ArgList &Args, const InputInfo &Input, ArgStringList &CmdArgs)
 Add -x lang to CmdArgs for Input. More...
 
static void appendUserToPath (SmallVectorImpl< char > &Result)
 
static void addPGOAndCoverageFlags (Compilation &C, const Driver &D, const InputInfo &Output, const ArgList &Args, ArgStringList &CmdArgs)
 
static bool ContainsCompileAction (const Action *A)
 Check whether the given input tree contains any compilation actions. More...
 
static bool UseRelaxAll (Compilation &C, const ArgList &Args)
 Check if -relax-all should be passed to the internal assembler. More...
 
static unsigned DwarfVersionNum (StringRef ArgValue)
 
static void RenderDebugEnablingArgs (const ArgList &Args, ArgStringList &CmdArgs, codegenoptions::DebugInfoKind DebugInfoKind, unsigned DwarfVersion, llvm::DebuggerKind DebuggerTuning)
 
static void RenderDebugInfoCompressionArgs (const ArgList &Args, ArgStringList &CmdArgs, const Driver &D)
 
static const char * RelocationModelName (llvm::Reloc::Model Model)
 
static bool isSignedCharDefault (const llvm::Triple &Triple)
 
static bool isNoCommonDefault (const llvm::Triple &Triple)
 
static void CollectArgsForIntegratedAssembler (Compilation &C, const ArgList &Args, ArgStringList &CmdArgs, const Driver &D)
 
static bool maybeConsumeDash (const std::string &EH, size_t &I)
 
static EHFlags parseClangCLEHFlags (const Driver &D, const ArgList &Args)
 /EH controls whether to run destructor cleanups when exceptions are thrown. More...
 

Function Documentation

static void addDashXForInput ( const ArgList &  Args,
const InputInfo Input,
ArgStringList &  CmdArgs 
)
static

Add -x lang to CmdArgs for Input.

Definition at line 650 of file Clang.cpp.

References clang::driver::InputInfo::getType(), and clang::driver::types::getTypeName().

Referenced by clang::driver::tools::Clang::ConstructJob().

static void addDebugCompDirArg ( const ArgList &  Args,
ArgStringList &  CmdArgs 
)
static

Add a CC1 option to specify the debug compilation directory.

Definition at line 609 of file Clang.cpp.

Referenced by clang::driver::tools::Clang::ConstructJob(), and clang::driver::tools::ClangAs::ConstructJob().

static void addExceptionArgs ( const ArgList &  Args,
types::ID  InputType,
const ToolChain TC,
bool  KernelOrKext,
const ObjCRuntime objcRuntime,
ArgStringList &  CmdArgs 
)
static

Adds exception related arguments to the driver command arguments.

There's a master flag, -fexceptions and also language specific flags to enable/disable C++ and Objective-C exceptions. This makes it possible to for example disable C++ exceptions but enable Objective-C exceptions.

Definition at line 412 of file Clang.cpp.

References clang::driver::Driver::Diag(), clang::driver::ToolChain::getDriver(), clang::driver::ToolChain::getRTTIArg(), clang::driver::ToolChain::getRTTIMode(), clang::driver::ToolChain::getTriple(), clang::driver::types::isCXX(), clang::driver::types::isObjC(), clang::driver::ToolChain::RM_DisabledExplicitly, clang::driver::ToolChain::RM_DisabledImplicitly, clang::driver::ToolChain::RM_EnabledImplicitly, and shouldUseExceptionTablesForObjCExceptions().

Referenced by clang::driver::tools::Clang::ConstructJob().

static void addPGOAndCoverageFlags ( Compilation C,
const Driver D,
const InputInfo Output,
const ArgList &  Args,
ArgStringList &  CmdArgs 
)
static
static void appendUserToPath ( SmallVectorImpl< char > &  Result)
static

Definition at line 680 of file Clang.cpp.

References clang::isAlphanumeric(), and P.

Referenced by clang::driver::tools::Clang::ConstructJob().

static void CheckCodeGenerationOptions ( const Driver D,
const ArgList &  Args 
)
static

Definition at line 62 of file Clang.cpp.

References clang::driver::Driver::Diag().

Referenced by clang::driver::tools::Clang::ConstructJob().

static void CheckPreprocessingOptions ( const Driver D,
const ArgList &  Args 
)
static
static void CollectArgsForIntegratedAssembler ( Compilation C,
const ArgList &  Args,
ArgStringList &  CmdArgs,
const Driver D 
)
static
static bool ContainsCompileAction ( const Action A)
static

Check whether the given input tree contains any compilation actions.

Definition at line 840 of file Clang.cpp.

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

Referenced by UseRelaxAll().

static codegenoptions::DebugInfoKind DebugLevelToInfoKind ( const Arg &  A)
static
static unsigned DwarfVersionNum ( StringRef  ArgValue)
static
static void EscapeSpacesAndBackslashes ( const char *  Arg,
SmallVectorImpl< char > &  Res 
)
static
static void forAllAssociatedToolChains ( Compilation C,
const JobAction JA,
const ToolChain RegularToolChain,
llvm::function_ref< void(const ToolChain &)>  Work 
)
static
static void getAMDGPUTargetFeatures ( const Driver D,
const ArgList &  Args,
std::vector< StringRef > &  Features 
)
static
static void getHexagonTargetFeatures ( const ArgList &  Args,
std::vector< StringRef > &  Features 
)
static

Definition at line 276 of file Clang.cpp.

References clang::driver::tools::handleTargetFeaturesGroup().

Referenced by getTargetFeatures().

static bool getRefinementStep ( StringRef  In,
const Driver D,
const Arg &  A,
size_t Position 
)
static

This is a helper function for validating the optional refinement step parameter in reciprocal argument strings.

Return false if there is an error parsing the refinement step. Otherwise, return true and set the Position of the refinement step in the input string.

Definition at line 149 of file Clang.cpp.

References clang::driver::Driver::Diag().

Referenced by ParseMRecip().

static void getTargetFeatures ( const ToolChain TC,
const llvm::Triple &  Triple,
const ArgList &  Args,
ArgStringList &  CmdArgs,
bool  ForAS 
)
static
static void getWebAssemblyTargetFeatures ( const ArgList &  Args,
std::vector< StringRef > &  Features 
)
static

Definition at line 291 of file Clang.cpp.

References clang::driver::tools::handleTargetFeaturesGroup().

Referenced by getTargetFeatures().

static bool isNoCommonDefault ( const llvm::Triple &  Triple)
static

Definition at line 1301 of file Clang.cpp.

Referenced by clang::driver::tools::Clang::ConstructJob().

static bool isSignedCharDefault ( const llvm::Triple &  Triple)
static

Definition at line 1272 of file Clang.cpp.

Referenced by clang::driver::tools::Clang::ConstructJob().

static bool maybeConsumeDash ( const std::string &  EH,
size_t I 
)
static

Definition at line 4631 of file Clang.cpp.

Referenced by parseClangCLEHFlags().

static bool mustUseNonLeafFramePointerForTarget ( const llvm::Triple &  Triple)
static

Definition at line 516 of file Clang.cpp.

Referenced by shouldUseFramePointer().

static EHFlags parseClangCLEHFlags ( const Driver D,
const ArgList &  Args 
)
static

/EH controls whether to run destructor cleanups when exceptions are thrown.

There are three modifiers:

  • s: Cleanup after "synchronous" exceptions, aka C++ exceptions.
  • a: Cleanup after "asynchronous" exceptions, aka structured exceptions. The 'a' modifier is unimplemented and fundamentally hard in LLVM IR.
  • c: Assume that extern "C" functions are implicitly nounwind. The default is /EHs-c-, meaning cleanups are disabled.

Definition at line 4652 of file Clang.cpp.

References clang::driver::Driver::Diag(), E, I, and maybeConsumeDash().

static void ParseMRecip ( const Driver D,
const ArgList &  Args,
ArgStringList &  OutStrings 
)
static

The -mrecip flag requires processing of many optional parameters.

Definition at line 177 of file Clang.cpp.

References clang::driver::Driver::Diag(), and getRefinementStep().

Referenced by clang::driver::tools::Clang::ConstructJob().

static void QuoteTarget ( StringRef  Target,
SmallVectorImpl< char > &  Res 
)
static

Definition at line 91 of file Clang.cpp.

static const char* RelocationModelName ( llvm::Reloc::Model  Model)
static
static void RenderDebugEnablingArgs ( const ArgList &  Args,
ArgStringList &  CmdArgs,
codegenoptions::DebugInfoKind  DebugInfoKind,
unsigned  DwarfVersion,
llvm::DebuggerKind  DebuggerTuning 
)
static
static void RenderDebugInfoCompressionArgs ( const ArgList &  Args,
ArgStringList &  CmdArgs,
const Driver D 
)
static
static bool ShouldDisableAutolink ( const ArgList &  Args,
const ToolChain TC 
)
static
static bool ShouldDisableDwarfDirectory ( const ArgList &  Args,
const ToolChain TC 
)
static
static bool shouldEnableVectorizerAtOLevel ( const ArgList &  Args,
bool  isSlpVec 
)
static

Vectorize at all optimization levels greater than 1 except for -Oz.

For -Oz the loop vectorizer is disable, while the slp vectorizer is enabled.

Definition at line 619 of file Clang.cpp.

References S.

Referenced by clang::driver::tools::Clang::ConstructJob().

static bool shouldUseExceptionTablesForObjCExceptions ( const ObjCRuntime runtime,
const llvm::Triple &  Triple 
)
static

Definition at line 392 of file Clang.cpp.

References clang::ObjCRuntime::isNonFragile().

Referenced by addExceptionArgs().

static bool shouldUseFramePointer ( const ArgList &  Args,
const llvm::Triple &  Triple 
)
static
static bool shouldUseLeafFramePointer ( const ArgList &  Args,
const llvm::Triple &  Triple 
)
static

Definition at line 593 of file Clang.cpp.

References useFramePointerForTargetByDefault().

Referenced by clang::driver::tools::Clang::ConstructJob().

static bool useFramePointerForTargetByDefault ( const ArgList &  Args,
const llvm::Triple &  Triple 
)
static
static bool UseRelaxAll ( Compilation C,
const ArgList &  Args 
)
static

Check if -relax-all should be passed to the internal assembler.

This is done by default when compiling non-assembler source with -O0.

Definition at line 853 of file Clang.cpp.

References ContainsCompileAction(), and clang::driver::Compilation::getActions().

Referenced by CollectArgsForIntegratedAssembler().