Lines Matching +full:diag +full:- +full:version

1 //===-- Clang.cpp - Clang+LLVM ToolChain Implementations --------*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
34 #include "clang/Basic/Version.h"
47 #include "llvm/Config/llvm-config.h"
80 D.Diag(clang::diag::err_drv_argument_only_allowed_with) in CheckPreprocessingOptions()
81 << A->getBaseArg().getAsString(Args) in CheckPreprocessingOptions()
82 << (D.IsCLMode() ? "/E, /P or /EP" : "-E"); in CheckPreprocessingOptions()
92 D.Diag(diag::err_drv_argument_not_allowed_with) << A->getAsString(Args) in CheckCodeGenerationOptions()
93 << "-static"; in CheckCodeGenerationOptions()
97 // This is used for the space-separated argument list specified with
98 // the -dwarf-debug-flags option.
137 Work(*II->second); in forAllAssociatedToolChains()
158 // step parameter. This is reasonable for all currently-supported in getRefinementStep()
161 // under-perform the native operation. Also, if the estimate does not in getRefinementStep()
165 D.Diag(diag::err_drv_invalid_value) << Option << RefStep; in getRefinementStep()
170 D.Diag(diag::err_drv_invalid_value) << Option << RefStep; in getRefinementStep()
177 /// The -mrecip flag requires processing of many optional parameters.
183 StringRef Out = "-mrecip="; in ParseMRecip()
189 unsigned NumOptions = A->getNumValues(); in ParseMRecip()
198 StringRef Val = A->getValue(0); in ParseMRecip()
217 OptionStrings.insert(std::make_pair("vec-divd", false)); in ParseMRecip()
218 OptionStrings.insert(std::make_pair("vec-divf", false)); in ParseMRecip()
219 OptionStrings.insert(std::make_pair("vec-divh", false)); in ParseMRecip()
223 OptionStrings.insert(std::make_pair("vec-sqrtd", false)); in ParseMRecip()
224 OptionStrings.insert(std::make_pair("vec-sqrtf", false)); in ParseMRecip()
225 OptionStrings.insert(std::make_pair("vec-sqrth", false)); in ParseMRecip()
228 StringRef Val = A->getValue(i); in ParseMRecip()
246 D.Diag(diag::err_drv_unknown_argument) << Val; in ParseMRecip()
254 D.Diag(diag::err_drv_invalid_value) << A->getOption().getName() << Val; in ParseMRecip()
259 if (OptionIter->second == true) { in ParseMRecip()
261 D.Diag(diag::err_drv_invalid_value) << A->getOption().getName() << Val; in ParseMRecip()
266 OptionIter->second = true; in ParseMRecip()
278 if (i != NumOptions - 1) in ParseMRecip()
285 /// The -mprefer-vector-width option accepts either a positive integer
293 StringRef Value = A->getValue(); in ParseMPreferVectorWidth()
295 CmdArgs.push_back("-mprefer-vector-width=none"); in ParseMPreferVectorWidth()
299 D.Diag(diag::err_drv_invalid_value) << A->getOption().getName() << Value; in ParseMPreferVectorWidth()
302 CmdArgs.push_back(Args.MakeArgString("-mprefer-vector-width=" + Value)); in ParseMPreferVectorWidth()
309 // We use the zero-cost exception tables for Objective-C if the non-fragile in shouldUseExceptionTablesForObjCExceptions()
324 /// main flag, -fexceptions and also language specific flags to enable/disable
325 /// C++ and Objective-C exceptions. This makes it possible to for example
326 /// disable C++ exceptions but enable Objective-C exceptions.
334 // -mkernel and -fapple-kext imply no exceptions, so claim exception related in addExceptionArgs()
356 CmdArgs.push_back("-fasync-exceptions"); in addExceptionArgs()
361 // Obj-C exceptions are enabled by default, regardless of -fexceptions. This in addExceptionArgs()
366 CmdArgs.push_back("-fobjc-exceptions"); in addExceptionArgs()
380 ExceptionArg->getOption().matches(options::OPT_fcxx_exceptions) || in addExceptionArgs()
381 ExceptionArg->getOption().matches(options::OPT_fexceptions); in addExceptionArgs()
384 CmdArgs.push_back("-fcxx-exceptions"); in addExceptionArgs()
399 CmdArgs.push_back("-fexceptions"); in addExceptionArgs()
425 if (A->getOption().matches(options::OPT_ffile_compilation_dir_EQ)) in addDebugCompDirArg()
426 CmdArgs.push_back(Args.MakeArgString(Twine("-fdebug-compilation-dir=") + in addDebugCompDirArg()
427 A->getValue())); in addDebugCompDirArg()
429 A->render(Args, CmdArgs); in addDebugCompDirArg()
432 CmdArgs.push_back(Args.MakeArgString("-fdebug-compilation-dir=" + *CWD)); in addDebugCompDirArg()
441 // No need to generate a value for -object-file-name if it was provided. in addDebugObjectName()
443 if (StringRef(Arg->getValue()).starts_with("-object-file-name")) in addDebugObjectName()
450 if (ObjFileNameForDebug != "-" && in addDebugObjectName()
458 // backslash style as -object-file-name is used for embedding object file path in addDebugObjectName()
468 Args.MakeArgString(Twine("-object-file-name=") + ObjFileNameForDebug)); in addDebugObjectName()
476 D.Diag(diag::err_drv_invalid_argument_to_option) << Map << Name; in addDebugPrefixMapArg()
478 CmdArgs.push_back(Args.MakeArgString("-fdebug-prefix-map=" + Map)); in addDebugPrefixMapArg()
483 AddOneArg(A->getValue(), A->getOption().getName()); in addDebugPrefixMapArg()
484 A->claim(); in addDebugPrefixMapArg()
497 StringRef Map = A->getValue(); in addMacroPrefixMapArg()
499 D.Diag(diag::err_drv_invalid_argument_to_option) in addMacroPrefixMapArg()
500 << Map << A->getOption().getName(); in addMacroPrefixMapArg()
502 CmdArgs.push_back(Args.MakeArgString("-fmacro-prefix-map=" + Map)); in addMacroPrefixMapArg()
503 A->claim(); in addMacroPrefixMapArg()
512 StringRef Map = A->getValue(); in addCoveragePrefixMapArg()
514 D.Diag(diag::err_drv_invalid_argument_to_option) in addCoveragePrefixMapArg()
515 << Map << A->getOption().getName(); in addCoveragePrefixMapArg()
517 CmdArgs.push_back(Args.MakeArgString("-fcoverage-prefix-map=" + Map)); in addCoveragePrefixMapArg()
518 A->claim(); in addCoveragePrefixMapArg()
522 /// Vectorize at all optimization levels greater than 1 except for -Oz.
523 /// For -Oz the loop vectorizer is disabled, while the slp vectorizer is
527 if (A->getOption().matches(options::OPT_O4) || in shouldEnableVectorizerAtOLevel()
528 A->getOption().matches(options::OPT_Ofast)) in shouldEnableVectorizerAtOLevel()
531 if (A->getOption().matches(options::OPT_O0)) in shouldEnableVectorizerAtOLevel()
534 assert(A->getOption().matches(options::OPT_O) && "Must have a -O flag"); in shouldEnableVectorizerAtOLevel()
536 // Vectorize -Os. in shouldEnableVectorizerAtOLevel()
537 StringRef S(A->getValue()); in shouldEnableVectorizerAtOLevel()
541 // Don't vectorize -Oz, unless it's the slp vectorizer. in shouldEnableVectorizerAtOLevel()
555 /// Add -x lang to \p CmdArgs for \p Input.
558 // When using -verify-pch, we don't want to provide the type in addDashXForInput()
559 // 'precompiled-header' if it was inferred from the file extension in addDashXForInput()
563 CmdArgs.push_back("-x"); in addDashXForInput()
576 ClangType = "c++-cpp-output"; in addDashXForInput()
595 PGOGenerateArg->getOption().matches(options::OPT_fno_profile_generate)) in addPGOAndCoverageFlags()
605 ProfileGenerateArg->getOption().matches( in addPGOAndCoverageFlags()
610 D.Diag(diag::err_drv_argument_not_allowed_with) in addPGOAndCoverageFlags()
611 << PGOGenerateArg->getSpelling() << ProfileGenerateArg->getSpelling(); in addPGOAndCoverageFlags()
616 D.Diag(diag::err_drv_argument_not_allowed_with) in addPGOAndCoverageFlags()
617 << ProfileUseArg->getSpelling() << PGOGenerateArg->getSpelling(); in addPGOAndCoverageFlags()
620 D.Diag(diag::err_drv_argument_not_allowed_with) in addPGOAndCoverageFlags()
621 << ProfileGenerateArg->getSpelling() << ProfileUseArg->getSpelling(); in addPGOAndCoverageFlags()
624 D.Diag(diag::err_drv_argument_not_allowed_with) in addPGOAndCoverageFlags()
625 << CSPGOGenerateArg->getSpelling() << PGOGenerateArg->getSpelling(); in addPGOAndCoverageFlags()
631 D.Diag(diag::err_drv_unsupported_opt_for_target) in addPGOAndCoverageFlags()
632 << ProfileSampleUseArg->getSpelling() << TC.getTriple().str(); in addPGOAndCoverageFlags()
636 if (ProfileGenerateArg->getOption().matches( in addPGOAndCoverageFlags()
638 CmdArgs.push_back(Args.MakeArgString(Twine("-fprofile-instrument-path=") + in addPGOAndCoverageFlags()
639 ProfileGenerateArg->getValue())); in addPGOAndCoverageFlags()
641 CmdArgs.push_back("-fprofile-instrument=clang"); in addPGOAndCoverageFlags()
647 "--dependent-lib=" + TC.getCompilerRTBasename(Args, "profile"))); in addPGOAndCoverageFlags()
655 CmdArgs.push_back("-fprofile-instrument=llvm"); in addPGOAndCoverageFlags()
660 CmdArgs.push_back("-fprofile-instrument=csllvm"); in addPGOAndCoverageFlags()
668 "--dependent-lib=" + TC.getCompilerRTBasename(Args, "profile"))); in addPGOAndCoverageFlags()
670 if (PGOGenArg->getOption().matches( in addPGOAndCoverageFlags()
673 SmallString<128> Path(PGOGenArg->getValue()); in addPGOAndCoverageFlags()
676 Args.MakeArgString(Twine("-fprofile-instrument-path=") + Path)); in addPGOAndCoverageFlags()
681 if (ProfileUseArg->getOption().matches(options::OPT_fprofile_instr_use_EQ)) in addPGOAndCoverageFlags()
683 Twine("-fprofile-instrument-use-path=") + ProfileUseArg->getValue())); in addPGOAndCoverageFlags()
684 else if ((ProfileUseArg->getOption().matches( in addPGOAndCoverageFlags()
686 ProfileUseArg->getOption().matches( in addPGOAndCoverageFlags()
689 ProfileUseArg->getNumValues() == 0 ? "" : ProfileUseArg->getValue()); in addPGOAndCoverageFlags()
693 Args.MakeArgString(Twine("-fprofile-instrument-use-path=") + Path)); in addPGOAndCoverageFlags()
705 D.Diag(clang::diag::err_drv_argument_only_allowed_with) in addPGOAndCoverageFlags()
706 << "-fcoverage-mapping" in addPGOAndCoverageFlags()
707 << "-fprofile-instr-generate"; in addPGOAndCoverageFlags()
709 CmdArgs.push_back("-fcoverage-mapping"); in addPGOAndCoverageFlags()
716 D.Diag(clang::diag::err_drv_argument_only_allowed_with) in addPGOAndCoverageFlags()
717 << "-fcoverage-mcdc" in addPGOAndCoverageFlags()
718 << "-fcoverage-mapping"; in addPGOAndCoverageFlags()
720 CmdArgs.push_back("-fcoverage-mcdc"); in addPGOAndCoverageFlags()
725 if (A->getOption().matches(options::OPT_ffile_compilation_dir_EQ)) in addPGOAndCoverageFlags()
727 Twine("-fcoverage-compilation-dir=") + A->getValue())); in addPGOAndCoverageFlags()
729 A->render(Args, CmdArgs); in addPGOAndCoverageFlags()
732 CmdArgs.push_back(Args.MakeArgString("-fcoverage-compilation-dir=" + *CWD)); in addPGOAndCoverageFlags()
738 D.Diag(clang::diag::err_drv_argument_only_allowed_with) in addPGOAndCoverageFlags()
739 << "-fprofile-exclude-files=" in addPGOAndCoverageFlags()
740 << "--coverage"; in addPGOAndCoverageFlags()
742 StringRef v = Arg->getValue(); in addPGOAndCoverageFlags()
744 Args.MakeArgString(Twine("-fprofile-exclude-files=" + v))); in addPGOAndCoverageFlags()
750 D.Diag(clang::diag::err_drv_argument_only_allowed_with) in addPGOAndCoverageFlags()
751 << "-fprofile-filter-files=" in addPGOAndCoverageFlags()
752 << "--coverage"; in addPGOAndCoverageFlags()
754 StringRef v = Arg->getValue(); in addPGOAndCoverageFlags()
755 CmdArgs.push_back(Args.MakeArgString(Twine("-fprofile-filter-files=" + v))); in addPGOAndCoverageFlags()
759 StringRef Val = A->getValue(); in addPGOAndCoverageFlags()
760 if (Val == "atomic" || Val == "prefer-atomic") in addPGOAndCoverageFlags()
761 CmdArgs.push_back("-fprofile-update=atomic"); in addPGOAndCoverageFlags()
763 D.Diag(diag::err_drv_unsupported_option_argument) in addPGOAndCoverageFlags()
764 << A->getSpelling() << Val; in addPGOAndCoverageFlags()
770 StringRef Val = A->getValue(); in addPGOAndCoverageFlags()
772 D.Diag(diag::err_drv_invalid_int_value) << A->getAsString(Args) << Val; in addPGOAndCoverageFlags()
776 StringRef Val = A->getValue(); in addPGOAndCoverageFlags()
779 D.Diag(diag::err_drv_invalid_int_value) << A->getAsString(Args) << Val; in addPGOAndCoverageFlags()
782 CmdArgs.push_back(Args.MakeArgString("-fprofile-function-groups=" + in addPGOAndCoverageFlags()
785 CmdArgs.push_back(Args.MakeArgString("-fprofile-selected-function-group=" + in addPGOAndCoverageFlags()
788 // Leave -fprofile-dir= an unused argument unless .gcda emission is in addPGOAndCoverageFlags()
789 // enabled. To be polite, with '-fprofile-arcs -fno-profile-arcs' consider in addPGOAndCoverageFlags()
790 // the flag used. There is no -fno-profile-dir, so the user has no in addPGOAndCoverageFlags()
797 // TODO: Don't claim -c/-S to warn about -fsyntax-only -c/-S, -E -c/-S, in addPGOAndCoverageFlags()
798 // like we warn about -fsyntax-only -E. in addPGOAndCoverageFlags()
802 // or fall back to a file in the current directory for `clang -c --coverage in addPGOAndCoverageFlags()
803 // d/a.c` in the absence of -o. in addPGOAndCoverageFlags()
809 CoverageFilename = DumpDir->getValue(); in addPGOAndCoverageFlags()
813 CoverageFilename = FinalOutput->getValue(); in addPGOAndCoverageFlags()
815 CoverageFilename = FinalOutput->getValue(); in addPGOAndCoverageFlags()
824 Args.MakeArgString("-coverage-notes-file=" + CoverageFilename)); in addPGOAndCoverageFlags()
830 CoverageFilename = FProfileDir->getValue(); in addPGOAndCoverageFlags()
835 Args.MakeArgString("-coverage-data-file=" + CoverageFilename)); in addPGOAndCoverageFlags()
848 Args.MakeArgString("-dwarf-version=" + Twine(DwarfVersion))); in RenderDebugEnablingArgs()
851 CmdArgs.push_back("-debugger-tuning=gdb"); in RenderDebugEnablingArgs()
854 CmdArgs.push_back("-debugger-tuning=lldb"); in RenderDebugEnablingArgs()
857 CmdArgs.push_back("-debugger-tuning=sce"); in RenderDebugEnablingArgs()
860 CmdArgs.push_back("-debugger-tuning=dbx"); in RenderDebugEnablingArgs()
869 assert(A && "Expected non-nullptr argument."); in checkDebugInfoOption()
872 D.Diag(diag::warn_drv_unsupported_debug_info_opt_for_target) in checkDebugInfoOption()
873 << A->getAsString(Args) << TC.getTripleString(); in checkDebugInfoOption()
885 StringRef Value = A->getValue(); in RenderDebugInfoCompressionArgs()
887 CmdArgs.push_back("--compress-debug-sections=none"); in RenderDebugInfoCompressionArgs()
891 Args.MakeArgString("--compress-debug-sections=" + Twine(Value))); in RenderDebugInfoCompressionArgs()
893 D.Diag(diag::warn_debug_compression_unavailable) << "zlib"; in RenderDebugInfoCompressionArgs()
898 Args.MakeArgString("--compress-debug-sections=" + Twine(Value))); in RenderDebugInfoCompressionArgs()
900 D.Diag(diag::warn_debug_compression_unavailable) << "zstd"; in RenderDebugInfoCompressionArgs()
903 D.Diag(diag::err_drv_unsupported_option_argument) in RenderDebugInfoCompressionArgs()
904 << A->getSpelling() << Value; in RenderDebugInfoCompressionArgs()
913 // If no version was requested by the user, use the default value from the in handleAMDGPUCodeObjectVersionOptions()
921 Args.MakeArgString(Twine("--amdhsa-code-object-version=") + in handleAMDGPUCodeObjectVersionOptions()
923 CmdArgs.insert(CmdArgs.begin() + 1, "-mllvm"); in handleAMDGPUCodeObjectVersionOptions()
924 // -cc1as does not accept -mcode-object-version option. in handleAMDGPUCodeObjectVersionOptions()
927 Args.MakeArgString(Twine("-mcode-object-version=") + in handleAMDGPUCodeObjectVersionOptions()
937 llvm::file_magic Magic = llvm::identify_magic((*MemBuf)->getBuffer()); in maybeHasClangPchSignature()
954 if (Status->isDirectory()) { in gchProbe()
958 if (maybeHasClangPchSignature(D, DI->path())) in gchProbe()
961 D.Diag(diag::warn_drv_pch_ignoring_gch_dir) << Path; in gchProbe()
967 D.Diag(diag::warn_drv_pch_ignoring_gch_file) << Path; in gchProbe()
991 // -M and -MM imply -w. in AddPreprocessingOptions()
993 CmdArgs.push_back("-w"); in AddPreprocessingOptions()
1001 DepFile = MF->getValue(); in AddPreprocessingOptions()
1006 DepFile = "-"; in AddPreprocessingOptions()
1011 CmdArgs.push_back("-dependency-file"); in AddPreprocessingOptions()
1017 A->claim(); in AddPreprocessingOptions()
1018 if (A->getOption().matches(options::OPT_MT)) { in AddPreprocessingOptions()
1019 A->render(Args, CmdArgs); in AddPreprocessingOptions()
1021 CmdArgs.push_back("-MT"); in AddPreprocessingOptions()
1023 quoteMakeTarget(A->getValue(), Quoted); in AddPreprocessingOptions()
1032 // If user provided -o, that is the dependency target, except in AddPreprocessingOptions()
1036 DepTarget = OutputOpt->getValue(); in AddPreprocessingOptions()
1046 CmdArgs.push_back("-MT"); in AddPreprocessingOptions()
1052 if (ArgM->getOption().matches(options::OPT_M) || in AddPreprocessingOptions()
1053 ArgM->getOption().matches(options::OPT_MD)) in AddPreprocessingOptions()
1054 CmdArgs.push_back("-sys-header-deps"); in AddPreprocessingOptions()
1058 CmdArgs.push_back("-module-file-deps"); in AddPreprocessingOptions()
1062 if (!ArgM || ArgM->getOption().matches(options::OPT_MD) || in AddPreprocessingOptions()
1063 ArgM->getOption().matches(options::OPT_MMD)) in AddPreprocessingOptions()
1064 D.Diag(diag::err_drv_mg_requires_m_or_mm); in AddPreprocessingOptions()
1065 CmdArgs.push_back("-MG"); in AddPreprocessingOptions()
1072 // before we -I or -include anything else, because we must pick up the in AddPreprocessingOptions()
1093 CmdArgs.push_back("-internal-isystem"); in AddPreprocessingOptions()
1097 CmdArgs.push_back("-include"); in AddPreprocessingOptions()
1101 // Add -i* options, and automatically translate to in AddPreprocessingOptions()
1102 // -include-pch/-include-pth for transparent PCH support. It's in AddPreprocessingOptions()
1112 CmdArgs.push_back(Args.MakeArgString("-building-pch-with-obj")); in AddPreprocessingOptions()
1113 // -fpch-instantiate-templates is the default when creating in AddPreprocessingOptions()
1117 CmdArgs.push_back(Args.MakeArgString("-fpch-instantiate-templates")); in AddPreprocessingOptions()
1120 StringRef ThroughHeader = YcArg ? YcArg->getValue() : YuArg->getValue(); in AddPreprocessingOptions()
1122 CmdArgs.push_back("-include-pch"); in AddPreprocessingOptions()
1131 Twine("-pch-through-hdrstop-") + (YcArg ? "create" : "use"))); in AddPreprocessingOptions()
1134 Args.MakeArgString(Twine("-pch-through-header=") + ThroughHeader)); in AddPreprocessingOptions()
1141 if (A->getOption().matches(options::OPT_include) && in AddPreprocessingOptions()
1143 // Handling of gcc-style gch precompiled headers. in AddPreprocessingOptions()
1148 SmallString<128> P(A->getValue()); in AddPreprocessingOptions()
1164 A->claim(); in AddPreprocessingOptions()
1165 CmdArgs.push_back("-include-pch"); in AddPreprocessingOptions()
1170 D.Diag(diag::warn_drv_pch_not_first_include) << P in AddPreprocessingOptions()
1171 << A->getAsString(Args); in AddPreprocessingOptions()
1174 } else if (A->getOption().matches(options::OPT_isystem_after)) { in AddPreprocessingOptions()
1181 } else if (A->getOption().matches(options::OPT_stdlibxx_isystem)) { in AddPreprocessingOptions()
1182 // Translated to -internal-isystem by the driver, no need to pass to cc1. in AddPreprocessingOptions()
1184 } else if (A->getOption().matches(options::OPT_ibuiltininc)) { in AddPreprocessingOptions()
1190 A->claim(); in AddPreprocessingOptions()
1191 A->render(Args, CmdArgs); in AddPreprocessingOptions()
1199 // Add -Wp, and -Xpreprocessor if using the preprocessor. in AddPreprocessingOptions()
1202 // souls abuse -Wp, to pass preprocessor options in gcc syntax. To in AddPreprocessingOptions()
1208 // -I- is a deprecated GCC feature, reject it. in AddPreprocessingOptions()
1210 D.Diag(diag::err_drv_I_dash_not_supported) << A->getAsString(Args); in AddPreprocessingOptions()
1212 // If we have a --sysroot, and don't have an explicit -isysroot flag, add an in AddPreprocessingOptions()
1213 // -isysroot to the CC1 invocation. in AddPreprocessingOptions()
1217 CmdArgs.push_back("-isysroot"); in AddPreprocessingOptions()
1225 // CPATH - included following the user specified includes (but prior to in AddPreprocessingOptions()
1227 addDirectoryList(Args, CmdArgs, "-I", "CPATH"); in AddPreprocessingOptions()
1228 // C_INCLUDE_PATH - system includes enabled when compiling C. in AddPreprocessingOptions()
1229 addDirectoryList(Args, CmdArgs, "-c-isystem", "C_INCLUDE_PATH"); in AddPreprocessingOptions()
1230 // CPLUS_INCLUDE_PATH - system includes enabled when compiling C++. in AddPreprocessingOptions()
1231 addDirectoryList(Args, CmdArgs, "-cxx-isystem", "CPLUS_INCLUDE_PATH"); in AddPreprocessingOptions()
1232 // OBJC_INCLUDE_PATH - system includes enabled when compiling ObjC. in AddPreprocessingOptions()
1233 addDirectoryList(Args, CmdArgs, "-objc-isystem", "OBJC_INCLUDE_PATH"); in AddPreprocessingOptions()
1234 // OBJCPLUS_INCLUDE_PATH - system includes enabled when compiling ObjC++. in AddPreprocessingOptions()
1235 addDirectoryList(Args, CmdArgs, "-objcxx-isystem", "OBJCPLUS_INCLUDE_PATH"); in AddPreprocessingOptions()
1268 CmdArgs.push_back("-internal-isystem"); in AddPreprocessingOptions()
1276 CmdArgs.push_back("-internal-isystem"); in AddPreprocessingOptions()
1299 CmdArgs.push_back("-source-date-epoch"); in AddPreprocessingOptions()
1347 // If more than one "-arch <arch>" is specified, we're targeting multiple in hasMultipleInvocations()
1361 D.Diag(diag::err_drv_invalid_output_with_multiple_archs) in checkRemarksOptions()
1362 << "-foptimization-record-file"; in checkRemarksOptions()
1374 Format = A->getValue(); in renderRemarksOptions()
1376 CmdArgs.push_back("-opt-record-file"); in renderRemarksOptions()
1380 CmdArgs.push_back(A->getValue()); in renderRemarksOptions()
1390 F = FinalOutput->getValue(); in renderRemarksOptions()
1410 F += "-"; in renderRemarksOptions()
1415 // If we're having more than one "-arch", we should name the files in renderRemarksOptions()
1417 // We're doing that by appending "-<arch>" with "<arch>" being the arch in renderRemarksOptions()
1424 // attach -<arch> to it. in renderRemarksOptions()
1425 F += "-"; in renderRemarksOptions()
1441 CmdArgs.push_back("-opt-record-passes"); in renderRemarksOptions()
1442 CmdArgs.push_back(A->getValue()); in renderRemarksOptions()
1446 CmdArgs.push_back("-opt-record-format"); in renderRemarksOptions()
1454 CmdArgs.push_back("-fno-aapcs-bitfield-width"); in AddAAPCSVolatileBitfieldArgs()
1457 CmdArgs.push_back("-faapcs-bitfield-load"); in AddAAPCSVolatileBitfieldArgs()
1464 // FIXME: Support -meabi. in RenderARMABI()
1468 ABIName = A->getValue(); in RenderARMABI()
1474 CmdArgs.push_back("-target-abi"); in RenderARMABI()
1481 return Arg == "+strict-align" || Arg == "-strict-align"; in AddUnalignedAccessWarning()
1484 StringRef(*StrictAlignIter) == "+strict-align") in AddUnalignedAccessWarning()
1485 CmdArgs.push_back("-Wunaligned-access"); in AddUnalignedAccessWarning()
1495 CC1Args.push_back("-fptrauth-intrinsics"); in handlePAuthABI()
1499 CC1Args.push_back("-fptrauth-calls"); in handlePAuthABI()
1503 CC1Args.push_back("-fptrauth-returns"); in handlePAuthABI()
1507 CC1Args.push_back("-fptrauth-auth-traps"); in handlePAuthABI()
1512 CC1Args.push_back("-fptrauth-vtable-pointer-address-discrimination"); in handlePAuthABI()
1517 CC1Args.push_back("-fptrauth-vtable-pointer-type-discrimination"); in handlePAuthABI()
1521 CC1Args.push_back("-fptrauth-indirect-gotos"); in handlePAuthABI()
1525 CC1Args.push_back("-fptrauth-init-fini"); in handlePAuthABI()
1540 D.Diag(diag::warn_incompatible_branch_protection_option) in CollectARMPACBTIOptions()
1546 if (A->getOption().matches(options::OPT_msign_return_address_EQ)) { in CollectARMPACBTIOptions()
1547 Scope = A->getValue(); in CollectARMPACBTIOptions()
1548 if (Scope != "none" && Scope != "non-leaf" && Scope != "all") in CollectARMPACBTIOptions()
1549 D.Diag(diag::err_drv_unsupported_option_argument) in CollectARMPACBTIOptions()
1550 << A->getSpelling() << Scope; in CollectARMPACBTIOptions()
1560 // To know if we need to enable PAuth-LR As part of the standard branch in CollectARMPACBTIOptions()
1574 if (!llvm::ARM::parseBranchProtection(A->getValue(), PBP, DiagMsg, in CollectARMPACBTIOptions()
1576 D.Diag(diag::err_drv_unsupported_option_argument) in CollectARMPACBTIOptions()
1577 << A->getSpelling() << DiagMsg; in CollectARMPACBTIOptions()
1579 D.Diag(diag::warn_unsupported_branch_protection) in CollectARMPACBTIOptions()
1580 << "b-key" << A->getAsString(Args); in CollectARMPACBTIOptions()
1589 Args.MakeArgString(Twine("-msign-return-address=") + Scope)); in CollectARMPACBTIOptions()
1592 D.Diag(diag::err_drv_unsupported_opt_for_target) in CollectARMPACBTIOptions()
1593 << A->getAsString(Args) << Triple.getTriple(); in CollectARMPACBTIOptions()
1595 Args.MakeArgString(Twine("-msign-return-address-key=") + Key)); in CollectARMPACBTIOptions()
1599 D.Diag(diag::err_drv_unsupported_opt_for_target) in CollectARMPACBTIOptions()
1600 << A->getAsString(Args) << Triple.getTriple(); in CollectARMPACBTIOptions()
1602 Args.MakeArgString(Twine("-mbranch-protection-pauth-lr"))); in CollectARMPACBTIOptions()
1605 CmdArgs.push_back("-mbranch-target-enforce"); in CollectARMPACBTIOptions()
1610 D.Diag(diag::err_drv_unsupported_opt_for_target) in CollectARMPACBTIOptions()
1611 << A->getAsString(Args) << Triple.getTriple(); in CollectARMPACBTIOptions()
1612 CmdArgs.push_back("-mguarded-control-stack"); in CollectARMPACBTIOptions()
1624 // FIXME: This changes CPP defines, we need -target-soft-float. in AddARMTargetArgs()
1625 CmdArgs.push_back("-msoft-float"); in AddARMTargetArgs()
1626 CmdArgs.push_back("-mfloat-abi"); in AddARMTargetArgs()
1630 CmdArgs.push_back("-mfloat-abi"); in AddARMTargetArgs()
1635 CmdArgs.push_back("-mfloat-abi"); in AddARMTargetArgs()
1639 // Forward the -mglobal-merge option for explicit control over the pass. in AddARMTargetArgs()
1642 CmdArgs.push_back("-mllvm"); in AddARMTargetArgs()
1643 if (A->getOption().matches(options::OPT_mno_global_merge)) in AddARMTargetArgs()
1644 CmdArgs.push_back("-arm-global-merge=false"); in AddARMTargetArgs()
1646 CmdArgs.push_back("-arm-global-merge=true"); in AddARMTargetArgs()
1651 CmdArgs.push_back("-no-implicit-float"); in AddARMTargetArgs()
1654 CmdArgs.push_back("-mcmse"); in AddARMTargetArgs()
1754 ABIName = A->getValue(); in RenderAArch64ABI()
1762 CmdArgs.push_back("-target-abi"); in RenderAArch64ABI()
1774 CmdArgs.push_back("-disable-red-zone"); in AddAArch64TargetArgs()
1778 CmdArgs.push_back("-no-implicit-float"); in AddAArch64TargetArgs()
1782 // Forward the -mglobal-merge option for explicit control over the pass. in AddAArch64TargetArgs()
1785 CmdArgs.push_back("-mllvm"); in AddAArch64TargetArgs()
1786 if (A->getOption().matches(options::OPT_mno_global_merge)) in AddAArch64TargetArgs()
1787 CmdArgs.push_back("-aarch64-enable-global-merge=false"); in AddAArch64TargetArgs()
1789 CmdArgs.push_back("-aarch64-enable-global-merge=true"); in AddAArch64TargetArgs()
1798 // Handle -msve_vector_bits=<bits> in AddAArch64TargetArgs()
1800 StringRef Val = A->getValue(); in AddAArch64TargetArgs()
1810 Args.MakeArgString("-mvscale-max=" + llvm::Twine(Bits / 128))); in AddAArch64TargetArgs()
1816 Args.MakeArgString("-mvscale-min=" + llvm::Twine(Bits / 128))); in AddAArch64TargetArgs()
1817 // Silently drop requests for vector-length agnostic code as it's implied. in AddAArch64TargetArgs()
1819 // Handle the unsupported values passed to msve-vector-bits. in AddAArch64TargetArgs()
1820 D.Diag(diag::err_drv_unsupported_option_argument) in AddAArch64TargetArgs()
1821 << A->getSpelling() << Val; in AddAArch64TargetArgs()
1827 CmdArgs.push_back("-tune-cpu"); in AddAArch64TargetArgs()
1828 if (strcmp(A->getValue(), "native") == 0) in AddAArch64TargetArgs()
1831 CmdArgs.push_back(A->getValue()); in AddAArch64TargetArgs()
1867 CmdArgs.push_back("-target-abi"); in AddLoongArchTargetArgs()
1872 // Handle -mtune. in AddLoongArchTargetArgs()
1874 std::string TuneCPU = A->getValue(); in AddLoongArchTargetArgs()
1876 CmdArgs.push_back("-tune-cpu"); in AddLoongArchTargetArgs()
1889 CmdArgs.push_back("-target-abi"); in AddMIPSTargetArgs()
1895 CmdArgs.push_back("-msoft-float"); in AddMIPSTargetArgs()
1896 CmdArgs.push_back("-mfloat-abi"); in AddMIPSTargetArgs()
1901 CmdArgs.push_back("-mfloat-abi"); in AddMIPSTargetArgs()
1907 if (A->getOption().matches(options::OPT_mno_ldc1_sdc1)) { in AddMIPSTargetArgs()
1908 CmdArgs.push_back("-mllvm"); in AddMIPSTargetArgs()
1909 CmdArgs.push_back("-mno-ldc1-sdc1"); in AddMIPSTargetArgs()
1915 if (A->getOption().matches(options::OPT_mno_check_zero_division)) { in AddMIPSTargetArgs()
1916 CmdArgs.push_back("-mllvm"); in AddMIPSTargetArgs()
1917 CmdArgs.push_back("-mno-check-zero-division"); in AddMIPSTargetArgs()
1922 CmdArgs.push_back("-mllvm"); in AddMIPSTargetArgs()
1923 CmdArgs.push_back("-mfix4300"); in AddMIPSTargetArgs()
1927 StringRef v = A->getValue(); in AddMIPSTargetArgs()
1928 CmdArgs.push_back("-mllvm"); in AddMIPSTargetArgs()
1929 CmdArgs.push_back(Args.MakeArgString("-mips-ssection-threshold=" + v)); in AddMIPSTargetArgs()
1930 A->claim(); in AddMIPSTargetArgs()
1937 // -mabicalls is the default for many MIPS environments, even with -fno-pic. in AddMIPSTargetArgs()
1938 // -mgpopt is the default for static, -fno-pic environments but these two in AddMIPSTargetArgs()
1939 // options conflict. We want to be certain that -mno-abicalls -mgpopt is in AddMIPSTargetArgs()
1940 // the only case where -mllvm -mgpopt is passed. in AddMIPSTargetArgs()
1941 // NOTE: We need a warning here or in the backend to warn when -mgpopt is in AddMIPSTargetArgs()
1942 // passed explicitly when compiling something with -mabicalls in AddMIPSTargetArgs()
1946 // is in use, as -fno-pic for N64 implies -mno-abicalls. in AddMIPSTargetArgs()
1948 ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls); in AddMIPSTargetArgs()
1959 bool WantGPOpt = GPOpt && GPOpt->getOption().matches(options::OPT_mgpopt); in AddMIPSTargetArgs()
1960 // We quietly ignore -mno-gpopt as the backend defaults to -mno-gpopt. in AddMIPSTargetArgs()
1962 CmdArgs.push_back("-mllvm"); in AddMIPSTargetArgs()
1963 CmdArgs.push_back("-mgpopt"); in AddMIPSTargetArgs()
1972 CmdArgs.push_back("-mllvm"); in AddMIPSTargetArgs()
1973 if (LocalSData->getOption().matches(options::OPT_mlocal_sdata)) { in AddMIPSTargetArgs()
1974 CmdArgs.push_back("-mlocal-sdata=1"); in AddMIPSTargetArgs()
1976 CmdArgs.push_back("-mlocal-sdata=0"); in AddMIPSTargetArgs()
1978 LocalSData->claim(); in AddMIPSTargetArgs()
1982 CmdArgs.push_back("-mllvm"); in AddMIPSTargetArgs()
1983 if (ExternSData->getOption().matches(options::OPT_mextern_sdata)) { in AddMIPSTargetArgs()
1984 CmdArgs.push_back("-mextern-sdata=1"); in AddMIPSTargetArgs()
1986 CmdArgs.push_back("-mextern-sdata=0"); in AddMIPSTargetArgs()
1988 ExternSData->claim(); in AddMIPSTargetArgs()
1992 CmdArgs.push_back("-mllvm"); in AddMIPSTargetArgs()
1993 if (EmbeddedData->getOption().matches(options::OPT_membedded_data)) { in AddMIPSTargetArgs()
1994 CmdArgs.push_back("-membedded-data=1"); in AddMIPSTargetArgs()
1996 CmdArgs.push_back("-membedded-data=0"); in AddMIPSTargetArgs()
1998 EmbeddedData->claim(); in AddMIPSTargetArgs()
2002 D.Diag(diag::warn_drv_unsupported_gpopt) << (ABICalls ? 0 : 1); in AddMIPSTargetArgs()
2005 GPOpt->claim(); in AddMIPSTargetArgs()
2008 StringRef Val = StringRef(A->getValue()); in AddMIPSTargetArgs()
2011 CmdArgs.push_back("-mllvm"); in AddMIPSTargetArgs()
2012 CmdArgs.push_back(Args.MakeArgString("-mips-compact-branches=" + Val)); in AddMIPSTargetArgs()
2014 D.Diag(diag::err_drv_unsupported_option_argument) in AddMIPSTargetArgs()
2015 << A->getSpelling() << Val; in AddMIPSTargetArgs()
2017 D.Diag(diag::warn_target_unsupported_compact_branches) << CPUName; in AddMIPSTargetArgs()
2022 if (A->getOption().matches(options::OPT_mno_relax_pic_calls)) { in AddMIPSTargetArgs()
2023 CmdArgs.push_back("-mllvm"); in AddMIPSTargetArgs()
2024 CmdArgs.push_back("-mips-jalr-reloc=0"); in AddMIPSTargetArgs()
2034 CmdArgs.push_back("-tune-cpu"); in AddPPCTargetArgs()
2061 StringRef V = A->getValue(); in AddPPCTargetArgs()
2064 A->claim(); in AddPPCTargetArgs()
2067 A->claim(); in AddPPCTargetArgs()
2068 } else if (V == "vec-default") { in AddPPCTargetArgs()
2070 A->claim(); in AddPPCTargetArgs()
2071 } else if (V == "vec-extabi") { in AddPPCTargetArgs()
2073 A->claim(); in AddPPCTargetArgs()
2076 A->claim(); in AddPPCTargetArgs()
2079 A->claim(); in AddPPCTargetArgs()
2084 ABIName = A->getValue(); in AddPPCTargetArgs()
2087 CmdArgs.push_back("-mabi=ieeelongdouble"); in AddPPCTargetArgs()
2090 D.Diag(diag::err_drv_unsupported_opt_for_target) in AddPPCTargetArgs()
2091 << "-mabi=vec-extabi" << T.str(); in AddPPCTargetArgs()
2092 CmdArgs.push_back("-mabi=vec-extabi"); in AddPPCTargetArgs()
2098 CmdArgs.push_back("-msoft-float"); in AddPPCTargetArgs()
2099 CmdArgs.push_back("-mfloat-abi"); in AddPPCTargetArgs()
2104 CmdArgs.push_back("-mfloat-abi"); in AddPPCTargetArgs()
2109 CmdArgs.push_back("-target-abi"); in AddPPCTargetArgs()
2126 D.Diag(diag::warn_drv_unsupported_sdata); in SetRISCVSmallDataLimit()
2134 D.Diag(diag::warn_drv_unsupported_sdata); in SetRISCVSmallDataLimit()
2140 D.Diag(diag::warn_drv_unsupported_sdata); in SetRISCVSmallDataLimit()
2143 SmallDataLimit = A->getValue(); in SetRISCVSmallDataLimit()
2145 // Forward the -msmall-data-limit= option. in SetRISCVSmallDataLimit()
2146 CmdArgs.push_back("-msmall-data-limit"); in SetRISCVSmallDataLimit()
2155 CmdArgs.push_back("-target-abi"); in AddRISCVTargetArgs()
2162 CmdArgs.push_back("-no-implicit-float"); in AddRISCVTargetArgs()
2165 CmdArgs.push_back("-tune-cpu"); in AddRISCVTargetArgs()
2166 if (strcmp(A->getValue(), "native") == 0) in AddRISCVTargetArgs()
2169 CmdArgs.push_back(A->getValue()); in AddRISCVTargetArgs()
2172 // Handle -mrvv-vector-bits=<bits> in AddRISCVTargetArgs()
2174 StringRef Val = A->getValue(); in AddRISCVTargetArgs()
2184 MinVLen = (*ISAInfo)->getMinVLen(); in AddRISCVTargetArgs()
2203 Args.MakeArgString("-mvscale-max=" + llvm::Twine(VScaleMin))); in AddRISCVTargetArgs()
2205 Args.MakeArgString("-mvscale-min=" + llvm::Twine(VScaleMin))); in AddRISCVTargetArgs()
2207 // Handle the unsupported values passed to mrvv-vector-bits. in AddRISCVTargetArgs()
2208 D.Diag(diag::err_drv_unsupported_option_argument) in AddRISCVTargetArgs()
2209 << A->getSpelling() << Val; in AddRISCVTargetArgs()
2221 CmdArgs.push_back("-msoft-float"); in AddSparcTargetArgs()
2222 CmdArgs.push_back("-mfloat-abi"); in AddSparcTargetArgs()
2227 CmdArgs.push_back("-mfloat-abi"); in AddSparcTargetArgs()
2232 StringRef Name = A->getValue(); in AddSparcTargetArgs()
2239 CmdArgs.push_back("-tune-cpu"); in AddSparcTargetArgs()
2247 CmdArgs.push_back("-tune-cpu"); in AddSystemZTargetArgs()
2248 if (strcmp(A->getValue(), "native") == 0) in AddSystemZTargetArgs()
2251 CmdArgs.push_back(A->getValue()); in AddSystemZTargetArgs()
2263 D.Diag(diag::err_drv_unsupported_opt) in AddSystemZTargetArgs()
2264 << "-mpacked-stack -mbackchain -mhard-float"; in AddSystemZTargetArgs()
2267 CmdArgs.push_back("-mbackchain"); in AddSystemZTargetArgs()
2269 CmdArgs.push_back("-mpacked-stack"); in AddSystemZTargetArgs()
2272 CmdArgs.push_back("-msoft-float"); in AddSystemZTargetArgs()
2273 CmdArgs.push_back("-mfloat-abi"); in AddSystemZTargetArgs()
2286 CmdArgs.push_back("-disable-red-zone"); in AddX86TargetArgs()
2290 CmdArgs.push_back("-mno-tls-direct-seg-refs"); in AddX86TargetArgs()
2292 // Default to avoid implicit floating-point for kernel/kext code, but allow in AddX86TargetArgs()
2293 // that to be overridden with -mno-soft-float. in AddX86TargetArgs()
2299 const Option &O = A->getOption(); in AddX86TargetArgs()
2304 CmdArgs.push_back("-no-implicit-float"); in AddX86TargetArgs()
2307 StringRef Value = A->getValue(); in AddX86TargetArgs()
2309 CmdArgs.push_back("-mllvm"); in AddX86TargetArgs()
2310 CmdArgs.push_back(Args.MakeArgString("-x86-asm-syntax=" + Value)); in AddX86TargetArgs()
2311 CmdArgs.push_back(Args.MakeArgString("-inline-asm=" + Value)); in AddX86TargetArgs()
2313 D.Diag(diag::err_drv_unsupported_option_argument) in AddX86TargetArgs()
2314 << A->getSpelling() << Value; in AddX86TargetArgs()
2317 CmdArgs.push_back("-mllvm"); in AddX86TargetArgs()
2318 CmdArgs.push_back("-x86-asm-syntax=intel"); in AddX86TargetArgs()
2323 if (A->getOption().matches(options::OPT_mskip_rax_setup)) in AddX86TargetArgs()
2324 CmdArgs.push_back(Args.MakeArgString("-mskip-rax-setup")); in AddX86TargetArgs()
2328 CmdArgs.push_back("-mfloat-abi"); in AddX86TargetArgs()
2330 CmdArgs.push_back("-mstack-alignment=4"); in AddX86TargetArgs()
2333 // Handle -mtune. in AddX86TargetArgs()
2335 // Default to "generic" unless -march is present or targetting the PS4/PS5. in AddX86TargetArgs()
2341 // Override based on -mtune. in AddX86TargetArgs()
2343 StringRef Name = A->getValue(); in AddX86TargetArgs()
2354 CmdArgs.push_back("-tune-cpu"); in AddX86TargetArgs()
2361 CmdArgs.push_back("-mqdsp6-compat"); in AddHexagonTargetArgs()
2362 CmdArgs.push_back("-Wreturn-type"); in AddHexagonTargetArgs()
2365 CmdArgs.push_back("-mllvm"); in AddHexagonTargetArgs()
2367 Args.MakeArgString("-hexagon-small-data-threshold=" + Twine(*G))); in AddHexagonTargetArgs()
2371 CmdArgs.push_back("-fshort-enums"); in AddHexagonTargetArgs()
2373 CmdArgs.push_back("-mllvm"); in AddHexagonTargetArgs()
2374 CmdArgs.push_back("-enable-hexagon-ieee-rnd-near"); in AddHexagonTargetArgs()
2376 CmdArgs.push_back("-mllvm"); in AddHexagonTargetArgs()
2377 CmdArgs.push_back("-machine-sink-split=0"); in AddHexagonTargetArgs()
2383 StringRef CPUName = A->getValue(); in AddLanaiTargetArgs()
2385 CmdArgs.push_back("-target-cpu"); in AddLanaiTargetArgs()
2389 StringRef Value = A->getValue(); in AddLanaiTargetArgs()
2395 getToolChain().getDriver().Diag( in AddLanaiTargetArgs()
2396 diag::err_drv_unsupported_option_argument) in AddLanaiTargetArgs()
2397 << A->getSpelling() << Value; in AddLanaiTargetArgs()
2408 CmdArgs.push_back("-fvisibility=hidden"); in AddWebAssemblyTargetArgs()
2413 CmdArgs.push_back("-mfloat-abi"); in AddVETargetArgs()
2433 D.Diag(clang::diag::err_drv_compilationdatabase) << Filename in DumpCompilationDatabase()
2449 Buf = "-x"; in DumpCompilationDatabase()
2453 Buf = "--sysroot="; in DumpCompilationDatabase()
2459 CDB << ", \"-o\", \"" << escape(Output.getFilename()) << "\""; in DumpCompilationDatabase()
2461 auto &O = A->getOption(); in DumpCompilationDatabase()
2478 A->render(Args, ASL); in DumpCompilationDatabase()
2482 Buf = "--target="; in DumpCompilationDatabase()
2502 Driver.Diag(diag::err_drv_compilationdatabase) << Dir << Err.message(); in DumpCompilationDatabaseFragmentToDir()
2514 Driver.Diag(diag::err_drv_compilationdatabase) << Path << Err.message(); in DumpCompilationDatabaseFragmentToDir()
2529 CmdArgs.push_back("-mllvm"); in AddARMImplicitITArgs()
2530 CmdArgs.push_back(Args.MakeArgString("-arm-implicit-it=" + Value)); in AddARMImplicitITArgs()
2537 // Default to -mno-relax-all. in CollectArgsForIntegratedAssembler()
2539 // Note: RISC-V requires an indirect jump for offsets larger than 1MiB. This in CollectArgsForIntegratedAssembler()
2542 // before the assembler. Forcing assembler branch relaxation for -O0 makes the in CollectArgsForIntegratedAssembler()
2548 // Only default to -mincremental-linker-compatible if we think we are in CollectArgsForIntegratedAssembler()
2555 CmdArgs.push_back("-mincremental-linker-compatible"); in CollectArgsForIntegratedAssembler()
2565 // When passing -I arguments to the assembler we sometimes need to in CollectArgsForIntegratedAssembler()
2567 // '-Wa,-I -Wa,foo' we need to accept the -Wa,foo arg after seeing the in CollectArgsForIntegratedAssembler()
2568 // -Wa,-I arg and when parsing '-Wa,-I,foo' we need to accept the 'foo' in CollectArgsForIntegratedAssembler()
2569 // arg after parsing the '-I' arg. in CollectArgsForIntegratedAssembler()
2581 A->claim(); in CollectArgsForIntegratedAssembler()
2583 if (A->getOption().getID() == options::OPT_mimplicit_it_EQ) { in CollectArgsForIntegratedAssembler()
2590 ImplicitIt = A->getValue(); in CollectArgsForIntegratedAssembler()
2592 D.Diag(diag::err_drv_unsupported_option_argument) in CollectArgsForIntegratedAssembler()
2593 << A->getSpelling() << ImplicitIt; in CollectArgsForIntegratedAssembler()
2600 for (StringRef Value : A->getValues()) { in CollectArgsForIntegratedAssembler()
2608 Value == "-mbig-obj") in CollectArgsForIntegratedAssembler()
2616 if (Value == "-msse2avx") { in CollectArgsForIntegratedAssembler()
2617 CmdArgs.push_back("-msse2avx"); in CollectArgsForIntegratedAssembler()
2623 if (Value == "--no-type-check") { in CollectArgsForIntegratedAssembler()
2624 CmdArgs.push_back("-mno-type-check"); in CollectArgsForIntegratedAssembler()
2632 if (Value.starts_with("-mimplicit-it=")) { in CollectArgsForIntegratedAssembler()
2638 if (Value == "-mthumb") in CollectArgsForIntegratedAssembler()
2639 // -mthumb has already been processed in ComputeLLVMTriple() in CollectArgsForIntegratedAssembler()
2647 if (Value == "--trap") { in CollectArgsForIntegratedAssembler()
2648 CmdArgs.push_back("-target-feature"); in CollectArgsForIntegratedAssembler()
2649 CmdArgs.push_back("+use-tcc-in-div"); in CollectArgsForIntegratedAssembler()
2652 if (Value == "--break") { in CollectArgsForIntegratedAssembler()
2653 CmdArgs.push_back("-target-feature"); in CollectArgsForIntegratedAssembler()
2654 CmdArgs.push_back("-use-tcc-in-div"); in CollectArgsForIntegratedAssembler()
2657 if (Value.starts_with("-msoft-float")) { in CollectArgsForIntegratedAssembler()
2658 CmdArgs.push_back("-target-feature"); in CollectArgsForIntegratedAssembler()
2659 CmdArgs.push_back("+soft-float"); in CollectArgsForIntegratedAssembler()
2662 if (Value.starts_with("-mhard-float")) { in CollectArgsForIntegratedAssembler()
2663 CmdArgs.push_back("-target-feature"); in CollectArgsForIntegratedAssembler()
2664 CmdArgs.push_back("-soft-float"); in CollectArgsForIntegratedAssembler()
2669 .Case("-mips1", "+mips1") in CollectArgsForIntegratedAssembler()
2670 .Case("-mips2", "+mips2") in CollectArgsForIntegratedAssembler()
2671 .Case("-mips3", "+mips3") in CollectArgsForIntegratedAssembler()
2672 .Case("-mips4", "+mips4") in CollectArgsForIntegratedAssembler()
2673 .Case("-mips5", "+mips5") in CollectArgsForIntegratedAssembler()
2674 .Case("-mips32", "+mips32") in CollectArgsForIntegratedAssembler()
2675 .Case("-mips32r2", "+mips32r2") in CollectArgsForIntegratedAssembler()
2676 .Case("-mips32r3", "+mips32r3") in CollectArgsForIntegratedAssembler()
2677 .Case("-mips32r5", "+mips32r5") in CollectArgsForIntegratedAssembler()
2678 .Case("-mips32r6", "+mips32r6") in CollectArgsForIntegratedAssembler()
2679 .Case("-mips64", "+mips64") in CollectArgsForIntegratedAssembler()
2680 .Case("-mips64r2", "+mips64r2") in CollectArgsForIntegratedAssembler()
2681 .Case("-mips64r3", "+mips64r3") in CollectArgsForIntegratedAssembler()
2682 .Case("-mips64r5", "+mips64r5") in CollectArgsForIntegratedAssembler()
2683 .Case("-mips64r6", "+mips64r6") in CollectArgsForIntegratedAssembler()
2689 if (Value == "-force_cpusubtype_ALL") { in CollectArgsForIntegratedAssembler()
2691 } else if (Value == "-L") { in CollectArgsForIntegratedAssembler()
2692 CmdArgs.push_back("-msave-temp-labels"); in CollectArgsForIntegratedAssembler()
2693 } else if (Value == "--fatal-warnings") { in CollectArgsForIntegratedAssembler()
2694 CmdArgs.push_back("-massembler-fatal-warnings"); in CollectArgsForIntegratedAssembler()
2695 } else if (Value == "--no-warn" || Value == "-W") { in CollectArgsForIntegratedAssembler()
2696 CmdArgs.push_back("-massembler-no-warn"); in CollectArgsForIntegratedAssembler()
2697 } else if (Value == "--noexecstack") { in CollectArgsForIntegratedAssembler()
2699 } else if (Value.starts_with("-compress-debug-sections") || in CollectArgsForIntegratedAssembler()
2700 Value.starts_with("--compress-debug-sections") || in CollectArgsForIntegratedAssembler()
2701 Value == "-nocompress-debug-sections" || in CollectArgsForIntegratedAssembler()
2702 Value == "--nocompress-debug-sections") { in CollectArgsForIntegratedAssembler()
2704 } else if (Value == "--crel") { in CollectArgsForIntegratedAssembler()
2706 } else if (Value == "--no-crel") { in CollectArgsForIntegratedAssembler()
2708 } else if (Value == "--allow-experimental-crel") { in CollectArgsForIntegratedAssembler()
2710 } else if (Value == "-mrelax-relocations=yes" || in CollectArgsForIntegratedAssembler()
2711 Value == "--mrelax-relocations=yes") { in CollectArgsForIntegratedAssembler()
2713 } else if (Value == "-mrelax-relocations=no" || in CollectArgsForIntegratedAssembler()
2714 Value == "--mrelax-relocations=no") { in CollectArgsForIntegratedAssembler()
2716 } else if (Value.starts_with("-I")) { in CollectArgsForIntegratedAssembler()
2719 // -I. The next arg will be the include directory. in CollectArgsForIntegratedAssembler()
2720 if (Value == "-I") in CollectArgsForIntegratedAssembler()
2722 } else if (Value.starts_with("-gdwarf-")) { in CollectArgsForIntegratedAssembler()
2723 // "-gdwarf-N" options are not cc1as options. in CollectArgsForIntegratedAssembler()
2732 } else if (Value.starts_with("-mcpu") || Value.starts_with("-mfpu") || in CollectArgsForIntegratedAssembler()
2733 Value.starts_with("-mhwdiv") || Value.starts_with("-march")) { in CollectArgsForIntegratedAssembler()
2735 } else if (Value == "-defsym" || Value == "--defsym") { in CollectArgsForIntegratedAssembler()
2736 if (A->getNumValues() != 2) { in CollectArgsForIntegratedAssembler()
2737 D.Diag(diag::err_drv_defsym_invalid_format) << Value; in CollectArgsForIntegratedAssembler()
2740 const char *S = A->getValue(1); in CollectArgsForIntegratedAssembler()
2746 D.Diag(diag::err_drv_defsym_invalid_format) << S; in CollectArgsForIntegratedAssembler()
2751 D.Diag(diag::err_drv_defsym_invalid_symval) << SVal; in CollectArgsForIntegratedAssembler()
2754 CmdArgs.push_back("--defsym"); in CollectArgsForIntegratedAssembler()
2756 } else if (Value == "-fdebug-compilation-dir") { in CollectArgsForIntegratedAssembler()
2757 CmdArgs.push_back("-fdebug-compilation-dir"); in CollectArgsForIntegratedAssembler()
2759 } else if (Value.consume_front("-fdebug-compilation-dir=")) { in CollectArgsForIntegratedAssembler()
2760 // The flag is a -Wa / -Xassembler argument and Options doesn't in CollectArgsForIntegratedAssembler()
2762 // -fdebug-compilation-dir (without '=') here. in CollectArgsForIntegratedAssembler()
2763 CmdArgs.push_back("-fdebug-compilation-dir"); in CollectArgsForIntegratedAssembler()
2765 } else if (Value == "--version") { in CollectArgsForIntegratedAssembler()
2768 D.Diag(diag::err_drv_unsupported_option_argument) in CollectArgsForIntegratedAssembler()
2769 << A->getSpelling() << Value; in CollectArgsForIntegratedAssembler()
2777 D.Diag(diag::err_drv_experimental_crel); in CollectArgsForIntegratedAssembler()
2779 CmdArgs.push_back("--crel"); in CollectArgsForIntegratedAssembler()
2781 D.Diag(diag::err_drv_unsupported_opt_for_target) in CollectArgsForIntegratedAssembler()
2782 << "-Wa,--crel" << D.getTargetTriple(); in CollectArgsForIntegratedAssembler()
2786 CmdArgs.push_back("-mrelax-relocations=no"); in CollectArgsForIntegratedAssembler()
2788 CmdArgs.push_back("-mnoexecstack"); in CollectArgsForIntegratedAssembler()
2790 CmdArgs.push_back("-target-feature"); in CollectArgsForIntegratedAssembler()
2794 // forward -fembed-bitcode to assmebler in CollectArgsForIntegratedAssembler()
2800 CmdArgs.push_back("-as-secure-log-file"); in CollectArgsForIntegratedAssembler()
2827 : "-fcomplex-arithmetic=" + ComplexRangeKindToStr(Range); in ComplexArithmeticStr()
2833 D.Diag(clang::diag::warn_drv_overriding_option) << str1 << str2; in EmitComplexRangeDiag()
2841 return "-complex-range=" + ComplexRangeStr; in RenderComplexRangeOption()
2857 // -fmath-errno is the default on some platforms, e.g. BSD-derived OSes. in RenderFloatingPointOptions()
2862 bool TrappingMath = false; // Implemented via -ffp-exception-behavior in RenderFloatingPointOptions()
2863 bool TrappingMathPresent = false; // Is trapping-math in args, and not in RenderFloatingPointOptions()
2864 // overriden by ffp-exception-behavior? in RenderFloatingPointOptions()
2866 // -ffp-model values: strict, fast, precise in RenderFloatingPointOptions()
2868 // -ffp-exception-behavior options: strict, maytrap, ignore in RenderFloatingPointOptions()
2870 // -ffp-eval-method options: double, extended, source in RenderFloatingPointOptions()
2877 // CUDA and HIP don't rely on the frontend to pass an ffp-contract option. in RenderFloatingPointOptions()
2892 // Lambda to set fast-math options. This is also used by -ffp-model=fast in RenderFloatingPointOptions()
2904 // If fast-math is set then set the fp-contract mode to fast. in RenderFloatingPointOptions()
2906 // ffast-math enables basic range rules for complex multiplication and in RenderFloatingPointOptions()
2923 CmdArgs.push_back("-mlimit-float-precision"); in RenderFloatingPointOptions()
2924 CmdArgs.push_back(A->getValue()); in RenderFloatingPointOptions()
2928 switch (A->getOption().getID()) { in RenderFloatingPointOptions()
2936 "-fcx-limited-range"); in RenderFloatingPointOptions()
2938 if (GccRangeComplexOption != "-fno-cx-limited-range") in RenderFloatingPointOptions()
2939 EmitComplexRangeDiag(D, GccRangeComplexOption, "-fcx-limited-range"); in RenderFloatingPointOptions()
2941 GccRangeComplexOption = "-fcx-limited-range"; in RenderFloatingPointOptions()
2947 "-fno-cx-limited-range"); in RenderFloatingPointOptions()
2949 if (GccRangeComplexOption.compare("-fcx-limited-range") != 0 && in RenderFloatingPointOptions()
2950 GccRangeComplexOption.compare("-fno-cx-fortran-rules") != 0) in RenderFloatingPointOptions()
2952 "-fno-cx-limited-range"); in RenderFloatingPointOptions()
2954 GccRangeComplexOption = "-fno-cx-limited-range"; in RenderFloatingPointOptions()
2960 "-fcx-fortran-rules"); in RenderFloatingPointOptions()
2962 EmitComplexRangeDiag(D, GccRangeComplexOption, "-fcx-fortran-rules"); in RenderFloatingPointOptions()
2963 GccRangeComplexOption = "-fcx-fortran-rules"; in RenderFloatingPointOptions()
2969 "-fno-cx-fortran-rules"); in RenderFloatingPointOptions()
2971 if (GccRangeComplexOption != "-fno-cx-limited-range") in RenderFloatingPointOptions()
2973 "-fno-cx-fortran-rules"); in RenderFloatingPointOptions()
2975 GccRangeComplexOption = "-fno-cx-fortran-rules"; in RenderFloatingPointOptions()
2980 StringRef Val = A->getValue(); in RenderFloatingPointOptions()
2990 D.Diag(diag::err_drv_unsupported_option_argument) in RenderFloatingPointOptions()
2991 << A->getSpelling() << Val; in RenderFloatingPointOptions()
2995 if (GccRangeComplexOption.compare("-fcx-limited-range") != 0) { in RenderFloatingPointOptions()
2996 if (GccRangeComplexOption.compare("-fcx-fortran-rules") != 0) { in RenderFloatingPointOptions()
3014 // If -ffp-model= is seen, reset to fno-fast-math in RenderFloatingPointOptions()
3018 // Turning *off* -ffast-math restores the toolchain default. in RenderFloatingPointOptions()
3025 StringRef Val = A->getValue(); in RenderFloatingPointOptions()
3027 // Only -ffp-model=fast is compatible with OFast, ignore. in RenderFloatingPointOptions()
3028 D.Diag(clang::diag::warn_drv_overriding_option) in RenderFloatingPointOptions()
3029 << Args.MakeArgString("-ffp-model=" + Val) << "-Ofast"; in RenderFloatingPointOptions()
3034 D.Diag(clang::diag::warn_drv_overriding_option) in RenderFloatingPointOptions()
3035 << Args.MakeArgString("-ffp-model=" + FPModel) in RenderFloatingPointOptions()
3036 << Args.MakeArgString("-ffp-model=" + Val); in RenderFloatingPointOptions()
3051 D.Diag(diag::err_drv_unsupported_option_argument) in RenderFloatingPointOptions()
3052 << A->getSpelling() << Val; in RenderFloatingPointOptions()
3075 D.Diag(clang::diag::warn_drv_overriding_option) in RenderFloatingPointOptions()
3076 << Args.MakeArgString("-ffp-exception-behavior=" + in RenderFloatingPointOptions()
3078 << "-ftrapping-math"; in RenderFloatingPointOptions()
3087 D.Diag(clang::diag::warn_drv_overriding_option) in RenderFloatingPointOptions()
3088 << Args.MakeArgString("-ffp-exception-behavior=" + in RenderFloatingPointOptions()
3090 << "-fno-trapping-math"; in RenderFloatingPointOptions()
3105 DenormalFPMath = llvm::parseDenormalFPAttribute(A->getValue()); in RenderFloatingPointOptions()
3108 D.Diag(diag::err_drv_invalid_value) in RenderFloatingPointOptions()
3109 << A->getAsString(Args) << A->getValue(); in RenderFloatingPointOptions()
3114 DenormalFP32Math = llvm::parseDenormalFPAttribute(A->getValue()); in RenderFloatingPointOptions()
3116 D.Diag(diag::err_drv_invalid_value) in RenderFloatingPointOptions()
3117 << A->getAsString(Args) << A->getValue(); in RenderFloatingPointOptions()
3121 // Validate and pass through -ffp-contract option. in RenderFloatingPointOptions()
3123 StringRef Val = A->getValue(); in RenderFloatingPointOptions()
3125 Val == "fast-honor-pragmas") { in RenderFloatingPointOptions()
3129 D.Diag(diag::err_drv_unsupported_option_argument) in RenderFloatingPointOptions()
3130 << A->getSpelling() << Val; in RenderFloatingPointOptions()
3134 // Validate and pass through -ffp-exception-behavior option. in RenderFloatingPointOptions()
3136 StringRef Val = A->getValue(); in RenderFloatingPointOptions()
3140 D.Diag(clang::diag::warn_drv_overriding_option) in RenderFloatingPointOptions()
3141 << Args.MakeArgString("-ffp-exception-behavior=" + in RenderFloatingPointOptions()
3143 << Args.MakeArgString("-ffp-exception-behavior=" + Val); in RenderFloatingPointOptions()
3151 D.Diag(diag::err_drv_unsupported_option_argument) in RenderFloatingPointOptions()
3152 << A->getSpelling() << Val; in RenderFloatingPointOptions()
3156 // Validate and pass through -ffp-eval-method option. in RenderFloatingPointOptions()
3158 StringRef Val = A->getValue(); in RenderFloatingPointOptions()
3162 D.Diag(diag::err_drv_unsupported_option_argument) in RenderFloatingPointOptions()
3163 << A->getSpelling() << Val; in RenderFloatingPointOptions()
3168 StringRef Val = A->getValue(); in RenderFloatingPointOptions()
3179 D.Diag(diag::err_drv_unsupported_option_argument) in RenderFloatingPointOptions()
3180 << A->getSpelling() << Val; in RenderFloatingPointOptions()
3183 D.Diag(diag::err_drv_unsupported_option_argument) in RenderFloatingPointOptions()
3184 << A->getSpelling() << Val; in RenderFloatingPointOptions()
3224 // If -Ofast is the optimization level, then -ffast-math should be enabled in RenderFloatingPointOptions()
3235 // Turning on -ffast-math (with either flag) removes the need for in RenderFloatingPointOptions()
3236 // MathErrno. However, turning *off* -ffast-math merely restores the in RenderFloatingPointOptions()
3243 // -fno_fast_math restores default fpcontract handling in RenderFloatingPointOptions()
3254 // in the way we intend. If -ffp-model=strict has been used, we in RenderFloatingPointOptions()
3256 // takes us out of the settings described by fp-model=strict, but in RenderFloatingPointOptions()
3260 // If -ffp-model=strict has been specified on command line but in RenderFloatingPointOptions()
3265 // OK: Current Arg doesn't conflict with -ffp-model=strict in RenderFloatingPointOptions()
3270 auto RHS = (A->getNumValues() == 0) in RenderFloatingPointOptions()
3271 ? A->getSpelling() in RenderFloatingPointOptions()
3272 : Args.MakeArgString(A->getSpelling() + A->getValue()); in RenderFloatingPointOptions()
3273 if (RHS != "-ffp-model=strict") in RenderFloatingPointOptions()
3274 D.Diag(clang::diag::warn_drv_overriding_option) in RenderFloatingPointOptions()
3275 << "-ffp-model=strict" << RHS; in RenderFloatingPointOptions()
3280 A->claim(); in RenderFloatingPointOptions()
3284 CmdArgs.push_back("-menable-no-infs"); in RenderFloatingPointOptions()
3287 CmdArgs.push_back("-menable-no-nans"); in RenderFloatingPointOptions()
3290 CmdArgs.push_back("-fapprox-func"); in RenderFloatingPointOptions()
3293 CmdArgs.push_back("-fmath-errno"); in RenderFloatingPointOptions()
3297 CmdArgs.push_back("-funsafe-math-optimizations"); in RenderFloatingPointOptions()
3300 CmdArgs.push_back("-fno-signed-zeros"); in RenderFloatingPointOptions()
3303 CmdArgs.push_back("-mreassociate"); in RenderFloatingPointOptions()
3306 CmdArgs.push_back("-freciprocal-math"); in RenderFloatingPointOptions()
3317 ArgStr << "-fdenormal-fp-math=" << DenormalFPMath; in RenderFloatingPointOptions()
3325 ArgStr << "-fdenormal-fp-math-f32=" << DenormalFP32Math; in RenderFloatingPointOptions()
3330 CmdArgs.push_back(Args.MakeArgString("-ffp-contract=" + FPContract)); in RenderFloatingPointOptions()
3333 CmdArgs.push_back(Args.MakeArgString("-frounding-math")); in RenderFloatingPointOptions()
3335 CmdArgs.push_back(Args.MakeArgString("-fno-rounding-math")); in RenderFloatingPointOptions()
3338 CmdArgs.push_back(Args.MakeArgString("-ffp-exception-behavior=" + in RenderFloatingPointOptions()
3342 CmdArgs.push_back(Args.MakeArgString("-ffp-eval-method=" + FPEvalMethod)); in RenderFloatingPointOptions()
3345 CmdArgs.push_back(Args.MakeArgString("-ffloat16-excess-precision=" + in RenderFloatingPointOptions()
3348 CmdArgs.push_back(Args.MakeArgString("-fbfloat16-excess-precision=" + in RenderFloatingPointOptions()
3353 // -ffast-math enables the __FAST_MATH__ preprocessor macro, but check for the in RenderFloatingPointOptions()
3354 // individual features enabled by -ffast-math instead of the option itself as in RenderFloatingPointOptions()
3358 CmdArgs.push_back("-ffast-math"); in RenderFloatingPointOptions()
3364 // Enable -ffp-contract=fast in RenderFloatingPointOptions()
3365 CmdArgs.push_back(Args.MakeArgString("-ffp-contract=fast")); in RenderFloatingPointOptions()
3367 D.Diag(clang::diag::warn_drv_overriding_option) in RenderFloatingPointOptions()
3368 << "-ffp-model=fast" in RenderFloatingPointOptions()
3369 << Args.MakeArgString("-ffp-contract=" + FPContract); in RenderFloatingPointOptions()
3375 CmdArgs.push_back("-ffinite-math-only"); in RenderFloatingPointOptions()
3378 CmdArgs.push_back("-mfpmath"); in RenderFloatingPointOptions()
3379 CmdArgs.push_back(A->getValue()); in RenderFloatingPointOptions()
3382 // Disable a codegen optimization for floating-point casts. in RenderFloatingPointOptions()
3385 CmdArgs.push_back("-fno-strict-float-cast-overflow"); in RenderFloatingPointOptions()
3392 CmdArgs.push_back(Args.MakeArgString("-fcomplex-arithmetic=" + in RenderFloatingPointOptions()
3396 CmdArgs.push_back("-fcx-limited-range"); in RenderFloatingPointOptions()
3398 CmdArgs.push_back("-fcx-fortran-rules"); in RenderFloatingPointOptions()
3400 CmdArgs.push_back("-fno-cx-limited-range"); in RenderFloatingPointOptions()
3402 CmdArgs.push_back("-fno-cx-fortran-rules"); in RenderFloatingPointOptions()
3410 CmdArgs.push_back("-analyzer-checker=core"); in RenderAnalyzerOptions()
3411 CmdArgs.push_back("-analyzer-checker=apiModeling"); in RenderAnalyzerOptions()
3414 CmdArgs.push_back("-analyzer-checker=unix"); in RenderAnalyzerOptions()
3417 CmdArgs.push_back("-analyzer-checker=unix.API"); in RenderAnalyzerOptions()
3418 CmdArgs.push_back("-analyzer-checker=unix.Malloc"); in RenderAnalyzerOptions()
3419 CmdArgs.push_back("-analyzer-checker=unix.MallocSizeof"); in RenderAnalyzerOptions()
3420 CmdArgs.push_back("-analyzer-checker=unix.MismatchedDeallocator"); in RenderAnalyzerOptions()
3421 CmdArgs.push_back("-analyzer-checker=unix.cstring.BadSizeArg"); in RenderAnalyzerOptions()
3422 CmdArgs.push_back("-analyzer-checker=unix.cstring.NullArg"); in RenderAnalyzerOptions()
3427 CmdArgs.push_back("-analyzer-disable-checker=unix.API"); in RenderAnalyzerOptions()
3428 CmdArgs.push_back("-analyzer-disable-checker=unix.Vfork"); in RenderAnalyzerOptions()
3432 CmdArgs.push_back("-analyzer-checker=osx"); in RenderAnalyzerOptions()
3434 "-analyzer-checker=security.insecureAPI.decodeValueOfObjCType"); in RenderAnalyzerOptions()
3437 CmdArgs.push_back("-analyzer-checker=fuchsia"); in RenderAnalyzerOptions()
3439 CmdArgs.push_back("-analyzer-checker=deadcode"); in RenderAnalyzerOptions()
3442 CmdArgs.push_back("-analyzer-checker=cplusplus"); in RenderAnalyzerOptions()
3445 CmdArgs.push_back("-analyzer-checker=security.insecureAPI.UncheckedReturn"); in RenderAnalyzerOptions()
3446 CmdArgs.push_back("-analyzer-checker=security.insecureAPI.getpw"); in RenderAnalyzerOptions()
3447 CmdArgs.push_back("-analyzer-checker=security.insecureAPI.gets"); in RenderAnalyzerOptions()
3448 CmdArgs.push_back("-analyzer-checker=security.insecureAPI.mktemp"); in RenderAnalyzerOptions()
3449 CmdArgs.push_back("-analyzer-checker=security.insecureAPI.mkstemp"); in RenderAnalyzerOptions()
3450 CmdArgs.push_back("-analyzer-checker=security.insecureAPI.vfork"); in RenderAnalyzerOptions()
3454 CmdArgs.push_back("-analyzer-checker=nullability.NullPassedToNonnull"); in RenderAnalyzerOptions()
3455 CmdArgs.push_back("-analyzer-checker=nullability.NullReturnedFromNonnull"); in RenderAnalyzerOptions()
3459 CmdArgs.push_back("-analyzer-output"); in RenderAnalyzerOptions()
3461 CmdArgs.push_back(A->getValue()); in RenderAnalyzerOptions()
3466 // --analyze. We only want to show static analyzer diagnostics or frontend in RenderAnalyzerOptions()
3468 CmdArgs.push_back("-w"); in RenderAnalyzerOptions()
3470 // Add -Xanalyzer arguments when running as analyzer. in RenderAnalyzerOptions()
3494 // -stack-protector=0 is default. in RenderSSPOptions()
3503 if (A->getOption().matches(options::OPT_fstack_protector)) in RenderSSPOptions()
3506 else if (A->getOption().matches(options::OPT_fstack_protector_strong)) in RenderSSPOptions()
3508 else if (A->getOption().matches(options::OPT_fstack_protector_all)) in RenderSSPOptions()
3512 D.Diag(diag::warn_drv_unsupported_option_for_target) in RenderSSPOptions()
3513 << A->getSpelling() << EffectiveTriple.getTriple(); in RenderSSPOptions()
3521 CmdArgs.push_back("-stack-protector"); in RenderSSPOptions()
3525 // --param ssp-buffer-size= in RenderSSPOptions()
3527 StringRef Str(A->getValue()); in RenderSSPOptions()
3528 if (Str.starts_with("ssp-buffer-size=")) { in RenderSSPOptions()
3530 CmdArgs.push_back("-stack-protector-buffer-size"); in RenderSSPOptions()
3534 A->claim(); in RenderSSPOptions()
3540 StringRef Value = A->getValue(); in RenderSSPOptions()
3543 D.Diag(diag::err_drv_unsupported_opt_for_target) in RenderSSPOptions()
3544 << A->getAsString(Args) << TripleStr; in RenderSSPOptions()
3548 D.Diag(diag::err_drv_invalid_value_with_suggestion) in RenderSSPOptions()
3549 << A->getOption().getName() << Value << "tls global"; in RenderSSPOptions()
3555 D.Diag(diag::err_drv_ssp_missing_offset_argument) in RenderSSPOptions()
3556 << A->getAsString(Args); in RenderSSPOptions()
3561 D.Diag(diag::err_target_unsupported_tp_hard) in RenderSSPOptions()
3565 // Check whether the user asked for something other than -mtp=cp15 in RenderSSPOptions()
3567 StringRef Value = A->getValue(); in RenderSSPOptions()
3569 D.Diag(diag::err_drv_argument_not_allowed_with) in RenderSSPOptions()
3570 << A->getAsString(Args) << "-mstack-protector-guard=tls"; in RenderSSPOptions()
3574 CmdArgs.push_back("-target-feature"); in RenderSSPOptions()
3575 CmdArgs.push_back("+read-tp-tpidruro"); in RenderSSPOptions()
3578 D.Diag(diag::err_drv_invalid_value_with_suggestion) in RenderSSPOptions()
3579 << A->getOption().getName() << Value << "sysreg global"; in RenderSSPOptions()
3582 A->render(Args, CmdArgs); in RenderSSPOptions()
3586 StringRef Value = A->getValue(); in RenderSSPOptions()
3589 D.Diag(diag::err_drv_unsupported_opt_for_target) in RenderSSPOptions()
3590 << A->getAsString(Args) << TripleStr; in RenderSSPOptions()
3593 D.Diag(diag::err_drv_invalid_value) << A->getOption().getName() << Value; in RenderSSPOptions()
3598 D.Diag(diag::err_drv_invalid_int_value) in RenderSSPOptions()
3599 << A->getOption().getName() << Value; in RenderSSPOptions()
3602 A->render(Args, CmdArgs); in RenderSSPOptions()
3606 StringRef Value = A->getValue(); in RenderSSPOptions()
3608 D.Diag(diag::err_drv_unsupported_opt_for_target) in RenderSSPOptions()
3609 << A->getAsString(Args) << TripleStr; in RenderSSPOptions()
3611 D.Diag(diag::err_drv_invalid_value_with_suggestion) in RenderSSPOptions()
3612 << A->getOption().getName() << Value << "fs gs"; in RenderSSPOptions()
3616 D.Diag(diag::err_drv_invalid_value) << A->getOption().getName() << Value; in RenderSSPOptions()
3619 A->render(Args, CmdArgs); in RenderSSPOptions()
3623 StringRef Value = A->getValue(); in RenderSSPOptions()
3625 D.Diag(diag::err_drv_argument_only_allowed_with) in RenderSSPOptions()
3626 << A->getOption().getName() << "legal symbol name"; in RenderSSPOptions()
3629 A->render(Args, CmdArgs); in RenderSSPOptions()
3656 switch (A->getOption().getID()) { in RenderTrivialAutoVarInitOptions()
3660 A->claim(); in RenderTrivialAutoVarInitOptions()
3661 StringRef Val = A->getValue(); in RenderTrivialAutoVarInitOptions()
3665 D.Diag(diag::err_drv_unsupported_option_argument) in RenderTrivialAutoVarInitOptions()
3666 << A->getSpelling() << Val; in RenderTrivialAutoVarInitOptions()
3686 Args.MakeArgString("-ftrivial-auto-var-init=" + TrivialAutoVarInit)); in RenderTrivialAutoVarInitOptions()
3693 Args.getLastArg(options::OPT_ftrivial_auto_var_init)->getValue()) == in RenderTrivialAutoVarInitOptions()
3695 D.Diag(diag::err_drv_trivial_auto_var_init_stop_after_missing_dependency); in RenderTrivialAutoVarInitOptions()
3696 A->claim(); in RenderTrivialAutoVarInitOptions()
3697 StringRef Val = A->getValue(); in RenderTrivialAutoVarInitOptions()
3699 D.Diag(diag::err_drv_trivial_auto_var_init_stop_after_invalid_value); in RenderTrivialAutoVarInitOptions()
3701 Args.MakeArgString("-ftrivial-auto-var-init-stop-after=" + Val)); in RenderTrivialAutoVarInitOptions()
3707 Args.getLastArg(options::OPT_ftrivial_auto_var_init)->getValue()) == in RenderTrivialAutoVarInitOptions()
3709 D.Diag(diag::err_drv_trivial_auto_var_init_max_size_missing_dependency); in RenderTrivialAutoVarInitOptions()
3710 A->claim(); in RenderTrivialAutoVarInitOptions()
3711 StringRef Val = A->getValue(); in RenderTrivialAutoVarInitOptions()
3713 D.Diag(diag::err_drv_trivial_auto_var_init_max_size_invalid_value); in RenderTrivialAutoVarInitOptions()
3715 Args.MakeArgString("-ftrivial-auto-var-init-max-size=" + Val)); in RenderTrivialAutoVarInitOptions()
3721 // cl-denorms-are-zero is not forwarded. It is translated into a generic flag in RenderOpenCLOptions()
3738 std::string CLStdStr = std::string("-cl-std=") + A->getValue(); in RenderOpenCLOptions()
3741 std::string CLExtStr = std::string("-cl-ext=") + A->getValue(); in RenderOpenCLOptions()
3747 CmdArgs.push_back(Args.MakeArgString(A->getOption().getPrefixedName())); in RenderOpenCLOptions()
3753 CmdArgs.push_back("-finclude-default-header"); in RenderOpenCLOptions()
3754 CmdArgs.push_back("-fdeclare-opencl-builtins"); in RenderOpenCLOptions()
3773 A->renderAsInput(Args, CmdArgs); in RenderHLSLOptions()
3777 CmdArgs.push_back("-finclude-default-header"); in RenderHLSLOptions()
3785 CmdArgs.push_back("-fopenacc"); in RenderOpenACCOptions()
3788 StringRef Value = A->getValue(); in RenderOpenACCOptions()
3789 int Version; in RenderOpenACCOptions() local
3790 if (!Value.getAsInteger(10, Version)) in RenderOpenACCOptions()
3791 A->renderAsInput(Args, CmdArgs); in RenderOpenACCOptions()
3793 D.Diag(diag::err_drv_clang_unsupported) << Value; in RenderOpenACCOptions()
3805 switch (A->getOption().getID()) { in RenderARCMigrateToolOptions()
3808 CmdArgs.push_back("-arcmt-action=check"); in RenderARCMigrateToolOptions()
3811 CmdArgs.push_back("-arcmt-action=modify"); in RenderARCMigrateToolOptions()
3814 CmdArgs.push_back("-arcmt-action=migrate"); in RenderARCMigrateToolOptions()
3815 CmdArgs.push_back("-mt-migrate-directory"); in RenderARCMigrateToolOptions()
3816 CmdArgs.push_back(A->getValue()); in RenderARCMigrateToolOptions()
3831 D.Diag(diag::err_drv_argument_not_allowed_with) in RenderARCMigrateToolOptions()
3832 << A->getAsString(Args) << "-ccc-arcmt-migrate"; in RenderARCMigrateToolOptions()
3834 CmdArgs.push_back("-mt-migrate-directory"); in RenderARCMigrateToolOptions()
3835 CmdArgs.push_back(A->getValue()); in RenderARCMigrateToolOptions()
3841 CmdArgs.push_back("-objcmt-migrate-literals"); in RenderARCMigrateToolOptions()
3842 CmdArgs.push_back("-objcmt-migrate-subscripting"); in RenderARCMigrateToolOptions()
3843 CmdArgs.push_back("-objcmt-migrate-property"); in RenderARCMigrateToolOptions()
3871 // -fbuiltin is default unless -mkernel is used. in RenderBuiltinOptions()
3876 CmdArgs.push_back("-fno-builtin"); in RenderBuiltinOptions()
3878 // -ffreestanding implies -fno-builtin. in RenderBuiltinOptions()
3882 // Process the -fno-builtin-* options. in RenderBuiltinOptions()
3884 A->claim(); in RenderBuiltinOptions()
3886 // If -fno-builtin is specified, then there's no need to pass the option to in RenderBuiltinOptions()
3889 A->render(Args, CmdArgs); in RenderBuiltinOptions()
3892 // le32-specific flags: in RenderBuiltinOptions()
3893 // -fno-math-builtin: clang should not convert math builtins to intrinsics in RenderBuiltinOptions()
3896 CmdArgs.push_back("-fno-math-builtin"); in RenderBuiltinOptions()
3917 return StringRef(ModuleOutputEQ->getValue()); in getCXX20NamedModuleOutputPath()
3922 OutputPath = FinalOutput->getValue(); in getCXX20NamedModuleOutputPath()
3939 // -fmodules enables the use of precompiled modules (off by default). in RenderModulesOptions()
3940 // Users can pass -fno-cxx-modules to turn off modules support for in RenderModulesOptions()
3941 // C++/Objective-C++ programs. in RenderModulesOptions()
3947 CmdArgs.push_back("-fmodules"); in RenderModulesOptions()
3954 // -fmodule-maps enables implicit reading of module map files. By default, in RenderModulesOptions()
3958 CmdArgs.push_back("-fimplicit-module-maps"); in RenderModulesOptions()
3960 // -fmodules-decluse checks that modules used are declared so (off by default) in RenderModulesOptions()
3964 // -fmodules-strict-decluse is like -fmodule-decluse, but also checks that in RenderModulesOptions()
3968 CmdArgs.push_back("-fmodules-strict-decluse"); in RenderModulesOptions()
3970 // -fno-implicit-modules turns off implicitly compiling modules on demand. in RenderModulesOptions()
3975 CmdArgs.push_back("-fno-implicit-modules"); in RenderModulesOptions()
3978 // -fmodule-cache-path specifies where our implicitly-built module files in RenderModulesOptions()
3982 Path = A->getValue(); in RenderModulesOptions()
3999 const char Arg[] = "-fmodules-cache-path="; in RenderModulesOptions()
4008 CmdArgs.push_back("-fprebuilt-implicit-modules"); in RenderModulesOptions()
4012 CmdArgs.push_back("-fvalidate-ast-input-files-content"); in RenderModulesOptions()
4015 // -fmodule-name specifies the module that is currently being built (or in RenderModulesOptions()
4016 // used for header checking by -fmodule-maps). in RenderModulesOptions()
4019 // -fmodule-map-file can be used to specify files containing module in RenderModulesOptions()
4023 // -fbuiltin-module-map can be used to load the clang in RenderModulesOptions()
4031 Args.MakeArgString("-fmodule-map-file=" + BuiltinModuleMap)); in RenderModulesOptions()
4034 // The -fmodule-file=<name>=<file> form specifies the mapping of module in RenderModulesOptions()
4036 // The -fmodule-file=<file> form can be used to unconditionally load in RenderModulesOptions()
4041 // -fprebuilt-module-path specifies where to load the prebuilt module files. in RenderModulesOptions()
4044 std::string("-fprebuilt-module-path=") + A->getValue())); in RenderModulesOptions()
4045 A->claim(); in RenderModulesOptions()
4059 CmdArgs.push_back("-module-dependency-dir"); in RenderModulesOptions()
4066 // Pass through all -fmodules-ignore-macro arguments. in RenderModulesOptions()
4076 D.Diag(diag::err_drv_argument_not_allowed_with) in RenderModulesOptions()
4077 << A->getAsString(Args) << "-fbuild-session-timestamp"; in RenderModulesOptions()
4080 if (llvm::sys::fs::status(A->getValue(), Status)) in RenderModulesOptions()
4081 D.Diag(diag::err_drv_no_such_file) << A->getValue(); in RenderModulesOptions()
4083 "-fbuild-session-timestamp=" + in RenderModulesOptions()
4093 D.Diag(diag::err_drv_modules_validate_once_requires_timestamp); in RenderModulesOptions()
4102 CmdArgs.push_back("-fmodules-validate-system-headers"); in RenderModulesOptions()
4117 CmdArgs.push_back("-fskip-odr-check-in-gmf"); in RenderModulesOptions()
4122 CmdArgs.push_back("-fexperimental-modules-reduced-bmi"); in RenderModulesOptions()
4128 "-fmodule-output=" + in RenderModulesOptions()
4132 // Noop if we see '-fexperimental-modules-reduced-bmi' with other translation in RenderModulesOptions()
4140 // to get the object file. Then the `-fmodule-output` flag will be in RenderModulesOptions()
4155 // -fsigned-char is default. in RenderCharacterOptions()
4160 if (A->getOption().matches(options::OPT_funsigned_char) || in RenderCharacterOptions()
4161 A->getOption().matches(options::OPT_fno_signed_char)) { in RenderCharacterOptions()
4162 CmdArgs.push_back("-fno-signed-char"); in RenderCharacterOptions()
4165 CmdArgs.push_back("-fno-signed-char"); in RenderCharacterOptions()
4173 if (A->getOption().matches(options::OPT_fshort_wchar)) { in RenderCharacterOptions()
4174 CmdArgs.push_back("-fwchar-type=short"); in RenderCharacterOptions()
4175 CmdArgs.push_back("-fno-signed-wchar"); in RenderCharacterOptions()
4178 CmdArgs.push_back("-fwchar-type=int"); in RenderCharacterOptions()
4181 CmdArgs.push_back("-fno-signed-wchar"); in RenderCharacterOptions()
4183 CmdArgs.push_back("-fsigned-wchar"); in RenderCharacterOptions()
4186 CmdArgs.push_back("-fno-signed-wchar"); in RenderCharacterOptions()
4195 // -fobjc-dispatch-method is only relevant with the nonfragile-abi, and legacy in RenderObjCOptions()
4197 // always legacy dispatch and -fno-objc-legacy-dispatch gets ignored silently. in RenderObjCOptions()
4203 CmdArgs.push_back("-fobjc-dispatch-method=mixed"); in RenderObjCOptions()
4205 CmdArgs.push_back("-fobjc-dispatch-method=non-legacy"); in RenderObjCOptions()
4213 CmdArgs.push_back("-fobjc-subscripting-legacy-runtime"); in RenderObjCOptions()
4215 // Allow -fno-objc-arr to trump -fobjc-arr/-fobjc-arc. in RenderObjCOptions()
4220 CmdArgs.push_back("-fobjc-arc"); in RenderObjCOptions()
4227 CmdArgs.push_back("-fobjc-arc-cxxlib=libc++"); in RenderObjCOptions()
4229 CmdArgs.push_back("-fobjc-arc-cxxlib=libstdc++"); in RenderObjCOptions()
4233 // We default off for Objective-C, on for Objective-C++. in RenderObjCOptions()
4237 CmdArgs.push_back("-fobjc-arc-exceptions"); in RenderObjCOptions()
4254 Arg->getOption().matches( in RenderObjCOptions()
4256 CmdArgs.push_back("-fno-objc-convert-messages-to-runtime-calls"); in RenderObjCOptions()
4259 // -fobjc-infer-related-result-type is the default, except in the Objective-C in RenderObjCOptions()
4262 CmdArgs.push_back("-fno-objc-infer-related-result-type"); in RenderObjCOptions()
4264 // Pass down -fobjc-weak or -fno-objc-weak if present. in RenderObjCOptions()
4271 if (WeakArg->getOption().matches(options::OPT_fobjc_weak)) in RenderObjCOptions()
4272 D.Diag(diag::err_objc_weak_unsupported); in RenderObjCOptions()
4274 WeakArg->render(Args, CmdArgs); in RenderObjCOptions()
4279 CmdArgs.push_back("-fobjc-disable-direct-methods-for-testing"); in RenderObjCOptions()
4290 switch (A->getOption().getID()) { in RenderDiagnosticsOptions()
4306 // -fcaret-diagnostics is default. in RenderDiagnosticsOptions()
4309 CmdArgs.push_back("-fno-caret-diagnostics"); in RenderDiagnosticsOptions()
4318 CmdArgs.push_back("-fdiagnostics-show-category"); in RenderDiagnosticsOptions()
4319 CmdArgs.push_back(A->getValue()); in RenderDiagnosticsOptions()
4328 std::string("-fdiagnostics-hotness-threshold=") + A->getValue(); in RenderDiagnosticsOptions()
4335 std::string("-fdiagnostics-misexpect-tolerance=") + A->getValue(); in RenderDiagnosticsOptions()
4340 CmdArgs.push_back("-fdiagnostics-format"); in RenderDiagnosticsOptions()
4341 CmdArgs.push_back(A->getValue()); in RenderDiagnosticsOptions()
4342 if (StringRef(A->getValue()) == "sarif" || in RenderDiagnosticsOptions()
4343 StringRef(A->getValue()) == "SARIF") in RenderDiagnosticsOptions()
4344 D.Diag(diag::warn_drv_sarif_format_unstable); in RenderDiagnosticsOptions()
4350 const Option &O = A->getOption(); in RenderDiagnosticsOptions()
4352 CmdArgs.push_back("-fdiagnostics-show-note-include-stack"); in RenderDiagnosticsOptions()
4354 CmdArgs.push_back("-fno-diagnostics-show-note-include-stack"); in RenderDiagnosticsOptions()
4358 // re-parsed to construct this job; claim any possible color diagnostic here in RenderDiagnosticsOptions()
4364 StringRef Value(A->getValue()); in RenderDiagnosticsOptions()
4366 D.Diag(diag::err_drv_invalid_argument_to_option) in RenderDiagnosticsOptions()
4367 << Value << A->getOption().getName(); in RenderDiagnosticsOptions()
4371 CmdArgs.push_back("-fcolor-diagnostics"); in RenderDiagnosticsOptions()
4374 CmdArgs.push_back("-fansi-escape-codes"); in RenderDiagnosticsOptions()
4383 CmdArgs.push_back("-fdiagnostics-absolute-paths"); in RenderDiagnosticsOptions()
4387 CmdArgs.push_back("-fno-show-column"); in RenderDiagnosticsOptions()
4397 if (!Arg || Arg->getOption().matches(options::OPT_gno_split_dwarf)) in getDebugFissionKind()
4400 if (Arg->getOption().matches(options::OPT_gsplit_dwarf)) in getDebugFissionKind()
4403 StringRef Value = Arg->getValue(); in getDebugFissionKind()
4409 D.Diag(diag::err_drv_unsupported_option_argument) in getDebugFissionKind()
4410 << Arg->getSpelling() << Arg->getValue(); in getDebugFissionKind()
4422 if (DwarfFormatArg->getOption().matches(options::OPT_gdwarf64)) { in renderDwarfFormat()
4424 D.Diag(diag::err_drv_argument_only_allowed_with) in renderDwarfFormat()
4425 << DwarfFormatArg->getAsString(Args) << "DWARFv3 or greater"; in renderDwarfFormat()
4427 D.Diag(diag::err_drv_argument_only_allowed_with) in renderDwarfFormat()
4428 << DwarfFormatArg->getAsString(Args) << "64 bit architecture"; in renderDwarfFormat()
4430 D.Diag(diag::err_drv_argument_only_allowed_with) in renderDwarfFormat()
4431 << DwarfFormatArg->getAsString(Args) << "ELF platforms"; in renderDwarfFormat()
4434 DwarfFormatArg->render(Args, CmdArgs); in renderDwarfFormat()
4447 CmdArgs.push_back("-fdebug-info-for-profiling"); in renderDebugOptions()
4451 // reach cc1 they've been factored into three well-defined orthogonal choices: in renderDebugOptions()
4453 // * what dwarf version to write in renderDebugOptions()
4464 // Normally -gsplit-dwarf is only useful with -gN. For IR input, Clang does in renderDebugOptions()
4465 // object file generation and no IR generation, -gN should not be needed. So in renderDebugOptions()
4466 // allow -gsplit-dwarf with either -gN or IR input. in renderDebugOptions()
4479 // If the last option explicitly specified a debug-info level, use it. in renderDebugOptions()
4481 A->getOption().matches(options::OPT_gN_Group)) { in renderDebugOptions()
4483 // For -g0 or -gline-tables-only, drop -gsplit-dwarf. This gets a bit more in renderDebugOptions()
4485 // (SplitDWARFInlining) - then there's value in composing split-dwarf and in renderDebugOptions()
4486 // line-tables-only, so let those compose naturally in that case. in renderDebugOptions()
4501 if (A->getOption().matches(options::OPT_glldb)) in renderDebugOptions()
4503 else if (A->getOption().matches(options::OPT_gsce)) in renderDebugOptions()
4505 else if (A->getOption().matches(options::OPT_gdbx)) in renderDebugOptions()
4512 // If a -gdwarf argument appeared, remember it. in renderDebugOptions()
4521 // If the user asked for debug info but did not explicitly specify -gcodeview in renderDebugOptions()
4522 // or -gdwarf, ask the toolchain for the default format. in renderDebugOptions()
4535 unsigned RequestedDWARFVersion = 0; // DWARF version requested by the user in renderDebugOptions()
4536 unsigned EffectiveDWARFVersion = 0; // DWARF version TC can generate. It may in renderDebugOptions()
4540 // Clamp effective DWARF version to the max supported by the toolchain. in renderDebugOptions()
4547 // -gline-directives-only supported only for the DWARF debug info. in renderDebugOptions()
4558 CmdArgs.push_back("-gstrict-dwarf"); in renderDebugOptions()
4560 // And we handle flag -grecord-gcc-switches later with DWARFDebugFlags. in renderDebugOptions()
4575 CmdArgs.push_back("-gno-column-info"); in renderDebugOptions()
4579 // If -gline-tables-only or -gline-directives-only is the last option it in renderDebugOptions()
4586 CmdArgs.push_back("-dwarf-ext-refs"); in renderDebugOptions()
4587 CmdArgs.push_back("-fmodule-format=obj"); in renderDebugOptions()
4593 CmdArgs.push_back("-fsplit-dwarf-inlining"); in renderDebugOptions()
4598 // We parse these two '-f' options whether or not they will be used, in renderDebugOptions()
4599 // to claim them even if you wrote "-fstandalone-debug -gline-tables-only" in renderDebugOptions()
4619 // checked if a DWARF version was stated explicitly, and have otherwise in renderDebugOptions()
4624 D.Diag(diag::err_drv_argument_only_allowed_with) in renderDebugOptions()
4625 << A->getAsString(Args) << "-gdwarf-5"; in renderDebugOptions()
4627 // The toolchain has reduced allowed dwarf version, so we can't enable in renderDebugOptions()
4628 // -gembed-source. in renderDebugOptions()
4629 D.Diag(diag::warn_drv_dwarf_version_limited_by_target) in renderDebugOptions()
4630 << A->getAsString(Args) << TC.getTripleString() << 5 in renderDebugOptions()
4633 CmdArgs.push_back("-gembed-source"); in renderDebugOptions()
4637 CmdArgs.push_back("-gcodeview"); in renderDebugOptions()
4664 // -fdebug-macro turns on macro debug info generation. in renderDebugOptions()
4669 CmdArgs.push_back("-debug-info-macro"); in renderDebugOptions()
4671 // -ggnu-pubnames turns on gnu style pubnames in the backend. in renderDebugOptions()
4679 (PubnamesArg->getOption().matches(options::OPT_gpubnames) || in renderDebugOptions()
4680 PubnamesArg->getOption().matches(options::OPT_ggnu_pubnames))); in renderDebugOptions()
4683 (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) && in renderDebugOptions()
4684 !PubnamesArg->getOption().matches(options::OPT_gno_pubnames)))) in renderDebugOptions()
4685 CmdArgs.push_back(PubnamesArg && PubnamesArg->getOption().matches( in renderDebugOptions()
4687 ? "-gpubnames" in renderDebugOptions()
4688 : "-ggnu-pubnames"); in renderDebugOptions()
4696 const auto &Opt = SimpleTemplateNamesArg->getOption(); in renderDebugOptions()
4699 CmdArgs.push_back("-gsimple-template-names=simple"); in renderDebugOptions()
4711 const auto &Opt = DebugTemplateAlias->getOption(); in renderDebugOptions()
4716 CmdArgs.push_back("-gtemplate-alias"); in renderDebugOptions()
4719 StringRef v = A->getValue(); in renderDebugOptions()
4720 CmdArgs.push_back(Args.MakeArgString("-gsrc-hash=" + v)); in renderDebugOptions()
4726 // -gdwarf-aranges turns on the emission of the aranges section in the in renderDebugOptions()
4733 CmdArgs.push_back("-mllvm"); in renderDebugOptions()
4734 CmdArgs.push_back("-generate-arange-section"); in renderDebugOptions()
4744 D.Diag(diag::err_drv_unsupported_opt_for_target) in renderDebugOptions()
4746 ->getAsString(Args) in renderDebugOptions()
4752 CmdArgs.push_back("-mllvm"); in renderDebugOptions()
4753 CmdArgs.push_back("-generate-type-units"); in renderDebugOptions()
4766 CmdArgs.push_back("-gomit-unreferenced-methods"); in renderDebugOptions()
4775 CmdArgs.push_back("-fno-dwarf-directory-asm"); in renderDebugOptions()
4780 CmdArgs.push_back("-debug-forward-template-params"); in renderDebugOptions()
4785 CmdArgs.push_back("-dwarf-explicit-import"); in renderDebugOptions()
4794 CmdArgs.push_back("-fjmc"); in renderDebugOptions()
4796 D.Diag(clang::diag::warn_drv_jmc_requires_debuginfo) << "/JMC" in renderDebugOptions()
4799 D.Diag(clang::diag::warn_drv_jmc_requires_debuginfo) << "-fjmc" in renderDebugOptions()
4800 << "-g"; in renderDebugOptions()
4802 D.Diag(clang::diag::warn_drv_fjmc_for_elf_only); in renderDebugOptions()
4806 // Add in -fdebug-compilation-dir if necessary. in renderDebugOptions()
4828 RTOptionID = A->getOption().getID(); in ProcessVSRuntimeLibrary()
4831 RTOptionID = llvm::StringSwitch<unsigned>(A->getValue()) in ProcessVSRuntimeLibrary()
4843 CmdArgs.push_back("-D_DEBUG"); in ProcessVSRuntimeLibrary()
4844 CmdArgs.push_back("-D_MT"); in ProcessVSRuntimeLibrary()
4845 CmdArgs.push_back("-D_DLL"); in ProcessVSRuntimeLibrary()
4846 FlagForCRT = "--dependent-lib=msvcrt"; in ProcessVSRuntimeLibrary()
4849 CmdArgs.push_back("-D_DEBUG"); in ProcessVSRuntimeLibrary()
4850 CmdArgs.push_back("-D_MT"); in ProcessVSRuntimeLibrary()
4851 CmdArgs.push_back("-D_DLL"); in ProcessVSRuntimeLibrary()
4852 FlagForCRT = "--dependent-lib=msvcrtd"; in ProcessVSRuntimeLibrary()
4856 CmdArgs.push_back("-D_DEBUG"); in ProcessVSRuntimeLibrary()
4857 CmdArgs.push_back("-D_MT"); in ProcessVSRuntimeLibrary()
4858 CmdArgs.push_back("-flto-visibility-public-std"); in ProcessVSRuntimeLibrary()
4859 FlagForCRT = "--dependent-lib=libcmt"; in ProcessVSRuntimeLibrary()
4862 CmdArgs.push_back("-D_DEBUG"); in ProcessVSRuntimeLibrary()
4863 CmdArgs.push_back("-D_MT"); in ProcessVSRuntimeLibrary()
4864 CmdArgs.push_back("-flto-visibility-public-std"); in ProcessVSRuntimeLibrary()
4865 FlagForCRT = "--dependent-lib=libcmtd"; in ProcessVSRuntimeLibrary()
4872 CmdArgs.push_back("-D_VC_NODEFAULTLIB"); in ProcessVSRuntimeLibrary()
4879 CmdArgs.push_back("--dependent-lib=oldnames"); in ProcessVSRuntimeLibrary()
4886 CmdArgs.push_back("--dependent-lib=softintrin"); in ProcessVSRuntimeLibrary()
4904 // device-side compilations). OpenMP device jobs also take the host IR as a in ConstructJob()
4930 InputInfo ExtractAPIPlaceholderInput(Inputs[0].getType(), "extract-api", in ConstructJob()
4931 "extract-api"); in ConstructJob()
4946 D.Diag(diag::err_drv_extract_api_wrong_kind) in ConstructJob()
4969 // Windows), we need to pass Windows-specific flags to cc1. in ConstructJob()
4971 IsWindowsMSVC |= AuxTriple && AuxTriple->isWindowsMSVCEnvironment(); in ConstructJob()
4975 D.Diag(diag::err_drv_clang_unsupported) << "C++ for IAMCU"; in ConstructJob()
4977 // Invoke ourselves in -cc1 mode. in ConstructJob()
4980 CmdArgs.push_back("-cc1"); in ConstructJob()
4983 CmdArgs.push_back("-triple"); in ConstructJob()
4987 DumpCompilationDatabase(C, MJ->getValue(), TripleStr, Output, Input, Args); in ConstructJob()
4991 DumpCompilationDatabaseFragmentToDir(GenCDBFragment->getValue(), C, in ConstructJob()
4998 // and vice-versa. in ConstructJob()
5003 ->getTriple() in ConstructJob()
5006 // Host-side compilation. in ConstructJob()
5010 ->getTriple() in ConstructJob()
5013 // We need to figure out which CUDA version we're compiling for, as that in ConstructJob()
5018 if (CTC && CTC->CudaInstallation.version() != CudaVersion::UNKNOWN) in ConstructJob()
5020 Twine("-target-sdk-version=") + in ConstructJob()
5021 CudaVersionToString(CTC->CudaInstallation.version()))); in ConstructJob()
5023 // CUDA-9.0. We still do not support generating code that actually uses in ConstructJob()
5026 // https://github.com/llvm/llvm-project/issues/58410 in ConstructJob()
5027 if (CTC->CudaInstallation.version() >= CudaVersion::CUDA_90) in ConstructJob()
5028 CmdArgs.push_back("-fcuda-allow-variadic-functions"); in ConstructJob()
5031 CmdArgs.push_back("-aux-triple"); in ConstructJob()
5041 "-mprintf-kind=" + in ConstructJob()
5045 Args.MakeArgString("-Werror=format-invalid-specifier")); in ConstructJob()
5052 PF->claim(); in ConstructJob()
5055 CmdArgs.push_back("-fsycl-is-device"); in ConstructJob()
5058 A->render(Args, CmdArgs); in ConstructJob()
5060 // Ensure the default version in SYCL mode is 2020. in ConstructJob()
5061 CmdArgs.push_back("-sycl-std=2020"); in ConstructJob()
5069 ->getTriple() in ConstructJob()
5071 CmdArgs.push_back("-aux-triple"); in ConstructJob()
5078 unsigned Version = 0; in ConstructJob() local
5080 Triple.getArchName().substr(Offset).consumeInteger(10, Version); in ConstructJob()
5081 if (Failure || Version < 7) in ConstructJob()
5082 D.Diag(diag::err_target_unsupported_arch) << Triple.getArchName() in ConstructJob()
5093 CmdArgs.push_back("-Wspir-compat"); in ConstructJob()
5103 CmdArgs.push_back("-funified-lto"); in ConstructJob()
5108 // "argument unused" warnings for assembler flags when e.g. adding "-E" to in ConstructJob()
5110 // also inconsistent with most other flags -- we don't warn on in ConstructJob()
5111 // -ffunction-sections not being used in -E mode either for example, even in ConstructJob()
5139 CmdArgs.push_back("-analyze"); in ConstructJob()
5141 CmdArgs.push_back("-migrate"); in ConstructJob()
5144 CmdArgs.push_back("-Eonly"); in ConstructJob()
5146 CmdArgs.push_back("-E"); in ConstructJob()
5149 CmdArgs.push_back("-P"); in ConstructJob()
5151 CmdArgs.push_back("-fdirectives-only"); in ConstructJob()
5154 CmdArgs.push_back("-emit-obj"); in ConstructJob()
5158 // Also ignore explicit -force_cpusubtype_ALL option. in ConstructJob()
5162 CmdArgs.push_back("-fsyntax-only"); in ConstructJob()
5164 CmdArgs.push_back("-emit-module-interface"); in ConstructJob()
5166 CmdArgs.push_back("-emit-header-unit"); in ConstructJob()
5168 CmdArgs.push_back("-emit-pch"); in ConstructJob()
5170 CmdArgs.push_back("-verify-pch"); in ConstructJob()
5174 CmdArgs.push_back("-extract-api"); in ConstructJob()
5177 PrettySGFArg->render(Args, CmdArgs); in ConstructJob()
5182 ProductNameArg->render(Args, CmdArgs); in ConstructJob()
5185 ExtractAPIIgnoresFileArg->render(Args, CmdArgs); in ConstructJob()
5189 D.Diag(diag::err_drv_missing_symbol_graph_dir); in ConstructJob()
5191 EmitExtensionSymbolGraphs->render(Args, CmdArgs); in ConstructJob()
5194 SymbolGraphDirArg->render(Args, CmdArgs); in ConstructJob()
5199 CmdArgs.push_back("-fsyntax-only"); in ConstructJob()
5202 CmdArgs.push_back("-emit-llvm"); in ConstructJob()
5205 // Emit textual llvm IR for AMDGPU offloading for -emit-llvm -S in ConstructJob()
5208 CmdArgs.push_back("-emit-llvm"); in ConstructJob()
5210 CmdArgs.push_back("-emit-llvm-bc"); in ConstructJob()
5217 : "ifs-v1"; in ConstructJob()
5218 CmdArgs.push_back("-emit-interface-stubs"); in ConstructJob()
5220 Args.MakeArgString(Twine("-interface-stub-version=") + ArgStr.str())); in ConstructJob()
5222 CmdArgs.push_back("-S"); in ConstructJob()
5224 CmdArgs.push_back("-emit-pch"); in ConstructJob()
5226 CmdArgs.push_back("-module-file-info"); in ConstructJob()
5228 CmdArgs.push_back("-rewrite-objc"); in ConstructJob()
5231 CmdArgs.push_back("-rewrite-objc"); in ConstructJob()
5237 // Preserve use-list order by default when emitting bitcode, so that in ConstructJob()
5240 // the use-list order, since serialization to bitcode is part of the flow. in ConstructJob()
5242 CmdArgs.push_back("-emit-llvm-uselists"); in ConstructJob()
5249 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
5252 ->getAsString(Args) in ConstructJob()
5256 D.Diag(diag::err_drv_unsupported_opt_for_language_mode) in ConstructJob()
5259 ->getAsString(Args) in ConstructJob()
5260 << "-fno-gpu-rdc"; in ConstructJob()
5264 Twine("-flto=") + (LTOMode == LTOK_Thin ? "thin" : "full"))); in ConstructJob()
5266 // features enabled by -flto-unit. in ConstructJob()
5269 CmdArgs.push_back("-flto-unit"); in ConstructJob()
5278 D.Diag(diag::err_drv_arg_requires_bitcode_input) << A->getAsString(Args); in ConstructJob()
5296 !MemProfArg->getOption().matches(options::OPT_fno_memory_profile)) in ConstructJob()
5297 MemProfArg->render(Args, CmdArgs); in ConstructJob()
5302 D.Diag(diag::err_drv_argument_not_allowed_with) in ConstructJob()
5303 << MemProfUseArg->getAsString(Args) << MemProfArg->getAsString(Args); in ConstructJob()
5306 D.Diag(diag::err_drv_argument_not_allowed_with) in ConstructJob()
5307 << MemProfUseArg->getAsString(Args) << PGOInstrArg->getAsString(Args); in ConstructJob()
5308 MemProfUseArg->render(Args, CmdArgs); in ConstructJob()
5311 // Embed-bitcode option. in ConstructJob()
5312 // Only white-listed flags below are allowed to be embedded. in ConstructJob()
5315 // Add flags implied by -fembed-bitcode. in ConstructJob()
5318 CmdArgs.push_back("-disable-llvm-passes"); in ConstructJob()
5369 if (llvm::is_contained(kBitcodeOptionIgnorelist, A->getOption().getID())) in ConstructJob()
5370 D.Diag(diag::err_drv_unsupported_embed_bitcode) << A->getSpelling(); in ConstructJob()
5396 if (A->getOption().matches(options::OPT_O4)) { in ConstructJob()
5397 CmdArgs.push_back("-O3"); in ConstructJob()
5398 D.Diag(diag::warn_O4_is_O3); in ConstructJob()
5400 A->render(Args, CmdArgs); in ConstructJob()
5408 CmdArgs.push_back("-o"); in ConstructJob()
5429 CmdArgs.push_back("-fembed-bitcode=marker"); in ConstructJob()
5435 CmdArgs.push_back("-disable-free"); in ConstructJob()
5436 CmdArgs.push_back("-clear-ast-before-backend"); in ConstructJob()
5447 CmdArgs.push_back("-disable-llvm-verifier"); in ConstructJob()
5457 D.Diag(diag::warn_ignoring_fdiscard_for_bitcode); in ConstructJob()
5459 CmdArgs.push_back("-discard-value-names"); in ConstructJob()
5463 // -save-temps. in ConstructJob()
5464 CmdArgs.push_back("-main-file-name"); in ConstructJob()
5470 CmdArgs.push_back("-static-define"); in ConstructJob()
5473 CmdArgs.push_back("-DUNICODE"); in ConstructJob()
5480 CmdArgs.push_back("-setup-static-analyzer"); in ConstructJob()
5482 // Enable compatilibily mode to avoid analyzer-config related errors. in ConstructJob()
5487 if (StringRef(Arg->getValue()) == "-analyzer-config") { in ConstructJob()
5493 if (StringRef(Arg->getValue()) == "-analyzer-config") { in ConstructJob()
5498 CmdArgs.push_back("-analyzer-config-compatibility-mode=true"); in ConstructJob()
5505 CmdArgs.push_back("-function-alignment"); in ConstructJob()
5509 // We support -falign-loops=N where N is a power of 2. GCC supports more in ConstructJob()
5513 if (StringRef(A->getValue()).getAsInteger(10, Value) || Value > 65536) in ConstructJob()
5514 TC.getDriver().Diag(diag::err_drv_invalid_int_value) in ConstructJob()
5515 << A->getAsString(Args) << A->getValue(); in ConstructJob()
5516 else if (Value & (Value - 1)) in ConstructJob()
5517 TC.getDriver().Diag(diag::err_drv_alignment_not_power_of_two) in ConstructJob()
5518 << A->getAsString(Args) << A->getValue(); in ConstructJob()
5521 CmdArgs.push_back(Args.MakeArgString("-falign-loops=" + in ConstructJob()
5543 CmdArgs.push_back("-D_UNIX03_WITHDRAWN"); in ConstructJob()
5546 CmdArgs.push_back("-D_OPEN_DEFAULT"); in ConstructJob()
5550 CmdArgs.push_back("-D_XOPEN_SOURCE=600"); in ConstructJob()
5563 if (LastPICDataRelArg->getOption().matches( in ConstructJob()
5567 D.Diag(diag::err_drv_argument_only_allowed_with) in ConstructJob()
5568 << "-mno-pic-data-is-text-relative" in ConstructJob()
5569 << "-fpic/-fpie"; in ConstructJob()
5572 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
5573 << (NoPICDataIsTextRelative ? "-mno-pic-data-is-text-relative" in ConstructJob()
5574 : "-mpic-data-is-text-relative") in ConstructJob()
5586 D.Diag(diag::err_cmse_pi_are_incompatible) << IsROPI; in ConstructJob()
5588 D.Diag(diag::err_cmse_pi_are_incompatible) << !IsRWPI; in ConstructJob()
5593 D.Diag(diag::err_drv_ropi_incompatible_with_cxx); in ConstructJob()
5597 CmdArgs.push_back("-mrelocation-model"); in ConstructJob()
5601 CmdArgs.push_back("-pic-level"); in ConstructJob()
5604 CmdArgs.push_back("-pic-is-pie"); in ConstructJob()
5606 CmdArgs.push_back("-mcmodel=medium"); in ConstructJob()
5611 CmdArgs.push_back("-fropi"); in ConstructJob()
5614 CmdArgs.push_back("-frwpi"); in ConstructJob()
5617 CmdArgs.push_back("-meabi"); in ConstructJob()
5618 CmdArgs.push_back(A->getValue()); in ConstructJob()
5621 // -fsemantic-interposition is forwarded to CC1: set the in ConstructJob()
5625 // -fno-semantic-interposition: if the target supports .Lfoo$local local in ConstructJob()
5627 // This is the CC1 default for ELF to match COFF/Mach-O. in ConstructJob()
5630 // -fno-semantic-interposition but local aliases are not used. So references in ConstructJob()
5640 CmdArgs.push_back("-fhalf-no-semantic-interposition"); in ConstructJob()
5641 else if (A->getOption().matches(options::OPT_fsemantic_interposition)) in ConstructJob()
5642 A->render(Args, CmdArgs); in ConstructJob()
5644 CmdArgs.push_back("-fhalf-no-semantic-interposition"); in ConstructJob()
5651 if (!TC.isThreadModelSupported(A->getValue())) in ConstructJob()
5652 D.Diag(diag::err_drv_invalid_thread_model_for_target) in ConstructJob()
5653 << A->getValue() << A->getAsString(Args); in ConstructJob()
5654 Model = A->getValue(); in ConstructJob()
5658 CmdArgs.push_back("-mthread-model"); in ConstructJob()
5664 StringRef Name = A->getValue(); in ConstructJob()
5668 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
5670 } else if (Name == "LIBMVEC-X86") { in ConstructJob()
5673 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
5678 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
5681 A->render(Args, CmdArgs); in ConstructJob()
5686 CmdArgs.push_back("-fmerge-all-constants"); in ConstructJob()
5695 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
5696 << A->getSpelling() << RawTriple.str(); in ConstructJob()
5697 CmdArgs.push_back("-mabi=quadword-atomics"); in ConstructJob()
5702 // support for 128-bit long double is available for AIX. in ConstructJob()
5704 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
5705 << A->getSpelling() << RawTriple.str(); in ConstructJob()
5709 StringRef V = A->getValue(), V1 = V; in ConstructJob()
5712 D.Diag(diag::err_drv_invalid_argument_to_option) in ConstructJob()
5713 << V << A->getOption().getName(); in ConstructJob()
5715 CmdArgs.push_back(Args.MakeArgString("-fwarn-stack-size=" + V)); in ConstructJob()
5726 CmdArgs.push_back("-mregparm"); in ConstructJob()
5727 CmdArgs.push_back(A->getValue()); in ConstructJob()
5733 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
5734 << A->getSpelling() << RawTriple.str(); in ConstructJob()
5735 } else if (A->getOption().matches(options::OPT_maix_struct_return)) { in ConstructJob()
5736 CmdArgs.push_back("-maix-struct-return"); in ConstructJob()
5738 assert(A->getOption().matches(options::OPT_msvr4_struct_return)); in ConstructJob()
5739 CmdArgs.push_back("-msvr4-struct-return"); in ConstructJob()
5746 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
5747 << A->getSpelling() << RawTriple.str(); in ConstructJob()
5748 } else if (A->getOption().matches(options::OPT_fpcc_struct_return)) { in ConstructJob()
5749 CmdArgs.push_back("-fpcc-struct-return"); in ConstructJob()
5751 assert(A->getOption().matches(options::OPT_freg_struct_return)); in ConstructJob()
5752 CmdArgs.push_back("-freg-struct-return"); in ConstructJob()
5758 CmdArgs.push_back("-fdefault-calling-conv=rtdcall"); in ConstructJob()
5760 CmdArgs.push_back("-fdefault-calling-conv=stdcall"); in ConstructJob()
5764 // enable-matrix is needed by both the LangOpts and by LLVM. in ConstructJob()
5765 CmdArgs.push_back("-fenable-matrix"); in ConstructJob()
5766 CmdArgs.push_back("-mllvm"); in ConstructJob()
5767 CmdArgs.push_back("-enable-matrix"); in ConstructJob()
5775 FPKeepKindStr = "-mframe-pointer=none"; in ConstructJob()
5778 FPKeepKindStr = "-mframe-pointer=reserved"; in ConstructJob()
5781 FPKeepKindStr = "-mframe-pointer=non-leaf"; in ConstructJob()
5784 FPKeepKindStr = "-mframe-pointer=all"; in ConstructJob()
5795 D.Diag(diag::warn_drv_deprecated_arg_ofast); in ConstructJob()
5796 // If -Ofast is the optimization level, then -fstrict-aliasing should be in ConstructJob()
5804 CmdArgs.push_back("-relaxed-aliasing"); in ConstructJob()
5807 CmdArgs.push_back("-pointer-tbaa"); in ConstructJob()
5810 CmdArgs.push_back("-no-struct-path-tbaa"); in ConstructJob()
5842 // -fprotect-parens=0 is default. in ConstructJob()
5845 CmdArgs.push_back("-fprotect-parens"); in ConstructJob()
5852 StringRef V = A->getValue(); in ConstructJob()
5854 CmdArgs.push_back("-fextend-arguments=64"); in ConstructJob()
5856 D.Diag(diag::err_drv_invalid_argument_to_option) in ConstructJob()
5857 << A->getValue() << A->getOption().getName(); in ConstructJob()
5859 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
5860 << A->getOption().getName() << TripleStr; in ConstructJob()
5865 A->render(Args, CmdArgs); in ConstructJob()
5867 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
5868 << A->getAsString(Args) << TripleStr; in ConstructJob()
5873 A->render(Args, CmdArgs); in ConstructJob()
5875 (A->getOption().getID() != options::OPT_mlong_double_80)) in ConstructJob()
5876 A->render(Args, CmdArgs); in ConstructJob()
5878 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
5879 << A->getAsString(Args) << TripleStr; in ConstructJob()
5887 CmdArgs.push_back("-fno-verbose-asm"); in ConstructJob()
5889 // Parse 'none' or '$major.$minor'. Disallow -fbinutils-version=0 because we in ConstructJob()
5892 StringRef V = A->getValue(); in ConstructJob()
5895 A->render(Args, CmdArgs); in ConstructJob()
5899 A->render(Args, CmdArgs); in ConstructJob()
5901 D.Diag(diag::err_drv_invalid_argument_to_option) in ConstructJob()
5902 << A->getValue() << A->getOption().getName(); in ConstructJob()
5906 // option to disable integrated-as explicitly. in ConstructJob()
5908 CmdArgs.push_back("-no-integrated-as"); in ConstructJob()
5911 CmdArgs.push_back("-mdebug-pass"); in ConstructJob()
5915 CmdArgs.push_back("-mdebug-pass"); in ConstructJob()
5919 // Enable -mconstructor-aliases except on darwin, where we have to work around in ConstructJob()
5923 CmdArgs.push_back("-mconstructor-aliases"); in ConstructJob()
5928 CmdArgs.push_back("-fforbid-guard-variables"); in ConstructJob()
5932 CmdArgs.push_back("-mms-bitfields"); in ConstructJob()
5942 CmdArgs.push_back("-fms-volatile"); in ConstructJob()
5944 // Non-PIC code defaults to -fdirect-access-external-data while PIC code in ConstructJob()
5945 // defaults to -fno-direct-access-external-data. Pass the option if different in ConstructJob()
5949 if (A->getOption().matches(options::OPT_fdirect_access_external_data) != in ConstructJob()
5951 A->render(Args, CmdArgs); in ConstructJob()
5953 // Some targets default to -fno-direct-access-external-data even for in ConstructJob()
5954 // -fno-pic. in ConstructJob()
5955 CmdArgs.push_back("-fno-direct-access-external-data"); in ConstructJob()
5959 CmdArgs.push_back("-fno-plt"); in ConstructJob()
5962 // -fhosted is default. in ConstructJob()
5969 CmdArgs.push_back("-ffreestanding"); in ConstructJob()
5973 // This is a coarse approximation of what llvm-gcc actually does, both in ConstructJob()
5974 // -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more in ConstructJob()
5992 CmdArgs.push_back("-funwind-tables=2"); in ConstructJob()
5994 CmdArgs.push_back("-funwind-tables=1"); in ConstructJob()
5996 // Prepare `-aux-target-cpu` and `-aux-target-feature` unless in ConstructJob()
5997 // `--gpu-use-aux-triple-only` is specified. in ConstructJob()
6005 CmdArgs.push_back("-aux-target-cpu"); in ConstructJob()
6017 StringRef Value = A->getValue(); in ConstructJob()
6021 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
6022 << A->getOption().getName() << TripleStr; in ConstructJob()
6024 D.Diag(diag::err_drv_invalid_int_value) in ConstructJob()
6025 << A->getOption().getName() << Value; in ConstructJob()
6030 CmdArgs.push_back("-enable-tlsdesc"); in ConstructJob()
6035 CmdArgs.push_back("-target-cpu"); in ConstructJob()
6041 // Add clang-cl arguments. in ConstructJob()
6062 CmdArgs.push_back("-split-dwarf-file"); in ConstructJob()
6065 CmdArgs.push_back("-split-dwarf-output"); in ConstructJob()
6070 // Pass the linker version in use. in ConstructJob()
6072 CmdArgs.push_back("-target-linker-version"); in ConstructJob()
6073 CmdArgs.push_back(A->getValue()); in ConstructJob()
6084 D.Diag(diag::err_drv_clang_unsupported_opt_cxx_darwin_i386) in ConstructJob()
6085 << Unsupported->getOption().getName(); in ConstructJob()
6089 D.Diag(diag::err_drv_clang_unsupported_opt_faltivec) in ConstructJob()
6090 << Unsupported->getOption().getName() in ConstructJob()
6091 << "please use -maltivec and include altivec.h explicitly"; in ConstructJob()
6093 D.Diag(diag::err_drv_clang_unsupported_opt_faltivec) in ConstructJob()
6094 << Unsupported->getOption().getName() << "please use -mno-altivec"; in ConstructJob()
6100 CmdArgs.push_back("-H"); in ConstructJob()
6101 CmdArgs.push_back("-sys-header-deps"); in ConstructJob()
6106 CmdArgs.push_back("-header-include-file"); in ConstructJob()
6109 : "-"); in ConstructJob()
6110 CmdArgs.push_back("-sys-header-deps"); in ConstructJob()
6112 "-header-include-format=" + in ConstructJob()
6115 Args.MakeArgString("-header-include-filtering=" + in ConstructJob()
6123 CmdArgs.push_back("-diagnostic-log-file"); in ConstructJob()
6126 : "-"); in ConstructJob()
6132 CmdArgs.push_back("-disable-pragma-debug-crash"); in ConstructJob()
6138 CmdArgs.push_back("-mllvm"); in ConstructJob()
6139 CmdArgs.push_back(Args.MakeArgString("-crash-diagnostics-dir=" + Dir)); in ConstructJob()
6146 CmdArgs.push_back("-ffunction-sections"); in ConstructJob()
6152 if (A->getOption().matches(options::OPT_fbasic_block_address_map)) in ConstructJob()
6153 A->render(Args, CmdArgs); in ConstructJob()
6155 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
6156 << A->getAsString(Args) << TripleStr; in ConstructJob()
6161 StringRef Val = A->getValue(); in ConstructJob()
6165 D.Diag(diag::err_drv_invalid_value) in ConstructJob()
6166 << A->getAsString(Args) << A->getValue(); in ConstructJob()
6168 A->render(Args, CmdArgs); in ConstructJob()
6171 // basic blocks for some cross-section branches. in ConstructJob()
6173 D.Diag(diag::err_drv_invalid_value) in ConstructJob()
6174 << A->getAsString(Args) << A->getValue(); in ConstructJob()
6176 A->render(Args, CmdArgs); in ConstructJob()
6179 // for the host-side compilation, so seeing it here is not an error. in ConstructJob()
6183 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
6184 << A->getAsString(Args) << TripleStr; in ConstructJob()
6191 CmdArgs.push_back("-fdata-sections"); in ConstructJob()
6207 if (!A->getOption().matches(options::OPT_fno_split_machine_functions)) { in ConstructJob()
6210 A->render(Args, CmdArgs); in ConstructJob()
6212 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
6213 << A->getAsString(Args) << TripleStr; in ConstructJob()
6231 CmdArgs.push_back("-mllvm"); in ConstructJob()
6232 CmdArgs.push_back("-sample-profile-use-profi"); in ConstructJob()
6244 CmdArgs.push_back("-nostdsysteminc"); in ConstructJob()
6245 CmdArgs.push_back("-nobuiltininc"); in ConstructJob()
6248 CmdArgs.push_back("-nostdsysteminc"); in ConstructJob()
6254 CmdArgs.push_back("-resource-dir"); in ConstructJob()
6261 // Add preprocessing options like -I, -D, etc. if we are using the in ConstructJob()
6264 // FIXME: Support -fpreprocessed in ConstructJob()
6268 // Don't warn about "clang -c -DPIC -fPIC test.i" because libtool.m4 assumes in ConstructJob()
6270 // When building with ccache, it will pass -D options to clang even on in ConstructJob()
6271 // preprocessed inputs and configure concludes that -fPIC is not supported. in ConstructJob()
6274 // Manually translate -O4 to -O3; let clang reject others. in ConstructJob()
6276 if (A->getOption().matches(options::OPT_O4)) { in ConstructJob()
6277 CmdArgs.push_back("-O3"); in ConstructJob()
6278 D.Diag(diag::warn_O4_is_O3); in ConstructJob()
6280 A->render(Args, CmdArgs); in ConstructJob()
6287 D.Diag(diag::warn_ignored_gcc_optimization) << A->getAsString(Args); in ConstructJob()
6288 A->claim(); in ConstructJob()
6293 D.Diag(diag::warn_ignored_clang_option) << A->getAsString(Args); in ConstructJob()
6294 A->claim(); in ConstructJob()
6303 A->claim(); in ConstructJob()
6304 if (A->getOption().getID() == options::OPT__SLASH_wd) { in ConstructJob()
6306 if (StringRef(A->getValue()).getAsInteger(10, WarningNumber)) { in ConstructJob()
6307 D.Diag(diag::err_drv_invalid_int_value) in ConstructJob()
6308 << A->getAsString(Args) << A->getValue(); in ConstructJob()
6314 "-Wno-" + DiagnosticIDs::getWarningOptionForGroup(*Group))); in ConstructJob()
6318 A->render(Args, CmdArgs); in ConstructJob()
6324 CmdArgs.push_back("-pedantic"); in ConstructJob()
6332 A->render(Args, CmdArgs); in ConstructJob()
6341 A->render(Args, CmdArgs); in ConstructJob()
6343 // Handle -{std, ansi, trigraphs} -- take the last of -{std, ansi} in ConstructJob()
6344 // (-ansi is equivalent to -std=c89 or -std=c++98). in ConstructJob()
6346 // If a std is supplied, only add -trigraphs if it follows the in ConstructJob()
6352 if (Std->getOption().matches(options::OPT_ansi)) in ConstructJob()
6354 CmdArgs.push_back("-std=c++98"); in ConstructJob()
6356 CmdArgs.push_back("-std=c89"); in ConstructJob()
6358 Std->render(Args, CmdArgs); in ConstructJob()
6360 // If -f(no-)trigraphs appears after the language standard flag, honor it. in ConstructJob()
6365 A->render(Args, CmdArgs); in ConstructJob()
6367 // Honor -std-default. in ConstructJob()
6369 // FIXME: Clang doesn't correctly handle -std= when the input language in ConstructJob()
6372 // splitting it between the driver and clang -cc1. in ConstructJob()
6375 Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ, "-std=", in ConstructJob()
6387 // GCC's behavior for -Wwrite-strings is a bit strange: in ConstructJob()
6395 // a non-const char* in C, rather than using this crude hack. in ConstructJob()
6398 // respect -Weverything, -Wno-everything, -Werror=write-strings, and so on. in ConstructJob()
6403 WriteStrings->getOption().matches(options::OPT_Wwrite_strings)) in ConstructJob()
6404 CmdArgs.push_back("-fconst-strings"); in ConstructJob()
6407 // GCC provides a macro definition '__DEPRECATED' when -Wdeprecated is active in ConstructJob()
6409 // in the presence of '-w', match this behavior bug-for-bug. in ConstructJob()
6413 CmdArgs.push_back("-fdeprecated-macro"); in ConstructJob()
6416 // Translate GCC's misnamer '-fasm' arguments to '-fgnu-keywords'. in ConstructJob()
6418 if (Asm->getOption().matches(options::OPT_fasm)) in ConstructJob()
6419 CmdArgs.push_back("-fgnu-keywords"); in ConstructJob()
6421 CmdArgs.push_back("-fno-gnu-keywords"); in ConstructJob()
6425 CmdArgs.push_back("-fno-autolink"); in ConstructJob()
6435 CmdArgs.push_back("-fexperimental-new-constant-interpreter"); in ConstructJob()
6438 CmdArgs.push_back("-fbracket-depth"); in ConstructJob()
6439 CmdArgs.push_back(A->getValue()); in ConstructJob()
6444 if (A->getNumValues()) { in ConstructJob()
6445 StringRef bytes = A->getValue(); in ConstructJob()
6446 CmdArgs.push_back(Args.MakeArgString("-Wlarge-by-value-copy=" + bytes)); in ConstructJob()
6448 CmdArgs.push_back("-Wlarge-by-value-copy=64"); // default value in ConstructJob()
6452 CmdArgs.push_back("-relocatable-pch"); in ConstructJob()
6456 "standalone", "objc", "swift", "swift-5.0", "swift-4.2", "swift-4.1", in ConstructJob()
6459 if (!llvm::is_contained(kCFABIs, StringRef(A->getValue()))) in ConstructJob()
6460 D.Diag(diag::err_drv_invalid_cf_runtime_abi) << A->getValue(); in ConstructJob()
6462 A->render(Args, CmdArgs); in ConstructJob()
6466 CmdArgs.push_back("-fconstant-string-class"); in ConstructJob()
6467 CmdArgs.push_back(A->getValue()); in ConstructJob()
6471 CmdArgs.push_back("-ftabstop"); in ConstructJob()
6472 CmdArgs.push_back(A->getValue()); in ConstructJob()
6479 CmdArgs.push_back("-stack-usage-file"); in ConstructJob()
6482 SmallString<128> OutputFilename(OutputOpt->getValue()); in ConstructJob()
6490 CmdArgs.push_back("-ferror-limit"); in ConstructJob()
6492 CmdArgs.push_back(A->getValue()); in ConstructJob()
6502 // Pass -fmessage-length=. in ConstructJob()
6505 StringRef V(A->getValue()); in ConstructJob()
6507 D.Diag(diag::err_drv_invalid_argument_to_option) in ConstructJob()
6508 << V << A->getOption().getName(); in ConstructJob()
6510 // If -fmessage-length=N was not specified, determine whether this is a in ConstructJob()
6511 // terminal and, if so, implicitly define -fmessage-length appropriately. in ConstructJob()
6516 Args.MakeArgString("-fmessage-length=" + Twine(MessageLength))); in ConstructJob()
6520 Args.MakeArgString("-frandomize-layout-seed=" + Twine(A->getValue(0)))); in ConstructJob()
6523 CmdArgs.push_back(Args.MakeArgString("-frandomize-layout-seed-file=" + in ConstructJob()
6524 Twine(A->getValue(0)))); in ConstructJob()
6526 // -fvisibility= and -fvisibility-ms-compat are of a piece. in ConstructJob()
6529 if (A->getOption().matches(options::OPT_fvisibility_EQ)) { in ConstructJob()
6530 A->render(Args, CmdArgs); in ConstructJob()
6532 assert(A->getOption().matches(options::OPT_fvisibility_ms_compat)); in ConstructJob()
6533 CmdArgs.push_back("-fvisibility=hidden"); in ConstructJob()
6534 CmdArgs.push_back("-ftype-visibility=default"); in ConstructJob()
6540 CmdArgs.push_back("-fvisibility=protected"); in ConstructJob()
6548 if (A->getOption().matches( in ConstructJob()
6550 CmdArgs.push_back("-fvisibility-from-dllstorageclass"); in ConstructJob()
6562 CmdArgs.push_back("-fvisibility-inlines-hidden"); in ConstructJob()
6567 // -fvisibility-global-new-delete-hidden is a deprecated spelling of in ConstructJob()
6568 // -fvisibility-global-new-delete=force-hidden. in ConstructJob()
6571 D.Diag(diag::warn_drv_deprecated_arg) in ConstructJob()
6572 << A->getAsString(Args) << /*hasReplacement=*/true in ConstructJob()
6573 << "-fvisibility-global-new-delete=force-hidden"; in ConstructJob()
6579 if (A->getOption().matches(options::OPT_fvisibility_global_new_delete_EQ)) { in ConstructJob()
6580 A->render(Args, CmdArgs); in ConstructJob()
6582 assert(A->getOption().matches( in ConstructJob()
6584 CmdArgs.push_back("-fvisibility-global-new-delete=force-hidden"); in ConstructJob()
6592 CmdArgs.push_back("-fnew-infallible"); in ConstructJob()
6596 CmdArgs.push_back("-fno-operator-names"); in ConstructJob()
6598 // Forward -f (flag) options which we can pass directly. in ConstructJob()
6608 CmdArgs.push_back("-femulated-tls"); in ConstructJob()
6618 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
6619 << A->getAsString(Args) << TripleStr; in ConstructJob()
6622 // AltiVec-like language extensions aren't relevant for assembling. in ConstructJob()
6639 CmdArgs.push_back("-fopenmp"); in ConstructJob()
6646 CmdArgs.push_back("-fnoopenmp-use-tls"); in ConstructJob()
6653 CmdArgs.push_back("-fno-openmp-extensions"); in ConstructJob()
6661 CmdArgs.push_back("-fopenmp-optimistic-collapse"); in ConstructJob()
6664 // cuda-mode flag in ConstructJob()
6667 CmdArgs.push_back("-fopenmp-cuda-mode"); in ConstructJob()
6673 CmdArgs.push_back("-fopenmp-target-debug"); in ConstructJob()
6680 CmdArgs.push_back("-fopenmp-assume-teams-oversubscription"); in ConstructJob()
6684 CmdArgs.push_back("-fopenmp-assume-threads-oversubscription"); in ConstructJob()
6686 CmdArgs.push_back("-fopenmp-assume-no-thread-state"); in ConstructJob()
6688 CmdArgs.push_back("-fopenmp-assume-no-nested-parallelism"); in ConstructJob()
6690 CmdArgs.push_back("-fopenmp-offload-mandatory"); in ConstructJob()
6692 CmdArgs.push_back("-fopenmp-force-usm"); in ConstructJob()
6696 // for a specific runtime library, we just don't pass the '-fopenmp' flag in ConstructJob()
6714 CmdArgs.push_back("--offload-new-driver"); in ConstructJob()
6724 CmdArgs.push_back(Args.MakeArgString("-fprofile-list=" + Filename)); in ConstructJob()
6726 D.Diag(clang::diag::err_drv_no_such_file) << Filename; in ConstructJob()
6730 StringRef S0 = A->getValue(), S = S0; in ConstructJob()
6736 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
6737 << A->getAsString(Args) << TripleStr; in ConstructJob()
6741 D.Diag(diag::err_drv_invalid_argument_to_option) in ConstructJob()
6742 << S0 << A->getOption().getName(); in ConstructJob()
6744 D.Diag(diag::err_drv_unsupported_fpatchable_function_entry_argument); in ConstructJob()
6746 CmdArgs.push_back(Args.MakeArgString(A->getSpelling() + Twine(Size))); in ConstructJob()
6748 "-fpatchable-function-entry-offset=" + Twine(Offset))); in ConstructJob()
6760 A->render(Args, CmdArgs); in ConstructJob()
6762 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
6763 << A->getAsString(Args) << TripleStr; in ConstructJob()
6767 A->render(Args, CmdArgs); in ConstructJob()
6769 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
6770 << A->getAsString(Args) << TripleStr; in ConstructJob()
6774 A->render(Args, CmdArgs); in ConstructJob()
6776 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
6777 << A->getAsString(Args) << TripleStr; in ConstructJob()
6783 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
6784 << A->getAsString(Args) << TripleStr; in ConstructJob()
6789 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
6790 << A->getAsString(Args) << TripleStr; in ConstructJob()
6794 if (A->getOption().matches(options::OPT_p)) { in ConstructJob()
6795 A->claim(); in ConstructJob()
6797 CmdArgs.push_back("-pg"); in ConstructJob()
6801 // Reject AIX-specific link options on other targets. in ConstructJob()
6805 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
6806 << A->getSpelling() << TripleStr; in ConstructJob()
6812 CmdArgs.push_back("-fapple-kext"); in ConstructJob()
6826 CmdArgs.push_back(Args.MakeArgString("-ftime-trace=" + Twine(Name))); in ConstructJob()
6832 CmdArgs.push_back("-ftrapv-handler"); in ConstructJob()
6833 CmdArgs.push_back(A->getValue()); in ConstructJob()
6838 // -fno-strict-overflow implies -fwrapv if it isn't disabled, but in ConstructJob()
6839 // -fstrict-overflow won't turn off an explicitly enabled -fwrapv. in ConstructJob()
6841 if (A->getOption().matches(options::OPT_fwrapv)) in ConstructJob()
6842 CmdArgs.push_back("-fwrapv"); in ConstructJob()
6845 if (A->getOption().matches(options::OPT_fno_strict_overflow)) in ConstructJob()
6846 CmdArgs.push_back("-fwrapv"); in ConstructJob()
6874 CmdArgs.push_back(Args.MakeArgString("-mstack-alignment=" + alignment)); in ConstructJob()
6881 CmdArgs.push_back(Args.MakeArgString("-mstack-probe-size=" + Size)); in ConstructJob()
6883 CmdArgs.push_back("-mstack-probe-size=0"); in ConstructJob()
6891 if (A->getOption().matches(options::OPT_mrestrict_it)) { in ConstructJob()
6892 CmdArgs.push_back("-mllvm"); in ConstructJob()
6893 CmdArgs.push_back("-arm-restrict-it"); in ConstructJob()
6895 CmdArgs.push_back("-mllvm"); in ConstructJob()
6896 CmdArgs.push_back("-arm-default-it"); in ConstructJob()
6900 // Forward -cl options to -cc1 in ConstructJob()
6903 // Forward hlsl options to -cc1 in ConstructJob()
6906 // Forward OpenACC options to -cc1 in ConstructJob()
6912 CmdArgs.push_back("-fhip-new-launch-api"); in ConstructJob()
6923 CmdArgs.push_back("-fgpu-rdc"); in ConstructJob()
6929 CmdArgs.push_back("-fgpu-exclude-wrong-side-overloads"); in ConstructJob()
6930 CmdArgs.push_back("-fgpu-defer-diag"); in ConstructJob()
6934 // Forward -nogpulib to -cc1. in ConstructJob()
6936 CmdArgs.push_back("-nogpulib"); in ConstructJob()
6940 Args.MakeArgString(Twine("-fcf-protection=") + A->getValue())); in ConstructJob()
6945 Args.MakeArgString(Twine("-mfunction-return=") + A->getValue())); in ConstructJob()
6949 // Forward -f options with positive and negative forms; we translate these by in ConstructJob()
6950 // hand. Do not propagate PGO options to the GPU-side compilations as the in ConstructJob()
6951 // profile info is for the host-side compilation only. in ConstructJob()
6960 D.Diag(diag::err_drv_argument_not_allowed_with) in ConstructJob()
6963 StringRef fname = A->getValue(); in ConstructJob()
6965 D.Diag(diag::err_drv_no_such_file) << fname; in ConstructJob()
6967 A->render(Args, CmdArgs); in ConstructJob()
6973 CmdArgs.push_back("-fpseudo-probe-for-profiling"); in ConstructJob()
6974 // Enforce -funique-internal-linkage-names if it's not explicitly turned in ConstructJob()
6978 CmdArgs.push_back("-funique-internal-linkage-names"); in ConstructJob()
6987 CmdArgs.push_back("-fapinotes"); in ConstructJob()
6990 CmdArgs.push_back("-fapinotes-modules"); in ConstructJob()
6993 // -fblocks=0 is default. in ConstructJob()
6999 CmdArgs.push_back("-fblocks"); in ConstructJob()
7002 CmdArgs.push_back("-fblocks-runtime-optional"); in ConstructJob()
7005 // -fencode-extended-block-signature=1 is default. in ConstructJob()
7007 CmdArgs.push_back("-fencode-extended-block-signature"); in ConstructJob()
7012 CmdArgs.push_back("-fcoro-aligned-allocation"); in ConstructJob()
7026 CmdArgs.push_back("-fno-rtti"); in ConstructJob()
7028 // -fshort-enums=0 is default for all architectures except Hexagon and z/OS. in ConstructJob()
7031 CmdArgs.push_back("-fshort-enums"); in ConstructJob()
7035 // -fuse-cxa-atexit is default. in ConstructJob()
7042 CmdArgs.push_back("-fno-use-cxa-atexit"); in ConstructJob()
7047 CmdArgs.push_back("-fregister-global-dtors-with-atexit"); in ConstructJob()
7052 // -fno-minimize-whitespace is default. in ConstructJob()
7057 D.Diag(diag::err_drv_opt_unsupported_input_type) in ConstructJob()
7058 << "-fminimize-whitespace" << types::getTypeName(InputType); in ConstructJob()
7059 CmdArgs.push_back("-fminimize-whitespace"); in ConstructJob()
7062 // -fno-keep-system-includes is default. in ConstructJob()
7067 D.Diag(diag::err_drv_opt_unsupported_input_type) in ConstructJob()
7068 << "-fkeep-system-includes" << types::getTypeName(InputType); in ConstructJob()
7069 CmdArgs.push_back("-fkeep-system-includes"); in ConstructJob()
7072 // -fms-extensions=0 is default. in ConstructJob()
7075 CmdArgs.push_back("-fms-extensions"); in ConstructJob()
7077 // -fms-compatibility=0 is default. in ConstructJob()
7083 CmdArgs.push_back("-fms-compatibility"); in ConstructJob()
7086 CmdArgs.push_back("-fms-define-stdc"); in ConstructJob()
7093 // Handle -fgcc-version, if present. in ConstructJob()
7096 // Check that the version has 1 to 3 components and the minor and patch in ConstructJob()
7098 StringRef Val = A->getValue(); in ConstructJob()
7104 D.Diag(diag::err_drv_invalid_value) in ConstructJob()
7105 << A->getAsString(Args) << A->getValue(); in ConstructJob()
7108 // Imitate GCC 4.2.1 by default if -fms-compatibility is not in effect. in ConstructJob()
7113 Args.MakeArgString("-fgnuc-version=" + GNUCVer.getAsString())); in ConstructJob()
7119 Args.MakeArgString("-fms-compatibility-version=" + MSVT.getAsString())); in ConstructJob()
7126 LanguageStandard = llvm::StringSwitch<StringRef>(StdArg->getValue()) in ConstructJob()
7127 .Case("c11", "-std=c11") in ConstructJob()
7128 .Case("c17", "-std=c17") in ConstructJob()
7131 D.Diag(clang::diag::warn_drv_unused_argument) in ConstructJob()
7132 << StdArg->getAsString(Args); in ConstructJob()
7140 LanguageStandard = llvm::StringSwitch<StringRef>(StdArg->getValue()) in ConstructJob()
7141 .Case("c++14", "-std=c++14") in ConstructJob()
7142 .Case("c++17", "-std=c++17") in ConstructJob()
7143 .Case("c++20", "-std=c++20") in ConstructJob()
7145 .Case("c++latest", "-std=c++26") in ConstructJob()
7148 D.Diag(clang::diag::warn_drv_unused_argument) in ConstructJob()
7149 << StdArg->getAsString(Args); in ConstructJob()
7154 LanguageStandard = "-std=c++14"; in ConstructJob()
7156 LanguageStandard = "-std=c++11"; in ConstructJob()
7165 // -fno-declspec is default, except for PS4/PS5. in ConstructJob()
7168 CmdArgs.push_back("-fdeclspec"); in ConstructJob()
7170 CmdArgs.push_back("-fno-declspec"); // Explicitly disabling __declspec. in ConstructJob()
7172 // -fthreadsafe-static is default, except for MSVC compatibility versions less in ConstructJob()
7178 CmdArgs.push_back("-fno-threadsafe-statics"); in ConstructJob()
7180 // Add -fno-assumptions, if it was specified. in ConstructJob()
7183 CmdArgs.push_back("-fno-assumptions"); in ConstructJob()
7185 // -fgnu-keywords default varies depending on language; only pass if in ConstructJob()
7197 if (A->getOption().matches(options::OPT_fno_inline)) in ConstructJob()
7198 A->render(Args, CmdArgs); in ConstructJob()
7200 InlineArg->render(Args, CmdArgs); in ConstructJob()
7208 (Std->containsValue("c++2a") || Std->containsValue("gnu++2a") || in ConstructJob()
7209 Std->containsValue("c++20") || Std->containsValue("gnu++20") || in ConstructJob()
7210 Std->containsValue("c++2b") || Std->containsValue("gnu++2b") || in ConstructJob()
7211 Std->containsValue("c++23") || Std->containsValue("gnu++23") || in ConstructJob()
7212 Std->containsValue("c++2c") || Std->containsValue("gnu++2c") || in ConstructJob()
7213 Std->containsValue("c++26") || Std->containsValue("gnu++26") || in ConstructJob()
7214 Std->containsValue("c++latest") || Std->containsValue("gnu++latest")); in ConstructJob()
7218 // -fdelayed-template-parsing is default when targeting MSVC. in ConstructJob()
7222 …// https://learn.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msv… in ConstructJob()
7223 // MSVC actually defaults to -fno-delayed-template-parsing (/Zc:twoPhase- in ConstructJob()
7225 // not enable -fdelayed-template-parsing by default after C++20. in ConstructJob()
7227 // FIXME: Given -fdelayed-template-parsing is a source of bugs, we should be in ConstructJob()
7233 D.Diag(clang::diag::warn_drv_delayed_template_parsing_after_cxx20); in ConstructJob()
7235 CmdArgs.push_back("-fdelayed-template-parsing"); in ConstructJob()
7240 CmdArgs.push_back("-fvalidate-ast-input-files-content"); in ConstructJob()
7243 CmdArgs.push_back("-fpch-instantiate-templates"); in ConstructJob()
7246 CmdArgs.push_back("-fmodules-codegen"); in ConstructJob()
7249 CmdArgs.push_back("-fmodules-debuginfo"); in ConstructJob()
7259 CmdArgs.push_back("-fobjc-encode-cxx-class-template-spec"); in ConstructJob()
7263 CmdArgs.push_back("-fapplication-extension"); in ConstructJob()
7265 // Handle GCC-style exception args. in ConstructJob()
7275 const Option &Opt = A->getOption(); in ConstructJob()
7277 CmdArgs.push_back("-exception-model=sjlj"); in ConstructJob()
7279 CmdArgs.push_back("-exception-model=seh"); in ConstructJob()
7281 CmdArgs.push_back("-exception-model=dwarf"); in ConstructJob()
7283 CmdArgs.push_back("-exception-model=wasm"); in ConstructJob()
7289 CmdArgs.push_back("-exception-model=dwarf"); in ConstructJob()
7292 CmdArgs.push_back("-exception-model=sjlj"); in ConstructJob()
7295 CmdArgs.push_back("-exception-model=seh"); in ConstructJob()
7304 // -fassume-unique-vtables is on by default. in ConstructJob()
7308 // -frelaxed-template-template-args is deprecated. in ConstructJob()
7312 if (A->getOption().matches( in ConstructJob()
7314 D.Diag(diag::warn_drv_deprecated_arg_no_relaxed_template_template_args); in ConstructJob()
7315 CmdArgs.push_back("-fno-relaxed-template-template-args"); in ConstructJob()
7317 D.Diag(diag::warn_drv_deprecated_arg) in ConstructJob()
7318 << A->getAsString(Args) << /*hasReplacement=*/false; in ConstructJob()
7322 // -fsized-deallocation is on by default in C++14 onwards and otherwise off in ConstructJob()
7327 // -faligned-allocation is on by default in C++17 onwards and otherwise off in ConstructJob()
7332 if (A->getOption().matches(options::OPT_fno_aligned_allocation)) in ConstructJob()
7333 CmdArgs.push_back("-fno-aligned-allocation"); in ConstructJob()
7335 CmdArgs.push_back("-faligned-allocation"); in ConstructJob()
7339 // a GCC-compatible option that also turns on aligned allocation. in ConstructJob()
7343 Args.MakeArgString(Twine("-fnew-alignment=") + A->getValue())); in ConstructJob()
7345 // -fconstant-cfstrings is default, and may be subject to argument translation in ConstructJob()
7351 CmdArgs.push_back("-fno-constant-cfstrings"); in ConstructJob()
7356 // Honor -fpack-struct= and -fpack-struct, if given. Note that in ConstructJob()
7357 // -fno-pack-struct doesn't apply to -fpack-struct=. in ConstructJob()
7359 std::string PackStructStr = "-fpack-struct="; in ConstructJob()
7360 PackStructStr += A->getValue(); in ConstructJob()
7364 CmdArgs.push_back("-fpack-struct=1"); in ConstructJob()
7367 // Handle -fmax-type-align=N and -fno-type-align in ConstructJob()
7371 std::string MaxTypeAlignStr = "-fmax-type-align="; in ConstructJob()
7372 MaxTypeAlignStr += A->getValue(); in ConstructJob()
7377 std::string MaxTypeAlignStr = "-fmax-type-align=16"; in ConstructJob()
7383 CmdArgs.push_back("-Qn"); in ConstructJob()
7385 // -fno-common is the default, set -fcommon only when that flag is set. in ConstructJob()
7388 // -fsigned-bitfields is default, and clang doesn't yet support in ConstructJob()
7389 // -funsigned-bitfields. in ConstructJob()
7392 D.Diag(diag::warn_drv_clang_unsupported) in ConstructJob()
7393 << Args.getLastArg(options::OPT_funsigned_bitfields)->getAsString(Args); in ConstructJob()
7395 // -fsigned-bitfields is default, and clang doesn't support -fno-for-scope. in ConstructJob()
7397 D.Diag(diag::err_drv_clang_unsupported) in ConstructJob()
7398 << Args.getLastArg(options::OPT_fno_for_scope)->getAsString(Args); in ConstructJob()
7400 // -finput_charset=UTF-8 is default. Reject others in ConstructJob()
7402 StringRef value = inputCharset->getValue(); in ConstructJob()
7403 if (!value.equals_insensitive("utf-8")) in ConstructJob()
7404 D.Diag(diag::err_drv_invalid_value) << inputCharset->getAsString(Args) in ConstructJob()
7408 // -fexec_charset=UTF-8 is default. Reject others in ConstructJob()
7410 StringRef value = execCharset->getValue(); in ConstructJob()
7411 if (!value.equals_insensitive("utf-8")) in ConstructJob()
7412 D.Diag(diag::err_drv_invalid_value) << execCharset->getAsString(Args) in ConstructJob()
7432 CmdArgs.push_back("-vectorize-loops"); in ConstructJob()
7434 // -fslp-vectorize is enabled based on the optimization level selected. in ConstructJob()
7440 CmdArgs.push_back("-vectorize-slp"); in ConstructJob()
7448 // -fdollars-in-identifiers default varies depending on platform and in ConstructJob()
7452 if (A->getOption().matches(options::OPT_fdollars_in_identifiers)) in ConstructJob()
7453 CmdArgs.push_back("-fdollars-in-identifiers"); in ConstructJob()
7455 CmdArgs.push_back("-fno-dollars-in-identifiers"); in ConstructJob()
7461 // Remarks can be enabled with any of the `-f.*optimization-record.*` flags. in ConstructJob()
7468 CmdArgs.push_back("-frewrite-imports"); in ConstructJob()
7475 // TODO: Once -module-dependency-dir works with -frewrite-includes it'd be in ConstructJob()
7480 CmdArgs.push_back("-frewrite-includes"); in ConstructJob()
7482 // Only allow -traditional or -traditional-cpp outside in preprocessing modes. in ConstructJob()
7486 CmdArgs.push_back("-traditional-cpp"); in ConstructJob()
7488 D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args); in ConstructJob()
7499 CmdArgs.push_back("-serialize-diagnostic-file"); in ConstructJob()
7500 CmdArgs.push_back(Args.MakeArgString(A->getValue())); in ConstructJob()
7504 CmdArgs.push_back("-fretain-comments-from-system-headers"); in ConstructJob()
7506 // Forward -fcomment-block-commands to -cc1. in ConstructJob()
7508 // Forward -fparse-all-comments to -cc1. in ConstructJob()
7511 // Turn -fplugin=name.so into -load name.so in ConstructJob()
7513 CmdArgs.push_back("-load"); in ConstructJob()
7514 CmdArgs.push_back(A->getValue()); in ConstructJob()
7515 A->claim(); in ConstructJob()
7518 // Turn -fplugin-arg-pluginname-key=value into in ConstructJob()
7519 // -plugin-arg-pluginname key=value in ConstructJob()
7521 // passes to its plugins, but we don't, so just pass it on as-is. in ConstructJob()
7523 // The syntax for -fplugin-arg- is ambiguous if both plugin name and in ConstructJob()
7527 auto ArgValue = StringRef(A->getValue()); in ConstructJob()
7528 auto FirstDashIndex = ArgValue.find('-'); in ConstructJob()
7532 A->claim(); in ConstructJob()
7535 D.Diag(diag::warn_drv_missing_plugin_name) << A->getAsString(Args); in ConstructJob()
7537 D.Diag(diag::warn_drv_missing_plugin_arg) in ConstructJob()
7538 << PluginName << A->getAsString(Args); in ConstructJob()
7543 CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-arg-") + PluginName)); in ConstructJob()
7547 // Forward -fpass-plugin=name.so to -cc1. in ConstructJob()
7550 Args.MakeArgString(Twine("-fpass-plugin=") + A->getValue())); in ConstructJob()
7551 A->claim(); in ConstructJob()
7554 // Forward --vfsoverlay to -cc1. in ConstructJob()
7556 CmdArgs.push_back("--vfsoverlay"); in ConstructJob()
7557 CmdArgs.push_back(A->getValue()); in ConstructJob()
7558 A->claim(); in ConstructJob()
7570 CmdArgs.push_back(Args.MakeArgString(Twine("-stats-file=") + StatsFile)); in ConstructJob()
7572 CmdArgs.push_back("-stats-file-append"); in ConstructJob()
7575 // Forward -Xclang arguments to -cc1, and -mllvm arguments to the LLVM option in ConstructJob()
7578 Arg->claim(); in ConstructJob()
7579 // -finclude-default-header flag is for preprocessor, in ConstructJob()
7580 // do not pass it to other cc1 commands when save-temps is enabled in ConstructJob()
7583 if (StringRef(Arg->getValue()) == "-finclude-default-header") in ConstructJob()
7586 CmdArgs.push_back(Arg->getValue()); in ConstructJob()
7589 A->claim(); in ConstructJob()
7591 // We translate this by hand to the -cc1 argument, since nightly test uses in ConstructJob()
7592 // it and developers have been trained to spell it with -mllvm. Both in ConstructJob()
7594 if (StringRef(A->getValue(0)) == "-disable-llvm-optzns") { in ConstructJob()
7595 CmdArgs.push_back("-disable-llvm-optzns"); in ConstructJob()
7597 A->render(Args, CmdArgs); in ConstructJob()
7601 // With -save-temps, we want to save the unoptimized bitcode output from the in ConstructJob()
7602 // CompileJobAction, use -disable-llvm-passes to get pristine IR generated in ConstructJob()
7604 // When -fembed-bitcode is enabled, optimized bitcode is emitted because it in ConstructJob()
7606 // FIXME: -fembed-bitcode -save-temps will save optimized bitcode instead of in ConstructJob()
7613 CmdArgs.push_back("-disable-llvm-passes"); in ConstructJob()
7619 // Optionally embed the -cc1 level arguments into the debug info or a in ConstructJob()
7622 // -grecord-gcc-switches options is set on. in ConstructJob()
7623 // By default, -gno-record-gcc-switches is set on and no recording. in ConstructJob()
7632 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
7633 << Args.getLastArg(options::OPT_frecord_command_line)->getAsString(Args) in ConstructJob()
7638 Arg->render(Args, OriginalArgs); in ConstructJob()
7650 CmdArgs.push_back("-dwarf-debug-flags"); in ConstructJob()
7654 CmdArgs.push_back("-record-command-line"); in ConstructJob()
7659 // Host-side offloading compilation receives all device-side outputs. Include in ConstructJob()
7661 // are not empty we use the new-driver scheme, otherwise use the old scheme. in ConstructJob()
7663 CmdArgs.push_back("-fcuda-include-gpubinary"); in ConstructJob()
7664 CmdArgs.push_back(CudaDeviceInput->getFilename()); in ConstructJob()
7668 CmdArgs.push_back("-fcuda-include-gpubinary"); in ConstructJob()
7672 CmdArgs.push_back(Args.MakeArgString("-fembed-offload-object=" + in ConstructJob()
7680 CmdArgs.push_back("-fcuda-short-ptr"); in ConstructJob()
7686 while (SourceAction->getKind() != Action::InputClass) { in ConstructJob()
7687 assert(!SourceAction->getInputs().empty() && "unexpected root action!"); in ConstructJob()
7688 SourceAction = SourceAction->getInputs()[0]; in ConstructJob()
7690 auto CUID = cast<InputAction>(SourceAction)->getId(); in ConstructJob()
7692 CmdArgs.push_back(Args.MakeArgString(Twine("-cuid=") + Twine(CUID))); in ConstructJob()
7694 // -ffast-math turns on -fgpu-approx-transcendentals implicitly, but will in ConstructJob()
7695 // be overriden by -fno-gpu-approx-transcendentals. in ConstructJob()
7701 CmdArgs.push_back("-fgpu-approx-transcendentals"); in ConstructJob()
7708 CmdArgs.push_back("-fcuda-allow-variadic-functions"); in ConstructJob()
7723 std::string("-inline-threshold=") + InlineThresh.str(); in ConstructJob()
7724 CmdArgs.append({"-mllvm", Args.MakeArgStringRef(ArgStr)}); in ConstructJob()
7733 // OpenMP offloading device jobs take the argument -fopenmp-host-ir-file-path in ConstructJob()
7735 // device declarations can be identified. Also, -fopenmp-is-target-device is in ConstructJob()
7739 CmdArgs.push_back("-fopenmp-is-target-device"); in ConstructJob()
7741 CmdArgs.push_back("-fopenmp-host-ir-file-path"); in ConstructJob()
7742 CmdArgs.push_back(Args.MakeArgString(OpenMPDeviceInput->getFilename())); in ConstructJob()
7756 // information using -fopenmp-targets= option. in ConstructJob()
7758 SmallString<128> Targets("-fopenmp-targets="); in ConstructJob()
7763 [](auto TC) { return TC.second->getTripleString(); }); in ConstructJob()
7774 D.Diag(diag::err_drv_argument_only_allowed_with) in ConstructJob()
7775 << "-fvirtual-function-elimination" in ConstructJob()
7776 << "-flto=full"; in ConstructJob()
7778 CmdArgs.push_back("-fvirtual-function-elimination"); in ConstructJob()
7781 // VFE requires whole-program-vtables, and enables it by default. in ConstructJob()
7786 D.Diag(diag::err_drv_argument_not_allowed_with) in ConstructJob()
7787 << "-fno-whole-program-vtables" in ConstructJob()
7788 << "-fvirtual-function-elimination"; in ConstructJob()
7803 D.Diag(diag::err_drv_argument_only_allowed_with) in ConstructJob()
7804 << "-fwhole-program-vtables" in ConstructJob()
7805 << ((IsPS4 && !UnifiedLTO) ? "-flto=full" : "-flto"); in ConstructJob()
7807 // Propagate -fwhole-program-vtables if this is an LTO compile. in ConstructJob()
7809 CmdArgs.push_back("-fwhole-program-vtables"); in ConstructJob()
7820 D.Diag(diag::err_drv_argument_not_allowed_with) << "-fno-split-lto-unit" in ConstructJob()
7821 << "-fsanitize=cfi"; in ConstructJob()
7823 CmdArgs.push_back("-fsplit-lto-unit"); in ConstructJob()
7827 if (IsUsingLTO && A->getOption().matches(options::OPT_ffat_lto_objects)) { in ConstructJob()
7830 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
7831 << A->getAsString(Args) << TC.getTripleString(); in ConstructJob()
7834 Twine("-flto=") + (LTOMode == LTOK_Thin ? "thin" : "full"))); in ConstructJob()
7835 CmdArgs.push_back("-flto-unit"); in ConstructJob()
7836 CmdArgs.push_back("-ffat-lto-objects"); in ConstructJob()
7837 A->render(Args, CmdArgs); in ConstructJob()
7843 CmdArgs.push_back("-mllvm"); in ConstructJob()
7844 if (A->getOption().matches(options::OPT_fglobal_isel)) { in ConstructJob()
7845 CmdArgs.push_back("-global-isel=1"); in ConstructJob()
7847 // GISel is on by default on AArch64 -O0, so don't bother adding in ConstructJob()
7855 if (!A || A->getOption().matches(options::OPT_O0)) in ConstructJob()
7859 CmdArgs.push_back("-mllvm"); in ConstructJob()
7860 CmdArgs.push_back("-global-isel-abort=2"); in ConstructJob()
7863 D.Diag(diag::warn_drv_global_isel_incomplete) << Triple.getArchName(); in ConstructJob()
7865 D.Diag(diag::warn_drv_global_isel_incomplete_opt); in ConstructJob()
7868 CmdArgs.push_back("-global-isel=0"); in ConstructJob()
7873 CmdArgs.push_back("-forder-file-instrumentation"); in ConstructJob()
7878 CmdArgs.push_back("-mllvm"); in ConstructJob()
7879 CmdArgs.push_back("-enable-order-file-instrumentation"); in ConstructJob()
7885 if (A->getOption().matches(options::OPT_fforce_enable_int128)) in ConstructJob()
7886 CmdArgs.push_back("-fforce-enable-int128"); in ConstructJob()
7907 CmdArgs.push_back("-target-feature"); in ConstructJob()
7908 CmdArgs.push_back("-fmv"); in ConstructJob()
7918 CmdArgs.push_back("-faddrsig"); in ConstructJob()
7923 CmdArgs.push_back("-D__GCC_HAVE_DWARF2_CFI_ASM=1"); in ConstructJob()
7926 std::string Str = A->getAsString(Args); in ConstructJob()
7928 D.Diag(diag::err_drv_unsupported_opt_for_target) in ConstructJob()
7933 // Add the "-o out -x type src.c" flags last. This is done primarily to make in ConstructJob()
7934 // the -cc1 command easier to edit when reproducing compiler crashes. in ConstructJob()
7942 CmdArgs.push_back("-o"); in ConstructJob()
7945 CmdArgs.push_back("-o"); in ConstructJob()
7982 C.getJobs().getJobs().back()->PrintInputFilenames = true; in ConstructJob()
7988 D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer" in ConstructJob()
7989 << A->getAsString(Args); in ConstructJob()
7993 // -fpch-preprocess is used with gcc to add a special marker in the output to in ConstructJob()
8002 // Disable warnings for clang -E -emit-llvm foo.c in ConstructJob()
8014 /// Add options related to the Objective-C runtime/ABI.
8016 /// Returns true if the runtime is non-fragile.
8026 // Just forward -fobjc-runtime= to the frontend. This supercedes in AddObjCRuntimeArgs()
8029 runtimeArg->getOption().matches(options::OPT_fobjc_runtime_EQ)) { in AddObjCRuntimeArgs()
8031 StringRef value = runtimeArg->getValue(); in AddObjCRuntimeArgs()
8033 getToolChain().getDriver().Diag(diag::err_drv_unknown_objc_runtime) in AddObjCRuntimeArgs()
8040 getToolChain().getDriver().Diag( in AddObjCRuntimeArgs()
8041 diag::err_drv_gnustep_objc_runtime_incompatible_binary) in AddObjCRuntimeArgs()
8045 runtimeArg->render(args, cmdArgs); in AddObjCRuntimeArgs()
8049 // Otherwise, we'll need the ABI "version". Version numbers are in AddObjCRuntimeArgs()
8051 // 1 - Traditional "fragile" ABI in AddObjCRuntimeArgs()
8052 // 2 - Non-fragile ABI, version 1 in AddObjCRuntimeArgs()
8053 // 3 - Non-fragile ABI, version 2 in AddObjCRuntimeArgs()
8055 // If -fobjc-abi-version= is present, use that to set the version. in AddObjCRuntimeArgs()
8057 StringRef value = abiArg->getValue(); in AddObjCRuntimeArgs()
8065 getToolChain().getDriver().Diag(diag::err_drv_clang_unsupported) << value; in AddObjCRuntimeArgs()
8067 // Otherwise, determine if we are using the non-fragile ABI. in AddObjCRuntimeArgs()
8075 // Determine the non-fragile ABI version to use. in AddObjCRuntimeArgs()
8084 StringRef value = abiArg->getValue(); in AddObjCRuntimeArgs()
8090 getToolChain().getDriver().Diag(diag::err_drv_clang_unsupported) in AddObjCRuntimeArgs()
8100 // We don't actually care about the ABI version other than whether in AddObjCRuntimeArgs()
8101 // it's non-fragile. in AddObjCRuntimeArgs()
8120 // -fnext-runtime in AddObjCRuntimeArgs()
8121 } else if (runtimeArg->getOption().matches(options::OPT_fnext_runtime)) { in AddObjCRuntimeArgs()
8131 // -fgnu-runtime in AddObjCRuntimeArgs()
8133 assert(runtimeArg->getOption().matches(options::OPT_fgnu_runtime)); in AddObjCRuntimeArgs()
8135 // non-fragile mode or the GCC runtime in fragile mode. in AddObjCRuntimeArgs()
8146 args.MakeArgString("-fobjc-runtime=" + runtime.getAsString())); in AddObjCRuntimeArgs()
8151 bool HaveDash = (I + 1 < EH.size() && EH[I + 1] == '-'); in maybeConsumeDash()
8166 /// - s: Cleanup after "synchronous" exceptions, aka C++ exceptions.
8167 /// - a: Cleanup after "asynchronous" exceptions, aka structured exceptions.
8169 /// - c: Assume that extern "C" functions are implicitly nounwind.
8170 /// The default is /EHs-c-, meaning cleanups are disabled.
8186 D.Diag(clang::diag::warn_drv_unused_argument) << "/EHa" << EHVal; in parseClangCLEHFlags()
8203 D.Diag(clang::diag::err_drv_invalid_value) << "/EH" << EHVal; in parseClangCLEHFlags()
8207 // The /GX, /GX- flags are only processed if there are not /EH flags. in parseClangCLEHFlags()
8234 CmdArgs.push_back("--show-includes"); in AddClangCLArgs()
8235 if (ShowIncludes->getOption().matches(options::OPT__SLASH_showIncludes)) in AddClangCLArgs()
8236 CmdArgs.push_back("-sys-header-deps"); in AddClangCLArgs()
8242 CmdArgs.push_back("-fno-rtti-data"); in AddClangCLArgs()
8244 // This controls whether or not we emit stack-protector instrumentation. in AddClangCLArgs()
8248 CmdArgs.push_back("-stack-protector"); in AddClangCLArgs()
8258 CmdArgs.push_back("-fcxx-exceptions"); in AddClangCLArgs()
8259 CmdArgs.push_back("-fexceptions"); in AddClangCLArgs()
8261 CmdArgs.push_back("-fasync-exceptions"); in AddClangCLArgs()
8264 CmdArgs.push_back("-fexternc-nounwind"); in AddClangCLArgs()
8266 // /EP should expand to -E -P. in AddClangCLArgs()
8268 CmdArgs.push_back("-E"); in AddClangCLArgs()
8269 CmdArgs.push_back("-P"); in AddClangCLArgs()
8275 CmdArgs.push_back("-fno-dllexport-inlines"); in AddClangCLArgs()
8280 CmdArgs.push_back("-fno-wchar"); in AddClangCLArgs()
8294 D.Diag(diag::err_drv_argument_not_allowed_with) in AddClangCLArgs()
8298 CmdArgs.push_back("-fno-rtti"); in AddClangCLArgs()
8300 D.Diag(diag::err_drv_argument_not_allowed_with) << "/GR" in AddClangCLArgs()
8307 D.Diag(clang::diag::err_drv_argument_not_allowed_with) in AddClangCLArgs()
8308 << MostGeneralArg->getAsString(Args) << BestCaseArg->getAsString(Args); in AddClangCLArgs()
8318 D.Diag(clang::diag::err_drv_argument_not_allowed_with) in AddClangCLArgs()
8319 << FirstConflict->getAsString(Args) in AddClangCLArgs()
8320 << SecondConflict->getAsString(Args); in AddClangCLArgs()
8323 CmdArgs.push_back("-fms-memptr-rep=single"); in AddClangCLArgs()
8325 CmdArgs.push_back("-fms-memptr-rep=multiple"); in AddClangCLArgs()
8327 CmdArgs.push_back("-fms-memptr-rep=virtual"); in AddClangCLArgs()
8331 CmdArgs.push_back("-regcall4"); in AddClangCLArgs()
8338 unsigned DCCOptId = CCArg->getOption().getID(); in AddClangCLArgs()
8344 DCCFlag = "-fdefault-calling-conv=cdecl"; in AddClangCLArgs()
8348 DCCFlag = "-fdefault-calling-conv=fastcall"; in AddClangCLArgs()
8352 DCCFlag = "-fdefault-calling-conv=stdcall"; in AddClangCLArgs()
8356 DCCFlag = "-fdefault-calling-conv=vectorcall"; in AddClangCLArgs()
8360 DCCFlag = "-fdefault-calling-conv=regcall"; in AddClangCLArgs()
8370 CmdArgs.push_back("-regcall4"); in AddClangCLArgs()
8375 CmdArgs.push_back("-fdiagnostics-format"); in AddClangCLArgs()
8380 CmdArgs.push_back("-fms-kernel"); in AddClangCLArgs()
8383 StringRef GuardArgs = A->getValue(); in AddClangCLArgs()
8384 // The only valid options are "cf", "cf,nochecks", "cf-", "ehcont" and in AddClangCLArgs()
8385 // "ehcont-". in AddClangCLArgs()
8387 // Emit CFG instrumentation and the table of address-taken functions. in AddClangCLArgs()
8388 CmdArgs.push_back("-cfguard"); in AddClangCLArgs()
8390 // Emit only the table of address-taken functions. in AddClangCLArgs()
8391 CmdArgs.push_back("-cfguard-no-checks"); in AddClangCLArgs()
8394 CmdArgs.push_back("-ehcontguard"); in AddClangCLArgs()
8395 } else if (GuardArgs.equals_insensitive("cf-") || in AddClangCLArgs()
8396 GuardArgs.equals_insensitive("ehcont-")) { in AddClangCLArgs()
8399 D.Diag(diag::err_drv_invalid_value) << A->getSpelling() << GuardArgs; in AddClangCLArgs()
8401 A->claim(); in AddClangCLArgs()
8425 SmallString<128> OutputFilename(OutputOpt->getValue()); in getDependencyFileName()
8442 CmdArgs.push_back("-target-abi"); in AddMIPSTargetArgs()
8452 StringRef Value = A->getValue(); in AddX86TargetArgs()
8454 CmdArgs.push_back("-mllvm"); in AddX86TargetArgs()
8455 CmdArgs.push_back(Args.MakeArgString("-x86-asm-syntax=" + Value)); in AddX86TargetArgs()
8457 getToolChain().getDriver().Diag(diag::err_drv_unsupported_option_argument) in AddX86TargetArgs()
8458 << A->getSpelling() << Value; in AddX86TargetArgs()
8465 CmdArgs.push_back("-target-abi"); in AddLoongArchTargetArgs()
8476 CmdArgs.push_back("-target-abi"); in AddRISCVTargetArgs()
8481 CmdArgs.push_back("-mllvm"); in AddRISCVTargetArgs()
8482 CmdArgs.push_back("-riscv-add-build-attributes"); in AddRISCVTargetArgs()
8499 // Don't warn about "clang -w -c foo.s" in ConstructJob()
8501 // and "clang -emit-llvm -c foo.s" in ConstructJob()
8506 // Invoke ourselves in -cc1as mode. in ConstructJob()
8509 CmdArgs.push_back("-cc1as"); in ConstructJob()
8512 CmdArgs.push_back("-triple"); in ConstructJob()
8519 CmdArgs.push_back("-filetype"); in ConstructJob()
8523 // -save-temps or preprocessed assembly. in ConstructJob()
8524 CmdArgs.push_back("-main-file-name"); in ConstructJob()
8530 CmdArgs.push_back("-target-cpu"); in ConstructJob()
8537 // Ignore explicit -force_cpusubtype_ALL option. in ConstructJob()
8540 // Pass along any -I options so we get proper .include search paths. in ConstructJob()
8543 // Pass along any --embed-dir or similar options so we get proper embed paths. in ConstructJob()
8547 auto FindSource = [](const Action *S) -> const Action * { in ConstructJob()
8548 while (S->getKind() != Action::InputClass) { in ConstructJob()
8549 assert(!S->getInputs().empty() && "unexpected root action!"); in ConstructJob()
8550 S = S->getInputs()[0]; in ConstructJob()
8556 // Forward -g and handle debug info related flags, assuming we are dealing in ConstructJob()
8561 WantDebug = !A->getOption().matches(options::OPT_g0) && in ConstructJob()
8562 !A->getOption().matches(options::OPT_ggdb0); in ConstructJob()
8564 // If a -gdwarf argument appeared, remember it. in ConstructJob()
8573 // If the user asked for debug info but did not explicitly specify -gcodeview in ConstructJob()
8574 // or -gdwarf, ask the toolchain for the default format. in ConstructJob()
8593 // Add the -fdebug-compilation-dir flag if needed. in ConstructJob()
8597 if (SourceAction->getType() == types::TY_Asm || in ConstructJob()
8598 SourceAction->getType() == types::TY_PP_Asm) { in ConstructJob()
8601 // that some assembler invocation receives no -debug-info-kind, in ConstructJob()
8609 // Set the AT_producer to the clang version when using the integrated in ConstructJob()
8611 CmdArgs.push_back("-dwarf-debug-producer"); in ConstructJob()
8614 // And pass along -I options in ConstructJob()
8623 // Handle -fPIC et al -- the relocation-model affects the assembler in ConstructJob()
8633 CmdArgs.push_back("-mrelocation-model"); in ConstructJob()
8637 // Optionally embed the -cc1as level arguments into the debug info, for build in ConstructJob()
8642 Arg->render(Args, OriginalArgs); in ConstructJob()
8653 CmdArgs.push_back("-dwarf-debug-flags"); in ConstructJob()
8657 // FIXME: Add -static support, once we have it. in ConstructJob()
8684 CmdArgs.push_back("-mllvm"); in ConstructJob()
8685 CmdArgs.push_back("-arm-add-build-attributes"); in ConstructJob()
8693 CmdArgs.push_back("-mllvm"); in ConstructJob()
8694 CmdArgs.push_back("-aarch64-mark-bti-property"); in ConstructJob()
8711 CmdArgs.push_back("-mllvm"); in ConstructJob()
8712 CmdArgs.push_back("-hexagon-add-build-attributes"); in ConstructJob()
8718 // gracefully by -cc1 (warning about unknown warning flags, etc) but -cc1as in ConstructJob()
8733 // Fixup any previous commands that use -object-file-name because when we in ConstructJob()
8740 if (StringRef(JArgs[I]).starts_with("-object-file-name=") && in ConstructJob()
8753 CmdArgs.push_back("-o"); in ConstructJob()
8760 CmdArgs.push_back("-split-dwarf-output"); in ConstructJob()
8789 // The version with only one output is expected to refer to a bundling job. in ConstructJob()
8793 // clang-offload-bundler -type=bc in ConstructJob()
8794 // -targets=host-triple,openmp-triple1,openmp-triple2 in ConstructJob()
8795 // -output=output_file in ConstructJob()
8796 // -input=unbundle_file_host in ConstructJob()
8797 // -input=unbundle_file_tgt1 in ConstructJob()
8798 // -input=unbundle_file_tgt2 in ConstructJob()
8804 Twine("-type=") + types::getTypeTempSuffix(Output.getType()))); in ConstructJob()
8811 Triples += "-targets="; in ConstructJob()
8823 OA->doOnEachDependence([&](Action *A, const ToolChain *TC, const char *) { in ConstructJob()
8825 CurKind = A->getOffloadingDeviceKind(); in ConstructJob()
8830 Triples += '-'; in ConstructJob()
8831 Triples += CurTC->getTriple().normalize(); in ConstructJob()
8833 !StringRef(CurDep->getOffloadingArch()).empty()) { in ConstructJob()
8834 Triples += '-'; in ConstructJob()
8835 Triples += CurDep->getOffloadingArch(); in ConstructJob()
8838 // TODO: Replace parsing of -march flag. Can be done by storing GPUArch in ConstructJob()
8842 // Extract GPUArch from -march argument in TC argument list. in ConstructJob()
8845 auto Arch = ArchStr.starts_with_insensitive("-march="); in ConstructJob()
8848 Triples += "-"; in ConstructJob()
8859 TCArgs.MakeArgString(Twine("-output=") + Output.getFilename())); in ConstructJob()
8864 UB += "-input="; in ConstructJob()
8870 OA->doOnEachDependence([&](Action *, const ToolChain *TC, const char *) { in ConstructJob()
8875 C.getArgs().MakeArgString(CurTC->getInputFilename(Inputs[I]))); in ConstructJob()
8877 UB += CurTC->getInputFilename(Inputs[I]); in ConstructJob()
8893 // The version with multiple outputs is expected to refer to a unbundling job. in ConstructJobMultipleOutputs()
8897 // clang-offload-bundler -type=bc in ConstructJobMultipleOutputs()
8898 // -targets=host-triple,openmp-triple1,openmp-triple2 in ConstructJobMultipleOutputs()
8899 // -input=input_file in ConstructJobMultipleOutputs()
8900 // -output=unbundle_file_host in ConstructJobMultipleOutputs()
8901 // -output=unbundle_file_tgt1 in ConstructJobMultipleOutputs()
8902 // -output=unbundle_file_tgt2 in ConstructJobMultipleOutputs()
8903 // -unbundle in ConstructJobMultipleOutputs()
8912 Twine("-type=") + types::getTypeTempSuffix(Input.getType()))); in ConstructJobMultipleOutputs()
8916 Triples += "-targets="; in ConstructJobMultipleOutputs()
8924 Triples += '-'; in ConstructJobMultipleOutputs()
8925 Triples += Dep.DependentToolChain->getTriple().normalize(); in ConstructJobMultipleOutputs()
8929 Triples += '-'; in ConstructJobMultipleOutputs()
8932 // TODO: Replace parsing of -march flag. Can be done by storing GPUArch in ConstructJobMultipleOutputs()
8936 // Extract GPUArch from -march argument in TC argument list. in ConstructJobMultipleOutputs()
8939 auto Arch = ArchStr.starts_with_insensitive("-march="); in ConstructJobMultipleOutputs()
8942 Triples += "-"; in ConstructJobMultipleOutputs()
8954 TCArgs.MakeArgString(Twine("-input=") + Input.getFilename())); in ConstructJobMultipleOutputs()
8959 UB += "-output="; in ConstructJobMultipleOutputs()
8960 UB += DepInfo[I].DependentToolChain->getInputFilename(Outputs[I]); in ConstructJobMultipleOutputs()
8963 CmdArgs.push_back("-unbundle"); in ConstructJobMultipleOutputs()
8964 CmdArgs.push_back("-allow-missing-bundles"); in ConstructJobMultipleOutputs()
8966 CmdArgs.push_back("-verbose"); in ConstructJobMultipleOutputs()
8984 CmdArgs.push_back("-o"); in ConstructJob()
8990 const ToolChain *TC = OffloadAction->getOffloadingToolChain(); in ConstructJob()
8992 C.getArgsForToolChain(TC, OffloadAction->getOffloadingArch(), in ConstructJob()
8993 OffloadAction->getOffloadingDeviceKind()); in ConstructJob()
8994 StringRef File = C.getArgs().MakeArgString(TC->getInputFilename(Input)); in ConstructJob()
8995 StringRef Arch = OffloadAction->getOffloadingArch() in ConstructJob()
8996 ? OffloadAction->getOffloadingArch() in ConstructJob()
8999 Action::GetOffloadKindName(OffloadAction->getOffloadingDeviceKind()); in ConstructJob()
9003 getTargetFeatures(TC->getDriver(), TC->getTriple(), TCArgs, Features, in ConstructJob()
9006 [](StringRef Arg) { return !Arg.starts_with("-target"); }); in ConstructJob()
9008 if (TC->getTriple().isAMDGPU()) { in ConstructJob()
9015 // TODO: We need to pass in the full target-id and handle it properly in the in ConstructJob()
9019 "triple=" + TC->getTripleString(), in ConstructJob()
9024 if (TC->getDriver().isUsingLTO(/* IsOffload */ true) || in ConstructJob()
9025 TC->getTriple().isAMDGPU()) in ConstructJob()
9029 CmdArgs.push_back(Args.MakeArgString("--image=" + llvm::join(Parts, ","))); in ConstructJob()
9052 if (TC->getTriple().isNVPTX()) { in ConstructJob()
9056 "--cuda-path=" + CudaInstallation.getInstallPath())); in ConstructJob()
9065 if (A->getOption().matches(options::OPT_O4) || in ConstructJob()
9066 A->getOption().matches(options::OPT_Ofast)) in ConstructJob()
9068 else if (A->getOption().matches(options::OPT_O)) { in ConstructJob()
9069 OOpt = A->getValue(); in ConstructJob()
9074 } else if (A->getOption().matches(options::OPT_O0)) in ConstructJob()
9077 CmdArgs.push_back(Args.MakeArgString(Twine("--opt-level=O") + OOpt)); in ConstructJob()
9081 Args.MakeArgString("--host-triple=" + TheTriple.getTriple())); in ConstructJob()
9083 CmdArgs.push_back("--wrapper-verbose"); in ConstructJob()
9086 if (!A->getOption().matches(options::OPT_g0)) in ConstructJob()
9087 CmdArgs.push_back("--device-debug"); in ConstructJob()
9090 // code-object-version=X needs to be passed to clang-linker-wrapper to ensure in ConstructJob()
9093 CmdArgs.push_back(Args.MakeArgString("-mllvm")); in ConstructJob()
9095 Twine("--amdhsa-code-object-version=") + A->getValue())); in ConstructJob()
9099 CmdArgs.push_back(Args.MakeArgString("--ptxas-arg=" + A)); in ConstructJob()
9103 CmdArgs.push_back(Args.MakeArgString(Twine("--offload-opt=-pass-remarks=") + in ConstructJob()
9104 A->getValue())); in ConstructJob()
9107 Twine("--offload-opt=-pass-remarks-missed=") + A->getValue())); in ConstructJob()
9110 Twine("--offload-opt=-pass-remarks-analysis=") + A->getValue())); in ConstructJob()
9112 CmdArgs.push_back("--save-temps"); in ConstructJob()
9115 Linker->ConstructJob(C, JA, Output, Inputs, Args, LinkingOutput); in ConstructJob()
9118 // Forward -Xoffload-linker<-triple> arguments to the device link job. in ConstructJob()
9120 StringRef Val = A->getValue(0); in ConstructJob()
9123 Args.MakeArgString(Twine("--device-linker=") + A->getValue(1))); in ConstructJob()
9126 "--device-linker=" + in ConstructJob()
9128 A->getValue(1))); in ConstructJob()
9135 CmdArgs.push_back("--embed-bitcode"); in ConstructJob()
9137 // Forward `-mllvm` arguments to the LLVM invocations if present. in ConstructJob()
9139 CmdArgs.push_back("-mllvm"); in ConstructJob()
9140 CmdArgs.push_back(A->getValue()); in ConstructJob()
9141 A->claim(); in ConstructJob()
9145 CmdArgs.push_back(Args.MakeArgString(Twine("--linker-path=") + in ConstructJob()
9146 LinkCommand->getExecutable())); in ConstructJob()
9147 for (const char *LinkArg : LinkCommand->getArguments()) in ConstructJob()
9153 Args.MakeArgString(getToolChain().GetProgramPath("clang-linker-wrapper")); in ConstructJob()
9157 LinkCommand->replaceExecutable(Exec); in ConstructJob()
9158 LinkCommand->replaceArguments(CmdArgs); in ConstructJob()