29 #include "clang/Config/config.h" 46 #include "llvm/ADT/APInt.h" 47 #include "llvm/ADT/ArrayRef.h" 48 #include "llvm/ADT/CachedHashString.h" 49 #include "llvm/ADT/Hashing.h" 50 #include "llvm/ADT/None.h" 51 #include "llvm/ADT/Optional.h" 52 #include "llvm/ADT/SmallString.h" 53 #include "llvm/ADT/SmallVector.h" 54 #include "llvm/ADT/StringRef.h" 55 #include "llvm/ADT/StringSwitch.h" 56 #include "llvm/ADT/Triple.h" 57 #include "llvm/ADT/Twine.h" 58 #include "llvm/IR/DebugInfoMetadata.h" 59 #include "llvm/Linker/Linker.h" 60 #include "llvm/MC/MCTargetOptions.h" 61 #include "llvm/Option/Arg.h" 62 #include "llvm/Option/ArgList.h" 63 #include "llvm/Option/OptSpecifier.h" 64 #include "llvm/Option/OptTable.h" 65 #include "llvm/Option/Option.h" 66 #include "llvm/ProfileData/InstrProfReader.h" 67 #include "llvm/Support/CodeGen.h" 68 #include "llvm/Support/Compiler.h" 69 #include "llvm/Support/Error.h" 70 #include "llvm/Support/ErrorHandling.h" 71 #include "llvm/Support/ErrorOr.h" 72 #include "llvm/Support/FileSystem.h" 73 #include "llvm/Support/Host.h" 74 #include "llvm/Support/MathExtras.h" 75 #include "llvm/Support/MemoryBuffer.h" 76 #include "llvm/Support/Path.h" 77 #include "llvm/Support/Process.h" 78 #include "llvm/Support/Regex.h" 79 #include "llvm/Support/VersionTuple.h" 80 #include "llvm/Support/VirtualFileSystem.h" 81 #include "llvm/Support/raw_ostream.h" 82 #include "llvm/Target/TargetOptions.h" 94 using namespace clang;
95 using namespace driver;
96 using namespace options;
126 DefaultOpt = llvm::CodeGenOpt::Default;
128 if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
129 if (A->getOption().matches(options::OPT_O0))
132 if (A->getOption().matches(options::OPT_Ofast))
133 return llvm::CodeGenOpt::Aggressive;
135 assert(A->getOption().matches(options::OPT_O));
137 StringRef S(A->getValue());
138 if (S ==
"s" || S ==
"z" || S.empty())
139 return llvm::CodeGenOpt::Default;
142 return llvm::CodeGenOpt::Less;
151 if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
152 if (A->getOption().matches(options::OPT_O)) {
153 switch (A->getValue()[0]) {
167 OptSpecifier GroupWithValue,
168 std::vector<std::string> &Diagnostics) {
169 for (
auto *A : Args.filtered(Group)) {
170 if (A->getOption().getKind() == Option::FlagClass) {
173 Diagnostics.push_back(A->getOption().getName().drop_front(1));
174 }
else if (A->getOption().matches(GroupWithValue)) {
176 Diagnostics.push_back(A->getOption().getName().drop_front(1).rtrim(
"=-"));
179 for (
const auto *Arg : A->getValues())
180 Diagnostics.emplace_back(Arg);
191 std::vector<std::string> &Funcs) {
193 for (
const auto &Arg : Args) {
194 const Option &O = Arg->getOption();
195 if (O.matches(options::OPT_fno_builtin_)) {
196 const char *FuncName = Arg->getValue();
198 Values.push_back(FuncName);
201 Funcs.insert(Funcs.end(), Values.begin(), Values.end());
207 if (Arg *A = Args.getLastArg(OPT_analyzer_store)) {
208 StringRef Name = A->getValue();
211 .Case(CMDFLAG, NAME##Model)
212 #include "clang/StaticAnalyzer/Core/Analyses.def" 215 Diags.
Report(diag::err_drv_invalid_value)
216 << A->getAsString(Args) << Name;
223 if (Arg *A = Args.getLastArg(OPT_analyzer_constraints)) {
224 StringRef Name = A->getValue();
227 .Case(CMDFLAG, NAME##Model)
228 #include "clang/StaticAnalyzer/Core/Analyses.def" 231 Diags.
Report(diag::err_drv_invalid_value)
232 << A->getAsString(Args) << Name;
239 if (Arg *A = Args.getLastArg(OPT_analyzer_output)) {
240 StringRef Name = A->getValue();
243 .Case(CMDFLAG, PD_##NAME)
244 #include "clang/StaticAnalyzer/Core/Analyses.def" 247 Diags.
Report(diag::err_drv_invalid_value)
248 << A->getAsString(Args) << Name;
255 if (Arg *A = Args.getLastArg(OPT_analyzer_purge)) {
256 StringRef Name = A->getValue();
260 #include "clang/StaticAnalyzer/Core/Analyses.def" 263 Diags.
Report(diag::err_drv_invalid_value)
264 << A->getAsString(Args) << Name;
271 if (Arg *A = Args.getLastArg(OPT_analyzer_inlining_mode)) {
272 StringRef Name = A->getValue();
276 #include "clang/StaticAnalyzer/Core/Analyses.def" 279 Diags.
Report(diag::err_drv_invalid_value)
280 << A->getAsString(Args) << Name;
290 Args.hasArg(OPT_analyzer_checker_help_developer);
294 Args.hasArg(OPT_analyzer_checker_option_help_alpha);
296 Args.hasArg(OPT_analyzer_checker_option_help_developer);
301 !llvm::StringSwitch<bool>(
302 Args.getLastArgValue(OPT_analyzer_config_compatibility_mode))
304 .Case(
"false",
false)
309 Args.hasArg(OPT_analyzer_viz_egraph_graphviz);
313 Opts.
AnalyzeAll = Args.hasArg(OPT_analyzer_opt_analyze_headers);
316 Args.hasArg(OPT_analyzer_opt_analyze_nested_blocks);
319 Opts.
TrimGraph = Args.hasArg(OPT_trim_egraph);
322 Opts.
PrintStats = Args.hasArg(OPT_analyzer_stats);
329 Args.filtered(OPT_analyzer_checker, OPT_analyzer_disable_checker)) {
331 bool IsEnabled = A->getOption().getID() == OPT_analyzer_checker;
334 StringRef CheckerAndPackageList = A->getValue();
336 CheckerAndPackageList.split(CheckersAndPackages,
",");
337 for (
const StringRef &CheckerOrPackage : CheckersAndPackages)
342 for (
const auto *A : Args.filtered(OPT_analyzer_config)) {
346 StringRef configList = A->getValue();
348 configList.split(configVals,
",");
349 for (
const auto &configVal : configVals) {
351 std::tie(key, val) = configVal.split(
"=");
354 diag::err_analyzer_config_no_value) << configVal;
358 if (val.find(
'=') != StringRef::npos) {
360 diag::err_analyzer_config_multiple_values)
370 Diags.
Report(diag::err_analyzer_config_unknown) << key;
385 for (
unsigned i = 0; i < Args.getNumInputArgStrings(); ++i) {
388 os << Args.getArgString(i);
396 StringRef OptionName, StringRef DefaultVal) {
397 return Config.insert({OptionName, DefaultVal}).first->second;
402 StringRef &OptionField, StringRef Name,
403 StringRef DefaultVal) {
412 bool &OptionField, StringRef Name,
bool DefaultVal) {
413 auto PossiblyInvalidVal = llvm::StringSwitch<Optional<bool>>(
416 .Case(
"false",
false)
419 if (!PossiblyInvalidVal) {
421 Diags->
Report(diag::err_analyzer_config_invalid_input)
422 << Name <<
"a boolean";
424 OptionField = DefaultVal;
426 OptionField = PossiblyInvalidVal.getValue();
431 unsigned &OptionField, StringRef Name,
432 unsigned DefaultVal) {
434 OptionField = DefaultVal;
435 bool HasFailed =
getStringOption(Config, Name, std::to_string(DefaultVal))
436 .getAsInteger(0, OptionField);
437 if (Diags && HasFailed)
438 Diags->
Report(diag::err_analyzer_config_invalid_input)
439 << Name <<
"an unsigned";
447 #define ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, DEFAULT_VAL) \ 448 initOption(AnOpts.Config, Diags, AnOpts.NAME, CMDFLAG, DEFAULT_VAL); 450 #define ANALYZER_OPTION_DEPENDS_ON_USER_MODE(TYPE, NAME, CMDFLAG, DESC, \ 451 SHALLOW_VAL, DEEP_VAL) \ 452 switch (AnOpts.getUserMode()) { \ 454 initOption(AnOpts.Config, Diags, AnOpts.NAME, CMDFLAG, SHALLOW_VAL); \ 457 initOption(AnOpts.Config, Diags, AnOpts.NAME, CMDFLAG, DEEP_VAL); \ 461 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.def" 462 #undef ANALYZER_OPTION 463 #undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE 470 if (!AnOpts.RawSilencedCheckersAndPackages.empty()) {
471 std::vector<StringRef> Checkers =
473 std::vector<StringRef> Packages =
477 AnOpts.RawSilencedCheckersAndPackages.split(CheckersAndPackages,
";");
479 for (
const StringRef &CheckerOrPackage : CheckersAndPackages) {
481 bool IsChecker = CheckerOrPackage.contains(
'.');
484 ? llvm::find(Checkers, CheckerOrPackage) != Checkers.end()
485 : llvm::find(Packages, CheckerOrPackage) != Packages.end();
488 Diags->
Report(diag::err_unknown_analyzer_checker_or_package)
499 if (AnOpts.ShouldTrackConditionsDebug && !AnOpts.ShouldTrackConditions)
500 Diags->
Report(diag::err_analyzer_config_invalid_input)
501 <<
"track-conditions-debug" <<
"'track-conditions' to also be enabled";
503 if (!AnOpts.CTUDir.empty() && !llvm::sys::fs::is_directory(AnOpts.CTUDir))
504 Diags->
Report(diag::err_analyzer_config_invalid_input) <<
"ctu-dir" 507 if (!AnOpts.ModelPath.empty() &&
508 !llvm::sys::fs::is_directory(AnOpts.ModelPath))
509 Diags->
Report(diag::err_analyzer_config_invalid_input) <<
"model-path" 525 if (Arg *A = Args.getLastArg(OPT_mcode_model)) {
526 StringRef
Value = A->getValue();
527 if (Value ==
"small" || Value ==
"kernel" || Value ==
"medium" ||
528 Value ==
"large" || Value ==
"tiny")
530 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) <<
Value;
537 if (Arg *A = Args.getLastArg(OPT_mrelocation_model)) {
538 StringRef
Value = A->getValue();
539 auto RM = llvm::StringSwitch<llvm::Optional<llvm::Reloc::Model>>(
Value)
540 .Case(
"static", llvm::Reloc::Static)
541 .Case(
"pic", llvm::Reloc::PIC_)
542 .Case(
"ropi", llvm::Reloc::ROPI)
543 .Case(
"rwpi", llvm::Reloc::RWPI)
544 .Case(
"ropi-rwpi", llvm::Reloc::ROPI_RWPI)
545 .Case(
"dynamic-no-pic", llvm::Reloc::DynamicNoPIC)
549 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) <<
Value;
551 return llvm::Reloc::PIC_;
556 static std::shared_ptr<llvm::Regex>
559 StringRef Val = RpassArg->getValue();
560 std::string RegexError;
561 std::shared_ptr<llvm::Regex> Pattern = std::make_shared<llvm::Regex>(Val);
562 if (!Pattern->isValid(RegexError)) {
563 Diags.
Report(diag::err_drv_optimization_remark_pattern)
564 << RegexError << RpassArg->getAsString(Args);
571 const std::vector<std::string> &Levels,
575 for (
const auto &
Level : Levels) {
577 llvm::StringSwitch<DiagnosticLevelMask>(
Level)
586 Diags->
Report(diag::err_drv_invalid_value) << FlagName <<
Level;
594 const std::vector<std::string> &Sanitizers,
596 for (
const auto &Sanitizer : Sanitizers) {
599 Diags.
Report(diag::err_drv_invalid_value) << FlagName << Sanitizer;
609 llvm::SplitString(Bundle, BundleParts,
",");
610 for (
const auto &B : BundleParts) {
614 D.
Report(diag::err_drv_invalid_value) << FlagName << Bundle;
627 Arg *A = Args.getLastArg(OPT_fprofile_instrument_EQ);
630 StringRef S = A->getValue();
631 unsigned I = llvm::StringSwitch<unsigned>(S)
638 Diags.
Report(diag::err_drv_invalid_pgo_instrumentor) << A->getAsString(Args)
643 Opts.setProfileInstr(Instrumentor);
648 const Twine &ProfileName) {
651 if (
auto E = ReaderOrErr.takeError()) {
652 llvm::consumeError(std::move(E));
656 std::unique_ptr<llvm::IndexedInstrProfReader> PGOReader =
657 std::move(ReaderOrErr.get());
658 if (PGOReader->isIRLevelProfile()) {
659 if (PGOReader->hasCSIRLevelProfile())
672 llvm::Triple Triple = llvm::Triple(TargetOpts.
Triple);
676 unsigned MaxOptLevel = 3;
677 if (OptimizationLevel > MaxOptLevel) {
680 Diags.
Report(diag::warn_drv_optimization_value)
681 << Args.getLastArg(OPT_O)->getAsString(Args) <<
"-O" << MaxOptLevel;
682 OptimizationLevel = MaxOptLevel;
684 Opts.OptimizationLevel = OptimizationLevel;
688 Opts.setInlining((Opts.OptimizationLevel == 0)
693 if (Arg *InlineArg = Args.getLastArg(
694 options::OPT_finline_functions, options::OPT_finline_hint_functions,
695 options::OPT_fno_inline_functions, options::OPT_fno_inline)) {
696 if (Opts.OptimizationLevel > 0) {
697 const Option &InlineOpt = InlineArg->getOption();
698 if (InlineOpt.matches(options::OPT_finline_functions))
699 Opts.setInlining(CodeGenOptions::NormalInlining);
700 else if (InlineOpt.matches(options::OPT_finline_hint_functions))
707 Opts.ExperimentalNewPassManager = Args.hasFlag(
708 OPT_fexperimental_new_pass_manager, OPT_fno_experimental_new_pass_manager,
709 ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER);
711 Opts.DebugPassManager =
712 Args.hasFlag(OPT_fdebug_pass_manager, OPT_fno_debug_pass_manager,
715 if (Arg *A = Args.getLastArg(OPT_fveclib)) {
716 StringRef Name = A->getValue();
717 if (Name ==
"Accelerate")
719 else if (Name ==
"MASSV")
721 else if (Name ==
"SVML")
723 else if (Name ==
"none")
726 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
729 if (Arg *A = Args.getLastArg(OPT_debug_info_kind_EQ)) {
731 llvm::StringSwitch<unsigned>(A->getValue())
739 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args)
742 Opts.setDebugInfo(static_cast<codegenoptions::DebugInfoKind>(Val));
744 if (Arg *A = Args.getLastArg(OPT_debugger_tuning_EQ)) {
745 unsigned Val = llvm::StringSwitch<unsigned>(A->getValue())
746 .Case(
"gdb",
unsigned(llvm::DebuggerKind::GDB))
747 .Case(
"lldb",
unsigned(llvm::DebuggerKind::LLDB))
748 .Case(
"sce",
unsigned(llvm::DebuggerKind::SCE))
751 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args)
754 Opts.setDebuggerTuning(static_cast<llvm::DebuggerKind>(Val));
757 Opts.DebugColumnInfo = Args.hasArg(OPT_dwarf_column_info);
758 Opts.EmitCodeView = Args.hasArg(OPT_gcodeview);
759 Opts.CodeViewGHash = Args.hasArg(OPT_gcodeview_ghash);
760 Opts.MacroDebugInfo = Args.hasArg(OPT_debug_info_macro);
761 Opts.WholeProgramVTables = Args.hasArg(OPT_fwhole_program_vtables);
762 Opts.VirtualFunctionElimination =
763 Args.hasArg(OPT_fvirtual_function_elimination);
764 Opts.LTOVisibilityPublicStd = Args.hasArg(OPT_flto_visibility_public_std);
767 Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining);
768 Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
769 Opts.DebugExplicitImport = Args.hasArg(OPT_dwarf_explicit_import);
770 Opts.DebugFwdTemplateParams = Args.hasArg(OPT_debug_forward_template_params);
771 Opts.EmbedSource = Args.hasArg(OPT_gembed_source);
773 Opts.ForceDwarfFrameSection =
774 Args.hasFlag(OPT_fforce_dwarf_frame, OPT_fno_force_dwarf_frame,
false);
776 for (
const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ))
780 Args.getLastArg(OPT_emit_llvm_uselists, OPT_no_emit_llvm_uselists))
781 Opts.EmitLLVMUseLists = A->getOption().getID() == OPT_emit_llvm_uselists;
783 Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
784 Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
786 const llvm::Triple::ArchType DebugEntryValueArchs[] = {
787 llvm::Triple::x86, llvm::Triple::x86_64, llvm::Triple::aarch64,
788 llvm::Triple::arm, llvm::Triple::armeb};
790 llvm::Triple T(TargetOpts.
Triple);
792 llvm::is_contained(DebugEntryValueArchs, T.getArch()))
793 Opts.EnableDebugEntryValues = Args.hasArg(OPT_femit_debug_entry_values);
795 Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
796 Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
797 Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
798 Opts.ForbidGuardVariables = Args.hasArg(OPT_fforbid_guard_variables);
799 Opts.UseRegisterSizedBitfieldAccess = Args.hasArg(
800 OPT_fuse_register_sized_bitfield_access);
801 Opts.RelaxedAliasing = Args.hasArg(OPT_relaxed_aliasing);
802 Opts.StructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa);
803 Opts.NewStructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa) &&
804 Args.hasArg(OPT_new_struct_path_tbaa);
805 Opts.FineGrainedBitfieldAccesses =
806 Args.hasFlag(OPT_ffine_grained_bitfield_accesses,
807 OPT_fno_fine_grained_bitfield_accesses,
false);
810 Opts.MergeAllConstants = Args.hasArg(OPT_fmerge_all_constants);
811 Opts.NoCommon = Args.hasArg(OPT_fno_common);
812 Opts.NoInlineLineTables = Args.hasArg(OPT_gno_inline_line_tables);
813 Opts.NoImplicitFloat = Args.hasArg(OPT_no_implicit_float);
815 Opts.SimplifyLibCalls = !(Args.hasArg(OPT_fno_builtin) ||
816 Args.hasArg(OPT_ffreestanding));
817 if (Opts.SimplifyLibCalls)
820 Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops,
821 (Opts.OptimizationLevel > 1));
822 Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
824 Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
825 Opts.Autolink = !Args.hasArg(OPT_fno_autolink);
827 Opts.DebugInfoForProfiling = Args.hasFlag(
828 OPT_fdebug_info_for_profiling, OPT_fno_debug_info_for_profiling,
false);
829 Opts.DebugNameTable =
static_cast<unsigned>(
830 Args.hasArg(OPT_ggnu_pubnames)
831 ? llvm::DICompileUnit::DebugNameTableKind::GNU
832 : Args.hasArg(OPT_gpubnames)
833 ? llvm::DICompileUnit::DebugNameTableKind::Default
835 Opts.DebugRangesBaseAddress = Args.hasArg(OPT_fdebug_ranges_base_address);
839 Args.getLastArgValue(OPT_fprofile_instrument_path_EQ);
841 Args.getLastArgValue(OPT_fprofile_instrument_use_path_EQ);
845 Args.getLastArgValue(OPT_fprofile_remapping_file_EQ);
847 Diags.
Report(diag::err_drv_argument_only_allowed_with)
848 << Args.getLastArg(OPT_fprofile_remapping_file_EQ)->getAsString(Args)
849 <<
"-fexperimental-new-pass-manager";
852 Opts.CoverageMapping =
853 Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping,
false);
854 Opts.DumpCoverageMapping = Args.hasArg(OPT_dump_coverage_mapping);
855 Opts.AsmVerbose = Args.hasArg(OPT_masm_verbose);
856 Opts.PreserveAsmComments = !Args.hasArg(OPT_fno_preserve_as_comments);
857 Opts.AssumeSaneOperatorNew = !Args.hasArg(OPT_fno_assume_sane_operator_new);
858 Opts.ObjCAutoRefCountExceptions = Args.hasArg(OPT_fobjc_arc_exceptions);
859 Opts.CXAAtExit = !Args.hasArg(OPT_fno_use_cxa_atexit);
860 Opts.RegisterGlobalDtorsWithAtExit =
861 Args.hasArg(OPT_fregister_global_dtors_with_atexit);
862 Opts.CXXCtorDtorAliases = Args.hasArg(OPT_mconstructor_aliases);
864 Opts.
DebugPass = Args.getLastArgValue(OPT_mdebug_pass);
867 if (Arg *A = Args.getLastArg(OPT_mframe_pointer_EQ)) {
869 StringRef Name = A->getValue();
873 else if (Name ==
"non-leaf")
875 else if (Name ==
"all")
878 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
883 Opts.setFramePointer(FP);
888 if (Args.hasArg(OPT_pg))
891 Opts.DisableFree = Args.hasArg(OPT_disable_free);
892 Opts.DiscardValueNames = Args.hasArg(OPT_discard_value_names);
893 Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
894 Opts.NoEscapingBlockTailCalls =
895 Args.hasArg(OPT_fno_escaping_block_tail_calls);
896 Opts.
FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
897 Opts.LessPreciseFPMAD = Args.hasArg(OPT_cl_mad_enable) ||
898 Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
899 Args.hasArg(OPT_cl_fast_relaxed_math);
901 Opts.NoInfsFPMath = (Args.hasArg(OPT_menable_no_infinities) ||
902 Args.hasArg(OPT_cl_finite_math_only) ||
903 Args.hasArg(OPT_cl_fast_relaxed_math));
904 Opts.NoNaNsFPMath = (Args.hasArg(OPT_menable_no_nans) ||
905 Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
906 Args.hasArg(OPT_cl_finite_math_only) ||
907 Args.hasArg(OPT_cl_fast_relaxed_math));
908 Opts.NoSignedZeros = (Args.hasArg(OPT_fno_signed_zeros) ||
909 Args.hasArg(OPT_cl_no_signed_zeros) ||
910 Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
911 Args.hasArg(OPT_cl_fast_relaxed_math));
912 Opts.Reassociate = Args.hasArg(OPT_mreassociate);
913 Opts.FlushDenorm = Args.hasArg(OPT_cl_denorms_are_zero) ||
914 (Args.hasArg(OPT_fcuda_is_device) &&
915 Args.hasArg(OPT_fcuda_flush_denormals_to_zero));
916 Opts.CorrectlyRoundedDivSqrt =
917 Args.hasArg(OPT_cl_fp32_correctly_rounded_divide_sqrt);
919 Args.hasArg(OPT_cl_uniform_work_group_size);
920 Opts.
Reciprocals = Args.getAllArgValues(OPT_mrecip_EQ);
921 Opts.ReciprocalMath = Args.hasArg(OPT_freciprocal_math);
922 Opts.NoTrappingMath = Args.hasArg(OPT_fno_trapping_math);
923 Opts.StrictFloatCastOverflow =
924 !Args.hasArg(OPT_fno_strict_float_cast_overflow);
926 Opts.NoZeroInitializedInBSS = Args.hasArg(OPT_mno_zero_initialized_in_bss);
928 Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
929 Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
930 Opts.NoWarn = Args.hasArg(OPT_massembler_no_warn);
931 Opts.EnableSegmentedStacks = Args.hasArg(OPT_split_stacks);
932 Opts.RelaxAll = Args.hasArg(OPT_mrelax_all);
933 Opts.IncrementalLinkerCompatible =
934 Args.hasArg(OPT_mincremental_linker_compatible);
935 Opts.PIECopyRelocations =
936 Args.hasArg(OPT_mpie_copy_relocations);
937 Opts.NoPLT = Args.hasArg(OPT_fno_plt);
938 Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels);
939 Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm);
940 Opts.SoftFloat = Args.hasArg(OPT_msoft_float);
941 Opts.StrictEnums = Args.hasArg(OPT_fstrict_enums);
942 Opts.StrictReturn = !Args.hasArg(OPT_fno_strict_return);
943 Opts.StrictVTablePointers = Args.hasArg(OPT_fstrict_vtable_pointers);
944 Opts.ForceEmitVTables = Args.hasArg(OPT_fforce_emit_vtables);
945 Opts.UnsafeFPMath = Args.hasArg(OPT_menable_unsafe_fp_math) ||
946 Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
947 Args.hasArg(OPT_cl_fast_relaxed_math);
948 Opts.UnwindTables = Args.hasArg(OPT_munwind_tables);
950 Opts.
ThreadModel = Args.getLastArgValue(OPT_mthread_model,
"posix");
952 Diags.
Report(diag::err_drv_invalid_value)
953 << Args.getLastArg(OPT_mthread_model)->getAsString(Args)
955 Opts.
TrapFuncName = Args.getLastArgValue(OPT_ftrap_function_EQ);
956 Opts.UseInitArray = !Args.hasArg(OPT_fno_use_init_array);
958 Opts.FunctionSections = Args.hasFlag(OPT_ffunction_sections,
959 OPT_fno_function_sections,
false);
960 Opts.DataSections = Args.hasFlag(OPT_fdata_sections,
961 OPT_fno_data_sections,
false);
962 Opts.StackSizeSection =
963 Args.hasFlag(OPT_fstack_size_section, OPT_fno_stack_size_section,
false);
964 Opts.UniqueSectionNames = Args.hasFlag(OPT_funique_section_names,
965 OPT_fno_unique_section_names,
true);
967 Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions);
969 Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
971 Opts.NullPointerIsValid = Args.hasArg(OPT_fno_delete_null_pointer_checks);
973 Opts.ProfileSampleAccurate = Args.hasArg(OPT_fprofile_sample_accurate);
975 Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
976 Opts.PrepareForThinLTO =
false;
977 if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
978 StringRef S = A->getValue();
980 Opts.PrepareForThinLTO =
true;
981 else if (S !=
"full")
982 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << S;
984 Opts.LTOUnit = Args.hasFlag(OPT_flto_unit, OPT_fno_lto_unit,
false);
985 Opts.EnableSplitLTOUnit = Args.hasArg(OPT_fsplit_lto_unit);
986 if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) {
988 Diags.
Report(diag::err_drv_argument_only_allowed_with)
989 << A->getAsString(Args) <<
"-x ir";
992 if (Arg *A = Args.getLastArg(OPT_save_temps_EQ))
994 llvm::StringSwitch<std::string>(A->getValue())
996 .Default(llvm::sys::path::filename(FrontendOpts.
OutputFile).str());
1000 Opts.MSVolatile = Args.hasArg(OPT_fms_volatile);
1002 Opts.VectorizeLoop = Args.hasArg(OPT_vectorize_loops);
1003 Opts.VectorizeSLP = Args.hasArg(OPT_vectorize_slp);
1007 Opts.
MainFileName = Args.getLastArgValue(OPT_main_file_name);
1008 Opts.VerifyModule = !Args.hasArg(OPT_disable_llvm_verifier);
1010 Opts.ControlFlowGuardNoChecks = Args.hasArg(OPT_cfguard_no_checks);
1011 Opts.ControlFlowGuard = Args.hasArg(OPT_cfguard);
1013 Opts.DisableGCov = Args.hasArg(OPT_test_coverage);
1014 Opts.EmitGcovArcs = Args.hasArg(OPT_femit_coverage_data);
1015 Opts.EmitGcovNotes = Args.hasArg(OPT_femit_coverage_notes);
1016 if (Opts.EmitGcovArcs || Opts.EmitGcovNotes) {
1019 Opts.CoverageExtraChecksum = Args.hasArg(OPT_coverage_cfg_checksum);
1020 Opts.CoverageNoFunctionNamesInData =
1021 Args.hasArg(OPT_coverage_no_function_names_in_data);
1023 Args.getLastArgValue(OPT_fprofile_filter_files_EQ);
1025 Args.getLastArgValue(OPT_fprofile_exclude_files_EQ);
1026 Opts.CoverageExitBlockBeforeBody =
1027 Args.hasArg(OPT_coverage_exit_block_before_body);
1028 if (Args.hasArg(OPT_coverage_version_EQ)) {
1029 StringRef CoverageVersion = Args.getLastArgValue(OPT_coverage_version_EQ);
1030 if (CoverageVersion.size() != 4) {
1031 Diags.
Report(diag::err_drv_invalid_value)
1032 << Args.getLastArg(OPT_coverage_version_EQ)->getAsString(Args)
1040 if (Arg *A = Args.getLastArg(OPT_fembed_bitcode_EQ)) {
1041 StringRef Name = A->getValue();
1042 unsigned Model = llvm::StringSwitch<unsigned>(Name)
1049 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
1052 Opts.setEmbedBitcode(
1053 static_cast<CodeGenOptions::EmbedBitcodeKind>(Model));
1059 for (
const auto &A : Args) {
1061 if (A->getOption().getID() == options::OPT_o ||
1062 A->getOption().getID() == options::OPT_INPUT ||
1063 A->getOption().getID() == options::OPT_x ||
1064 A->getOption().getID() == options::OPT_fembed_bitcode ||
1065 (A->getOption().getGroup().isValid() &&
1066 A->getOption().getGroup().getID() == options::OPT_W_Group))
1069 A->render(Args, ASL);
1070 for (
const auto &arg : ASL) {
1071 StringRef ArgStr(arg);
1072 Opts.
CmdArgs.insert(Opts.
CmdArgs.end(), ArgStr.begin(), ArgStr.end());
1079 Opts.PreserveVec3Type = Args.hasArg(OPT_fpreserve_vec3_type);
1080 Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
1081 Opts.InstrumentFunctionsAfterInlining =
1082 Args.hasArg(OPT_finstrument_functions_after_inlining);
1083 Opts.InstrumentFunctionEntryBare =
1084 Args.hasArg(OPT_finstrument_function_entry_bare);
1086 Opts.XRayInstrumentFunctions =
1087 Args.hasArg(OPT_fxray_instrument);
1088 Opts.XRayAlwaysEmitCustomEvents =
1089 Args.hasArg(OPT_fxray_always_emit_customevents);
1090 Opts.XRayAlwaysEmitTypedEvents =
1091 Args.hasArg(OPT_fxray_always_emit_typedevents);
1092 Opts.XRayInstructionThreshold =
1095 auto XRayInstrBundles =
1096 Args.getAllArgValues(OPT_fxray_instrumentation_bundle);
1097 if (XRayInstrBundles.empty())
1100 for (
const auto &A : XRayInstrBundles)
1104 Opts.PatchableFunctionEntryCount =
1107 Args, OPT_fpatchable_function_entry_offset_EQ, 0, Diags);
1108 Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
1109 Opts.CallFEntry = Args.hasArg(OPT_mfentry);
1110 Opts.MNopMCount = Args.hasArg(OPT_mnop_mcount);
1111 Opts.RecordMCount = Args.hasArg(OPT_mrecord_mcount);
1112 Opts.PackedStack = Args.hasArg(OPT_mpacked_stack);
1113 Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
1115 if (
const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
1116 StringRef Name = A->getValue();
1117 if (Name ==
"full") {
1118 Opts.CFProtectionReturn = 1;
1119 Opts.CFProtectionBranch = 1;
1120 }
else if (Name ==
"return")
1121 Opts.CFProtectionReturn = 1;
1122 else if (Name ==
"branch")
1123 Opts.CFProtectionBranch = 1;
1124 else if (Name !=
"none") {
1125 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
1130 if (
const Arg *A = Args.getLastArg(OPT_compress_debug_sections,
1131 OPT_compress_debug_sections_EQ)) {
1132 if (A->getOption().getID() == OPT_compress_debug_sections) {
1134 Opts.setCompressDebugSections(llvm::DebugCompressionType::GNU);
1136 auto DCT = llvm::StringSwitch<llvm::DebugCompressionType>(A->getValue())
1138 .Case(
"zlib", llvm::DebugCompressionType::Z)
1139 .Case(
"zlib-gnu", llvm::DebugCompressionType::GNU)
1141 Opts.setCompressDebugSections(DCT);
1145 Opts.RelaxELFRelocations = Args.hasArg(OPT_mrelax_relocations);
1148 Args.filtered(OPT_mlink_bitcode_file, OPT_mlink_builtin_bitcode)) {
1151 if (A->getOption().matches(OPT_mlink_builtin_bitcode)) {
1152 F.
LinkFlags = llvm::Linker::Flags::LinkOnlyNeeded;
1160 Opts.SanitizeCoverageType =
1162 Opts.SanitizeCoverageIndirectCalls =
1163 Args.hasArg(OPT_fsanitize_coverage_indirect_calls);
1164 Opts.SanitizeCoverageTraceBB = Args.hasArg(OPT_fsanitize_coverage_trace_bb);
1165 Opts.SanitizeCoverageTraceCmp = Args.hasArg(OPT_fsanitize_coverage_trace_cmp);
1166 Opts.SanitizeCoverageTraceDiv = Args.hasArg(OPT_fsanitize_coverage_trace_div);
1167 Opts.SanitizeCoverageTraceGep = Args.hasArg(OPT_fsanitize_coverage_trace_gep);
1168 Opts.SanitizeCoverage8bitCounters =
1169 Args.hasArg(OPT_fsanitize_coverage_8bit_counters);
1170 Opts.SanitizeCoverageTracePC = Args.hasArg(OPT_fsanitize_coverage_trace_pc);
1171 Opts.SanitizeCoverageTracePCGuard =
1172 Args.hasArg(OPT_fsanitize_coverage_trace_pc_guard);
1173 Opts.SanitizeCoverageNoPrune = Args.hasArg(OPT_fsanitize_coverage_no_prune);
1174 Opts.SanitizeCoverageInline8bitCounters =
1175 Args.hasArg(OPT_fsanitize_coverage_inline_8bit_counters);
1176 Opts.SanitizeCoveragePCTable = Args.hasArg(OPT_fsanitize_coverage_pc_table);
1177 Opts.SanitizeCoverageStackDepth =
1178 Args.hasArg(OPT_fsanitize_coverage_stack_depth);
1179 Opts.SanitizeMemoryTrackOrigins =
1181 Opts.SanitizeMemoryUseAfterDtor =
1182 Args.hasFlag(OPT_fsanitize_memory_use_after_dtor,
1183 OPT_fno_sanitize_memory_use_after_dtor,
1185 Opts.SanitizeMinimalRuntime = Args.hasArg(OPT_fsanitize_minimal_runtime);
1186 Opts.SanitizeCfiCrossDso = Args.hasArg(OPT_fsanitize_cfi_cross_dso);
1187 Opts.SanitizeCfiICallGeneralizePointers =
1188 Args.hasArg(OPT_fsanitize_cfi_icall_generalize_pointers);
1189 Opts.SanitizeCfiCanonicalJumpTables =
1190 Args.hasArg(OPT_fsanitize_cfi_canonical_jump_tables);
1191 Opts.SanitizeStats = Args.hasArg(OPT_fsanitize_stats);
1192 if (Arg *A = Args.getLastArg(
1193 OPT_fsanitize_address_poison_custom_array_cookie,
1194 OPT_fno_sanitize_address_poison_custom_array_cookie)) {
1195 Opts.SanitizeAddressPoisonCustomArrayCookie =
1196 A->getOption().getID() ==
1197 OPT_fsanitize_address_poison_custom_array_cookie;
1199 if (Arg *A = Args.getLastArg(OPT_fsanitize_address_use_after_scope,
1200 OPT_fno_sanitize_address_use_after_scope)) {
1201 Opts.SanitizeAddressUseAfterScope =
1202 A->getOption().getID() == OPT_fsanitize_address_use_after_scope;
1204 Opts.SanitizeAddressGlobalsDeadStripping =
1205 Args.hasArg(OPT_fsanitize_address_globals_dead_stripping);
1206 if (Arg *A = Args.getLastArg(OPT_fsanitize_address_use_odr_indicator,
1207 OPT_fno_sanitize_address_use_odr_indicator)) {
1208 Opts.SanitizeAddressUseOdrIndicator =
1209 A->getOption().getID() == OPT_fsanitize_address_use_odr_indicator;
1211 Opts.SSPBufferSize =
1213 Opts.StackRealignment = Args.hasArg(OPT_mstackrealign);
1214 if (Arg *A = Args.getLastArg(OPT_mstack_alignment)) {
1215 StringRef Val = A->getValue();
1216 unsigned StackAlignment = Opts.StackAlignment;
1217 Val.getAsInteger(10, StackAlignment);
1218 Opts.StackAlignment = StackAlignment;
1221 if (Arg *A = Args.getLastArg(OPT_mstack_probe_size)) {
1222 StringRef Val = A->getValue();
1223 unsigned StackProbeSize = Opts.StackProbeSize;
1224 Val.getAsInteger(0, StackProbeSize);
1225 Opts.StackProbeSize = StackProbeSize;
1228 Opts.NoStackArgProbe = Args.hasArg(OPT_mno_stack_arg_probe);
1230 if (Arg *A = Args.getLastArg(OPT_fobjc_dispatch_method_EQ)) {
1231 StringRef Name = A->getValue();
1232 unsigned Method = llvm::StringSwitch<unsigned>(Name)
1237 if (Method == ~0U) {
1238 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
1241 Opts.setObjCDispatchMethod(
1242 static_cast<CodeGenOptions::ObjCDispatchMethodKind>(Method));
1247 if (Args.hasArg(OPT_fno_objc_convert_messages_to_runtime_calls))
1248 Opts.ObjCConvertMessagesToRuntimeCalls = 0;
1250 if (Args.getLastArg(OPT_femulated_tls) ||
1251 Args.getLastArg(OPT_fno_emulated_tls)) {
1252 Opts.ExplicitEmulatedTLS =
true;
1254 Args.hasFlag(OPT_femulated_tls, OPT_fno_emulated_tls,
false);
1257 if (Arg *A = Args.getLastArg(OPT_ftlsmodel_EQ)) {
1258 StringRef Name = A->getValue();
1259 unsigned Model = llvm::StringSwitch<unsigned>(Name)
1266 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
1269 Opts.setDefaultTLSModel(static_cast<CodeGenOptions::TLSModel>(Model));
1275 if (Arg *A = Args.getLastArg(OPT_fdenormal_fp_math_EQ)) {
1276 StringRef Val = A->getValue();
1279 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
1282 if (Arg *A = Args.getLastArg(OPT_fpcc_struct_return, OPT_freg_struct_return)) {
1283 if (A->getOption().matches(OPT_fpcc_struct_return)) {
1286 assert(A->getOption().matches(OPT_freg_struct_return));
1292 Opts.
LinkerOptions = Args.getAllArgValues(OPT_linker_option);
1293 bool NeedLocTracking =
false;
1295 Opts.
OptRecordFile = Args.getLastArgValue(OPT_opt_record_file);
1297 NeedLocTracking =
true;
1299 if (Arg *A = Args.getLastArg(OPT_opt_record_passes)) {
1301 NeedLocTracking =
true;
1304 if (Arg *A = Args.getLastArg(OPT_opt_record_format)) {
1306 NeedLocTracking =
true;
1309 if (Arg *A = Args.getLastArg(OPT_Rpass_EQ)) {
1312 NeedLocTracking =
true;
1315 if (Arg *A = Args.getLastArg(OPT_Rpass_missed_EQ)) {
1318 NeedLocTracking =
true;
1321 if (Arg *A = Args.getLastArg(OPT_Rpass_analysis_EQ)) {
1324 NeedLocTracking =
true;
1327 Opts.DiagnosticsWithHotness =
1328 Args.hasArg(options::OPT_fdiagnostics_show_hotness);
1330 bool UsingProfile = UsingSampleProfile ||
1333 if (Opts.DiagnosticsWithHotness && !UsingProfile &&
1336 Diags.
Report(diag::warn_drv_diagnostics_hotness_requires_pgo)
1337 <<
"-fdiagnostics-show-hotness";
1340 Args, options::OPT_fdiagnostics_hotness_threshold_EQ, 0);
1341 if (Opts.DiagnosticsHotnessThreshold > 0 && !UsingProfile)
1342 Diags.
Report(diag::warn_drv_diagnostics_hotness_requires_pgo)
1343 <<
"-fdiagnostics-hotness-threshold=";
1348 if (UsingSampleProfile)
1349 NeedLocTracking =
true;
1361 Args.getAllArgValues(OPT_fsanitize_recover_EQ), Diags,
1364 Args.getAllArgValues(OPT_fsanitize_trap_EQ), Diags,
1368 Args.getLastArgValue(OPT_fcuda_include_gpubinary);
1370 Opts.Backchain = Args.hasArg(OPT_mbackchain);
1373 Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags);
1375 Opts.EmitVersionIdentMetadata = Args.hasFlag(OPT_Qy, OPT_Qn,
true);
1377 Opts.Addrsig = Args.hasArg(OPT_faddrsig);
1379 if (Arg *A = Args.getLastArg(OPT_msign_return_address_EQ)) {
1380 StringRef SignScope = A->getValue();
1382 if (SignScope.equals_lower(
"none"))
1384 else if (SignScope.equals_lower(
"all"))
1386 else if (SignScope.equals_lower(
"non-leaf"))
1387 Opts.setSignReturnAddress(
1390 Diags.
Report(diag::err_drv_invalid_value)
1391 << A->getAsString(Args) << SignScope;
1393 if (Arg *A = Args.getLastArg(OPT_msign_return_address_key_EQ)) {
1394 StringRef SignKey = A->getValue();
1395 if (!SignScope.empty() && !SignKey.empty()) {
1396 if (SignKey.equals_lower(
"a_key"))
1397 Opts.setSignReturnAddressKey(
1399 else if (SignKey.equals_lower(
"b_key"))
1400 Opts.setSignReturnAddressKey(
1403 Diags.
Report(diag::err_drv_invalid_value)
1404 << A->getAsString(Args) << SignKey;
1409 Opts.BranchTargetEnforcement = Args.hasArg(OPT_mbranch_target_enforce);
1411 Opts.KeepStaticConsts = Args.hasArg(OPT_fkeep_static_consts);
1413 Opts.SpeculativeLoadHardening = Args.hasArg(OPT_mspeculative_load_hardening);
1417 Opts.
PassPlugins = Args.getAllArgValues(OPT_fpass_plugin_EQ);
1419 Opts.
SymbolPartition = Args.getLastArgValue(OPT_fsymbol_partition_EQ);
1426 Opts.
OutputFile = Args.getLastArgValue(OPT_dependency_file);
1427 Opts.
Targets = Args.getAllArgValues(OPT_MT);
1434 if (Args.hasArg(OPT_show_includes)) {
1438 if (Args.hasArg(options::OPT_E) || Args.hasArg(options::OPT_P))
1445 Opts.
DOTOutputFile = Args.getLastArgValue(OPT_dependency_dot);
1447 Args.getLastArgValue(OPT_module_dependency_dir);
1448 if (Args.hasArg(OPT_MV))
1453 if (!Args.hasArg(OPT_fno_sanitize_blacklist)) {
1454 for (
const auto *A : Args.filtered(OPT_fsanitize_blacklist)) {
1455 StringRef Val = A->getValue();
1456 if (Val.find(
'=') == StringRef::npos)
1460 for (
const auto *A : Args.filtered(OPT_fsanitize_system_blacklist)) {
1461 StringRef Val = A->getValue();
1462 if (Val.find(
'=') == StringRef::npos)
1469 for (
const auto *A : Args.filtered(OPT_fdepfile_entry)) {
1470 Opts.
ExtraDeps.push_back(A->getValue());
1474 for (
const auto *A : Args.filtered(OPT_fmodule_file)) {
1475 StringRef Val = A->getValue();
1476 if (Val.find(
'=') == StringRef::npos)
1490 } ShowColors = DefaultColor ? Colors_Auto : Colors_Off;
1491 for (
auto *A : Args) {
1492 const Option &O = A->getOption();
1493 if (O.matches(options::OPT_fcolor_diagnostics) ||
1494 O.matches(options::OPT_fdiagnostics_color)) {
1495 ShowColors = Colors_On;
1496 }
else if (O.matches(options::OPT_fno_color_diagnostics) ||
1497 O.matches(options::OPT_fno_diagnostics_color)) {
1498 ShowColors = Colors_Off;
1499 }
else if (O.matches(options::OPT_fdiagnostics_color_EQ)) {
1500 StringRef
Value(A->getValue());
1501 if (
Value ==
"always")
1502 ShowColors = Colors_On;
1503 else if (
Value ==
"never")
1504 ShowColors = Colors_Off;
1505 else if (
Value ==
"auto")
1506 ShowColors = Colors_Auto;
1509 return ShowColors == Colors_On ||
1510 (ShowColors == Colors_Auto &&
1511 llvm::sys::Process::StandardErrHasColors());
1516 bool Success =
true;
1517 for (
const auto &Prefix : VerifyPrefixes) {
1520 auto BadChar = llvm::find_if(Prefix, [](
char C) {
1523 if (BadChar != Prefix.end() || !
isLetter(Prefix[0])) {
1526 Diags->
Report(diag::err_drv_invalid_value) <<
"-verify=" << Prefix;
1527 Diags->
Report(diag::note_drv_verify_prefix_spelling);
1536 bool DefaultDiagColor,
bool DefaultShowOpt) {
1537 bool Success =
true;
1541 Args.getLastArg(OPT_diagnostic_serialized_file, OPT__serialize_diags))
1543 Opts.IgnoreWarnings = Args.hasArg(OPT_w);
1544 Opts.NoRewriteMacros = Args.hasArg(OPT_Wno_rewrite_macros);
1545 Opts.Pedantic = Args.hasArg(OPT_pedantic);
1546 Opts.PedanticErrors = Args.hasArg(OPT_pedantic_errors);
1547 Opts.ShowCarets = !Args.hasArg(OPT_fno_caret_diagnostics);
1549 Opts.ShowColumn = Args.hasFlag(OPT_fshow_column,
1550 OPT_fno_show_column,
1552 Opts.ShowFixits = !Args.hasArg(OPT_fno_diagnostics_fixit_info);
1553 Opts.ShowLocation = !Args.hasArg(OPT_fno_show_source_location);
1554 Opts.AbsolutePath = Args.hasArg(OPT_fdiagnostics_absolute_paths);
1555 Opts.ShowOptionNames =
1556 Args.hasFlag(OPT_fdiagnostics_show_option,
1557 OPT_fno_diagnostics_show_option, DefaultShowOpt);
1559 llvm::sys::Process::UseANSIEscapeCodes(Args.hasArg(OPT_fansi_escape_codes));
1562 Opts.ShowNoteIncludeStack =
false;
1563 if (Arg *A = Args.getLastArg(OPT_fdiagnostics_show_note_include_stack,
1564 OPT_fno_diagnostics_show_note_include_stack))
1565 if (A->getOption().matches(OPT_fdiagnostics_show_note_include_stack))
1566 Opts.ShowNoteIncludeStack =
true;
1568 StringRef ShowOverloads =
1569 Args.getLastArgValue(OPT_fshow_overloads_EQ,
"all");
1570 if (ShowOverloads ==
"best")
1572 else if (ShowOverloads ==
"all")
1573 Opts.setShowOverloads(
Ovl_All);
1577 Diags->
Report(diag::err_drv_invalid_value)
1578 << Args.getLastArg(OPT_fshow_overloads_EQ)->getAsString(Args)
1582 StringRef ShowCategory =
1583 Args.getLastArgValue(OPT_fdiagnostics_show_category,
"none");
1584 if (ShowCategory ==
"none")
1585 Opts.ShowCategories = 0;
1586 else if (ShowCategory ==
"id")
1587 Opts.ShowCategories = 1;
1588 else if (ShowCategory ==
"name")
1589 Opts.ShowCategories = 2;
1593 Diags->
Report(diag::err_drv_invalid_value)
1594 << Args.getLastArg(OPT_fdiagnostics_show_category)->getAsString(Args)
1599 Args.getLastArgValue(OPT_fdiagnostics_format,
"clang");
1600 if (Format ==
"clang")
1602 else if (Format ==
"msvc")
1604 else if (Format ==
"msvc-fallback") {
1606 Opts.CLFallbackMode =
true;
1607 }
else if (Format ==
"vi")
1612 Diags->
Report(diag::err_drv_invalid_value)
1613 << Args.getLastArg(OPT_fdiagnostics_format)->getAsString(Args)
1617 Opts.ShowSourceRanges = Args.hasArg(OPT_fdiagnostics_print_source_range_info);
1618 Opts.ShowParseableFixits = Args.hasArg(OPT_fdiagnostics_parseable_fixits);
1619 Opts.ShowPresumedLoc = !Args.hasArg(OPT_fno_diagnostics_use_presumed_location);
1620 Opts.VerifyDiagnostics = Args.hasArg(OPT_verify) || Args.hasArg(OPT_verify_EQ);
1622 if (Args.hasArg(OPT_verify))
1627 Opts.VerifyDiagnostics =
false;
1634 Args.getAllArgValues(OPT_verify_ignore_unexpected_EQ),
1636 if (Args.hasArg(OPT_verify_ignore_unexpected))
1638 Opts.setVerifyIgnoreUnexpected(DiagMask);
1639 Opts.ElideType = !Args.hasArg(OPT_fno_elide_type);
1640 Opts.ShowTemplateTree = Args.hasArg(OPT_fdiagnostics_show_template_tree);
1642 Opts.MacroBacktraceLimit =
1646 Args, OPT_ftemplate_backtrace_limit,
1649 Args, OPT_fconstexpr_backtrace_limit,
1652 Args, OPT_fspell_checking_limit,
1655 Args, OPT_fcaret_diagnostics_max_lines,
1662 Diags->
Report(diag::warn_ignoring_ftabstop_value)
1673 Opts.
WorkingDir = Args.getLastArgValue(OPT_working_directory);
1681 std::string &BlockName,
1682 unsigned &MajorVersion,
1683 unsigned &MinorVersion,
1685 std::string &UserInfo) {
1687 Arg.split(Args,
':', 5);
1688 if (Args.size() < 5)
1691 BlockName = Args[0];
1692 if (Args[1].getAsInteger(10, MajorVersion))
return true;
1693 if (Args[2].getAsInteger(10, MinorVersion))
return true;
1694 if (Args[3].getAsInteger(2, Hashed))
return true;
1695 if (Args.size() > 4)
1704 if (
const Arg *A = Args.getLastArg(OPT_Action_Group)) {
1705 switch (A->getOption().getID()) {
1707 llvm_unreachable(
"Invalid option in group!");
1710 case OPT_ast_dump_all_EQ:
1711 case OPT_ast_dump_EQ: {
1712 unsigned Val = llvm::StringSwitch<unsigned>(A->getValue())
1720 Diags.
Report(diag::err_drv_invalid_value)
1721 << A->getAsString(Args) << A->getValue();
1727 case OPT_ast_dump_all:
1728 case OPT_ast_dump_lookups:
1734 case OPT_compiler_options_dump:
1736 case OPT_dump_raw_tokens:
1738 case OPT_dump_tokens:
1742 case OPT_emit_llvm_bc:
1748 case OPT_emit_llvm_only:
1750 case OPT_emit_codegen_only:
1759 case OPT_emit_module:
1761 case OPT_emit_module_interface:
1763 case OPT_emit_header_module:
1767 case OPT_emit_interface_stubs: {
1769 Args.hasArg(OPT_interface_stub_version_EQ)
1770 ? Args.getLastArgValue(OPT_interface_stub_version_EQ)
1771 :
"experimental-ifs-v1";
1772 if (ArgStr ==
"experimental-yaml-elf-v1" ||
1773 ArgStr ==
"experimental-tapi-elf-v1") {
1774 std::string ErrorMessage =
1775 "Invalid interface stub format: " + ArgStr.str() +
1777 Diags.
Report(diag::err_drv_invalid_value)
1778 <<
"Must specify a valid interface stub format type, ie: " 1779 "-interface-stub-version=experimental-ifs-v1" 1781 }
else if (ArgStr !=
"experimental-ifs-v1") {
1782 std::string ErrorMessage =
1783 "Invalid interface stub format: " + ArgStr.str() +
".";
1784 Diags.
Report(diag::err_drv_invalid_value)
1785 <<
"Must specify a valid interface stub format type, ie: " 1786 "-interface-stub-version=experimental-ifs-v1" 1795 case OPT_fsyntax_only:
1797 case OPT_module_file_info:
1799 case OPT_verify_pch:
1801 case OPT_print_preamble:
1805 case OPT_templight_dump:
1807 case OPT_rewrite_macros:
1809 case OPT_rewrite_objc:
1811 case OPT_rewrite_test:
1819 case OPT_print_dependency_directives_minimized_source:
1826 if (
const Arg* A = Args.getLastArg(OPT_plugin)) {
1827 Opts.
Plugins.emplace_back(A->getValue(0));
1832 for (
const auto *AA : Args.filtered(OPT_plugin_arg))
1833 Opts.
PluginArgs[AA->getValue(0)].emplace_back(AA->getValue(1));
1835 for (
const std::string &Arg :
1836 Args.getAllArgValues(OPT_ftest_module_file_extension_EQ)) {
1837 std::string BlockName;
1838 unsigned MajorVersion;
1839 unsigned MinorVersion;
1841 std::string UserInfo;
1843 MinorVersion, Hashed, UserInfo)) {
1844 Diags.
Report(diag::err_test_module_file_extension_format) << Arg;
1851 std::make_shared<TestModuleFileExtension>(
1852 BlockName, MajorVersion, MinorVersion, Hashed, UserInfo));
1855 if (
const Arg *A = Args.getLastArg(OPT_code_completion_at)) {
1859 Diags.
Report(diag::err_drv_invalid_value)
1860 << A->getAsString(Args) << A->getValue();
1864 Opts.
OutputFile = Args.getLastArgValue(OPT_o);
1865 Opts.
Plugins = Args.getAllArgValues(OPT_load);
1867 Opts.
ShowHelp = Args.hasArg(OPT_help);
1868 Opts.
ShowStats = Args.hasArg(OPT_print_stats);
1869 Opts.
ShowTimers = Args.hasArg(OPT_ftime_report);
1871 Opts.
TimeTrace = Args.hasArg(OPT_ftime_trace);
1876 Opts.
LLVMArgs = Args.getAllArgValues(OPT_mllvm);
1881 Opts.
ASTDumpDecls = Args.hasArg(OPT_ast_dump, OPT_ast_dump_EQ);
1882 Opts.
ASTDumpAll = Args.hasArg(OPT_ast_dump_all, OPT_ast_dump_all_EQ);
1883 Opts.
ASTDumpFilter = Args.getLastArgValue(OPT_ast_dump_filter);
1887 Opts.
ModuleMapFiles = Args.getAllArgValues(OPT_fmodule_map_file);
1889 for (
const auto *A : Args.filtered(OPT_fmodule_file)) {
1890 StringRef Val = A->getValue();
1891 if (Val.find(
'=') == StringRef::npos)
1900 = Args.hasArg(OPT_code_completion_macros);
1902 = Args.hasArg(OPT_code_completion_patterns);
1904 = !Args.hasArg(OPT_no_code_completion_globals);
1906 = !Args.hasArg(OPT_no_code_completion_ns_level_decls);
1908 = Args.hasArg(OPT_code_completion_brief_comments);
1910 = Args.hasArg(OPT_code_completion_with_fixits);
1913 = Args.getLastArgValue(OPT_foverride_record_layout_EQ);
1914 Opts.
AuxTriple = Args.getLastArgValue(OPT_aux_triple);
1915 Opts.
StatsFile = Args.getLastArgValue(OPT_stats_file);
1917 if (
const Arg *A = Args.getLastArg(OPT_arcmt_check,
1919 OPT_arcmt_migrate)) {
1920 switch (A->getOption().getID()) {
1922 llvm_unreachable(
"missed a case");
1923 case OPT_arcmt_check:
1926 case OPT_arcmt_modify:
1929 case OPT_arcmt_migrate:
1934 Opts.
MTMigrateDir = Args.getLastArgValue(OPT_mt_migrate_directory);
1936 = Args.getLastArgValue(OPT_arcmt_migrate_report_output);
1938 = Args.hasArg(OPT_arcmt_migrate_emit_arc_errors);
1940 if (Args.hasArg(OPT_objcmt_migrate_literals))
1942 if (Args.hasArg(OPT_objcmt_migrate_subscripting))
1944 if (Args.hasArg(OPT_objcmt_migrate_property_dot_syntax))
1946 if (Args.hasArg(OPT_objcmt_migrate_property))
1948 if (Args.hasArg(OPT_objcmt_migrate_readonly_property))
1950 if (Args.hasArg(OPT_objcmt_migrate_readwrite_property))
1952 if (Args.hasArg(OPT_objcmt_migrate_annotation))
1954 if (Args.hasArg(OPT_objcmt_returns_innerpointer_property))
1956 if (Args.hasArg(OPT_objcmt_migrate_instancetype))
1958 if (Args.hasArg(OPT_objcmt_migrate_nsmacros))
1960 if (Args.hasArg(OPT_objcmt_migrate_protocol_conformance))
1962 if (Args.hasArg(OPT_objcmt_atomic_property))
1964 if (Args.hasArg(OPT_objcmt_ns_nonatomic_iosonly))
1966 if (Args.hasArg(OPT_objcmt_migrate_designated_init))
1968 if (Args.hasArg(OPT_objcmt_migrate_all))
1975 Diags.
Report(diag::err_drv_argument_not_allowed_with)
1976 <<
"ARC migration" <<
"ObjC migration";
1980 if (
const Arg *A = Args.getLastArg(OPT_x)) {
1981 StringRef XValue = A->getValue();
1985 bool Preprocessed = XValue.consume_back(
"-cpp-output");
1986 bool ModuleMap = XValue.consume_back(
"-module-map");
1988 !Preprocessed && !ModuleMap && XValue.consume_back(
"-header");
1991 DashX = llvm::StringSwitch<InputKind>(XValue)
2004 if (DashX.
isUnknown() && Preprocessed && !IsHeaderFile && !ModuleMap)
2005 DashX = llvm::StringSwitch<InputKind>(XValue)
2012 DashX = llvm::StringSwitch<InputKind>(XValue)
2015 .Cases(
"ast",
"pcm",
2021 Diags.
Report(diag::err_drv_invalid_value)
2022 << A->getAsString(Args) << A->getValue();
2031 std::vector<std::string> Inputs = Args.getAllArgValues(OPT_INPUT);
2034 Inputs.push_back(
"-");
2035 for (
unsigned i = 0, e = Inputs.size(); i != e; ++i) {
2039 StringRef(Inputs[i]).rsplit(
'.').second);
2053 Opts.
Inputs.emplace_back(std::move(Inputs[i]), IK);
2061 std::string ClangExecutable =
2062 llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
2063 return Driver::GetResourcesPath(ClangExecutable, CLANG_RESOURCE_DIR);
2067 const std::string &WorkingDir) {
2068 Opts.
Sysroot = Args.getLastArgValue(OPT_isysroot,
"/");
2069 Opts.
Verbose = Args.hasArg(OPT_v);
2073 if (
const Arg *A = Args.getLastArg(OPT_stdlib_EQ))
2074 Opts.
UseLibcxx = (strcmp(A->getValue(),
"libc++") == 0);
2075 Opts.
ResourceDir = Args.getLastArgValue(OPT_resource_dir);
2079 if (!(
P.empty() || llvm::sys::path::is_absolute(
P))) {
2080 if (WorkingDir.empty())
2081 llvm::sys::fs::make_absolute(
P);
2083 llvm::sys::fs::make_absolute(WorkingDir,
P);
2085 llvm::sys::path::remove_dots(
P);
2090 for (
const auto *A : Args.filtered(OPT_fmodule_file)) {
2091 StringRef Val = A->getValue();
2092 if (Val.find(
'=') != StringRef::npos)
2095 for (
const auto *A : Args.filtered(OPT_fprebuilt_module_path))
2101 !Args.hasArg(OPT_fmodules_disable_diagnostic_validation);
2109 Args.hasArg(OPT_fmodules_validate_once_per_build_session);
2113 Args.hasArg(OPT_fmodules_validate_system_headers);
2115 Args.hasArg(OPT_fvalidate_ast_input_files_content);
2116 if (
const Arg *A = Args.getLastArg(OPT_fmodule_format_EQ))
2119 for (
const auto *A : Args.filtered(OPT_fmodules_ignore_macro)) {
2120 StringRef MacroDef = A->getValue();
2122 llvm::CachedHashString(MacroDef.split(
'=').first));
2126 bool IsIndexHeaderMap =
false;
2127 bool IsSysrootSpecified =
2128 Args.hasArg(OPT__sysroot_EQ) || Args.hasArg(OPT_isysroot);
2129 for (
const auto *A : Args.filtered(OPT_I, OPT_F, OPT_index_header_map)) {
2130 if (A->getOption().matches(OPT_index_header_map)) {
2132 IsIndexHeaderMap =
true;
2139 bool IsFramework = A->getOption().matches(OPT_F);
2140 std::string Path = A->getValue();
2142 if (IsSysrootSpecified && !IsFramework && A->getValue()[0] ==
'=') {
2144 llvm::sys::path::append(Buffer, Opts.
Sysroot,
2145 llvm::StringRef(A->getValue()).substr(1));
2146 Path = Buffer.str();
2149 Opts.
AddPath(Path, Group, IsFramework,
2151 IsIndexHeaderMap =
false;
2155 StringRef Prefix =
"";
2156 for (
const auto *A :
2157 Args.filtered(OPT_iprefix, OPT_iwithprefix, OPT_iwithprefixbefore)) {
2158 if (A->getOption().matches(OPT_iprefix))
2159 Prefix = A->getValue();
2160 else if (A->getOption().matches(OPT_iwithprefix))
2166 for (
const auto *A : Args.filtered(OPT_idirafter))
2168 for (
const auto *A : Args.filtered(OPT_iquote))
2170 for (
const auto *A : Args.filtered(OPT_isystem, OPT_iwithsysroot))
2172 !A->getOption().matches(OPT_iwithsysroot));
2173 for (
const auto *A : Args.filtered(OPT_iframework))
2175 for (
const auto *A : Args.filtered(OPT_iframeworkwithsysroot))
2180 for (
const auto *A : Args.filtered(OPT_c_isystem))
2182 for (
const auto *A : Args.filtered(OPT_cxx_isystem))
2184 for (
const auto *A : Args.filtered(OPT_objc_isystem))
2186 for (
const auto *A : Args.filtered(OPT_objcxx_isystem))
2190 for (
const auto *A :
2191 Args.filtered(OPT_internal_isystem, OPT_internal_externc_isystem)) {
2193 if (A->getOption().matches(OPT_internal_externc_isystem))
2195 Opts.
AddPath(A->getValue(), Group,
false,
true);
2199 for (
const auto *A :
2200 Args.filtered(OPT_system_header_prefix, OPT_no_system_header_prefix))
2202 A->getValue(), A->getOption().matches(OPT_system_header_prefix));
2204 for (
const auto *A : Args.filtered(OPT_ivfsoverlay))
2209 const llvm::Triple &T,
2220 Opts.AsmPreprocessor = 1;
2230 llvm_unreachable(
"Invalid input kind!");
2232 LangStd = LangStandard::lang_opencl10;
2235 LangStd = LangStandard::lang_cuda;
2239 #if defined(CLANG_DEFAULT_STD_C) 2240 LangStd = CLANG_DEFAULT_STD_C;
2244 LangStd = LangStandard::lang_gnu99;
2246 LangStd = LangStandard::lang_gnu11;
2250 #if defined(CLANG_DEFAULT_STD_C) 2251 LangStd = CLANG_DEFAULT_STD_C;
2253 LangStd = LangStandard::lang_gnu11;
2258 #if defined(CLANG_DEFAULT_STD_CXX) 2259 LangStd = CLANG_DEFAULT_STD_CXX;
2261 LangStd = LangStandard::lang_gnucxx14;
2265 LangStd = LangStandard::lang_c99;
2268 LangStd = LangStandard::lang_hip;
2275 Opts.C99 = Std.
isC99();
2276 Opts.C11 = Std.
isC11();
2277 Opts.C17 = Std.
isC17();
2278 Opts.C2x = Std.
isC2x();
2286 Opts.GNUInline = !Opts.C99 && !Opts.CPlusPlus;
2287 Opts.GNUCVersion = 0;
2293 if (LangStd == LangStandard::lang_opencl10)
2294 Opts.OpenCLVersion = 100;
2295 else if (LangStd == LangStandard::lang_opencl11)
2296 Opts.OpenCLVersion = 110;
2297 else if (LangStd == LangStandard::lang_opencl12)
2298 Opts.OpenCLVersion = 120;
2299 else if (LangStd == LangStandard::lang_opencl20)
2300 Opts.OpenCLVersion = 200;
2301 else if (LangStd == LangStandard::lang_openclcpp)
2302 Opts.OpenCLCPlusPlusVersion = 100;
2310 Opts.NativeHalfType = 1;
2311 Opts.NativeHalfArgsAndReturns = 1;
2312 Opts.OpenCLCPlusPlus = Opts.CPlusPlus;
2315 if (Opts.IncludeDefaultHeader) {
2316 if (Opts.DeclareOpenCLBuiltins) {
2318 PPOpts.
Includes.push_back(
"opencl-c-base.h");
2320 PPOpts.
Includes.push_back(
"opencl-c.h");
2332 if (Opts.RenderScript) {
2333 Opts.NativeHalfType = 1;
2334 Opts.NativeHalfArgsAndReturns = 1;
2338 Opts.Bool = Opts.OpenCL || Opts.CPlusPlus;
2341 Opts.Half = Opts.OpenCL;
2344 Opts.WChar = Opts.CPlusPlus;
2346 Opts.GNUKeywords = Opts.GNUMode;
2347 Opts.CXXOperatorNames = Opts.CPlusPlus;
2349 Opts.AlignedAllocation = Opts.CPlusPlus17;
2351 Opts.DollarIdents = !Opts.AsmPreprocessor;
2354 Opts.DoubleSquareBracketAttributes = Opts.CPlusPlus11 || Opts.C2x;
2360 StringRef value = arg->getValue();
2361 if (value ==
"default") {
2363 }
else if (value ==
"hidden" || value ==
"internal") {
2365 }
else if (value ==
"protected") {
2370 diags.
Report(diag::err_drv_invalid_value)
2371 << arg->getAsString(args) << value;
2381 llvm_unreachable(
"should not parse language flags for this input");
2410 llvm_unreachable(
"unexpected input language");
2419 return "Objective-C";
2423 return "Objective-C++";
2429 return "RenderScript";
2441 llvm_unreachable(
"unknown input language");
2450 if (
const Arg *A = Args.getLastArg(OPT_std_EQ)) {
2453 Diags.
Report(diag::err_drv_invalid_value)
2454 << A->getAsString(Args) << A->getValue();
2456 for (
unsigned KindValue = 0;
2460 static_cast<LangStandard::Kind>(KindValue));
2462 auto Diag = Diags.
Report(diag::note_drv_use_standard);
2464 unsigned NumAliases = 0;
2465 #define LANGSTANDARD(id, name, lang, desc, features) 2466 #define LANGSTANDARD_ALIAS(id, alias) \ 2467 if (KindValue == LangStandard::lang_##id) ++NumAliases; 2468 #define LANGSTANDARD_ALIAS_DEPR(id, alias) 2469 #include "clang/Basic/LangStandards.def" 2471 #define LANGSTANDARD(id, name, lang, desc, features) 2472 #define LANGSTANDARD_ALIAS(id, alias) \ 2473 if (KindValue == LangStandard::lang_##id) Diag << alias; 2474 #define LANGSTANDARD_ALIAS_DEPR(id, alias) 2475 #include "clang/Basic/LangStandards.def" 2483 Diags.
Report(diag::err_drv_argument_not_allowed_with)
2489 if (Args.hasArg(OPT_fno_dllexport_inlines))
2490 Opts.DllExportInlines =
false;
2492 if (
const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
2493 StringRef Name = A->getValue();
2494 if (Name ==
"full" || Name ==
"branch") {
2495 Opts.CFProtectionBranch = 1;
2500 if (
const Arg *A = Args.getLastArg(OPT_cl_std_EQ)) {
2502 = llvm::StringSwitch<LangStandard::Kind>(A->getValue())
2503 .Cases(
"cl",
"CL", LangStandard::lang_opencl10)
2504 .Cases(
"cl1.1",
"CL1.1", LangStandard::lang_opencl11)
2505 .Cases(
"cl1.2",
"CL1.2", LangStandard::lang_opencl12)
2506 .Cases(
"cl2.0",
"CL2.0", LangStandard::lang_opencl20)
2507 .Cases(
"clc++",
"CLC++", LangStandard::lang_openclcpp)
2511 Diags.
Report(diag::err_drv_invalid_value)
2512 << A->getAsString(Args) << A->getValue();
2515 LangStd = OpenCLLangStd;
2518 Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
2519 Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_opencl_builtins);
2521 llvm::Triple T(TargetOpts.
Triple);
2527 if (Args.getLastArg(OPT_cl_strict_aliasing)
2528 && Opts.OpenCLVersion > 100) {
2529 Diags.
Report(diag::warn_option_invalid_ocl_version)
2531 << Args.getLastArg(OPT_cl_strict_aliasing)->getAsString(Args);
2539 Opts.GNUKeywords = Args.hasFlag(OPT_fgnu_keywords, OPT_fno_gnu_keywords,
2542 Opts.Digraphs = Args.hasFlag(OPT_fdigraphs, OPT_fno_digraphs, Opts.Digraphs);
2544 if (Args.hasArg(OPT_fno_operator_names))
2545 Opts.CXXOperatorNames = 0;
2547 if (Args.hasArg(OPT_fcuda_is_device))
2548 Opts.CUDAIsDevice = 1;
2550 if (Args.hasArg(OPT_fcuda_allow_variadic_functions))
2551 Opts.CUDAAllowVariadicFunctions = 1;
2553 if (Args.hasArg(OPT_fno_cuda_host_device_constexpr))
2554 Opts.CUDAHostDeviceConstexpr = 0;
2556 if (Opts.CUDAIsDevice && Args.hasArg(OPT_fcuda_approx_transcendentals))
2557 Opts.CUDADeviceApproxTranscendentals = 1;
2559 Opts.GPURelocatableDeviceCode = Args.hasArg(OPT_fgpu_rdc);
2560 if (Args.hasArg(OPT_fgpu_allow_device_init)) {
2562 Opts.GPUAllowDeviceInit = 1;
2564 Diags.
Report(diag::warn_ignored_hip_only_option)
2565 << Args.getLastArg(OPT_fgpu_allow_device_init)->getAsString(Args);
2567 Opts.HIPUseNewLaunchAPI = Args.hasArg(OPT_fhip_new_launch_api);
2570 Args, OPT_gpu_max_threads_per_block_EQ, Opts.GPUMaxThreadsPerBlock);
2571 else if (Args.hasArg(OPT_gpu_max_threads_per_block_EQ))
2572 Diags.
Report(diag::warn_ignored_hip_only_option)
2573 << Args.getLastArg(OPT_gpu_max_threads_per_block_EQ)->getAsString(Args);
2576 if (Arg *arg = Args.getLastArg(OPT_fobjc_runtime_EQ)) {
2577 StringRef value = arg->getValue();
2579 Diags.
Report(diag::err_drv_unknown_objc_runtime) << value;
2582 if (Args.hasArg(OPT_fobjc_gc_only))
2584 else if (Args.hasArg(OPT_fobjc_gc))
2586 else if (Args.hasArg(OPT_fobjc_arc)) {
2587 Opts.ObjCAutoRefCount = 1;
2589 Diags.
Report(diag::err_arc_unsupported_on_runtime);
2596 if (Args.hasArg(OPT_fobjc_runtime_has_weak))
2597 Opts.ObjCWeakRuntime = 1;
2603 if (
auto weakArg = Args.getLastArg(OPT_fobjc_weak, OPT_fno_objc_weak)) {
2604 if (!weakArg->getOption().matches(OPT_fobjc_weak)) {
2605 assert(!Opts.ObjCWeak);
2607 Diags.
Report(diag::err_objc_weak_with_gc);
2608 }
else if (!Opts.ObjCWeakRuntime) {
2609 Diags.
Report(diag::err_objc_weak_unsupported);
2613 }
else if (Opts.ObjCAutoRefCount) {
2614 Opts.ObjCWeak = Opts.ObjCWeakRuntime;
2617 if (Args.hasArg(OPT_fno_objc_infer_related_result_type))
2618 Opts.ObjCInferRelatedResultType = 0;
2620 if (Args.hasArg(OPT_fobjc_subscripting_legacy_runtime))
2621 Opts.ObjCSubscriptingLegacyRuntime =
2625 if (Arg *A = Args.getLastArg(options::OPT_fgnuc_version_EQ)) {
2628 VersionTuple GNUCVer;
2629 bool Invalid = GNUCVer.tryParse(A->getValue());
2630 unsigned Major = GNUCVer.getMajor();
2631 unsigned Minor = GNUCVer.getMinor().getValueOr(0);
2632 unsigned Patch = GNUCVer.getSubminor().getValueOr(0);
2633 if (Invalid || GNUCVer.getBuild() || Minor >= 100 || Patch >= 100) {
2634 Diags.
Report(diag::err_drv_invalid_value)
2635 << A->getAsString(Args) << A->getValue();
2637 Opts.GNUCVersion = Major * 100 * 100 + Minor * 100 + Patch;
2640 if (Args.hasArg(OPT_fgnu89_inline)) {
2642 Diags.
Report(diag::err_drv_argument_not_allowed_with)
2648 if (Args.hasArg(OPT_fapple_kext)) {
2649 if (!Opts.CPlusPlus)
2650 Diags.
Report(diag::warn_c_kext);
2655 if (Args.hasArg(OPT_print_ivar_layout))
2656 Opts.ObjCGCBitmapPrint = 1;
2658 if (Args.hasArg(OPT_fno_constant_cfstrings))
2659 Opts.NoConstantCFStrings = 1;
2660 if (
const auto *A = Args.getLastArg(OPT_fcf_runtime_abi_EQ))
2662 llvm::StringSwitch<LangOptions::CoreFoundationABI>(A->getValue())
2663 .Cases(
"unspecified",
"standalone",
"objc",
2665 .Cases(
"swift",
"swift-5.0",
2671 if (Args.hasArg(OPT_fzvector))
2674 if (Args.hasArg(OPT_pthread))
2675 Opts.POSIXThreads = 1;
2678 if (Arg *visOpt = Args.getLastArg(OPT_fvisibility)) {
2685 if (Arg *typeVisOpt = Args.getLastArg(OPT_ftype_visibility)) {
2688 Opts.setTypeVisibilityMode(Opts.getValueVisibilityMode());
2691 if (Args.hasArg(OPT_fvisibility_inlines_hidden))
2692 Opts.InlineVisibilityHidden = 1;
2694 if (Args.hasArg(OPT_fvisibility_global_new_delete_hidden))
2695 Opts.GlobalAllocationFunctionVisibilityHidden = 1;
2697 if (Args.hasArg(OPT_fapply_global_visibility_to_externs))
2698 Opts.SetVisibilityForExternDecls = 1;
2700 if (Args.hasArg(OPT_ftrapv)) {
2704 Args.getLastArgValue(OPT_ftrapv_handler);
2706 else if (Args.hasArg(OPT_fwrapv))
2709 Opts.MSVCCompat = Args.hasArg(OPT_fms_compatibility);
2710 Opts.MicrosoftExt = Opts.MSVCCompat || Args.hasArg(OPT_fms_extensions);
2711 Opts.AsmBlocks = Args.hasArg(OPT_fasm_blocks) || Opts.MicrosoftExt;
2712 Opts.MSCompatibilityVersion = 0;
2713 if (
const Arg *A = Args.getLastArg(OPT_fms_compatibility_version)) {
2715 if (VT.tryParse(A->getValue()))
2716 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args)
2718 Opts.MSCompatibilityVersion = VT.getMajor() * 10000000 +
2719 VT.getMinor().getValueOr(0) * 100000 +
2720 VT.getSubminor().getValueOr(0);
2726 Opts.Trigraphs = !Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17;
2728 Args.hasFlag(OPT_ftrigraphs, OPT_fno_trigraphs, Opts.Trigraphs);
2730 Opts.DollarIdents = Args.hasFlag(OPT_fdollars_in_identifiers,
2731 OPT_fno_dollars_in_identifiers,
2733 Opts.PascalStrings = Args.hasArg(OPT_fpascal_strings);
2734 Opts.setVtorDispMode(
2736 Opts.Borland = Args.hasArg(OPT_fborland_extensions);
2737 Opts.WritableStrings = Args.hasArg(OPT_fwritable_strings);
2738 Opts.ConstStrings = Args.hasFlag(OPT_fconst_strings, OPT_fno_const_strings,
2740 if (Arg *A = Args.getLastArg(OPT_flax_vector_conversions_EQ)) {
2744 .Case(
"integer", LaxKind::Integer)
2747 Opts.setLaxVectorConversions(*
Kind);
2749 Diags.
Report(diag::err_drv_invalid_value)
2750 << A->getAsString(Args) << A->getValue();
2752 if (Args.hasArg(OPT_fno_threadsafe_statics))
2753 Opts.ThreadsafeStatics = 0;
2754 Opts.Exceptions = Args.hasArg(OPT_fexceptions);
2755 Opts.ObjCExceptions = Args.hasArg(OPT_fobjc_exceptions);
2756 Opts.CXXExceptions = Args.hasArg(OPT_fcxx_exceptions);
2760 Args.hasFlag(OPT_ffixed_point, OPT_fno_fixed_point,
false) &&
2762 Opts.PaddingOnUnsignedFixedPoint =
2763 Args.hasFlag(OPT_fpadding_on_unsigned_fixed_point,
2764 OPT_fno_padding_on_unsigned_fixed_point,
2769 Arg *A = Args.getLastArg(
2770 options::OPT_fsjlj_exceptions, options::OPT_fseh_exceptions,
2771 options::OPT_fdwarf_exceptions, options::OPT_fwasm_exceptions);
2773 const Option &Opt = A->getOption();
2774 llvm::Triple T(TargetOpts.
Triple);
2775 if (T.isWindowsMSVCEnvironment())
2776 Diags.
Report(diag::err_fe_invalid_exception_model)
2777 << Opt.getName() << T.str();
2779 Opts.SjLjExceptions = Opt.matches(options::OPT_fsjlj_exceptions);
2780 Opts.SEHExceptions = Opt.matches(options::OPT_fseh_exceptions);
2781 Opts.DWARFExceptions = Opt.matches(options::OPT_fdwarf_exceptions);
2782 Opts.WasmExceptions = Opt.matches(options::OPT_fwasm_exceptions);
2785 Opts.ExternCNoUnwind = Args.hasArg(OPT_fexternc_nounwind);
2786 Opts.TraditionalCPP = Args.hasArg(OPT_traditional_cpp);
2788 Opts.RTTI = Opts.CPlusPlus && !Args.hasArg(OPT_fno_rtti);
2789 Opts.RTTIData = Opts.RTTI && !Args.hasArg(OPT_fno_rtti_data);
2790 Opts.Blocks = Args.hasArg(OPT_fblocks) || (Opts.OpenCL
2791 && Opts.OpenCLVersion == 200);
2792 Opts.BlocksRuntimeOptional = Args.hasArg(OPT_fblocks_runtime_optional);
2793 Opts.Coroutines = Opts.CPlusPlus2a || Args.hasArg(OPT_fcoroutines_ts);
2795 Opts.ConvergentFunctions = Opts.OpenCL || (Opts.CUDA && Opts.CUDAIsDevice) ||
2796 Args.hasArg(OPT_fconvergent_functions);
2798 Opts.DoubleSquareBracketAttributes =
2799 Args.hasFlag(OPT_fdouble_square_bracket_attributes,
2800 OPT_fno_double_square_bracket_attributes,
2801 Opts.DoubleSquareBracketAttributes);
2803 Opts.CPlusPlusModules = Opts.CPlusPlus2a;
2804 Opts.ModulesTS = Args.hasArg(OPT_fmodules_ts);
2806 Args.hasArg(OPT_fmodules) || Opts.ModulesTS || Opts.CPlusPlusModules;
2807 Opts.ModulesStrictDeclUse = Args.hasArg(OPT_fmodules_strict_decluse);
2808 Opts.ModulesDeclUse =
2809 Args.hasArg(OPT_fmodules_decluse) || Opts.ModulesStrictDeclUse;
2812 Opts.ModulesLocalVisibility =
2813 Args.hasArg(OPT_fmodules_local_submodule_visibility) || Opts.ModulesTS ||
2814 Opts.CPlusPlusModules;
2815 Opts.ModulesCodegen = Args.hasArg(OPT_fmodules_codegen);
2816 Opts.ModulesDebugInfo = Args.hasArg(OPT_fmodules_debuginfo);
2817 Opts.ModulesSearchAll = Opts.Modules &&
2818 !Args.hasArg(OPT_fno_modules_search_all) &&
2819 Args.hasArg(OPT_fmodules_search_all);
2820 Opts.ModulesErrorRecovery = !Args.hasArg(OPT_fno_modules_error_recovery);
2821 Opts.ImplicitModules = !Args.hasArg(OPT_fno_implicit_modules);
2822 Opts.CharIsSigned = Opts.OpenCL || !Args.hasArg(OPT_fno_signed_char);
2823 Opts.WChar = Opts.CPlusPlus && !Args.hasArg(OPT_fno_wchar);
2824 Opts.Char8 = Args.hasFlag(OPT_fchar8__t, OPT_fno_char8__t, Opts.CPlusPlus2a);
2825 if (
const Arg *A = Args.getLastArg(OPT_fwchar_type_EQ)) {
2826 Opts.WCharSize = llvm::StringSwitch<unsigned>(A->getValue())
2831 if (Opts.WCharSize == 0)
2832 Diags.
Report(diag::err_fe_invalid_wchar_type) << A->getValue();
2834 Opts.WCharIsSigned = Args.hasFlag(OPT_fsigned_wchar, OPT_fno_signed_wchar,
true);
2835 Opts.ShortEnums = Args.hasArg(OPT_fshort_enums);
2836 Opts.Freestanding = Args.hasArg(OPT_ffreestanding);
2837 Opts.NoBuiltin = Args.hasArg(OPT_fno_builtin) || Opts.Freestanding;
2838 if (!Opts.NoBuiltin)
2840 Opts.NoMathBuiltin = Args.hasArg(OPT_fno_math_builtin);
2841 Opts.RelaxedTemplateTemplateArgs =
2842 Args.hasArg(OPT_frelaxed_template_template_args);
2843 Opts.SizedDeallocation = Args.hasArg(OPT_fsized_deallocation);
2844 Opts.AlignedAllocation =
2845 Args.hasFlag(OPT_faligned_allocation, OPT_fno_aligned_allocation,
2846 Opts.AlignedAllocation);
2847 Opts.AlignedAllocationUnavailable =
2848 Opts.AlignedAllocation && Args.hasArg(OPT_aligned_alloc_unavailable);
2849 Opts.NewAlignOverride =
2851 if (Opts.NewAlignOverride && !llvm::isPowerOf2_32(Opts.NewAlignOverride)) {
2852 Arg *A = Args.getLastArg(OPT_fnew_alignment_EQ);
2853 Diags.
Report(diag::err_fe_invalid_alignment) << A->getAsString(Args)
2855 Opts.NewAlignOverride = 0;
2857 Opts.ConceptSatisfactionCaching =
2858 !Args.hasArg(OPT_fno_concept_satisfaction_caching);
2859 if (Args.hasArg(OPT_fconcepts_ts))
2860 Diags.
Report(diag::warn_fe_concepts_ts_flag);
2861 Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions);
2862 Opts.AccessControl = !Args.hasArg(OPT_fno_access_control);
2863 Opts.ElideConstructors = !Args.hasArg(OPT_fno_elide_constructors);
2864 Opts.MathErrno = !Opts.OpenCL && Args.hasArg(OPT_fmath_errno);
2865 Opts.InstantiationDepth =
2869 Opts.ConstexprCallDepth =
2871 Opts.ConstexprStepLimit =
2873 Opts.EnableNewConstInterp =
2874 Args.hasArg(OPT_fexperimental_new_constant_interpreter);
2876 Opts.DelayedTemplateParsing = Args.hasArg(OPT_fdelayed_template_parsing);
2877 Opts.NumLargeByValueCopy =
2879 Opts.MSBitfields = Args.hasArg(OPT_mms_bitfields);
2881 Args.getLastArgValue(OPT_fconstant_string_class);
2882 Opts.ObjCDefaultSynthProperties =
2883 !Args.hasArg(OPT_disable_objc_default_synthesize_properties);
2884 Opts.EncodeExtendedBlockSig =
2885 Args.hasArg(OPT_fencode_extended_block_signature);
2886 Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls);
2889 Opts.AlignDouble = Args.hasArg(OPT_malign_double);
2890 Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
2892 : Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
2893 Opts.PPCIEEELongDouble = Args.hasArg(OPT_mabi_EQ_ieeelongdouble);
2895 Opts.ROPI = Args.hasArg(OPT_fropi);
2896 Opts.RWPI = Args.hasArg(OPT_frwpi);
2897 Opts.PIE = Args.hasArg(OPT_pic_is_pie);
2898 Opts.Static = Args.hasArg(OPT_static_define);
2899 Opts.DumpRecordLayoutsSimple = Args.hasArg(OPT_fdump_record_layouts_simple);
2900 Opts.DumpRecordLayouts = Opts.DumpRecordLayoutsSimple
2901 || Args.hasArg(OPT_fdump_record_layouts);
2902 Opts.DumpVTableLayouts = Args.hasArg(OPT_fdump_vtable_layouts);
2903 Opts.SpellChecking = !Args.hasArg(OPT_fno_spell_checking);
2904 Opts.NoBitFieldTypeAlign = Args.hasArg(OPT_fno_bitfield_type_align);
2905 Opts.SinglePrecisionConstants = Args.hasArg(OPT_cl_single_precision_constant);
2906 Opts.FastRelaxedMath = Args.hasArg(OPT_cl_fast_relaxed_math);
2907 Opts.HexagonQdsp6Compat = Args.hasArg(OPT_mqdsp6_compat);
2908 Opts.FakeAddressSpaceMap = Args.hasArg(OPT_ffake_address_space_map);
2909 Opts.ParseUnknownAnytype = Args.hasArg(OPT_funknown_anytype);
2910 Opts.DebuggerSupport = Args.hasArg(OPT_fdebugger_support);
2911 Opts.DebuggerCastResultToId = Args.hasArg(OPT_fdebugger_cast_result_to_id);
2912 Opts.DebuggerObjCLiteral = Args.hasArg(OPT_fdebugger_objc_literal);
2913 Opts.ApplePragmaPack = Args.hasArg(OPT_fapple_pragma_pack);
2914 Opts.
ModuleName = Args.getLastArgValue(OPT_fmodule_name_EQ);
2916 Opts.AppExt = Args.hasArg(OPT_fapplication_extension);
2919 Opts.NativeHalfType |= Args.hasArg(OPT_fnative_half_type);
2920 Opts.NativeHalfArgsAndReturns |= Args.hasArg(OPT_fnative_half_arguments_and_returns);
2923 Opts.HalfArgsAndReturns = Args.hasArg(OPT_fallow_half_arguments_and_returns)
2924 | Opts.NativeHalfArgsAndReturns;
2925 Opts.GNUAsm = !Args.hasArg(OPT_fno_gnu_inline_asm);
2926 Opts.Cmse = Args.hasArg(OPT_mcmse);
2936 Opts.DeclSpecKeyword =
2937 Args.hasFlag(OPT_fdeclspec, OPT_fno_declspec,
2938 (Opts.MicrosoftExt || Opts.Borland || Opts.CUDA));
2940 if (Arg *A = Args.getLastArg(OPT_faddress_space_map_mangling_EQ)) {
2941 switch (llvm::StringSwitch<unsigned>(A->getValue())
2947 Diags.
Report(diag::err_drv_invalid_value)
2948 <<
"-faddress-space-map-mangling=" << A->getValue();
2962 if (Arg *A = Args.getLastArg(OPT_fms_memptr_rep_EQ)) {
2964 llvm::StringSwitch<LangOptions::PragmaMSPointersToMembersKind>(
2974 Diags.
Report(diag::err_drv_invalid_value)
2975 <<
"-fms-memptr-rep=" << A->getValue();
2977 Opts.setMSPointerToMemberRepresentationMethod(InheritanceModel);
2981 if (Arg *A = Args.getLastArg(OPT_fdefault_calling_conv_EQ)) {
2983 llvm::StringSwitch<LangOptions::DefaultCallingConvention>(A->getValue())
2991 Diags.
Report(diag::err_drv_invalid_value)
2992 <<
"-fdefault-calling-conv=" << A->getValue();
2994 llvm::Triple T(TargetOpts.
Triple);
2995 llvm::Triple::ArchType Arch = T.getArch();
2998 Arch != llvm::Triple::x86;
3003 Diags.
Report(diag::err_drv_argument_not_allowed_with)
3004 << A->getSpelling() << T.getTriple();
3006 Opts.setDefaultCallingConv(DefaultCC);
3010 if (Arg *A = Args.getLastArg(OPT_mrtd)) {
3012 Diags.
Report(diag::err_drv_argument_not_allowed_with)
3013 << A->getSpelling() <<
"-fdefault-calling-conv";
3015 llvm::Triple T(TargetOpts.
Triple);
3016 if (T.getArch() != llvm::Triple::x86)
3017 Diags.
Report(diag::err_drv_argument_not_allowed_with)
3018 << A->getSpelling() << T.getTriple();
3025 Opts.OpenMP = Args.hasArg(options::OPT_fopenmp) ? 45 : 0;
3027 bool IsSimdSpecified =
3028 Args.hasFlag(options::OPT_fopenmp_simd, options::OPT_fno_openmp_simd,
3030 Opts.OpenMPSimd = !Opts.OpenMP && IsSimdSpecified;
3032 Opts.OpenMP && !Args.hasArg(options::OPT_fnoopenmp_use_tls);
3033 Opts.OpenMPIsDevice =
3034 Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_is_device);
3035 Opts.OpenMPIRBuilder =
3036 Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_enable_irbuilder);
3037 bool IsTargetSpecified =
3038 Opts.OpenMPIsDevice || Args.hasArg(options::OPT_fopenmp_targets_EQ);
3040 if (Opts.OpenMP || Opts.OpenMPSimd) {
3042 Args, OPT_fopenmp_version_EQ,
3043 (IsSimdSpecified || IsTargetSpecified) ? 45 : Opts.OpenMP, Diags))
3044 Opts.OpenMP = Version;
3045 else if (IsSimdSpecified || IsTargetSpecified)
3049 if (!Opts.OpenMPIsDevice) {
3050 switch (T.getArch()) {
3054 case llvm::Triple::nvptx:
3055 case llvm::Triple::nvptx64:
3056 Diags.
Report(diag::err_drv_omp_host_target_not_supported)
3065 if ((Opts.OpenMPIsDevice && T.isNVPTX()) || Opts.OpenCLCPlusPlus) {
3066 Opts.Exceptions = 0;
3067 Opts.CXXExceptions = 0;
3069 if (Opts.OpenMPIsDevice && T.isNVPTX()) {
3070 Opts.OpenMPCUDANumSMs =
3072 Opts.OpenMPCUDANumSMs, Diags);
3073 Opts.OpenMPCUDABlocksPerSM =
3075 Opts.OpenMPCUDABlocksPerSM, Diags);
3077 Args, options::OPT_fopenmp_cuda_teams_reduction_recs_num_EQ,
3078 Opts.OpenMPCUDAReductionBufNum, Diags);
3083 Opts.OpenMPOptimisticCollapse =
3084 Args.hasArg(options::OPT_fopenmp_optimistic_collapse) ? 1 : 0;
3087 if (Arg *A = Args.getLastArg(options::OPT_fopenmp_targets_EQ)) {
3089 for (
unsigned i = 0; i < A->getNumValues(); ++i) {
3090 llvm::Triple TT(A->getValue(i));
3092 if (TT.getArch() == llvm::Triple::UnknownArch ||
3093 !(TT.getArch() == llvm::Triple::aarch64 ||
3094 TT.getArch() == llvm::Triple::ppc ||
3095 TT.getArch() == llvm::Triple::ppc64 ||
3096 TT.getArch() == llvm::Triple::ppc64le ||
3097 TT.getArch() == llvm::Triple::nvptx ||
3098 TT.getArch() == llvm::Triple::nvptx64 ||
3099 TT.getArch() == llvm::Triple::x86 ||
3100 TT.getArch() == llvm::Triple::x86_64))
3101 Diags.
Report(diag::err_drv_invalid_omp_target) << A->getValue(i);
3109 if (Arg *A = Args.getLastArg(options::OPT_fopenmp_host_ir_file_path)) {
3112 Diags.
Report(diag::err_drv_omp_host_ir_file_not_found)
3116 Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
3119 Opts.OpenMPCUDAMode = Opts.OpenMPIsDevice && T.isNVPTX() &&
3120 Args.hasArg(options::OPT_fopenmp_cuda_mode);
3123 Opts.OpenMPCUDAForceFullRuntime =
3124 Opts.OpenMPIsDevice && T.isNVPTX() &&
3125 Args.hasArg(options::OPT_fopenmp_cuda_force_full_runtime);
3128 Opts.Deprecated = Args.hasFlag(OPT_fdeprecated_macro,
3129 OPT_fno_deprecated_macro,
3135 Opts.Optimize = Opt != 0;
3136 Opts.OptimizeSize = OptSize != 0;
3141 Opts.NoInlineDefine = !Opts.Optimize;
3142 if (Arg *InlineArg = Args.getLastArg(
3143 options::OPT_finline_functions, options::OPT_finline_hint_functions,
3144 options::OPT_fno_inline_functions, options::OPT_fno_inline))
3145 if (InlineArg->getOption().matches(options::OPT_fno_inline))
3146 Opts.NoInlineDefine =
true;
3148 Opts.FastMath = Args.hasArg(OPT_ffast_math) ||
3149 Args.hasArg(OPT_cl_fast_relaxed_math);
3150 Opts.FiniteMathOnly = Args.hasArg(OPT_ffinite_math_only) ||
3151 Args.hasArg(OPT_cl_finite_math_only) ||
3152 Args.hasArg(OPT_cl_fast_relaxed_math);
3153 Opts.UnsafeFPMath = Args.hasArg(OPT_menable_unsafe_fp_math) ||
3154 Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
3155 Args.hasArg(OPT_cl_fast_relaxed_math);
3157 if (Arg *A = Args.getLastArg(OPT_ffp_contract)) {
3158 StringRef Val = A->getValue();
3161 else if (Val ==
"on")
3163 else if (Val ==
"off")
3166 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
3170 if (Args.hasArg(OPT_frounding_math)) {
3173 Opts.setFPRoundingMode(FPRM);
3175 if (Args.hasArg(OPT_ftrapping_math)) {
3179 if (Args.hasArg(OPT_fno_trapping_math)) {
3184 if (Arg *A = Args.getLastArg(OPT_ffp_exception_behavior_EQ)) {
3185 StringRef Val = A->getValue();
3186 if (Val.equals(
"ignore"))
3188 else if (Val.equals(
"maytrap"))
3190 else if (Val.equals(
"strict"))
3193 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
3195 Opts.setFPExceptionMode(FPEB);
3197 Opts.RetainCommentsFromSystemHeaders =
3198 Args.hasArg(OPT_fretain_comments_from_system_headers);
3203 Diags.
Report(diag::err_drv_invalid_value)
3204 << Args.getLastArg(OPT_stack_protector)->getAsString(Args) << SSP;
3212 if (Arg *A = Args.getLastArg(OPT_ftrivial_auto_var_init)) {
3213 StringRef Val = A->getValue();
3214 if (Val ==
"uninitialized")
3215 Opts.setTrivialAutoVarInit(
3217 else if (Val ==
"zero")
3219 else if (Val ==
"pattern")
3222 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
3229 Opts.SanitizeAddressFieldPadding =
3232 std::vector<std::string> systemBlacklists =
3233 Args.getAllArgValues(OPT_fsanitize_system_blacklist);
3235 systemBlacklists.begin(),
3236 systemBlacklists.end());
3239 Opts.XRayInstrument =
3240 Args.hasFlag(OPT_fxray_instrument, OPT_fnoxray_instrument,
false);
3243 Opts.XRayAlwaysEmitCustomEvents =
3244 Args.hasFlag(OPT_fxray_always_emit_customevents,
3245 OPT_fnoxray_always_emit_customevents,
false);
3248 Opts.XRayAlwaysEmitTypedEvents =
3249 Args.hasFlag(OPT_fxray_always_emit_typedevents,
3250 OPT_fnoxray_always_emit_customevents,
false);
3254 Args.getAllArgValues(OPT_fxray_always_instrument);
3256 Args.getAllArgValues(OPT_fxray_never_instrument);
3260 Opts.ForceEmitVTables = Args.hasArg(OPT_fforce_emit_vtables);
3263 Opts.AllowEditorPlaceholders = Args.hasArg(OPT_fallow_editor_placeholders);
3265 Opts.RegisterStaticDestructors = !Args.hasArg(OPT_fno_cxx_static_destructors);
3267 if (Arg *A = Args.getLastArg(OPT_fclang_abi_compat_EQ)) {
3270 StringRef Ver = A->getValue();
3271 std::pair<StringRef, StringRef> VerParts = Ver.split(
'.');
3272 unsigned Major, Minor = 0;
3276 if (!VerParts.first.startswith(
"0") &&
3277 !VerParts.first.getAsInteger(10, Major) &&
3278 3 <= Major && Major <= CLANG_VERSION_MAJOR &&
3279 (Major == 3 ? VerParts.second.size() == 1 &&
3280 !VerParts.second.getAsInteger(10, Minor)
3281 : VerParts.first.size() == Ver.size() ||
3282 VerParts.second ==
"0")) {
3284 if (Major == 3 && Minor <= 8)
3286 else if (Major <= 4)
3288 else if (Major <= 6)
3290 else if (Major <= 7)
3292 else if (Major <= 9)
3294 }
else if (Ver !=
"latest") {
3295 Diags.
Report(diag::err_drv_invalid_value)
3296 << A->getAsString(Args) << A->getValue();
3300 Opts.CompleteMemberPointers = Args.hasArg(OPT_fcomplete_member_pointers);
3301 Opts.BuildingPCHWithObjectFile = Args.hasArg(OPT_building_pch_with_obj);
3345 llvm_unreachable(
"invalid frontend action");
3352 Opts.
PCHWithHdrStop = Args.hasArg(OPT_pch_through_hdrstop_create) ||
3353 Args.hasArg(OPT_pch_through_hdrstop_use);
3357 Opts.
DetailedRecord = Args.hasArg(OPT_detailed_preprocessing_record);
3362 for (
const auto *A : Args.filtered(OPT_error_on_deserialized_pch_decl))
3365 for (
const auto &A : Args.getAllArgValues(OPT_fmacro_prefix_map_EQ))
3368 if (
const Arg *A = Args.getLastArg(OPT_preamble_bytes_EQ)) {
3369 StringRef
Value(A->getValue());
3372 unsigned EndOfLine = 0;
3374 if (Comma == StringRef::npos ||
3375 Value.substr(0, Comma).getAsInteger(10, Bytes) ||
3376 Value.substr(Comma + 1).getAsInteger(10, EndOfLine))
3377 Diags.
Report(diag::err_drv_preamble_format);
3385 if (
const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
3386 StringRef Name = A->getValue();
3387 if (Name ==
"branch")
3389 else if (Name ==
"return")
3391 else if (Name ==
"full")
3396 for (
const auto *A : Args.filtered(OPT_D, OPT_U)) {
3397 if (A->getOption().matches(OPT_D))
3406 for (
const auto *A : Args.filtered(OPT_include))
3407 Opts.
Includes.emplace_back(A->getValue());
3409 for (
const auto *A : Args.filtered(OPT_chain_include))
3412 for (
const auto *A : Args.filtered(OPT_remap_file)) {
3413 std::pair<StringRef, StringRef>
Split = StringRef(A->getValue()).split(
';');
3415 if (Split.second.empty()) {
3416 Diags.
Report(diag::err_drv_invalid_remap_file) << A->getAsString(Args);
3423 if (Arg *A = Args.getLastArg(OPT_fobjc_arc_cxxlib_EQ)) {
3424 StringRef Name = A->getValue();
3425 unsigned Library = llvm::StringSwitch<unsigned>(Name)
3431 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
3450 Opts.
ShowCPP = !Args.hasArg(OPT_dM);
3457 Opts.
ShowMacros = Args.hasArg(OPT_dM) || Args.hasArg(OPT_dD);
3467 Opts.
ABI = Args.getLastArgValue(OPT_target_abi);
3468 if (Arg *A = Args.getLastArg(OPT_meabi)) {
3469 StringRef
Value = A->getValue();
3470 llvm::EABI EABIVersion = llvm::StringSwitch<llvm::EABI>(
Value)
3471 .Case(
"default", llvm::EABI::Default)
3472 .Case(
"4", llvm::EABI::EABI4)
3473 .Case(
"5", llvm::EABI::EABI5)
3474 .Case(
"gnu", llvm::EABI::GNU)
3477 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args)
3482 Opts.
CPU = Args.getLastArgValue(OPT_target_cpu);
3483 Opts.
FPMath = Args.getLastArgValue(OPT_mfpmath);
3485 Opts.
LinkerVersion = Args.getLastArgValue(OPT_target_linker_version);
3486 Opts.
Triple = Args.getLastArgValue(OPT_triple);
3489 Opts.
Triple = llvm::sys::getDefaultTargetTriple();
3494 options::OPT_fcuda_short_ptr, options::OPT_fno_cuda_short_ptr,
false);
3495 if (Arg *A = Args.getLastArg(options::OPT_target_sdk_version_EQ)) {
3496 llvm::VersionTuple Version;
3497 if (Version.tryParse(A->getValue()))
3498 Diags.
Report(diag::err_drv_invalid_value)
3499 << A->getAsString(Args) << A->getValue();
3508 bool Success =
true;
3513 unsigned MissingArgIndex, MissingArgCount;
3514 InputArgList Args = Opts.ParseArgs(CommandLineArgs, MissingArgIndex,
3515 MissingArgCount, IncludedFlagsBitmask);
3519 if (MissingArgCount) {
3520 Diags.
Report(diag::err_drv_missing_argument)
3521 << Args.getArgString(MissingArgIndex) << MissingArgCount;
3526 for (
const auto *A : Args.filtered(OPT_UNKNOWN)) {
3527 auto ArgString = A->getAsString(Args);
3528 std::string Nearest;
3529 if (Opts.findNearest(ArgString, Nearest, IncludedFlagsBitmask) > 1)
3530 Diags.
Report(diag::err_drv_unknown_argument) << ArgString;
3532 Diags.
Report(diag::err_drv_unknown_argument_with_suggestion)
3533 << ArgString << Nearest;
3542 Diags.
Report(diag::err_fe_dependency_file_requires_MT);
3564 if (Args.hasArg(OPT_fobjc_arc))
3565 LangOpts.ObjCAutoRefCount = 1;
3569 LangOpts.PIE = Args.hasArg(OPT_pic_is_pie);
3578 LangOpts.ObjCExceptions = 1;
3579 if (T.isOSDarwin() && DashX.isPreprocessed()) {
3587 if (Diags.isIgnored(diag::warn_profile_data_misexpect,
SourceLocation()))
3588 Res.FrontendOpts.
LLVMArgs.push_back(
"-pgo-warn-misexpect");
3590 LangOpts.FunctionAlignment =
3593 if (LangOpts.CUDA) {
3596 if (LangOpts.CUDAIsDevice)
3601 if (LangOpts.OpenMPIsDevice)
3609 !LangOpts.
Sanitize.
has(SanitizerKind::KernelAddress) &&
3611 !LangOpts.
Sanitize.
has(SanitizerKind::KernelMemory);
3626 Diags.Report(diag::warn_drv_fine_grained_bitfield_accesses_ignored);
3634 using llvm::hash_code;
3637 using llvm::hash_combine_range;
3645 #define LANGOPT(Name, Bits, Default, Description) \ 3646 code = hash_combine(code, LangOpts->Name); 3647 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 3648 code = hash_combine(code, static_cast<unsigned>(LangOpts->get##Name())); 3649 #define BENIGN_LANGOPT(Name, Bits, Default, Description) 3650 #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) 3651 #include "clang/Basic/LangOptions.def" 3653 for (StringRef Feature :
LangOpts->ModuleFeatures)
3659 for (
const auto &FeatureAsWritten :
TargetOpts->FeaturesAsWritten)
3672 StringRef MacroDef = I.first;
3674 llvm::CachedHashString(MacroDef.split(
'=').first)))
3695 hash_code UEC = hash_combine_range(hsOpts.
UserEntries.begin(),
3701 #define DIAGOPT(Name, Bits, Default) \ 3702 code = hash_combine(code, diagOpts.Name); 3703 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \ 3704 code = hash_combine(code, diagOpts.get##Name()); 3705 #include "clang/Basic/DiagnosticOptions.def" 3716 code = ext->hashExtension(code);
3721 if (getCodeGenOpts().DebugTypeExtRefs)
3722 for (
const auto &KeyValue : getCodeGenOpts().DebugPrefixMap)
3723 code =
hash_combine(code, KeyValue.first, KeyValue.second);
3729 if (!SanHash.
empty())
3741 llvm::vfs::getRealFileSystem());
3753 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buffer =
3754 Result->getBufferForFile(File);
3756 Diags.
Report(diag::err_missing_vfs_overlay_file) << File;
3761 std::move(Buffer.get()),
nullptr, File,
3764 Diags.
Report(diag::err_invalid_vfs_overlay) << File;
HeaderSearchOptions & getHeaderSearchOpts()
static Visibility parseVisibility(Arg *arg, ArgList &args, DiagnosticsEngine &diags)
Attempt to parse a visibility value out of the given argument.
std::string CoverageNotesFile
The filename with path we use for coverage notes files.
Expand macros but not #includes.
std::string ProfileInstrumentUsePath
Name of the profile file to use as input for -fprofile-instr-use.
std::string OutputFile
The output file, if any.
bool ParseDiagnosticArgs(DiagnosticOptions &Opts, llvm::opt::ArgList &Args, DiagnosticsEngine *Diags=nullptr, bool DefaultDiagColor=true, bool DefaultShowOpt=true)
Fill out Opts based on the options given in Args.
static void ParseFileSystemArgs(FileSystemOptions &Opts, ArgList &Args)
unsigned NoFinalizeRemoval
MSVtorDispMode
In the Microsoft ABI, this controls the placement of virtual displacement members used to implement v...
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
static void ParseCommentArgs(CommentOptions &Opts, ArgList &Args)
Conform to the underlying platform's C and C++ ABIs as closely as we can.
unsigned InlineMaxStackDepth
The inlining stack depth limit.
Paths for '#include <>' added by '-I'.
std::string ModuleDependencyOutputDir
The directory to copy module dependencies to when collecting them.
std::string ObjCMTWhiteListPath
std::string DwarfDebugFlags
The string to embed in the debug information for the compile unit, if non-empty.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
std::string DOTOutputFile
The file to write GraphViz-formatted header dependencies to.
void addMacroUndef(StringRef Name)
static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, DiagnosticsEngine &Diags, bool &IsHeaderFile)
Generate pre-compiled module from a module map.
Attempt to be ABI-compatible with code generated by Clang 6.0.x (SVN r321711).
unsigned IncludeBriefComments
Show brief documentation comments in code completion results.
static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, const TargetOptions &TargetOpts, PreprocessorOptions &PPOpts, DiagnosticsEngine &Diags)
std::string SaveTempsFilePrefix
Prefix to use for -save-temps output.
TargetOptions & getTargetOpts()
Print the output of the dependency directives source minimizer.
Parse and perform semantic analysis.
ObjCXXARCStandardLibraryKind
Enumerate the kinds of standard library that.
static StringRef getCodeModel(ArgList &Args, DiagnosticsEngine &Diags)
unsigned ShowCheckerHelpDeveloper
unsigned IncludeGlobals
Show top-level decls in code completion results.
SanitizerSet Sanitize
Set of enabled sanitizers.
Like System, but headers are implicitly wrapped in extern "C".
DependencyOutputOptions & getDependencyOutputOpts()
std::shared_ptr< HeaderSearchOptions > HeaderSearchOpts
Options controlling the #include directive.
prefer 'atomic' property over 'nonatomic'.
std::shared_ptr< llvm::Regex > OptimizationRemarkMissedPattern
Regular expression to select optimizations for which we should enable missed optimization remarks...
static unsigned getOptimizationLevel(ArgList &Args, InputKind IK, DiagnosticsEngine &Diags)
static StringRef getStringOption(AnalyzerOptions::ConfigTable &Config, StringRef OptionName, StringRef DefaultVal)
LangStandard - Information about the properties of a particular language standard.
CoreFoundationABI CFRuntime
unsigned IncludeModuleFiles
Include module file dependencies.
void set(XRayInstrMask K, bool Value)
Parse ASTs and print them.
bool hasDigraphs() const
hasDigraphs - Language supports digraphs.
Like System, but only used for C++.
std::string HeaderIncludeOutputFile
The file to write header include output to.
std::vector< std::string > Includes
static bool parseDiagnosticLevelMask(StringRef FlagName, const std::vector< std::string > &Levels, DiagnosticsEngine *Diags, DiagnosticLevelMask &M)
std::string OptRecordPasses
The regex that filters the passes that should be saved to the optimization records.
Defines types useful for describing an Objective-C runtime.
unsigned visualizeExplodedGraphWithGraphViz
std::string SampleProfileFile
Name of the profile file to use with -fprofile-sample-use.
Like System, but only used for ObjC++.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
#define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATFN)
std::shared_ptr< LangOptions > LangOpts
Options controlling the language variant.
static std::vector< StringRef > getRegisteredCheckers(bool IncludeExperimental=false)
Retrieves the list of checkers generated from Checkers.td.
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
std::vector< std::string > Reciprocals
std::vector< std::string > RewriteMapFiles
Set of files defining the rules for the symbol rewriting.
static const LangStandard & getLangStandardForKind(Kind K)
std::string ASTDumpFilter
If given, filter dumped AST Decl nodes by this substring.
FPRoundingModeKind
Possible rounding modes.
Objects with "hidden" visibility are not seen by the dynamic linker.
static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args, const std::string &WorkingDir)
for(auto typeArg :T->getTypeArgsAsWritten())
Options for controlling the target.
bool PropagateAttrs
If true, we set attributes functions in the bitcode library according to our CodeGenOptions, much as we set attrs on functions that we generate ourselves.
void addRemappedFile(StringRef From, StringRef To)
static void parseAnalyzerConfigs(AnalyzerOptions &AnOpts, DiagnosticsEngine *Diags)
std::string FixItSuffix
If given, the new suffix for fix-it rewritten files.
std::string HostTriple
When compiling for the device side, contains the triple used to compile for the host.
std::string SplitDwarfFile
The name for the split debug info file used for the DW_AT_[GNU_]dwo_name attribute in the skeleton CU...
Like System, but searched after the system directories.
std::string DebugPass
Enable additional debugging information.
Don't generate debug info.
unsigned TimeTraceGranularity
Minimum time granularity (in microseconds) traced by time profiler.
float __ovld __cnfn normalize(float p)
Returns a vector in the same direction as p but with a length of 1.
SanitizerSet SanitizeRecover
Set of sanitizer checks that are non-fatal (i.e.
Parse and apply any fixits to the source.
Defines the clang::SanitizerKind enum.
unsigned TimeTrace
Output time trace profile.
static void setPGOInstrumentor(CodeGenOptions &Opts, ArgList &Args, DiagnosticsEngine &Diags)
'macosx-fragile' is the Apple-provided NeXT-derived runtime on Mac OS X platforms that use the fragil...
std::map< std::string, std::string > DebugPrefixMap
std::vector< std::string > XRayAlwaysInstrumentFiles
Paths to the XRay "always instrument" files specifying which objects (files, functions, variables) should be imbued with the XRay "always instrument" attribute.
bool isCPlusPlus14() const
isCPlusPlus14 - Language is a C++14 variant (or later).
std::string FPMath
If given, the unit to use for floating point math.
static std::shared_ptr< llvm::Regex > GenerateOptimizationRemarkRegex(DiagnosticsEngine &Diags, ArgList &Args, Arg *RpassArg)
Create a new Regex instance out of the string value in RpassArg.
LLVM_READONLY bool isLetter(unsigned char c)
Return true if this character is an ASCII letter: [a-zA-Z].
std::map< std::string, std::string, std::greater< std::string > > MacroPrefixMap
A prefix map for FILE and BASE_FILE.
unsigned IncludeSystemHeaders
Include system header dependencies.
ShowIncludesDestination ShowIncludesDest
Destination of cl.exe style /showIncludes info.
static Kind getLangKind(StringRef Name)
Translate input source into HTML.
static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, DiagnosticsEngine &Diags, const TargetOptions &TargetOpts, const FrontendOptions &FrontendOpts)
std::string SplitDwarfOutput
Output filename for the split debug info, not used in the skeleton CU.
uint64_t getLastArgUInt64Value(const llvm::opt::ArgList &Args, llvm::opt::OptSpecifier Id, uint64_t Default, DiagnosticsEngine *Diags=nullptr, unsigned Base=0)
Interoperability with the Swift 4.1 runtime.
SanitizerMask Mask
Bitmask of enabled sanitizers.
Enable migration to add conforming protocols.
std::vector< uint8_t > CmdArgs
List of backend command-line options for -fembed-bitcode.
std::string DumpExplodedGraphTo
File path to which the exploded graph should be dumped.
__DEVICE__ int max(int __a, int __b)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
std::vector< std::string > ASTMergeFiles
The list of AST files to merge.
std::string CodeModel
The code model to use (-mcmodel).
std::vector< std::string > ModulesEmbedFiles
The list of files to embed into the compiled module file.
unsigned RelocatablePCH
When generating PCH files, instruct the AST writer to create relocatable PCH files.
Objects with "default" visibility are seen by the dynamic linker and act like normal objects...
std::shared_ptr< PreprocessorOptions > PreprocessorOpts
Options controlling the preprocessor (aside from #include handling).
unsigned IncludeCodePatterns
Show code patterns in code completion results.
Is determined by runtime environment, corresponds to "round.dynamic".
unsigned ShowCheckerHelpAlpha
Action - Represent an abstract compilation step to perform.
Generate LLVM IR, but do not emit anything.
static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args, DiagnosticsEngine &Diags)
std::vector< std::string > XRayAttrListFiles
Paths to the XRay attribute list files, specifying which objects (files, functions, variables) should be imbued with the appropriate XRay attribute(s).
CodeGenOptions & getCodeGenOpts()
bool hasLineComments() const
Language supports '//' comments.
unsigned ShowStats
Show frontend performance metrics and statistics.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
static void ParseDependencyOutputArgs(DependencyOutputOptions &Opts, ArgList &Args)
Emit only debug directives with the line numbers data.
static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args, DiagnosticsEngine &Diags)
std::vector< std::string > PassPlugins
List of dynamic shared object files to be loaded as pass plugins.
Visibility
Describes the different kinds of visibility that a declaration may have.
bool isOpenCL() const
isOpenCL - Language is a OpenCL variant.
bool isCPlusPlus2a() const
isCPlusPlus2a - Language is a post-C++17 variant (or later).
SmallVector< FrontendInputFile, 0 > Inputs
The input files and their types.
Concrete class used by the front-end to report problems and issues.
unsigned FixWhatYouCan
Apply fixes even if there are unfixable errors.
Defines the Diagnostic-related interfaces.
unsigned ShowCheckerOptionList
std::string FullCompilerInvocation
Store full compiler invocation for reproducible instructions in the generated report.
std::vector< std::string > Warnings
The list of -W...
AnalysisStores
AnalysisStores - Set of available analysis store models.
constexpr XRayInstrMask All
bool isCPlusPlus() const
isCPlusPlus - Language is a C++ variant.
bool DisablePCHValidation
When true, disables most of the normal validation performed on precompiled headers.
Interoperability with the Swift 5.0 runtime.
VersionTuple getOpenCLVersionTuple() const
Return the OpenCL C or C++ version as a VersionTuple.
Languages that the frontend can parse and compile.
static void setPGOUseInstrumentor(CodeGenOptions &Opts, const Twine &ProfileName)
unsigned FixAndRecompile
Apply fixes and recompile.
Defines the clang::Visibility enumeration and various utility functions.
std::string FloatABI
The ABI to use for passing floating point arguments.
std::vector< std::string > ModuleFeatures
The names of any features to enable in module 'requires' decls in addition to the hard-coded list in ...
PreprocessorOutputOptions & getPreprocessorOutputOpts()
std::string ThreadModel
The thread model to use.
FrontendOptions & getFrontendOpts()
std::vector< std::string > DependentLibraries
A list of dependent libraries.
bool DetailedRecord
Whether we should maintain a detailed record of all macro definitions and expansions.
Dump the compiler configuration.
MigratorOptions & getMigratorOpts()
Dump template instantiations.
std::string ProfileFilterFiles
Regexes separated by a semi-colon to filter the files to instrument.
std::string ProfileRemappingFile
Name of the profile remapping file to apply to the profile data supplied by -fprofile-sample-use or -...
char CoverageVersion[4]
The version string to put into coverage files.
Dump out preprocessed tokens.
unsigned DisableAllCheckers
Disable all analyzer checkers.
std::string CurrentModule
The name of the current module, of which the main source file is a part.
const char * getName() const
getName - Get the name of this standard.
AnalysisDiagClients AnalysisDiagOpt
const llvm::opt::OptTable & getDriverOptTable()
std::vector< std::string > NoBuiltinFuncs
A list of all -fno-builtin-* function names (e.g., memset).
std::vector< std::string > ChainedIncludes
Headers that will be converted to chained PCHs in memory.
Interoperability with the ObjectiveC runtime.
PreprocessorOutputOptions - Options for controlling the C preprocessor output (e.g., -E).
static bool IsHeaderFile(const std::string &Filename)
std::string LimitFloatPrecision
The float precision limit to use, if non-empty.
unsigned ASTDumpAll
Whether we deserialize all decls when forming AST dumps.
Generate pre-compiled module from a C++ module interface file.
static void setLangDefaults(LangOptions &Opts, InputKind IK, const llvm::Triple &T, PreprocessorOptions &PPOpts, LangStandard::Kind LangStd=LangStandard::lang_unspecified)
Set language defaults for the given input language and language standard in the given LangOptions obj...
AnalysisInliningMode InliningMode
The mode of function selection used during inlining.
CommentOptions CommentOpts
Options for parsing comments.
static std::string GetResourcesPath(const char *Argv0, void *MainAddr)
Get the directory where the compiler headers reside, relative to the compiler binary (found by the pa...
bool isCPlusPlus11() const
isCPlusPlus11 - Language is a C++11 variant (or later).
static std::vector< StringRef > getRegisteredPackages(bool IncludeExperimental=false)
Retrieves the list of packages generated from Checkers.td.
Defines the clang::LangOptions interface.
std::vector< std::string > Plugins
The list of plugins to load.
Show just the "best" overload candidates.
IncludeDirGroup
IncludeDirGroup - Identifies the group an include Entry belongs to, representing its relative positiv...
Limit generated debug info to reduce size (-fno-standalone-debug).
unsigned ShowEnabledCheckerList
std::string WorkingDir
If set, paths are resolved as if the working directory was set to the value of WorkingDir.
clang::Language getLanguage() const
Get the language that this standard describes.
std::string OMPHostIRFile
Name of the IR file that contains the result of the OpenMP target host code generation.
std::set< std::string > DeserializedPCHDeclsToErrorOn
This is a set of names for decls that we do not want to be deserialized, and we emit an error if they...
enum clang::FrontendOptions::@196 ARCMTAction
unsigned RewriteIncludes
Preprocess include directives only.
ASTDumpOutputFormat
Used to specify the format for printing AST dump information.
unsigned ShowTimers
Show timers for individual actions.
std::string LinkerVersion
If given, the version string of the linker in use.
Generate Interface Stub Files.
Only execute frontend initialization.
std::vector< std::string > SilencedCheckersAndPackages
Vector of checker/package names which will not emit warnings.
Defines version macros and version-related utility functions for Clang.
unsigned IncludeNamespaceLevelDecls
Show decls in namespace (including the global namespace) in code completion results.
Print the "preamble" of the input file.
unsigned LinkFlags
Bitwise combination of llvm::Linker::Flags, passed to the LLVM linker.
llvm::hash_code hash_value(const clang::SanitizerMask &Arg)
FPExceptionModeKind
Possible floating point exception behavior.
static llvm::Reloc::Model getRelocModel(ArgList &Args, DiagnosticsEngine &Diags)
bool tryParse(StringRef input)
Try to parse an Objective-C runtime specification from the given string.
bool PCHWithHdrStop
When true, we are creating or using a PCH where a #pragma hdrstop is expected to indicate the beginni...
unsigned ShowHeaderIncludes
Show header inclusions (-H).
std::shared_ptr< llvm::Regex > OptimizationRemarkPattern
Regular expression to select optimizations for which we should enable optimization remarks...
bool hasImplicitInt() const
hasImplicitInt - Language allows variables to be typed as int implicitly.
LLVM_READONLY bool isAlphanumeric(unsigned char c)
Return true if this character is an ASCII letter or digit: [a-zA-Z0-9].
static bool IsInputCompatibleWithStandard(InputKind IK, const LangStandard &S)
Check if input file kind and language standard are compatible.
void clear(SanitizerMask K=SanitizerKind::All)
Disable the sanitizers specified in K.
unsigned ModulesEmbedAllFiles
Whether we should embed all used files into the PCM file.
unsigned ShowConfigOptionsList
Enable migration of ObjC methods to 'instancetype'.
AnalysisInliningMode
AnalysisInlineFunctionSelection - Set of inlining function selection heuristics.
Enable migration to modern ObjC subscripting.
annotate property with NS_RETURNS_INNER_POINTER
Objects with "protected" visibility are seen by the dynamic linker but always dynamically resolve to ...
unsigned ShowMacros
Print macro definitions.
bool isC2x() const
isC2x - Language is a superset of C2x.
clang::ObjCRuntime ObjCRuntime
static void ParsePreprocessorOutputArgs(PreprocessorOutputOptions &Opts, ArgList &Args, frontend::ActionKind Action)
static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args, DiagnosticsEngine &Diags, frontend::ActionKind Action)
unsigned FixOnlyWarnings
Apply fixes only for warnings.
unsigned NoNSAllocReallocError
int getLastArgIntValue(const llvm::opt::ArgList &Args, llvm::opt::OptSpecifier Id, int Default, DiagnosticsEngine *Diags=nullptr, unsigned Base=0)
Return the value of the last argument as an integer, or a default.
unsigned AnalyzerWerror
Emit analyzer warnings as errors.
std::string OptRecordFormat
The format used for serializing remarks (default: YAML)
bool ForceEnableInt128
If given, enables support for __int128_t and __uint128_t types.
The result type of a method or function.
Enable inferring NS_DESIGNATED_INITIALIZER for ObjC methods.
Attempt to be ABI-compatible with code generated by Clang 3.8.x (SVN r257626).
static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group, OptSpecifier GroupWithValue, std::vector< std::string > &Diagnostics)
std::string AuxTriple
Auxiliary triple for CUDA compilation.
bool isC11() const
isC11 - Language is a superset of C11.
Defines the clang::XRayInstrKind enum.
bool AllowPCHWithCompilerErrors
When true, a PCH with compiler errors will not be rejected.
std::string CPU
If given, the name of the target CPU to generate code for.
bool hasHexFloats() const
hasHexFloats - Language supports hexadecimal float constants.
unsigned ShowIncludeDirectives
Print includes, imports etc. within preprocessed output.
SanitizerMask getPPTransparentSanitizers()
Return the sanitizers which do not affect preprocessing.
Enable migration to modern ObjC property.
std::string Filename
The filename of the bitcode file to link in.
unsigned ARCMTMigrateEmitARCErrors
Emit ARC errors even if the migrator can fix them.
void set(SanitizerMask K, bool Value)
Enable or disable a certain (single) sanitizer.
static void initOption(AnalyzerOptions::ConfigTable &Config, DiagnosticsEngine *Diags, StringRef &OptionField, StringRef Name, StringRef DefaultVal)
std::string ABI
If given, the name of the target ABI to use.
AnalysisConstraints
AnalysisConstraints - Set of available constraint models.
llvm::StringMap< std::string > ConfigTable
Permit no implicit vector bitcasts.
AnalyzerOptionsRef getAnalyzerOpts() const
AnalysisStores AnalysisStoreOpt
Encodes a location in the source.
Generate machine code, but don't emit anything.
std::vector< std::string > ModuleFiles
The list of additional prebuilt module files to load before processing the input. ...
ParsedSourceLocation CodeCompletionAt
If given, enable code completion at the provided location.
std::string ImplicitPCHInclude
The implicit PCH included at the start of the translation unit, or empty.
Rounding to nearest, corresponds to "round.tonearest".
Generate complete debug info.
Options for controlling the compiler diagnostics engine.
Attempt to be ABI-compatible with code generated by Clang 4.0.x (SVN r291814).
ConfigTable Config
A key-value table of use-specified configuration values.
std::string DiagnosticSerializationFile
The file to serialize diagnostics to (non-appending).
#define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATFN)
unsigned IncludeTimestamps
Whether timestamps should be written to the produced PCH file.
Parse ASTs and view them in Graphviz.
unsigned ShowCheckerOptionDeveloperList
std::vector< std::string > Remarks
The list of -R...
std::vector< std::string > OpenCLExtensionsAsWritten
The list of OpenCL extensions to enable or disable, as written on the command line.
std::vector< std::string > DefaultFunctionAttrs
Parse ASTs and list Decl nodes.
std::vector< std::pair< std::string, bool > > CheckersAndPackages
Pairs of checker/package name and enable/disable.
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
static void getAllNoBuiltinFuncValues(ArgList &Args, std::vector< std::string > &Funcs)
bool PCHWithHdrStopCreate
When true, we are creating a PCH or creating the PCH object while expecting a #pragma hdrstop to sepa...
Defines the clang::TargetOptions class.
std::unordered_map< std::string, std::vector< std::string > > PluginArgs
Args to pass to the plugins.
DiagnosticOptions & getDiagnosticOpts() const
DependencyOutputOptions - Options for controlling the compiler dependency file generation.
unsigned ASTDumpLookups
Whether we include lookup table dumps in AST dumps.
std::vector< std::string > ExtraDeps
A list of filenames to be used as extra dependencies for every target.
Load and verify that a PCH file is usable.
std::shared_ptr< TargetOptions > TargetOpts
Options controlling the target.
std::string ModuleName
The module currently being compiled as specified by -fmodule-name.
SanitizerSet SanitizeTrap
Set of sanitizer checks that trap rather than diagnose.
unsigned UseLineDirectives
Use #line instead of GCC-style # N.
Like System, but only used for ObjC.
unsigned ShowVersion
Show the -version text.
unsigned RewriteImports
Include contents of transitively-imported modules.
Limit generated debug info for classes to reduce size.
std::shared_ptr< llvm::Regex > OptimizationRemarkAnalysisPattern
Regular expression to select optimizations for which we should enable optimization analyses...
std::vector< std::string > FeaturesAsWritten
The list of target specific features to enable or disable, as written on the command line...
XRayInstrSet XRayInstrumentationBundle
Set of XRay instrumentation kinds to emit.
std::vector< BitcodeFileToLink > LinkBitcodeFiles
The files specified here are linked in to the module before optimizations.
constexpr XRayInstrMask None
bool isUnknownAnalyzerConfig(StringRef Name) const
PragmaMSPointersToMembersKind
unsigned GenerateGlobalModuleIndex
Whether we can generate the global module index if needed.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
std::string PCHThroughHeader
If non-empty, the filename used in an #include directive in the primary source file (or command-line ...
static const StringRef GetInputKindName(InputKind IK)
Get language name for given input kind.
void addMacroDef(StringRef Name)
llvm::EABI EABIVersion
The EABI version to use.
'#include ""' paths, added by 'gcc -iquote'.
std::string ThinLTOIndexFile
Name of the function summary index file to use for ThinLTO function importing.
std::vector< std::string > MacroIncludes
unsigned ShowHelp
Show the -help text.
std::string OverrideRecordLayoutsFile
File name of the file that will provide record layouts (in the format produced by -fdump-record-layou...
unsigned FixToTemporaries
Apply fixes to temporary files.
unsigned ShowComments
Show comments.
Like Angled, but marks system directories.
static bool parseTestModuleFileExtensionArg(StringRef Arg, std::string &BlockName, unsigned &MajorVersion, unsigned &MinorVersion, bool &Hashed, std::string &UserInfo)
Parse the argument to the -ftest-module-file-extension command-line argument.
static bool isBuiltinFunc(llvm::StringRef Name)
Returns true if this is a libc/libm function without the '__builtin_' prefix.
unsigned maxBlockVisitOnPath
The maximum number of times the analyzer visits a block.
std::string OutputFile
The file to write dependency output to.
bool allowsARC() const
Does this runtime allow ARC at all?
use NS_NONATOMIC_IOSONLY for property 'atomic' attribute
ASTDumpOutputFormat ASTDumpFormat
Specifies the output format of the AST.
DependencyOutputFormat OutputFormat
The format for the dependency file.
std::string CudaGpuBinaryFileName
Name of file passed with -fcuda-include-gpubinary option to forward to CUDA runtime back-end for inco...
Dataflow Directional Tag Classes.
std::string OverflowHandler
The name of the handler function to be called when -ftrapv is specified.
Assume that floating-point exceptions are masked.
static bool CreateFromArgs(CompilerInvocation &Res, ArrayRef< const char *> CommandLineArgs, DiagnosticsEngine &Diags)
Create a compiler invocation from a list of input options.
static ParsedSourceLocation FromString(StringRef Str)
Construct a parsed source location from a string; the Filename is empty on error. ...
PreprocessorOptions & getPreprocessorOpts()
bool UsePredefines
Initialize the preprocessor with the compiler and target specific predefines.
frontend::ActionKind ProgramAction
The frontend action to perform.
std::vector< llvm::Triple > OMPTargetTriples
Triples of the OpenMP targets that the host code codegen should take into account in order to generat...
std::vector< std::string > VerifyPrefixes
The prefixes for comment directives sought by -verify ("expected" by default).
std::string ARCMTMigrateReportOut
std::string SymbolPartition
The name of the partition that symbols are assigned to, specified with -fsymbol-partition (see https:...
IntrusiveRefCntPtr< llvm::vfs::FileSystem > createVFSFromCompilerInvocation(const CompilerInvocation &CI, DiagnosticsEngine &Diags)
std::string PreferVectorWidth
The preferred width for auto-vectorization transforms.
Emit only debug info necessary for generating line number tables (-gline-tables-only).
std::unique_ptr< DiagnosticConsumer > create(StringRef OutputFile, DiagnosticOptions *Diags, bool MergeChildRecords=false)
Returns a DiagnosticConsumer that serializes diagnostics to a bitcode file.
Like System, but only used for C.
bool empty() const
Returns true if no sanitizers are enabled.
unsigned UseGlobalModuleIndex
Whether we can use the global module index if available.
AnalysisConstraints AnalysisConstraintsOpt
llvm::Reloc::Model RelocationModel
The name of the relocation model to use.
static bool isStrictlyPreprocessorAction(frontend::ActionKind Action)
Helper class for holding the data necessary to invoke the compiler.
std::string DebugCompilationDir
The string to embed in debug information as the current working directory.
Enable migration to modern ObjC literals.
unsigned UsePhonyTargets
Include phony targets for each dependency, which can avoid some 'make' problems.
std::string AnalyzeSpecificFunction
bool IsHeaderFile
Indicates whether the front-end is explicitly told that the input is a header file (i...
FrontendOptions - Options for controlling the behavior of the frontend.
bool isC17() const
isC17 - Language is a superset of C17.
static bool ParseMigratorArgs(MigratorOptions &Opts, ArgList &Args)
SanitizerMask parseSanitizerValue(StringRef Value, bool AllowGroups)
Parse a single value from a -fsanitize= or -fno-sanitize= value list.
bool isGNUMode() const
isGNUMode - Language includes GNU extensions.
std::string StatsFile
Filename to write statistics to.
Assembly: we accept this only so that we can preprocess it.
Parse ASTs and dump them.
Emit location information but do not generate debug info in the output.
std::string ProfileExcludeFiles
Regexes separated by a semi-colon to filter the files to not instrument.
std::string CoverageDataFile
The filename with path we use for coverage data files.
bool DisablePragmaDebugCrash
Prevents intended crashes when using #pragma clang __debug. For testing.
Defines the clang::FileSystemOptions interface.
std::vector< std::string > LinkerOptions
A list of linker options to embed in the object file.
std::string RecordCommandLine
The string containing the commandline for the llvm.commandline metadata, if non-empty.
unsigned UseTemporary
Should a temporary file be used during compilation.
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
std::vector< std::shared_ptr< ModuleFileExtension > > ModuleFileExtensions
The list of module file extensions.
CodeCompleteOptions CodeCompleteOpts
static bool parseShowColorsArgs(const ArgList &Args, bool DefaultColor)
IntrusiveRefCntPtr< DiagnosticOptions > DiagnosticOpts
Options controlling the diagnostic engine.
bool hasReducedDebugInfo() const
Check if type and variable info should be emitted.
std::vector< std::string > AddPluginActions
The list of plugin actions to run in addition to the normal action.
ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary
The Objective-C++ ARC standard library that we should support, by providing appropriate definitions t...
AnalysisPurgeMode
AnalysisPurgeModes - Set of available strategies for dead symbol removal.
Stores options for the analyzer from the command line.
unsigned AnalyzerDisplayProgress
~CompilerInvocationBase()
Keeps track of options that affect how file operations are performed.
unsigned DisableFree
Disable memory freeing on exit.
Generate pre-compiled header.
Enable migration to modern ObjC readwrite property.
Generate pre-compiled module from a set of header files.
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
unsigned ShowMacroComments
Show comments, even in macros.
unsigned PrintSupportedCPUs
print the supported cpus for the current target
unsigned ShowCheckerOptionAlphaList
Defines the clang::SourceLocation class and associated facilities.
unsigned AnalyzeNestedBlocks
unsigned NoRetryExhausted
Do not re-analyze paths leading to exhausted nodes with a different strategy.
Interoperability with the Swift 4.2 runtime.
bool Internalize
If true, we use LLVM module internalizer.
std::vector< std::string > XRayNeverInstrumentFiles
Paths to the XRay "never instrument" files specifying which objects (files, functions, variables) should be imbued with the XRay "never instrument" attribute.
bool NVPTXUseShortPointers
If enabled, use 32-bit pointers for accessing const/local/shared address space.
std::string MainFileName
The user provided name for the "main file", if non-empty.
Enable migration to NS_ENUM/NS_OPTIONS macros.
std::vector< std::string > NoBuiltinFuncs
A list of all -fno-builtin-* function names (e.g., memset).
static bool checkVerifyPrefixes(const std::vector< std::string > &VerifyPrefixes, DiagnosticsEngine *Diags)
XRayInstrMask parseXRayInstrValue(StringRef Value)
bool isC99() const
isC99 - Language is a superset of C99.
unsigned IncludeFixIts
Include results after corrections (small fix-its), e.g.
unsigned ASTDumpDecls
Whether we include declaration dumps in AST dumps.
std::string ActionName
The name of the action to run when using a plugin action.
unsigned ShowLineMarkers
Show #line markers.
Enable migration to modern ObjC readonly property.
bool isCPlusPlus17() const
isCPlusPlus17 - Language is a C++17 variant (or later).
bool SetUpStaticAnalyzer
Set up preprocessor for RunAnalysis action.
FileSystemOptions & getFileSystemOpts()
static unsigned getOptimizationLevelSize(ArgList &Args)
Run one or more source code analyses.
bool has(SanitizerMask K) const
Check if a certain (single) sanitizer is enabled.
Attempt to be ABI-compatible with code generated by Clang 9.0.x (SVN r351319).
std::pair< unsigned, bool > PrecompiledPreambleBytes
If non-zero, the implicit PCH include is actually a precompiled preamble that covers this number of b...
#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATFN)
std::vector< std::string > LLVMArgs
A list of arguments to forward to LLVM's option processing; this should only be used for debugging an...
std::vector< std::string > Targets
A list of names to use as the targets in the dependency file; this list must contain at least one ent...
Enable annotation of ObjCMethods of all kinds.
std::string InstrProfileOutput
Name of the profile file to use as output for -fprofile-instr-generate, -fprofile-generate, and -fcs-profile-generate.
const char * getDescription() const
getDescription - Get the description of this standard.
std::string TrapFuncName
If not an empty string, trap intrinsics are lowered to calls to this function instead of to trap inst...
DiagnosticLevelMask
A bitmask representing the diagnostic levels used by VerifyDiagnosticConsumer.
LLVM IR: we accept this so that we can run the optimizer on it, and compile it to assembly or object ...
Dump information about a module file.
std::string OptRecordFile
The name of the file to which the backend should save YAML optimization records.
llvm::DenormalMode FPDenormalMode
The floating-point denormal mode to use.
unsigned AddMissingHeaderDeps
Add missing headers to dependency list.
std::string ThinLinkBitcodeFile
Name of a file that can optionally be written with minimized bitcode to be used as input for the Thin...
std::vector< std::string > SanitizerBlacklistFiles
Paths to blacklist files specifying which objects (files, functions, variables) should not be instrum...
Enable converting setter/getter expressions to property-dot syntx.
unsigned ShowCPP
Print normal preprocessed output.
Like Angled, but marks header maps used when building frameworks.
unsigned ShouldEmitErrorsOnInvalidConfigValue
llvm::VersionTuple SDKVersion
The version of the SDK which was used during the compilation.
static InputKind getInputKindForExtension(StringRef Extension)
getInputKindForExtension - Return the appropriate input kind for a file extension.
std::string ObjCConstantStringClass
#define ANALYSIS_INLINING_MODE(NAME, CMDFLAG, DESC)
unsigned IncludeMacros
Show macros in code completion results.
AnalysisPurgeMode AnalysisPurgeOpt
LangOptions * getLangOpts()
static void parseXRayInstrumentationBundle(StringRef FlagName, StringRef Bundle, ArgList &Args, DiagnosticsEngine &D, XRayInstrSet &S)
Strictly preserve the floating-point exception semantics.
bool DumpDeserializedPCHDecls
Dump declarations that are deserialized from PCH, for testing.
AnalysisDiagClients
AnalysisDiagClients - Set of available diagnostic clients for rendering analysis results.
Attempt to be ABI-compatible with code generated by Clang 7.0.x (SVN r338536).
std::string Triple
The name of the target triple to compile for.
#define ANALYSIS_PURGE(NAME, CMDFLAG, DESC)
Defines enum values for all the target-independent builtin functions.
std::string getModuleHash() const
Retrieve a module hash string that is suitable for uniquely identifying the conditions under which th...
static void parseSanitizerKinds(StringRef FlagName, const std::vector< std::string > &Sanitizers, DiagnosticsEngine &Diags, SanitizerSet &S)
bool allowsWeak() const
Does this runtime allow the use of __weak?
std::string DiagnosticLogFile
The file to log diagnostic output to.
Transformations do not cause new exceptions but may hide some.
bool LexEditorPlaceholders
When enabled, the preprocessor will construct editor placeholder tokens.
std::vector< std::string > ModuleMapFiles
The list of module map files to load before processing the input.