static bool ParseTBDGenArgs(TBDGenOptions &Opts, ArgList &Args, DiagnosticEngine &Diags, CompilerInvocation &Invocation) { using namespace options; Opts.HasMultipleIGMs = Invocation.getSILOptions().hasMultipleIGMs(); if (const Arg *A = Args.getLastArg(OPT_module_link_name)) { Opts.ModuleLinkName = A->getValue(); } if (const Arg *A = Args.getLastArg(OPT_tbd_install_name)) { Opts.InstallName = A->getValue(); } if (const Arg *A = Args.getLastArg(OPT_tbd_compatibility_version)) { if (auto vers = version::Version::parseVersionString( A->getValue(), SourceLoc(), &Diags)) { Opts.CompatibilityVersion = *vers; } } if (const Arg *A = Args.getLastArg(OPT_tbd_current_version)) { if (auto vers = version::Version::parseVersionString( A->getValue(), SourceLoc(), &Diags)) { Opts.CurrentVersion = *vers; } } return false; }
static bool ParseClangImporterArgs(ClangImporterOptions &Opts, ArgList &Args, DiagnosticEngine &Diags, StringRef workingDirectory) { using namespace options; if (const Arg *A = Args.getLastArg(OPT_module_cache_path)) { Opts.ModuleCachePath = A->getValue(); } if (const Arg *A = Args.getLastArg(OPT_target_cpu)) Opts.TargetCPU = A->getValue(); if (const Arg *A = Args.getLastArg(OPT_index_store_path)) Opts.IndexStorePath = A->getValue(); for (const Arg *A : Args.filtered(OPT_Xcc)) { Opts.ExtraArgs.push_back(A->getValue()); } for (auto A : Args.getAllArgValues(OPT_debug_prefix_map)) { // Forward -debug-prefix-map arguments from Swift to Clang as // -fdebug-prefix-map. This is required to ensure DIFiles created there, // like "<swift-imported-modules>", have their paths remapped properly. // (Note, however, that Clang's usage of std::map means that the remapping // may not be applied in the same order, which can matter if one mapping is // a prefix of another.) Opts.ExtraArgs.push_back("-fdebug-prefix-map=" + A); } if (!workingDirectory.empty()) { // Provide a working directory to Clang as well if there are any -Xcc // options, in case some of them are search-related. But do it at the // beginning, so that an explicit -Xcc -working-directory will win. Opts.ExtraArgs.insert(Opts.ExtraArgs.begin(), { "-working-directory", workingDirectory }); } Opts.InferImportAsMember |= Args.hasArg(OPT_enable_infer_import_as_member); Opts.DumpClangDiagnostics |= Args.hasArg(OPT_dump_clang_diagnostics); if (Args.hasArg(OPT_embed_bitcode)) Opts.Mode = ClangImporterOptions::Modes::EmbedBitcode; if (auto *A = Args.getLastArg(OPT_import_objc_header)) Opts.BridgingHeader = A->getValue(); Opts.DisableSwiftBridgeAttr |= Args.hasArg(OPT_disable_swift_bridge_attr); Opts.DisableModulesValidateSystemHeaders |= Args.hasArg(OPT_disable_modules_validate_system_headers); Opts.DisableAdapterModules |= Args.hasArg(OPT_emit_imported_modules); if (const Arg *A = Args.getLastArg(OPT_pch_output_dir)) { Opts.PrecompiledHeaderOutputDir = A->getValue(); Opts.PCHDisableValidation |= Args.hasArg(OPT_pch_disable_validation); } Opts.DebuggerSupport |= Args.hasArg(OPT_debugger_support); return false; }
void tools::SHAVE::Compiler::ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, const ArgList &Args, const char *LinkingOutput) const { ArgStringList CmdArgs; assert(Inputs.size() == 1); const InputInfo &II = Inputs[0]; assert(II.getType() == types::TY_C || II.getType() == types::TY_CXX || II.getType() == types::TY_PP_CXX); if (JA.getKind() == Action::PreprocessJobClass) { Args.ClaimAllArgs(); CmdArgs.push_back("-E"); } else { assert(Output.getType() == types::TY_PP_Asm); // Require preprocessed asm. CmdArgs.push_back("-S"); CmdArgs.push_back("-fno-exceptions"); // Always do this even if unspecified. } CmdArgs.push_back("-DMYRIAD2"); // Append all -I, -iquote, -isystem paths, defines/undefines, 'f' // flags, 'g' flags, 'M' flags, optimize flags, warning options, // mcpu flags, mllvm flags, and Xclang flags. // These are spelled the same way in clang and moviCompile. Args.AddAllArgsExcept( CmdArgs, {options::OPT_I_Group, options::OPT_clang_i_Group, options::OPT_std_EQ, options::OPT_D, options::OPT_U, options::OPT_f_Group, options::OPT_f_clang_Group, options::OPT_g_Group, options::OPT_M_Group, options::OPT_O_Group, options::OPT_W_Group, options::OPT_mcpu_EQ, options::OPT_mllvm, options::OPT_Xclang}, {options::OPT_fno_split_dwarf_inlining}); Args.hasArg(options::OPT_fno_split_dwarf_inlining); // Claim it if present. // If we're producing a dependency file, and assembly is the final action, // then the name of the target in the dependency file should be the '.o' // file, not the '.s' file produced by this step. For example, instead of // /tmp/mumble.s: mumble.c .../someheader.h // the filename on the lefthand side should be "mumble.o" if (Args.getLastArg(options::OPT_MF) && !Args.getLastArg(options::OPT_MT) && C.getActions().size() == 1 && C.getActions()[0]->getKind() == Action::AssembleJobClass) { Arg *A = Args.getLastArg(options::OPT_o); if (A) { CmdArgs.push_back("-MT"); CmdArgs.push_back(Args.MakeArgString(A->getValue())); } } CmdArgs.push_back(II.getFilename()); CmdArgs.push_back("-o"); CmdArgs.push_back(Output.getFilename()); std::string Exec = Args.MakeArgString(getToolChain().GetProgramPath("moviCompile")); C.addCommand(llvm::make_unique<Command>(JA, *this, Args.MakeArgString(Exec), CmdArgs, Inputs)); }
static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args, DiagnosticEngine &Diags, StringRef workingDirectory) { using namespace options; namespace path = llvm::sys::path; auto resolveSearchPath = [workingDirectory](StringRef searchPath) -> std::string { if (workingDirectory.empty() || path::is_absolute(searchPath)) return searchPath; SmallString<64> fullPath{workingDirectory}; path::append(fullPath, searchPath); return fullPath.str(); }; for (const Arg *A : Args.filtered(OPT_I)) { Opts.ImportSearchPaths.push_back(resolveSearchPath(A->getValue())); } for (const Arg *A : Args.filtered(OPT_F, OPT_Fsystem)) { Opts.FrameworkSearchPaths.push_back({resolveSearchPath(A->getValue()), /*isSystem=*/A->getOption().getID() == OPT_Fsystem}); } for (const Arg *A : Args.filtered(OPT_L)) { Opts.LibrarySearchPaths.push_back(resolveSearchPath(A->getValue())); } for (const Arg *A : Args.filtered(OPT_vfsoverlay)) { Opts.VFSOverlayFiles.push_back(resolveSearchPath(A->getValue())); } if (const Arg *A = Args.getLastArg(OPT_sdk)) Opts.SDKPath = A->getValue(); if (const Arg *A = Args.getLastArg(OPT_resource_dir)) Opts.RuntimeResourcePath = A->getValue(); Opts.SkipRuntimeLibraryImportPath |= Args.hasArg(OPT_nostdimport); // Opts.RuntimeIncludePath is set by calls to // setRuntimeIncludePath() or setMainExecutablePath(). // Opts.RuntimeImportPath is set by calls to // setRuntimeIncludePath() or setMainExecutablePath() and // updated by calls to setTargetTriple() or parseArgs(). // Assumes exactly one of setMainExecutablePath() or setRuntimeIncludePath() // is called before setTargetTriple() and parseArgs(). // TODO: improve the handling of RuntimeIncludePath. return false; }
void msp430::getMSP430TargetFeatures(const Driver &D, const ArgList &Args, std::vector<StringRef> &Features) { const Arg *MCU = Args.getLastArg(options::OPT_mmcu_EQ); if (MCU && !isSupportedMCU(MCU->getValue())) { D.Diag(diag::err_drv_clang_unsupported) << MCU->getValue(); return; } const Arg *HWMultArg = Args.getLastArg(options::OPT_mhwmult_EQ); if (!MCU && !HWMultArg) return; StringRef HWMult = HWMultArg ? HWMultArg->getValue() : "auto"; StringRef SupportedHWMult = getSupportedHWMult(MCU); if (HWMult == "auto") { // 'auto' - deduce hw multiplier support based on mcu name provided. // If no mcu name is provided, assume no hw multiplier is supported. if (!MCU) D.Diag(clang::diag::warn_drv_msp430_hwmult_no_device); HWMult = SupportedHWMult; } if (HWMult == "none") { // 'none' - disable hw multiplier. Features.push_back("-hwmult16"); Features.push_back("-hwmult32"); Features.push_back("-hwmultf5"); return; } if (MCU && SupportedHWMult == "none") D.Diag(clang::diag::warn_drv_msp430_hwmult_unsupported) << HWMult; if (MCU && HWMult != SupportedHWMult) D.Diag(clang::diag::warn_drv_msp430_hwmult_mismatch) << SupportedHWMult << HWMult; if (HWMult == "16bit") { // '16bit' - for 16-bit only hw multiplier. Features.push_back("+hwmult16"); } else if (HWMult == "32bit") { // '32bit' - for 16/32-bit hw multiplier. Features.push_back("+hwmult32"); } else if (HWMult == "f5series") { // 'f5series' - for 16/32-bit hw multiplier supported by F5 series mcus. Features.push_back("+hwmultf5"); } else { D.Diag(clang::diag::err_drv_unsupported_option_argument) << HWMultArg->getAsString(Args) << HWMult; } }
static std::string getNios2TargetCPU(const ArgList &Args) { Arg *A = Args.getLastArg(options::OPT_mcpu_EQ); if (!A) A = Args.getLastArg(options::OPT_march_EQ); if (!A) return ""; const char *name = A->getValue(); return llvm::StringSwitch<const char *>(name) .Case("r1", "nios2r1") .Case("r2", "nios2r2") .Default(name); }
static bool ParseClangImporterArgs(ClangImporterOptions &Opts, ArgList &Args, DiagnosticEngine &Diags, StringRef workingDirectory) { using namespace options; if (const Arg *A = Args.getLastArg(OPT_module_cache_path)) { Opts.ModuleCachePath = A->getValue(); } if (const Arg *A = Args.getLastArg(OPT_target_cpu)) Opts.TargetCPU = A->getValue(); if (const Arg *A = Args.getLastArg(OPT_index_store_path)) Opts.IndexStorePath = A->getValue(); for (const Arg *A : Args.filtered(OPT_Xcc)) { Opts.ExtraArgs.push_back(A->getValue()); } if (!workingDirectory.empty()) { // Provide a working directory to Clang as well if there are any -Xcc // options, in case some of them are search-related. But do it at the // beginning, so that an explicit -Xcc -working-directory will win. Opts.ExtraArgs.insert(Opts.ExtraArgs.begin(), { "-working-directory", workingDirectory }); } Opts.InferImportAsMember |= Args.hasArg(OPT_enable_infer_import_as_member); Opts.DumpClangDiagnostics |= Args.hasArg(OPT_dump_clang_diagnostics); if (Args.hasArg(OPT_embed_bitcode)) Opts.Mode = ClangImporterOptions::Modes::EmbedBitcode; if (auto *A = Args.getLastArg(OPT_import_objc_header)) Opts.BridgingHeader = A->getValue(); Opts.DisableSwiftBridgeAttr |= Args.hasArg(OPT_disable_swift_bridge_attr); Opts.DisableModulesValidateSystemHeaders |= Args.hasArg(OPT_disable_modules_validate_system_headers); Opts.DisableAdapterModules |= Args.hasArg(OPT_emit_imported_modules); if (const Arg *A = Args.getLastArg(OPT_pch_output_dir)) { Opts.PrecompiledHeaderOutputDir = A->getValue(); Opts.PCHDisableValidation |= Args.hasArg(OPT_pch_disable_validation); } Opts.DebuggerSupport |= Args.hasArg(OPT_debugger_support); return false; }
void tools::SHAVE::Assembler::ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, const ArgList &Args, const char *LinkingOutput) const { ArgStringList CmdArgs; assert(Inputs.size() == 1); const InputInfo &II = Inputs[0]; assert(II.getType() == types::TY_PP_Asm); // Require preprocessed asm input. assert(Output.getType() == types::TY_Object); CmdArgs.push_back("-no6thSlotCompression"); const Arg *CPUArg = Args.getLastArg(options::OPT_mcpu_EQ); if (CPUArg) CmdArgs.push_back( Args.MakeArgString("-cv:" + StringRef(CPUArg->getValue()))); CmdArgs.push_back("-noSPrefixing"); CmdArgs.push_back("-a"); // Mystery option. Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, options::OPT_Xassembler); for (const Arg *A : Args.filtered(options::OPT_I, options::OPT_isystem)) { A->claim(); CmdArgs.push_back( Args.MakeArgString(std::string("-i:") + A->getValue(0))); } CmdArgs.push_back("-elf"); // Output format. CmdArgs.push_back(II.getFilename()); CmdArgs.push_back( Args.MakeArgString(std::string("-o:") + Output.getFilename())); std::string Exec = Args.MakeArgString(getToolChain().GetProgramPath("moviAsm")); C.addCommand(llvm::make_unique<Command>(JA, *this, Args.MakeArgString(Exec), CmdArgs, Inputs)); }
ppc::FloatABI ppc::getPPCFloatABI(const Driver &D, const ArgList &Args) { ppc::FloatABI ABI = ppc::FloatABI::Invalid; if (Arg *A = Args.getLastArg(options::OPT_msoft_float, options::OPT_mhard_float, options::OPT_mfloat_abi_EQ)) { if (A->getOption().matches(options::OPT_msoft_float)) ABI = ppc::FloatABI::Soft; else if (A->getOption().matches(options::OPT_mhard_float)) ABI = ppc::FloatABI::Hard; else { ABI = llvm::StringSwitch<ppc::FloatABI>(A->getValue()) .Case("soft", ppc::FloatABI::Soft) .Case("hard", ppc::FloatABI::Hard) .Default(ppc::FloatABI::Invalid); if (ABI == ppc::FloatABI::Invalid && !StringRef(A->getValue()).empty()) { D.Diag(clang::diag::err_drv_invalid_mfloat_abi) << A->getAsString(Args); ABI = ppc::FloatABI::Hard; } } } // If unspecified, choose the default based on the platform. if (ABI == ppc::FloatABI::Invalid) { ABI = ppc::FloatABI::Hard; } return ABI; }
// Select the MIPS float ABI as determined by -msoft-float, -mhard-float, // and -mfloat-abi=. mips::FloatABI mips::getMipsFloatABI(const Driver &D, const ArgList &Args) { mips::FloatABI ABI = mips::FloatABI::Invalid; if (Arg *A = Args.getLastArg(options::OPT_msoft_float, options::OPT_mhard_float, options::OPT_mfloat_abi_EQ)) { if (A->getOption().matches(options::OPT_msoft_float)) ABI = mips::FloatABI::Soft; else if (A->getOption().matches(options::OPT_mhard_float)) ABI = mips::FloatABI::Hard; else { ABI = llvm::StringSwitch<mips::FloatABI>(A->getValue()) .Case("soft", mips::FloatABI::Soft) .Case("hard", mips::FloatABI::Hard) .Default(mips::FloatABI::Invalid); if (ABI == mips::FloatABI::Invalid && !StringRef(A->getValue()).empty()) { D.Diag(clang::diag::err_drv_invalid_mfloat_abi) << A->getAsString(Args); ABI = mips::FloatABI::Hard; } } } // If unspecified, choose the default based on the platform. if (ABI == mips::FloatABI::Invalid) { // Assume "hard", because it's a default value used by gcc. // When we start to recognize specific target MIPS processors, // we will be able to select the default more correctly. ABI = mips::FloatABI::Hard; } assert(ABI != mips::FloatABI::Invalid && "must select an ABI"); return ABI; }
Optional<unsigned> HexagonToolChain::getSmallDataThreshold( const ArgList &Args) { StringRef Gn = ""; if (Arg *A = Args.getLastArg(options::OPT_G)) { Gn = A->getValue(); } else if (Args.getLastArg(options::OPT_shared, options::OPT_fpic, options::OPT_fPIC)) { Gn = "0"; } unsigned G; if (!Gn.getAsInteger(10, G)) return G; return None; }
ToolChain::UnwindLibType ToolChain::GetUnwindLibType( const ArgList &Args) const { const Arg *A = Args.getLastArg(options::OPT_unwindlib_EQ); StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_UNWINDLIB; if (LibName == "none") return ToolChain::UNW_None; else if (LibName == "platform" || LibName == "") { ToolChain::RuntimeLibType RtLibType = GetRuntimeLibType(Args); if (RtLibType == ToolChain::RLT_CompilerRT) return ToolChain::UNW_None; else if (RtLibType == ToolChain::RLT_Libgcc) return ToolChain::UNW_Libgcc; } else if (LibName == "libunwind") { if (GetRuntimeLibType(Args) == RLT_Libgcc) getDriver().Diag(diag::err_drv_incompatible_unwindlib); return ToolChain::UNW_CompilerRT; } else if (LibName == "libgcc") return ToolChain::UNW_Libgcc; if (A) getDriver().Diag(diag::err_drv_invalid_unwindlib_name) << A->getAsString(Args); return GetDefaultUnwindLibType(); }
static ToolChain::RTTIMode CalculateRTTIMode(const ArgList &Args, const llvm::Triple &Triple, const Arg *CachedRTTIArg) { // Explicit rtti/no-rtti args if (CachedRTTIArg) { if (CachedRTTIArg->getOption().matches(options::OPT_frtti)) return ToolChain::RM_EnabledExplicitly; else return ToolChain::RM_DisabledExplicitly; } // -frtti is default, except for the PS4 CPU. if (!Triple.isPS4CPU()) return ToolChain::RM_EnabledImplicitly; // On the PS4, turning on c++ exceptions turns on rtti. // We're assuming that, if we see -fexceptions, rtti gets turned on. Arg *Exceptions = Args.getLastArg( options::OPT_fcxx_exceptions, options::OPT_fno_cxx_exceptions, options::OPT_fexceptions, options::OPT_fno_exceptions); if (Exceptions && (Exceptions->getOption().matches(options::OPT_fexceptions) || Exceptions->getOption().matches(options::OPT_fcxx_exceptions))) return ToolChain::RM_EnabledImplicitly; return ToolChain::RM_DisabledImplicitly; }
ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{ ToolChain::CXXStdlibType Type; bool HasValidType = false; bool ForcePlatformDefault = false; const Arg *A = Args.getLastArg(options::OPT_stdlib_EQ); if (A) { StringRef Value = A->getValue(); HasValidType = ParseCXXStdlibType(Value, Type); // Only use in tests to override CLANG_DEFAULT_CXX_STDLIB! if (Value == "platform") ForcePlatformDefault = true; else if (!HasValidType) getDriver().Diag(diag::err_drv_invalid_stdlib_name) << A->getAsString(Args); } // If no argument was provided or its value was invalid, look for the // default unless forced or configured to take the platform default. if (!HasValidType && (ForcePlatformDefault || !ParseCXXStdlibType(CLANG_DEFAULT_CXX_STDLIB, Type))) Type = GetDefaultCXXStdlibType(); return Type; }
void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args, ArgStringList &CmdArgs) const { // Darwin doesn't support real static executables, don't link any runtime // libraries with -static. if (Args.hasArg(options::OPT_static)) return; // Reject -static-libgcc for now, we can deal with this when and if someone // cares. This is useful in situations where someone wants to statically link // something like libstdc++, and needs its runtime support routines. if (const Arg *A = Args.getLastArg(options::OPT_static_libgcc)) { getDriver().Diag(clang::diag::err_drv_unsupported_opt) << A->getAsString(Args); return; } // Otherwise link libSystem, then the dynamic runtime library, and finally any // target specific static runtime library. CmdArgs.push_back("-lSystem"); // Select the dynamic runtime library and the target specific static library. const char *DarwinStaticLib = 0; if (isTargetIPhoneOS()) { CmdArgs.push_back("-lgcc_s.1"); // We may need some static functions for armv6/thumb which are required to // be in the same linkage unit as their caller. if (getDarwinArchName(Args) == "armv6") DarwinStaticLib = "libclang_rt.armv6.a"; } else { // The dynamic runtime library was merged with libSystem for 10.6 and // beyond; only 10.4 and 10.5 need an additional runtime library. if (isMacosxVersionLT(10, 5)) CmdArgs.push_back("-lgcc_s.10.4"); else if (isMacosxVersionLT(10, 6)) CmdArgs.push_back("-lgcc_s.10.5"); // For OS X, we only need a static runtime library when targetting 10.4, to // provide versions of the static functions which were omitted from // 10.4.dylib. if (isMacosxVersionLT(10, 5)) DarwinStaticLib = "libclang_rt.10.4.a"; } /// Add the target specific static library, if needed. if (DarwinStaticLib) { llvm::sys::Path P(getDriver().ResourceDir); P.appendComponent("lib"); P.appendComponent("darwin"); P.appendComponent(DarwinStaticLib); // For now, allow missing resource libraries to support developers who may // not have compiler-rt checked out or integrated into their build. if (!P.exists()) getDriver().Diag(clang::diag::warn_drv_missing_resource_library) << P.str(); else CmdArgs.push_back(Args.MakeArgString(P.str())); } }
bool tools::areOptimizationsEnabled(const ArgList &Args) { // Find the last -O arg and see if it is non-zero. if (Arg *A = Args.getLastArg(options::OPT_O_Group)) return !A->getOption().matches(options::OPT_O0); // Defaults to -O0. return false; }
/// Get the (LLVM) name of the Z80 cpu we are targeting. static StringRef getZ80TargetCPU(const ArgList &Args, const llvm::Triple &Triple) { if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) return A->getValue(); // Select the default CPU if none was given (or detection failed). return Triple.getArchName(); }
// Handle hvx target features explicitly. static void handleHVXTargetFeatures(const Driver &D, const ArgList &Args, std::vector<StringRef> &Features, bool &HasHVX) { // Handle HVX warnings. handleHVXWarnings(D, Args); // Add the +hvx* features based on commandline flags. StringRef HVXFeature, HVXLength; StringRef Cpu(toolchains::HexagonToolChain::GetTargetCPUVersion(Args)); // Handle -mhvx, -mhvx=, -mno-hvx. if (Arg *A = Args.getLastArg(options::OPT_mno_hexagon_hvx, options::OPT_mhexagon_hvx, options::OPT_mhexagon_hvx_EQ)) { if (A->getOption().matches(options::OPT_mno_hexagon_hvx)) return; if (A->getOption().matches(options::OPT_mhexagon_hvx_EQ)) { HasHVX = true; HVXFeature = Cpu = A->getValue(); HVXFeature = Args.MakeArgString(llvm::Twine("+hvx") + HVXFeature.lower()); } else if (A->getOption().matches(options::OPT_mhexagon_hvx)) { HasHVX = true; HVXFeature = Args.MakeArgString(llvm::Twine("+hvx") + Cpu); } Features.push_back(HVXFeature); } // Handle -mhvx-length=. if (Arg *A = Args.getLastArg(options::OPT_mhexagon_hvx_length_EQ)) { // These flags are valid only if HVX in enabled. if (!HasHVX) D.Diag(diag::err_drv_invalid_hvx_length); else if (A->getOption().matches(options::OPT_mhexagon_hvx_length_EQ)) HVXLength = A->getValue(); } // Default hvx-length based on Cpu. else if (HasHVX) HVXLength = getDefaultHvxLength(Cpu); if (!HVXLength.empty()) { HVXFeature = Args.MakeArgString(llvm::Twine("+hvx-length") + HVXLength.lower()); Features.push_back(HVXFeature); } }
llvm::StringRef Darwin::getDarwinArchName(const ArgList &Args) const { switch (getTriple().getArch()) { default: return getArchName(); case llvm::Triple::arm: { if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) if (const char *Arch = GetArmArchForMArch(A->getValue(Args))) return Arch; if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) if (const char *Arch = GetArmArchForMCpu(A->getValue(Args))) return Arch; return "arm"; } } }
static void handleHVXWarnings(const Driver &D, const ArgList &Args) { // Handle the unsupported values passed to mhvx-length. if (Arg *A = Args.getLastArg(options::OPT_mhexagon_hvx_length_EQ)) { StringRef Val = A->getValue(); if (!Val.equals_lower("64b") && !Val.equals_lower("128b")) D.Diag(diag::err_drv_unsupported_option_argument) << A->getOption().getName() << Val; } }
unsigned tools::getLTOParallelism(const ArgList &Args, const Driver &D) { unsigned Parallelism = 0; Arg *LtoJobsArg = Args.getLastArg(options::OPT_flto_jobs_EQ); if (LtoJobsArg && StringRef(LtoJobsArg->getValue()).getAsInteger(10, Parallelism)) D.Diag(diag::err_drv_invalid_int_value) << LtoJobsArg->getAsString(Args) << LtoJobsArg->getValue(); return Parallelism; }
// Get Arch/CPU from args. void arm::getARMArchCPUFromArgs(const ArgList &Args, llvm::StringRef &Arch, llvm::StringRef &CPU, bool FromAs) { if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) CPU = A->getValue(); if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) Arch = A->getValue(); if (!FromAs) return; for (const Arg *A : Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) { StringRef Value = A->getValue(); if (Value.startswith("-mcpu=")) CPU = Value.substr(6); if (Value.startswith("-march=")) Arch = Value.substr(7); } }
ToolChain::ToolChain(const Driver &D, const llvm::Triple &T, const ArgList &Args) : D(D), Triple(T), Args(Args), CachedRTTIArg(GetRTTIArgument(Args)), CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)) { if (Arg *A = Args.getLastArg(options::OPT_mthread_model)) if (!isThreadModelSupported(A->getValue())) D.Diag(diag::err_drv_invalid_thread_model_for_target) << A->getValue() << A->getAsString(Args); }
ToolChain::CXXStdlibType WebAssembly::GetCXXStdlibType(const ArgList &Args) const { if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) { StringRef Value = A->getValue(); if (Value != "libc++") getDriver().Diag(diag::err_drv_invalid_stdlib_name) << A->getAsString(Args); } return ToolChain::CST_Libcxx; }
static DebugInfoKind mustEmitDebugInfo(const ArgList &Args) { Arg *A = Args.getLastArg(options::OPT_O_Group); if (Args.hasFlag(options::OPT_cuda_noopt_device_debug, options::OPT_no_cuda_noopt_device_debug, !A || A->getOption().matches(options::OPT_O0))) { if (const Arg *A = Args.getLastArg(options::OPT_g_Group)) { const Option &Opt = A->getOption(); if (Opt.matches(options::OPT_gN_Group)) { if (Opt.matches(options::OPT_g0) || Opt.matches(options::OPT_ggdb0)) return NoDebug; if (Opt.matches(options::OPT_gline_tables_only) || Opt.matches(options::OPT_ggdb1)) return LineTableOnly; } return FullDebug; } } return NoDebug; }
const StringRef HexagonToolChain::GetTargetCPUVersion(const ArgList &Args) { Arg *CpuArg = nullptr; if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ, options::OPT_march_EQ)) CpuArg = A; StringRef CPU = CpuArg ? CpuArg->getValue() : GetDefaultCPU(); if (CPU.startswith("hexagon")) return CPU.substr(sizeof("hexagon") - 1); return CPU; }
std::string ToolChain::ComputeEffectiveClangTriple(const ArgList &Args) const { // Diagnose use of Darwin OS deployment target arguments on non-Darwin. if (Arg *A = Args.getLastArg(options::OPT_mmacosx_version_min_EQ, options::OPT_miphoneos_version_min_EQ, options::OPT_mios_simulator_version_min_EQ)) getDriver().Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args); return ComputeLLVMTriple(Args); }
ToolChain::RuntimeLibType Fuchsia::GetRuntimeLibType( const ArgList &Args) const { if (Arg *A = Args.getLastArg(clang::driver::options::OPT_rtlib_EQ)) { StringRef Value = A->getValue(); if (Value != "compiler-rt") getDriver().Diag(clang::diag::err_drv_invalid_rtlib_name) << A->getAsString(Args); } return ToolChain::RLT_CompilerRT; }
Optional<std::vector<std::string>> OutputFilesComputer::getOutputFilenamesFromCommandLineOrFilelist( const ArgList &args, DiagnosticEngine &diags) { if (const Arg *A = args.getLastArg(options::OPT_output_filelist)) { assert(!args.hasArg(options::OPT_o) && "don't use -o with -output-filelist"); return ArgsToFrontendOutputsConverter::readOutputFileList(A->getValue(), diags); } return args.getAllArgValues(options::OPT_o); }
void tools::AddTargetFeature(const ArgList &Args, std::vector<StringRef> &Features, OptSpecifier OnOpt, OptSpecifier OffOpt, StringRef FeatureName) { if (Arg *A = Args.getLastArg(OnOpt, OffOpt)) { if (A->getOption().matches(OnOpt)) Features.push_back(Args.MakeArgString("+" + FeatureName)); else Features.push_back(Args.MakeArgString("-" + FeatureName)); } }