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;
291 !llvm::StringSwitch<bool>(
292 Args.getLastArgValue(OPT_analyzer_config_compatibility_mode))
294 .Case(
"false",
false)
299 Args.hasArg(OPT_analyzer_viz_egraph_graphviz);
302 Opts.
AnalyzeAll = Args.hasArg(OPT_analyzer_opt_analyze_headers);
305 Args.hasArg(OPT_analyzer_opt_analyze_nested_blocks);
308 Opts.
TrimGraph = Args.hasArg(OPT_trim_egraph);
311 Opts.
PrintStats = Args.hasArg(OPT_analyzer_stats);
318 Args.filtered(OPT_analyzer_checker, OPT_analyzer_disable_checker)) {
320 bool enable = (A->getOption().getID() == OPT_analyzer_checker);
323 StringRef checkerList = A->getValue();
325 checkerList.split(checkers,
",");
326 for (
auto checker : checkers)
331 for (
const auto *A : Args.filtered(OPT_analyzer_config)) {
335 StringRef configList = A->getValue();
337 configList.split(configVals,
",");
338 for (
const auto &configVal : configVals) {
340 std::tie(key, val) = configVal.split(
"=");
343 diag::err_analyzer_config_no_value) << configVal;
347 if (val.find(
'=') != StringRef::npos) {
349 diag::err_analyzer_config_multiple_values)
359 Diags.
Report(diag::err_analyzer_config_unknown) << key;
374 for (
unsigned i = 0; i < Args.getNumInputArgStrings(); ++i) {
377 os << Args.getArgString(i);
385 StringRef OptionName, StringRef DefaultVal) {
386 return Config.insert({OptionName, DefaultVal}).first->second;
391 StringRef &OptionField, StringRef Name,
392 StringRef DefaultVal) {
401 bool &OptionField, StringRef Name,
bool DefaultVal) {
402 auto PossiblyInvalidVal = llvm::StringSwitch<Optional<bool>>(
405 .Case(
"false",
false)
408 if (!PossiblyInvalidVal) {
410 Diags->
Report(diag::err_analyzer_config_invalid_input)
411 << Name <<
"a boolean";
413 OptionField = DefaultVal;
415 OptionField = PossiblyInvalidVal.getValue();
420 unsigned &OptionField, StringRef Name,
421 unsigned DefaultVal) {
423 OptionField = DefaultVal;
424 bool HasFailed =
getStringOption(Config, Name, std::to_string(DefaultVal))
425 .getAsInteger(10, OptionField);
426 if (Diags && HasFailed)
427 Diags->
Report(diag::err_analyzer_config_invalid_input)
428 << Name <<
"an unsigned";
436 #define ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, DEFAULT_VAL) \ 437 initOption(AnOpts.Config, Diags, AnOpts.NAME, CMDFLAG, DEFAULT_VAL); 439 #define ANALYZER_OPTION_DEPENDS_ON_USER_MODE(TYPE, NAME, CMDFLAG, DESC, \ 440 SHALLOW_VAL, DEEP_VAL) \ 441 switch (AnOpts.getUserMode()) { \ 443 initOption(AnOpts.Config, Diags, AnOpts.NAME, CMDFLAG, SHALLOW_VAL); \ 446 initOption(AnOpts.Config, Diags, AnOpts.NAME, CMDFLAG, DEEP_VAL); \ 450 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.def" 451 #undef ANALYZER_OPTION 452 #undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE 459 if (!AnOpts.CTUDir.empty() && !llvm::sys::fs::is_directory(AnOpts.CTUDir))
460 Diags->
Report(diag::err_analyzer_config_invalid_input) <<
"ctu-dir" 463 if (!AnOpts.ModelPath.empty() &&
464 !llvm::sys::fs::is_directory(AnOpts.ModelPath))
465 Diags->
Report(diag::err_analyzer_config_invalid_input) <<
"model-path" 481 if (Arg *A = Args.getLastArg(OPT_mcode_model)) {
482 StringRef
Value = A->getValue();
483 if (Value ==
"small" || Value ==
"kernel" || Value ==
"medium" ||
484 Value ==
"large" || Value ==
"tiny")
486 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) <<
Value;
493 if (Arg *A = Args.getLastArg(OPT_mrelocation_model)) {
494 StringRef
Value = A->getValue();
495 auto RM = llvm::StringSwitch<llvm::Optional<llvm::Reloc::Model>>(
Value)
496 .Case(
"static", llvm::Reloc::Static)
497 .Case(
"pic", llvm::Reloc::PIC_)
498 .Case(
"ropi", llvm::Reloc::ROPI)
499 .Case(
"rwpi", llvm::Reloc::RWPI)
500 .Case(
"ropi-rwpi", llvm::Reloc::ROPI_RWPI)
501 .Case(
"dynamic-no-pic", llvm::Reloc::DynamicNoPIC)
505 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) <<
Value;
507 return llvm::Reloc::PIC_;
512 static std::shared_ptr<llvm::Regex>
515 StringRef Val = RpassArg->getValue();
516 std::string RegexError;
517 std::shared_ptr<llvm::Regex> Pattern = std::make_shared<llvm::Regex>(Val);
518 if (!Pattern->isValid(RegexError)) {
519 Diags.
Report(diag::err_drv_optimization_remark_pattern)
520 << RegexError << RpassArg->getAsString(Args);
527 const std::vector<std::string> &Levels,
531 for (
const auto &
Level : Levels) {
533 llvm::StringSwitch<DiagnosticLevelMask>(
Level)
542 Diags->
Report(diag::err_drv_invalid_value) << FlagName <<
Level;
550 const std::vector<std::string> &Sanitizers,
552 for (
const auto &Sanitizer : Sanitizers) {
555 Diags.
Report(diag::err_drv_invalid_value) << FlagName << Sanitizer;
565 llvm::SplitString(Bundle, BundleParts,
",");
566 for (
const auto B : BundleParts) {
570 D.
Report(diag::err_drv_invalid_value) << FlagName << Bundle;
583 Arg *A = Args.getLastArg(OPT_fprofile_instrument_EQ);
586 StringRef S = A->getValue();
587 unsigned I = llvm::StringSwitch<unsigned>(S)
593 Diags.
Report(diag::err_drv_invalid_pgo_instrumentor) << A->getAsString(Args)
598 Opts.setProfileInstr(Instrumentor);
603 const Twine &ProfileName) {
606 if (
auto E = ReaderOrErr.takeError()) {
607 llvm::consumeError(std::move(E));
611 std::unique_ptr<llvm::IndexedInstrProfReader> PGOReader =
612 std::move(ReaderOrErr.get());
613 if (PGOReader->isIRLevelProfile())
624 llvm::Triple Triple = llvm::Triple(TargetOpts.
Triple);
628 unsigned MaxOptLevel = 3;
629 if (OptimizationLevel > MaxOptLevel) {
632 Diags.
Report(diag::warn_drv_optimization_value)
633 << Args.getLastArg(OPT_O)->getAsString(Args) <<
"-O" << MaxOptLevel;
634 OptimizationLevel = MaxOptLevel;
636 Opts.OptimizationLevel = OptimizationLevel;
640 Opts.setInlining((Opts.OptimizationLevel == 0)
645 if (Arg *InlineArg = Args.getLastArg(
646 options::OPT_finline_functions, options::OPT_finline_hint_functions,
647 options::OPT_fno_inline_functions, options::OPT_fno_inline)) {
648 if (Opts.OptimizationLevel > 0) {
649 const Option &InlineOpt = InlineArg->getOption();
650 if (InlineOpt.matches(options::OPT_finline_functions))
651 Opts.setInlining(CodeGenOptions::NormalInlining);
652 else if (InlineOpt.matches(options::OPT_finline_hint_functions))
659 Opts.ExperimentalNewPassManager = Args.hasFlag(
660 OPT_fexperimental_new_pass_manager, OPT_fno_experimental_new_pass_manager,
661 ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER);
663 Opts.DebugPassManager =
664 Args.hasFlag(OPT_fdebug_pass_manager, OPT_fno_debug_pass_manager,
667 if (Arg *A = Args.getLastArg(OPT_fveclib)) {
668 StringRef Name = A->getValue();
669 if (Name ==
"Accelerate")
671 else if (Name ==
"SVML")
673 else if (Name ==
"none")
676 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
679 if (Arg *A = Args.getLastArg(OPT_debug_info_kind_EQ)) {
681 llvm::StringSwitch<unsigned>(A->getValue())
688 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args)
691 Opts.setDebugInfo(static_cast<codegenoptions::DebugInfoKind>(Val));
693 if (Arg *A = Args.getLastArg(OPT_debugger_tuning_EQ)) {
694 unsigned Val = llvm::StringSwitch<unsigned>(A->getValue())
695 .Case(
"gdb",
unsigned(llvm::DebuggerKind::GDB))
696 .Case(
"lldb",
unsigned(llvm::DebuggerKind::LLDB))
697 .Case(
"sce",
unsigned(llvm::DebuggerKind::SCE))
700 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args)
703 Opts.setDebuggerTuning(static_cast<llvm::DebuggerKind>(Val));
706 Opts.DebugColumnInfo = Args.hasArg(OPT_dwarf_column_info);
707 Opts.EmitCodeView = Args.hasArg(OPT_gcodeview);
708 Opts.CodeViewGHash = Args.hasArg(OPT_gcodeview_ghash);
709 Opts.MacroDebugInfo = Args.hasArg(OPT_debug_info_macro);
710 Opts.WholeProgramVTables = Args.hasArg(OPT_fwhole_program_vtables);
711 Opts.LTOVisibilityPublicStd = Args.hasArg(OPT_flto_visibility_public_std);
713 Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining);
716 Args.getLastArg(OPT_enable_split_dwarf, OPT_enable_split_dwarf_EQ)) {
717 if (A->getOption().matches(options::OPT_enable_split_dwarf)) {
720 StringRef Name = A->getValue();
721 if (Name ==
"single")
723 else if (Name ==
"split")
726 Diags.
Report(diag::err_drv_invalid_value)
727 << A->getAsString(Args) << Name;
731 Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
732 Opts.DebugExplicitImport = Args.hasArg(OPT_dwarf_explicit_import);
733 Opts.DebugFwdTemplateParams = Args.hasArg(OPT_debug_forward_template_params);
734 Opts.EmbedSource = Args.hasArg(OPT_gembed_source);
736 for (
const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ))
740 Args.getLastArg(OPT_emit_llvm_uselists, OPT_no_emit_llvm_uselists))
741 Opts.EmitLLVMUseLists = A->getOption().getID() == OPT_emit_llvm_uselists;
743 Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
744 Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
745 Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
746 Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
747 Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
748 Opts.ForbidGuardVariables = Args.hasArg(OPT_fforbid_guard_variables);
749 Opts.UseRegisterSizedBitfieldAccess = Args.hasArg(
750 OPT_fuse_register_sized_bitfield_access);
751 Opts.RelaxedAliasing = Args.hasArg(OPT_relaxed_aliasing);
752 Opts.StructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa);
753 Opts.NewStructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa) &&
754 Args.hasArg(OPT_new_struct_path_tbaa);
755 Opts.FineGrainedBitfieldAccesses =
756 Args.hasFlag(OPT_ffine_grained_bitfield_accesses,
757 OPT_fno_fine_grained_bitfield_accesses,
false);
760 Opts.MergeAllConstants = Args.hasArg(OPT_fmerge_all_constants);
761 Opts.NoCommon = Args.hasArg(OPT_fno_common);
762 Opts.NoImplicitFloat = Args.hasArg(OPT_no_implicit_float);
764 Opts.SimplifyLibCalls = !(Args.hasArg(OPT_fno_builtin) ||
765 Args.hasArg(OPT_ffreestanding));
766 if (Opts.SimplifyLibCalls)
769 Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops,
770 (Opts.OptimizationLevel > 1));
771 Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
773 Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
774 Opts.Autolink = !Args.hasArg(OPT_fno_autolink);
776 Opts.DebugInfoForProfiling = Args.hasFlag(
777 OPT_fdebug_info_for_profiling, OPT_fno_debug_info_for_profiling,
false);
778 Opts.DebugNameTable =
static_cast<unsigned>(
779 Args.hasArg(OPT_ggnu_pubnames)
780 ? llvm::DICompileUnit::DebugNameTableKind::GNU
781 : Args.hasArg(OPT_gpubnames)
782 ? llvm::DICompileUnit::DebugNameTableKind::Default
784 Opts.DebugRangesBaseAddress = Args.hasArg(OPT_fdebug_ranges_base_address);
788 Args.getLastArgValue(OPT_fprofile_instrument_path_EQ);
790 Args.getLastArgValue(OPT_fprofile_instrument_use_path_EQ);
794 Args.getLastArgValue(OPT_fprofile_remapping_file_EQ);
796 Diags.
Report(diag::err_drv_argument_only_allowed_with)
797 << Args.getLastArg(OPT_fprofile_remapping_file_EQ)->getAsString(Args)
798 <<
"-fexperimental-new-pass-manager";
801 Opts.CoverageMapping =
802 Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping,
false);
803 Opts.DumpCoverageMapping = Args.hasArg(OPT_dump_coverage_mapping);
804 Opts.AsmVerbose = Args.hasArg(OPT_masm_verbose);
805 Opts.PreserveAsmComments = !Args.hasArg(OPT_fno_preserve_as_comments);
806 Opts.AssumeSaneOperatorNew = !Args.hasArg(OPT_fno_assume_sane_operator_new);
807 Opts.ObjCAutoRefCountExceptions = Args.hasArg(OPT_fobjc_arc_exceptions);
808 Opts.CXAAtExit = !Args.hasArg(OPT_fno_use_cxa_atexit);
809 Opts.RegisterGlobalDtorsWithAtExit =
810 Args.hasArg(OPT_fregister_global_dtors_with_atexit);
811 Opts.CXXCtorDtorAliases = Args.hasArg(OPT_mconstructor_aliases);
813 Opts.
DebugPass = Args.getLastArgValue(OPT_mdebug_pass);
815 (Args.hasArg(OPT_mdisable_fp_elim) || Args.hasArg(OPT_pg));
816 Opts.DisableFree = Args.hasArg(OPT_disable_free);
817 Opts.DiscardValueNames = Args.hasArg(OPT_discard_value_names);
818 Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
819 Opts.NoEscapingBlockTailCalls =
820 Args.hasArg(OPT_fno_escaping_block_tail_calls);
821 Opts.
FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
822 Opts.LessPreciseFPMAD = Args.hasArg(OPT_cl_mad_enable) ||
823 Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
824 Args.hasArg(OPT_cl_fast_relaxed_math);
826 Opts.NoInfsFPMath = (Args.hasArg(OPT_menable_no_infinities) ||
827 Args.hasArg(OPT_cl_finite_math_only) ||
828 Args.hasArg(OPT_cl_fast_relaxed_math));
829 Opts.NoNaNsFPMath = (Args.hasArg(OPT_menable_no_nans) ||
830 Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
831 Args.hasArg(OPT_cl_finite_math_only) ||
832 Args.hasArg(OPT_cl_fast_relaxed_math));
833 Opts.NoSignedZeros = (Args.hasArg(OPT_fno_signed_zeros) ||
834 Args.hasArg(OPT_cl_no_signed_zeros) ||
835 Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
836 Args.hasArg(OPT_cl_fast_relaxed_math));
837 Opts.Reassociate = Args.hasArg(OPT_mreassociate);
838 Opts.FlushDenorm = Args.hasArg(OPT_cl_denorms_are_zero) ||
839 (Args.hasArg(OPT_fcuda_is_device) &&
840 Args.hasArg(OPT_fcuda_flush_denormals_to_zero));
841 Opts.CorrectlyRoundedDivSqrt =
842 Args.hasArg(OPT_cl_fp32_correctly_rounded_divide_sqrt);
844 Args.hasArg(OPT_cl_uniform_work_group_size);
845 Opts.
Reciprocals = Args.getAllArgValues(OPT_mrecip_EQ);
846 Opts.ReciprocalMath = Args.hasArg(OPT_freciprocal_math);
847 Opts.NoTrappingMath = Args.hasArg(OPT_fno_trapping_math);
848 Opts.StrictFloatCastOverflow =
849 !Args.hasArg(OPT_fno_strict_float_cast_overflow);
851 Opts.NoZeroInitializedInBSS = Args.hasArg(OPT_mno_zero_initialized_in_bss);
853 Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
854 Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
855 Opts.EnableSegmentedStacks = Args.hasArg(OPT_split_stacks);
856 Opts.RelaxAll = Args.hasArg(OPT_mrelax_all);
857 Opts.IncrementalLinkerCompatible =
858 Args.hasArg(OPT_mincremental_linker_compatible);
859 Opts.PIECopyRelocations =
860 Args.hasArg(OPT_mpie_copy_relocations);
861 Opts.NoPLT = Args.hasArg(OPT_fno_plt);
862 Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer);
863 Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels);
864 Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm);
865 Opts.SoftFloat = Args.hasArg(OPT_msoft_float);
866 Opts.StrictEnums = Args.hasArg(OPT_fstrict_enums);
867 Opts.StrictReturn = !Args.hasArg(OPT_fno_strict_return);
868 Opts.StrictVTablePointers = Args.hasArg(OPT_fstrict_vtable_pointers);
869 Opts.ForceEmitVTables = Args.hasArg(OPT_fforce_emit_vtables);
870 Opts.UnsafeFPMath = Args.hasArg(OPT_menable_unsafe_fp_math) ||
871 Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
872 Args.hasArg(OPT_cl_fast_relaxed_math);
873 Opts.UnwindTables = Args.hasArg(OPT_munwind_tables);
875 Opts.
ThreadModel = Args.getLastArgValue(OPT_mthread_model,
"posix");
877 Diags.
Report(diag::err_drv_invalid_value)
878 << Args.getLastArg(OPT_mthread_model)->getAsString(Args)
880 Opts.
TrapFuncName = Args.getLastArgValue(OPT_ftrap_function_EQ);
881 Opts.UseInitArray = Args.hasArg(OPT_fuse_init_array);
883 Opts.FunctionSections = Args.hasFlag(OPT_ffunction_sections,
884 OPT_fno_function_sections,
false);
885 Opts.DataSections = Args.hasFlag(OPT_fdata_sections,
886 OPT_fno_data_sections,
false);
887 Opts.StackSizeSection =
888 Args.hasFlag(OPT_fstack_size_section, OPT_fno_stack_size_section,
false);
889 Opts.UniqueSectionNames = Args.hasFlag(OPT_funique_section_names,
890 OPT_fno_unique_section_names,
true);
892 Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions);
894 Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
896 Opts.NullPointerIsValid = Args.hasArg(OPT_fno_delete_null_pointer_checks);
898 Opts.ProfileSampleAccurate = Args.hasArg(OPT_fprofile_sample_accurate);
900 Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
901 Opts.PrepareForThinLTO =
false;
902 if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
903 StringRef S = A->getValue();
905 Opts.PrepareForThinLTO =
true;
906 else if (S !=
"full")
907 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << S;
909 Opts.LTOUnit = Args.hasFlag(OPT_flto_unit, OPT_fno_lto_unit,
false);
910 Opts.EnableSplitLTOUnit = Args.hasArg(OPT_fsplit_lto_unit);
911 if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) {
913 Diags.
Report(diag::err_drv_argument_only_allowed_with)
914 << A->getAsString(Args) <<
"-x ir";
917 if (Arg *A = Args.getLastArg(OPT_save_temps_EQ))
919 llvm::StringSwitch<std::string>(A->getValue())
921 .Default(llvm::sys::path::filename(FrontendOpts.
OutputFile).str());
925 Opts.MSVolatile = Args.hasArg(OPT_fms_volatile);
927 Opts.VectorizeLoop = Args.hasArg(OPT_vectorize_loops);
928 Opts.VectorizeSLP = Args.hasArg(OPT_vectorize_slp);
932 Opts.
MainFileName = Args.getLastArgValue(OPT_main_file_name);
933 Opts.VerifyModule = !Args.hasArg(OPT_disable_llvm_verifier);
935 Opts.ControlFlowGuard = Args.hasArg(OPT_cfguard);
937 Opts.DisableGCov = Args.hasArg(OPT_test_coverage);
938 Opts.EmitGcovArcs = Args.hasArg(OPT_femit_coverage_data);
939 Opts.EmitGcovNotes = Args.hasArg(OPT_femit_coverage_notes);
940 if (Opts.EmitGcovArcs || Opts.EmitGcovNotes) {
943 Opts.CoverageExtraChecksum = Args.hasArg(OPT_coverage_cfg_checksum);
944 Opts.CoverageNoFunctionNamesInData =
945 Args.hasArg(OPT_coverage_no_function_names_in_data);
947 Args.getLastArgValue(OPT_fprofile_filter_files_EQ);
949 Args.getLastArgValue(OPT_fprofile_exclude_files_EQ);
950 Opts.CoverageExitBlockBeforeBody =
951 Args.hasArg(OPT_coverage_exit_block_before_body);
952 if (Args.hasArg(OPT_coverage_version_EQ)) {
953 StringRef CoverageVersion = Args.getLastArgValue(OPT_coverage_version_EQ);
954 if (CoverageVersion.size() != 4) {
955 Diags.
Report(diag::err_drv_invalid_value)
956 << Args.getLastArg(OPT_coverage_version_EQ)->getAsString(Args)
964 if (Arg *A = Args.getLastArg(OPT_fembed_bitcode_EQ)) {
965 StringRef Name = A->getValue();
966 unsigned Model = llvm::StringSwitch<unsigned>(Name)
973 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
976 Opts.setEmbedBitcode(
977 static_cast<CodeGenOptions::EmbedBitcodeKind>(Model));
983 for (
const auto &A : Args) {
985 if (A->getOption().getID() == options::OPT_o ||
986 A->getOption().getID() == options::OPT_INPUT ||
987 A->getOption().getID() == options::OPT_x ||
988 A->getOption().getID() == options::OPT_fembed_bitcode ||
989 (A->getOption().getGroup().isValid() &&
990 A->getOption().getGroup().getID() == options::OPT_W_Group))
993 A->render(Args, ASL);
994 for (
const auto &arg : ASL) {
995 StringRef ArgStr(arg);
996 Opts.
CmdArgs.insert(Opts.
CmdArgs.end(), ArgStr.begin(), ArgStr.end());
1003 Opts.PreserveVec3Type = Args.hasArg(OPT_fpreserve_vec3_type);
1004 Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
1005 Opts.InstrumentFunctionsAfterInlining =
1006 Args.hasArg(OPT_finstrument_functions_after_inlining);
1007 Opts.InstrumentFunctionEntryBare =
1008 Args.hasArg(OPT_finstrument_function_entry_bare);
1010 Opts.XRayInstrumentFunctions =
1011 Args.hasArg(OPT_fxray_instrument);
1012 Opts.XRayAlwaysEmitCustomEvents =
1013 Args.hasArg(OPT_fxray_always_emit_customevents);
1014 Opts.XRayAlwaysEmitTypedEvents =
1015 Args.hasArg(OPT_fxray_always_emit_typedevents);
1016 Opts.XRayInstructionThreshold =
1019 auto XRayInstrBundles =
1020 Args.getAllArgValues(OPT_fxray_instrumentation_bundle);
1021 if (XRayInstrBundles.empty())
1024 for (
const auto &A : XRayInstrBundles)
1028 Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
1029 Opts.CallFEntry = Args.hasArg(OPT_mfentry);
1030 Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
1032 if (
const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
1033 StringRef Name = A->getValue();
1034 if (Name ==
"full") {
1035 Opts.CFProtectionReturn = 1;
1036 Opts.CFProtectionBranch = 1;
1037 }
else if (Name ==
"return")
1038 Opts.CFProtectionReturn = 1;
1039 else if (Name ==
"branch")
1040 Opts.CFProtectionBranch = 1;
1041 else if (Name !=
"none") {
1042 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
1047 if (
const Arg *A = Args.getLastArg(OPT_compress_debug_sections,
1048 OPT_compress_debug_sections_EQ)) {
1049 if (A->getOption().getID() == OPT_compress_debug_sections) {
1051 Opts.setCompressDebugSections(llvm::DebugCompressionType::GNU);
1053 auto DCT = llvm::StringSwitch<llvm::DebugCompressionType>(A->getValue())
1055 .Case(
"zlib", llvm::DebugCompressionType::Z)
1056 .Case(
"zlib-gnu", llvm::DebugCompressionType::GNU)
1058 Opts.setCompressDebugSections(DCT);
1062 Opts.RelaxELFRelocations = Args.hasArg(OPT_mrelax_relocations);
1065 Args.filtered(OPT_mlink_bitcode_file, OPT_mlink_builtin_bitcode)) {
1068 if (A->getOption().matches(OPT_mlink_builtin_bitcode)) {
1069 F.
LinkFlags = llvm::Linker::Flags::LinkOnlyNeeded;
1077 Opts.SanitizeCoverageType =
1079 Opts.SanitizeCoverageIndirectCalls =
1080 Args.hasArg(OPT_fsanitize_coverage_indirect_calls);
1081 Opts.SanitizeCoverageTraceBB = Args.hasArg(OPT_fsanitize_coverage_trace_bb);
1082 Opts.SanitizeCoverageTraceCmp = Args.hasArg(OPT_fsanitize_coverage_trace_cmp);
1083 Opts.SanitizeCoverageTraceDiv = Args.hasArg(OPT_fsanitize_coverage_trace_div);
1084 Opts.SanitizeCoverageTraceGep = Args.hasArg(OPT_fsanitize_coverage_trace_gep);
1085 Opts.SanitizeCoverage8bitCounters =
1086 Args.hasArg(OPT_fsanitize_coverage_8bit_counters);
1087 Opts.SanitizeCoverageTracePC = Args.hasArg(OPT_fsanitize_coverage_trace_pc);
1088 Opts.SanitizeCoverageTracePCGuard =
1089 Args.hasArg(OPT_fsanitize_coverage_trace_pc_guard);
1090 Opts.SanitizeCoverageNoPrune = Args.hasArg(OPT_fsanitize_coverage_no_prune);
1091 Opts.SanitizeCoverageInline8bitCounters =
1092 Args.hasArg(OPT_fsanitize_coverage_inline_8bit_counters);
1093 Opts.SanitizeCoveragePCTable = Args.hasArg(OPT_fsanitize_coverage_pc_table);
1094 Opts.SanitizeCoverageStackDepth =
1095 Args.hasArg(OPT_fsanitize_coverage_stack_depth);
1096 Opts.SanitizeMemoryTrackOrigins =
1098 Opts.SanitizeMemoryUseAfterDtor =
1099 Args.hasFlag(OPT_fsanitize_memory_use_after_dtor,
1100 OPT_fno_sanitize_memory_use_after_dtor,
1102 Opts.SanitizeMinimalRuntime = Args.hasArg(OPT_fsanitize_minimal_runtime);
1103 Opts.SanitizeCfiCrossDso = Args.hasArg(OPT_fsanitize_cfi_cross_dso);
1104 Opts.SanitizeCfiICallGeneralizePointers =
1105 Args.hasArg(OPT_fsanitize_cfi_icall_generalize_pointers);
1106 Opts.SanitizeStats = Args.hasArg(OPT_fsanitize_stats);
1107 if (Arg *A = Args.getLastArg(
1108 OPT_fsanitize_address_poison_custom_array_cookie,
1109 OPT_fno_sanitize_address_poison_custom_array_cookie)) {
1110 Opts.SanitizeAddressPoisonCustomArrayCookie =
1111 A->getOption().getID() ==
1112 OPT_fsanitize_address_poison_custom_array_cookie;
1114 if (Arg *A = Args.getLastArg(OPT_fsanitize_address_use_after_scope,
1115 OPT_fno_sanitize_address_use_after_scope)) {
1116 Opts.SanitizeAddressUseAfterScope =
1117 A->getOption().getID() == OPT_fsanitize_address_use_after_scope;
1119 Opts.SanitizeAddressGlobalsDeadStripping =
1120 Args.hasArg(OPT_fsanitize_address_globals_dead_stripping);
1121 if (Arg *A = Args.getLastArg(OPT_fsanitize_address_use_odr_indicator,
1122 OPT_fno_sanitize_address_use_odr_indicator)) {
1123 Opts.SanitizeAddressUseOdrIndicator =
1124 A->getOption().getID() == OPT_fsanitize_address_use_odr_indicator;
1126 Opts.SSPBufferSize =
1128 Opts.StackRealignment = Args.hasArg(OPT_mstackrealign);
1129 if (Arg *A = Args.getLastArg(OPT_mstack_alignment)) {
1130 StringRef Val = A->getValue();
1131 unsigned StackAlignment = Opts.StackAlignment;
1132 Val.getAsInteger(10, StackAlignment);
1133 Opts.StackAlignment = StackAlignment;
1136 if (Arg *A = Args.getLastArg(OPT_mstack_probe_size)) {
1137 StringRef Val = A->getValue();
1138 unsigned StackProbeSize = Opts.StackProbeSize;
1139 Val.getAsInteger(0, StackProbeSize);
1140 Opts.StackProbeSize = StackProbeSize;
1143 Opts.NoStackArgProbe = Args.hasArg(OPT_mno_stack_arg_probe);
1145 if (Arg *A = Args.getLastArg(OPT_fobjc_dispatch_method_EQ)) {
1146 StringRef Name = A->getValue();
1147 unsigned Method = llvm::StringSwitch<unsigned>(Name)
1152 if (Method == ~0U) {
1153 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
1156 Opts.setObjCDispatchMethod(
1157 static_cast<CodeGenOptions::ObjCDispatchMethodKind>(Method));
1162 if (Args.hasArg(OPT_fno_objc_convert_messages_to_runtime_calls))
1163 Opts.ObjCConvertMessagesToRuntimeCalls = 0;
1165 if (Args.getLastArg(OPT_femulated_tls) ||
1166 Args.getLastArg(OPT_fno_emulated_tls)) {
1167 Opts.ExplicitEmulatedTLS =
true;
1169 Args.hasFlag(OPT_femulated_tls, OPT_fno_emulated_tls,
false);
1172 if (Arg *A = Args.getLastArg(OPT_ftlsmodel_EQ)) {
1173 StringRef Name = A->getValue();
1174 unsigned Model = llvm::StringSwitch<unsigned>(Name)
1181 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
1184 Opts.setDefaultTLSModel(static_cast<CodeGenOptions::TLSModel>(Model));
1188 if (Arg *A = Args.getLastArg(OPT_fdenormal_fp_math_EQ)) {
1189 StringRef Val = A->getValue();
1192 else if (Val ==
"preserve-sign")
1194 else if (Val ==
"positive-zero")
1197 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
1200 if (Arg *A = Args.getLastArg(OPT_fpcc_struct_return, OPT_freg_struct_return)) {
1201 if (A->getOption().matches(OPT_fpcc_struct_return)) {
1204 assert(A->getOption().matches(OPT_freg_struct_return));
1210 Opts.
LinkerOptions = Args.getAllArgValues(OPT_linker_option);
1211 bool NeedLocTracking =
false;
1213 Opts.
OptRecordFile = Args.getLastArgValue(OPT_opt_record_file);
1215 NeedLocTracking =
true;
1217 if (Arg *A = Args.getLastArg(OPT_Rpass_EQ)) {
1220 NeedLocTracking =
true;
1223 if (Arg *A = Args.getLastArg(OPT_Rpass_missed_EQ)) {
1226 NeedLocTracking =
true;
1229 if (Arg *A = Args.getLastArg(OPT_Rpass_analysis_EQ)) {
1232 NeedLocTracking =
true;
1235 Opts.DiagnosticsWithHotness =
1236 Args.hasArg(options::OPT_fdiagnostics_show_hotness);
1238 bool UsingProfile = UsingSampleProfile ||
1241 if (Opts.DiagnosticsWithHotness && !UsingProfile &&
1244 Diags.
Report(diag::warn_drv_diagnostics_hotness_requires_pgo)
1245 <<
"-fdiagnostics-show-hotness";
1248 Args, options::OPT_fdiagnostics_hotness_threshold_EQ, 0);
1249 if (Opts.DiagnosticsHotnessThreshold > 0 && !UsingProfile)
1250 Diags.
Report(diag::warn_drv_diagnostics_hotness_requires_pgo)
1251 <<
"-fdiagnostics-hotness-threshold=";
1256 if (UsingSampleProfile)
1257 NeedLocTracking =
true;
1269 Args.getAllArgValues(OPT_fsanitize_recover_EQ), Diags,
1272 Args.getAllArgValues(OPT_fsanitize_trap_EQ), Diags,
1276 Args.getLastArgValue(OPT_fcuda_include_gpubinary);
1278 Opts.Backchain = Args.hasArg(OPT_mbackchain);
1281 Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags);
1283 Opts.EmitVersionIdentMetadata = Args.hasFlag(OPT_Qy, OPT_Qn,
true);
1285 Opts.Addrsig = Args.hasArg(OPT_faddrsig);
1287 if (Arg *A = Args.getLastArg(OPT_msign_return_address_EQ)) {
1288 StringRef SignScope = A->getValue();
1290 if (SignScope.equals_lower(
"none"))
1292 else if (SignScope.equals_lower(
"all"))
1294 else if (SignScope.equals_lower(
"non-leaf"))
1295 Opts.setSignReturnAddress(
1296 CodeGenOptions::SignReturnAddressScope::NonLeaf);
1298 Diags.
Report(diag::err_drv_invalid_value)
1299 << A->getAsString(Args) << SignScope;
1301 if (Arg *A = Args.getLastArg(OPT_msign_return_address_key_EQ)) {
1302 StringRef SignKey = A->getValue();
1303 if (!SignScope.empty() && !SignKey.empty()) {
1304 if (SignKey.equals_lower(
"a_key"))
1305 Opts.setSignReturnAddressKey(
1306 CodeGenOptions::SignReturnAddressKeyValue::AKey);
1307 else if (SignKey.equals_lower(
"b_key"))
1308 Opts.setSignReturnAddressKey(
1309 CodeGenOptions::SignReturnAddressKeyValue::BKey);
1311 Diags.
Report(diag::err_drv_invalid_value)
1312 << A->getAsString(Args) << SignKey;
1317 Opts.BranchTargetEnforcement = Args.hasArg(OPT_mbranch_target_enforce);
1319 Opts.KeepStaticConsts = Args.hasArg(OPT_fkeep_static_consts);
1321 Opts.SpeculativeLoadHardening = Args.hasArg(OPT_mspeculative_load_hardening);
1330 Opts.
OutputFile = Args.getLastArgValue(OPT_dependency_file);
1331 Opts.
Targets = Args.getAllArgValues(OPT_MT);
1338 if (Args.hasArg(OPT_show_includes)) {
1342 if (Args.hasArg(options::OPT_E) || Args.hasArg(options::OPT_P))
1349 Opts.
DOTOutputFile = Args.getLastArgValue(OPT_dependency_dot);
1351 Args.getLastArgValue(OPT_module_dependency_dir);
1352 if (Args.hasArg(OPT_MV))
1357 Opts.
ExtraDeps = Args.getAllArgValues(OPT_fdepfile_entry);
1359 for (
const auto *A : Args.filtered(OPT_fmodule_file)) {
1360 StringRef Val = A->getValue();
1361 if (Val.find(
'=') == StringRef::npos)
1375 } ShowColors = DefaultColor ? Colors_Auto : Colors_Off;
1376 for (
auto *A : Args) {
1377 const Option &O = A->getOption();
1378 if (O.matches(options::OPT_fcolor_diagnostics) ||
1379 O.matches(options::OPT_fdiagnostics_color)) {
1380 ShowColors = Colors_On;
1381 }
else if (O.matches(options::OPT_fno_color_diagnostics) ||
1382 O.matches(options::OPT_fno_diagnostics_color)) {
1383 ShowColors = Colors_Off;
1384 }
else if (O.matches(options::OPT_fdiagnostics_color_EQ)) {
1385 StringRef
Value(A->getValue());
1386 if (
Value ==
"always")
1387 ShowColors = Colors_On;
1388 else if (
Value ==
"never")
1389 ShowColors = Colors_Off;
1390 else if (
Value ==
"auto")
1391 ShowColors = Colors_Auto;
1394 return ShowColors == Colors_On ||
1395 (ShowColors == Colors_Auto &&
1396 llvm::sys::Process::StandardErrHasColors());
1401 bool Success =
true;
1402 for (
const auto &Prefix : VerifyPrefixes) {
1405 auto BadChar = std::find_if(Prefix.begin(), Prefix.end(),
1407 &&
C !=
'-' &&
C !=
'_';});
1408 if (BadChar != Prefix.end() || !
isLetter(Prefix[0])) {
1411 Diags->
Report(diag::err_drv_invalid_value) <<
"-verify=" << Prefix;
1412 Diags->
Report(diag::note_drv_verify_prefix_spelling);
1421 bool DefaultDiagColor,
bool DefaultShowOpt) {
1422 bool Success =
true;
1426 Args.getLastArg(OPT_diagnostic_serialized_file, OPT__serialize_diags))
1428 Opts.IgnoreWarnings = Args.hasArg(OPT_w);
1429 Opts.NoRewriteMacros = Args.hasArg(OPT_Wno_rewrite_macros);
1430 Opts.Pedantic = Args.hasArg(OPT_pedantic);
1431 Opts.PedanticErrors = Args.hasArg(OPT_pedantic_errors);
1432 Opts.ShowCarets = !Args.hasArg(OPT_fno_caret_diagnostics);
1434 Opts.ShowColumn = Args.hasFlag(OPT_fshow_column,
1435 OPT_fno_show_column,
1437 Opts.ShowFixits = !Args.hasArg(OPT_fno_diagnostics_fixit_info);
1438 Opts.ShowLocation = !Args.hasArg(OPT_fno_show_source_location);
1439 Opts.AbsolutePath = Args.hasArg(OPT_fdiagnostics_absolute_paths);
1440 Opts.ShowOptionNames =
1441 Args.hasFlag(OPT_fdiagnostics_show_option,
1442 OPT_fno_diagnostics_show_option, DefaultShowOpt);
1444 llvm::sys::Process::UseANSIEscapeCodes(Args.hasArg(OPT_fansi_escape_codes));
1447 Opts.ShowNoteIncludeStack =
false;
1448 if (Arg *A = Args.getLastArg(OPT_fdiagnostics_show_note_include_stack,
1449 OPT_fno_diagnostics_show_note_include_stack))
1450 if (A->getOption().matches(OPT_fdiagnostics_show_note_include_stack))
1451 Opts.ShowNoteIncludeStack =
true;
1453 StringRef ShowOverloads =
1454 Args.getLastArgValue(OPT_fshow_overloads_EQ,
"all");
1455 if (ShowOverloads ==
"best")
1457 else if (ShowOverloads ==
"all")
1458 Opts.setShowOverloads(
Ovl_All);
1462 Diags->
Report(diag::err_drv_invalid_value)
1463 << Args.getLastArg(OPT_fshow_overloads_EQ)->getAsString(Args)
1467 StringRef ShowCategory =
1468 Args.getLastArgValue(OPT_fdiagnostics_show_category,
"none");
1469 if (ShowCategory ==
"none")
1470 Opts.ShowCategories = 0;
1471 else if (ShowCategory ==
"id")
1472 Opts.ShowCategories = 1;
1473 else if (ShowCategory ==
"name")
1474 Opts.ShowCategories = 2;
1478 Diags->
Report(diag::err_drv_invalid_value)
1479 << Args.getLastArg(OPT_fdiagnostics_show_category)->getAsString(Args)
1484 Args.getLastArgValue(OPT_fdiagnostics_format,
"clang");
1485 if (Format ==
"clang")
1487 else if (Format ==
"msvc")
1489 else if (Format ==
"msvc-fallback") {
1491 Opts.CLFallbackMode =
true;
1492 }
else if (Format ==
"vi")
1497 Diags->
Report(diag::err_drv_invalid_value)
1498 << Args.getLastArg(OPT_fdiagnostics_format)->getAsString(Args)
1502 Opts.ShowSourceRanges = Args.hasArg(OPT_fdiagnostics_print_source_range_info);
1503 Opts.ShowParseableFixits = Args.hasArg(OPT_fdiagnostics_parseable_fixits);
1504 Opts.ShowPresumedLoc = !Args.hasArg(OPT_fno_diagnostics_use_presumed_location);
1505 Opts.VerifyDiagnostics = Args.hasArg(OPT_verify) || Args.hasArg(OPT_verify_EQ);
1507 if (Args.hasArg(OPT_verify))
1512 Opts.VerifyDiagnostics =
false;
1519 Args.getAllArgValues(OPT_verify_ignore_unexpected_EQ),
1521 if (Args.hasArg(OPT_verify_ignore_unexpected))
1523 Opts.setVerifyIgnoreUnexpected(DiagMask);
1524 Opts.ElideType = !Args.hasArg(OPT_fno_elide_type);
1525 Opts.ShowTemplateTree = Args.hasArg(OPT_fdiagnostics_show_template_tree);
1527 Opts.MacroBacktraceLimit =
1531 Args, OPT_ftemplate_backtrace_limit,
1534 Args, OPT_fconstexpr_backtrace_limit,
1537 Args, OPT_fspell_checking_limit,
1540 Args, OPT_fcaret_diagnostics_max_lines,
1547 Diags->
Report(diag::warn_ignoring_ftabstop_value)
1558 Opts.
WorkingDir = Args.getLastArgValue(OPT_working_directory);
1566 std::string &BlockName,
1567 unsigned &MajorVersion,
1568 unsigned &MinorVersion,
1570 std::string &UserInfo) {
1572 Arg.split(Args,
':', 5);
1573 if (Args.size() < 5)
1576 BlockName = Args[0];
1577 if (Args[1].getAsInteger(10, MajorVersion))
return true;
1578 if (Args[2].getAsInteger(10, MinorVersion))
return true;
1579 if (Args[3].getAsInteger(2, Hashed))
return true;
1580 if (Args.size() > 4)
1589 if (
const Arg *A = Args.getLastArg(OPT_Action_Group)) {
1590 switch (A->getOption().getID()) {
1592 llvm_unreachable(
"Invalid option in group!");
1596 case OPT_ast_dump_all:
1597 case OPT_ast_dump_lookups:
1603 case OPT_compiler_options_dump:
1605 case OPT_dump_raw_tokens:
1607 case OPT_dump_tokens:
1611 case OPT_emit_llvm_bc:
1617 case OPT_emit_llvm_only:
1619 case OPT_emit_codegen_only:
1628 case OPT_emit_module:
1630 case OPT_emit_module_interface:
1632 case OPT_emit_header_module:
1638 case OPT_fsyntax_only:
1640 case OPT_module_file_info:
1642 case OPT_verify_pch:
1644 case OPT_print_preamble:
1648 case OPT_templight_dump:
1650 case OPT_rewrite_macros:
1652 case OPT_rewrite_objc:
1654 case OPT_rewrite_test:
1665 if (
const Arg* A = Args.getLastArg(OPT_plugin)) {
1666 Opts.
Plugins.emplace_back(A->getValue(0));
1671 for (
const auto *AA : Args.filtered(OPT_plugin_arg))
1672 Opts.
PluginArgs[AA->getValue(0)].emplace_back(AA->getValue(1));
1674 for (
const std::string &Arg :
1675 Args.getAllArgValues(OPT_ftest_module_file_extension_EQ)) {
1676 std::string BlockName;
1677 unsigned MajorVersion;
1678 unsigned MinorVersion;
1680 std::string UserInfo;
1682 MinorVersion, Hashed, UserInfo)) {
1683 Diags.
Report(diag::err_test_module_file_extension_format) << Arg;
1690 std::make_shared<TestModuleFileExtension>(
1691 BlockName, MajorVersion, MinorVersion, Hashed, UserInfo));
1694 if (
const Arg *A = Args.getLastArg(OPT_code_completion_at)) {
1698 Diags.
Report(diag::err_drv_invalid_value)
1699 << A->getAsString(Args) << A->getValue();
1703 Opts.
OutputFile = Args.getLastArgValue(OPT_o);
1704 Opts.
Plugins = Args.getAllArgValues(OPT_load);
1706 Opts.
ShowHelp = Args.hasArg(OPT_help);
1707 Opts.
ShowStats = Args.hasArg(OPT_print_stats);
1708 Opts.
ShowTimers = Args.hasArg(OPT_ftime_report);
1711 Opts.
LLVMArgs = Args.getAllArgValues(OPT_mllvm);
1717 Opts.
ASTDumpAll = Args.hasArg(OPT_ast_dump_all);
1718 Opts.
ASTDumpFilter = Args.getLastArgValue(OPT_ast_dump_filter);
1722 Opts.
ModuleMapFiles = Args.getAllArgValues(OPT_fmodule_map_file);
1724 for (
const auto *A : Args.filtered(OPT_fmodule_file)) {
1725 StringRef Val = A->getValue();
1726 if (Val.find(
'=') == StringRef::npos)
1734 = Args.hasArg(OPT_code_completion_macros);
1736 = Args.hasArg(OPT_code_completion_patterns);
1738 = !Args.hasArg(OPT_no_code_completion_globals);
1740 = !Args.hasArg(OPT_no_code_completion_ns_level_decls);
1742 = Args.hasArg(OPT_code_completion_brief_comments);
1744 = Args.hasArg(OPT_code_completion_with_fixits);
1747 = Args.getLastArgValue(OPT_foverride_record_layout_EQ);
1748 Opts.
AuxTriple = Args.getLastArgValue(OPT_aux_triple);
1749 Opts.
StatsFile = Args.getLastArgValue(OPT_stats_file);
1751 if (
const Arg *A = Args.getLastArg(OPT_arcmt_check,
1753 OPT_arcmt_migrate)) {
1754 switch (A->getOption().getID()) {
1756 llvm_unreachable(
"missed a case");
1757 case OPT_arcmt_check:
1760 case OPT_arcmt_modify:
1763 case OPT_arcmt_migrate:
1768 Opts.
MTMigrateDir = Args.getLastArgValue(OPT_mt_migrate_directory);
1770 = Args.getLastArgValue(OPT_arcmt_migrate_report_output);
1772 = Args.hasArg(OPT_arcmt_migrate_emit_arc_errors);
1774 if (Args.hasArg(OPT_objcmt_migrate_literals))
1776 if (Args.hasArg(OPT_objcmt_migrate_subscripting))
1778 if (Args.hasArg(OPT_objcmt_migrate_property_dot_syntax))
1780 if (Args.hasArg(OPT_objcmt_migrate_property))
1782 if (Args.hasArg(OPT_objcmt_migrate_readonly_property))
1784 if (Args.hasArg(OPT_objcmt_migrate_readwrite_property))
1786 if (Args.hasArg(OPT_objcmt_migrate_annotation))
1788 if (Args.hasArg(OPT_objcmt_returns_innerpointer_property))
1790 if (Args.hasArg(OPT_objcmt_migrate_instancetype))
1792 if (Args.hasArg(OPT_objcmt_migrate_nsmacros))
1794 if (Args.hasArg(OPT_objcmt_migrate_protocol_conformance))
1796 if (Args.hasArg(OPT_objcmt_atomic_property))
1798 if (Args.hasArg(OPT_objcmt_ns_nonatomic_iosonly))
1800 if (Args.hasArg(OPT_objcmt_migrate_designated_init))
1802 if (Args.hasArg(OPT_objcmt_migrate_all))
1809 Diags.
Report(diag::err_drv_argument_not_allowed_with)
1810 <<
"ARC migration" <<
"ObjC migration";
1814 if (
const Arg *A = Args.getLastArg(OPT_x)) {
1815 StringRef XValue = A->getValue();
1819 bool Preprocessed = XValue.consume_back(
"-cpp-output");
1820 bool ModuleMap = XValue.consume_back(
"-module-map");
1822 !Preprocessed && !ModuleMap && XValue.consume_back(
"-header");
1825 DashX = llvm::StringSwitch<InputKind>(XValue)
1838 if (DashX.
isUnknown() && Preprocessed && !IsHeaderFile && !ModuleMap)
1839 DashX = llvm::StringSwitch<InputKind>(XValue)
1846 DashX = llvm::StringSwitch<InputKind>(XValue)
1849 .Cases(
"ast",
"pcm",
1855 Diags.
Report(diag::err_drv_invalid_value)
1856 << A->getAsString(Args) << A->getValue();
1865 std::vector<std::string> Inputs = Args.getAllArgValues(OPT_INPUT);
1868 Inputs.push_back(
"-");
1869 for (
unsigned i = 0, e = Inputs.size(); i != e; ++i) {
1873 StringRef(Inputs[i]).rsplit(
'.').second);
1887 Opts.
Inputs.emplace_back(std::move(Inputs[i]), IK);
1895 std::string ClangExecutable =
1896 llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
1897 StringRef Dir = llvm::sys::path::parent_path(ClangExecutable);
1900 StringRef ClangResourceDir(CLANG_RESOURCE_DIR);
1902 if (ClangResourceDir !=
"")
1903 llvm::sys::path::append(P, ClangResourceDir);
1905 llvm::sys::path::append(P,
"..", Twine(
"lib") + CLANG_LIBDIR_SUFFIX,
1906 "clang", CLANG_VERSION_STRING);
1912 const std::string &WorkingDir) {
1913 Opts.
Sysroot = Args.getLastArgValue(OPT_isysroot,
"/");
1914 Opts.
Verbose = Args.hasArg(OPT_v);
1918 if (
const Arg *A = Args.getLastArg(OPT_stdlib_EQ))
1919 Opts.
UseLibcxx = (strcmp(A->getValue(),
"libc++") == 0);
1920 Opts.
ResourceDir = Args.getLastArgValue(OPT_resource_dir);
1924 if (!(
P.empty() || llvm::sys::path::is_absolute(
P))) {
1925 if (WorkingDir.empty())
1926 llvm::sys::fs::make_absolute(
P);
1928 llvm::sys::fs::make_absolute(WorkingDir,
P);
1930 llvm::sys::path::remove_dots(
P);
1935 for (
const auto *A : Args.filtered(OPT_fmodule_file)) {
1936 StringRef Val = A->getValue();
1937 if (Val.find(
'=') != StringRef::npos)
1940 for (
const auto *A : Args.filtered(OPT_fprebuilt_module_path))
1945 !Args.hasArg(OPT_fmodules_disable_diagnostic_validation);
1953 Args.hasArg(OPT_fmodules_validate_once_per_build_session);
1957 Args.hasArg(OPT_fmodules_validate_system_headers);
1958 if (
const Arg *A = Args.getLastArg(OPT_fmodule_format_EQ))
1961 for (
const auto *A : Args.filtered(OPT_fmodules_ignore_macro)) {
1962 StringRef MacroDef = A->getValue();
1964 llvm::CachedHashString(MacroDef.split(
'=').first));
1968 bool IsIndexHeaderMap =
false;
1969 bool IsSysrootSpecified =
1970 Args.hasArg(OPT__sysroot_EQ) || Args.hasArg(OPT_isysroot);
1971 for (
const auto *A : Args.filtered(OPT_I, OPT_F, OPT_index_header_map)) {
1972 if (A->getOption().matches(OPT_index_header_map)) {
1974 IsIndexHeaderMap =
true;
1981 bool IsFramework = A->getOption().matches(OPT_F);
1982 std::string Path = A->getValue();
1984 if (IsSysrootSpecified && !IsFramework && A->getValue()[0] ==
'=') {
1986 llvm::sys::path::append(Buffer, Opts.
Sysroot,
1987 llvm::StringRef(A->getValue()).substr(1));
1988 Path = Buffer.str();
1991 Opts.
AddPath(Path, Group, IsFramework,
1993 IsIndexHeaderMap =
false;
1997 StringRef Prefix =
"";
1998 for (
const auto *A :
1999 Args.filtered(OPT_iprefix, OPT_iwithprefix, OPT_iwithprefixbefore)) {
2000 if (A->getOption().matches(OPT_iprefix))
2001 Prefix = A->getValue();
2002 else if (A->getOption().matches(OPT_iwithprefix))
2008 for (
const auto *A : Args.filtered(OPT_idirafter))
2010 for (
const auto *A : Args.filtered(OPT_iquote))
2012 for (
const auto *A : Args.filtered(OPT_isystem, OPT_iwithsysroot))
2014 !A->getOption().matches(OPT_iwithsysroot));
2015 for (
const auto *A : Args.filtered(OPT_iframework))
2017 for (
const auto *A : Args.filtered(OPT_iframeworkwithsysroot))
2022 for (
const auto *A : Args.filtered(OPT_c_isystem))
2024 for (
const auto *A : Args.filtered(OPT_cxx_isystem))
2026 for (
const auto *A : Args.filtered(OPT_objc_isystem))
2028 for (
const auto *A : Args.filtered(OPT_objcxx_isystem))
2032 for (
const auto *A :
2033 Args.filtered(OPT_internal_isystem, OPT_internal_externc_isystem)) {
2035 if (A->getOption().matches(OPT_internal_externc_isystem))
2037 Opts.
AddPath(A->getValue(), Group,
false,
true);
2041 for (
const auto *A :
2042 Args.filtered(OPT_system_header_prefix, OPT_no_system_header_prefix))
2044 A->getValue(), A->getOption().matches(OPT_system_header_prefix));
2046 for (
const auto *A : Args.filtered(OPT_ivfsoverlay))
2051 const llvm::Triple &T,
2062 Opts.AsmPreprocessor = 1;
2072 llvm_unreachable(
"Invalid input kind!");
2074 LangStd = LangStandard::lang_opencl10;
2077 LangStd = LangStandard::lang_cuda;
2081 #if defined(CLANG_DEFAULT_STD_C) 2082 LangStd = CLANG_DEFAULT_STD_C;
2086 LangStd = LangStandard::lang_gnu99;
2088 LangStd = LangStandard::lang_gnu11;
2092 #if defined(CLANG_DEFAULT_STD_C) 2093 LangStd = CLANG_DEFAULT_STD_C;
2095 LangStd = LangStandard::lang_gnu11;
2100 #if defined(CLANG_DEFAULT_STD_CXX) 2101 LangStd = CLANG_DEFAULT_STD_CXX;
2103 LangStd = LangStandard::lang_gnucxx14;
2107 LangStd = LangStandard::lang_c99;
2110 LangStd = LangStandard::lang_hip;
2117 Opts.C99 = Std.
isC99();
2118 Opts.C11 = Std.
isC11();
2119 Opts.C17 = Std.
isC17();
2127 Opts.GNUInline = !Opts.C99 && !Opts.CPlusPlus;
2133 if (LangStd == LangStandard::lang_opencl10)
2134 Opts.OpenCLVersion = 100;
2135 else if (LangStd == LangStandard::lang_opencl11)
2136 Opts.OpenCLVersion = 110;
2137 else if (LangStd == LangStandard::lang_opencl12)
2138 Opts.OpenCLVersion = 120;
2139 else if (LangStd == LangStandard::lang_opencl20)
2140 Opts.OpenCLVersion = 200;
2141 else if (LangStd == LangStandard::lang_openclcpp)
2142 Opts.OpenCLCPlusPlusVersion = 100;
2148 Opts.LaxVectorConversions = 0;
2150 Opts.NativeHalfType = 1;
2151 Opts.NativeHalfArgsAndReturns = 1;
2152 Opts.OpenCLCPlusPlus = Opts.CPlusPlus;
2154 if (Opts.IncludeDefaultHeader) {
2155 PPOpts.
Includes.push_back(
"opencl-c.h");
2166 if (Opts.RenderScript) {
2167 Opts.NativeHalfType = 1;
2168 Opts.NativeHalfArgsAndReturns = 1;
2172 Opts.Bool = Opts.OpenCL || Opts.CPlusPlus;
2175 Opts.Half = Opts.OpenCL;
2178 Opts.WChar = Opts.CPlusPlus;
2180 Opts.GNUKeywords = Opts.GNUMode;
2181 Opts.CXXOperatorNames = Opts.CPlusPlus;
2183 Opts.AlignedAllocation = Opts.CPlusPlus17;
2185 Opts.DollarIdents = !Opts.AsmPreprocessor;
2191 StringRef value = arg->getValue();
2192 if (value ==
"default") {
2194 }
else if (value ==
"hidden" || value ==
"internal") {
2196 }
else if (value ==
"protected") {
2201 diags.
Report(diag::err_drv_invalid_value)
2202 << arg->getAsString(args) << value;
2212 llvm_unreachable(
"should not parse language flags for this input");
2242 llvm_unreachable(
"unexpected input language");
2251 return "Objective-C";
2255 return "Objective-C++";
2261 return "RenderScript";
2273 llvm_unreachable(
"unknown input language");
2282 if (
const Arg *A = Args.getLastArg(OPT_std_EQ)) {
2283 LangStd = llvm::StringSwitch<LangStandard::Kind>(A->getValue())
2285 .Case(name, LangStandard::lang_##
id)
2286 #define LANGSTANDARD_ALIAS(id, alias) \ 2287 .Case(alias, LangStandard::lang_##id) 2288 #include "clang/Frontend/LangStandards.def" 2291 Diags.
Report(diag::err_drv_invalid_value)
2292 << A->getAsString(Args) << A->getValue();
2294 for (
unsigned KindValue = 0;
2298 static_cast<LangStandard::Kind>(KindValue));
2300 auto Diag = Diags.
Report(diag::note_drv_use_standard);
2302 unsigned NumAliases = 0;
2303 #define LANGSTANDARD(id, name, lang, desc, features) 2304 #define LANGSTANDARD_ALIAS(id, alias) \ 2305 if (KindValue == LangStandard::lang_##id) ++NumAliases; 2306 #define LANGSTANDARD_ALIAS_DEPR(id, alias) 2307 #include "clang/Frontend/LangStandards.def" 2309 #define LANGSTANDARD(id, name, lang, desc, features) 2310 #define LANGSTANDARD_ALIAS(id, alias) \ 2311 if (KindValue == LangStandard::lang_##id) Diag << alias; 2312 #define LANGSTANDARD_ALIAS_DEPR(id, alias) 2313 #include "clang/Frontend/LangStandards.def" 2321 Diags.
Report(diag::err_drv_argument_not_allowed_with)
2327 if (Args.hasArg(OPT_fno_dllexport_inlines))
2328 Opts.DllExportInlines =
false;
2330 if (
const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
2331 StringRef Name = A->getValue();
2332 if (Name ==
"full" || Name ==
"branch") {
2333 Opts.CFProtectionBranch = 1;
2338 if (
const Arg *A = Args.getLastArg(OPT_cl_std_EQ)) {
2340 = llvm::StringSwitch<LangStandard::Kind>(A->getValue())
2341 .Cases(
"cl",
"CL", LangStandard::lang_opencl10)
2342 .Cases(
"cl1.1",
"CL1.1", LangStandard::lang_opencl11)
2343 .Cases(
"cl1.2",
"CL1.2", LangStandard::lang_opencl12)
2344 .Cases(
"cl2.0",
"CL2.0", LangStandard::lang_opencl20)
2345 .Case(
"c++", LangStandard::lang_openclcpp)
2349 Diags.
Report(diag::err_drv_invalid_value)
2350 << A->getAsString(Args) << A->getValue();
2353 LangStd = OpenCLLangStd;
2356 Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
2358 llvm::Triple T(TargetOpts.
Triple);
2364 if (Args.getLastArg(OPT_cl_strict_aliasing)
2365 && Opts.OpenCLVersion > 100) {
2366 Diags.
Report(diag::warn_option_invalid_ocl_version)
2368 << Args.getLastArg(OPT_cl_strict_aliasing)->getAsString(Args);
2376 Opts.GNUKeywords = Args.hasFlag(OPT_fgnu_keywords, OPT_fno_gnu_keywords,
2379 Opts.Digraphs = Args.hasFlag(OPT_fdigraphs, OPT_fno_digraphs, Opts.Digraphs);
2381 if (Args.hasArg(OPT_fno_operator_names))
2382 Opts.CXXOperatorNames = 0;
2384 if (Args.hasArg(OPT_fcuda_is_device))
2385 Opts.CUDAIsDevice = 1;
2387 if (Args.hasArg(OPT_fcuda_allow_variadic_functions))
2388 Opts.CUDAAllowVariadicFunctions = 1;
2390 if (Args.hasArg(OPT_fno_cuda_host_device_constexpr))
2391 Opts.CUDAHostDeviceConstexpr = 0;
2393 if (Opts.CUDAIsDevice && Args.hasArg(OPT_fcuda_approx_transcendentals))
2394 Opts.CUDADeviceApproxTranscendentals = 1;
2396 Opts.GPURelocatableDeviceCode = Args.hasArg(OPT_fgpu_rdc);
2399 if (Arg *arg = Args.getLastArg(OPT_fobjc_runtime_EQ)) {
2400 StringRef value = arg->getValue();
2402 Diags.
Report(diag::err_drv_unknown_objc_runtime) << value;
2405 if (Args.hasArg(OPT_fobjc_gc_only))
2407 else if (Args.hasArg(OPT_fobjc_gc))
2409 else if (Args.hasArg(OPT_fobjc_arc)) {
2410 Opts.ObjCAutoRefCount = 1;
2412 Diags.
Report(diag::err_arc_unsupported_on_runtime);
2419 if (Args.hasArg(OPT_fobjc_runtime_has_weak))
2420 Opts.ObjCWeakRuntime = 1;
2426 if (
auto weakArg = Args.getLastArg(OPT_fobjc_weak, OPT_fno_objc_weak)) {
2427 if (!weakArg->getOption().matches(OPT_fobjc_weak)) {
2428 assert(!Opts.ObjCWeak);
2430 Diags.
Report(diag::err_objc_weak_with_gc);
2431 }
else if (!Opts.ObjCWeakRuntime) {
2432 Diags.
Report(diag::err_objc_weak_unsupported);
2436 }
else if (Opts.ObjCAutoRefCount) {
2437 Opts.ObjCWeak = Opts.ObjCWeakRuntime;
2440 if (Args.hasArg(OPT_fno_objc_infer_related_result_type))
2441 Opts.ObjCInferRelatedResultType = 0;
2443 if (Args.hasArg(OPT_fobjc_subscripting_legacy_runtime))
2444 Opts.ObjCSubscriptingLegacyRuntime =
2448 if (Args.hasArg(OPT_fgnu89_inline)) {
2450 Diags.
Report(diag::err_drv_argument_not_allowed_with)
2456 if (Args.hasArg(OPT_fapple_kext)) {
2457 if (!Opts.CPlusPlus)
2458 Diags.
Report(diag::warn_c_kext);
2463 if (Args.hasArg(OPT_print_ivar_layout))
2464 Opts.ObjCGCBitmapPrint = 1;
2466 if (Args.hasArg(OPT_fno_constant_cfstrings))
2467 Opts.NoConstantCFStrings = 1;
2468 if (
const auto *A = Args.getLastArg(OPT_fcf_runtime_abi_EQ))
2470 llvm::StringSwitch<LangOptions::CoreFoundationABI>(A->getValue())
2471 .Cases(
"unspecified",
"standalone",
"objc",
2473 .Cases(
"swift",
"swift-5.0",
2479 if (Args.hasArg(OPT_fzvector))
2482 if (Args.hasArg(OPT_pthread))
2483 Opts.POSIXThreads = 1;
2486 if (Arg *visOpt = Args.getLastArg(OPT_fvisibility)) {
2493 if (Arg *typeVisOpt = Args.getLastArg(OPT_ftype_visibility)) {
2496 Opts.setTypeVisibilityMode(Opts.getValueVisibilityMode());
2499 if (Args.hasArg(OPT_fvisibility_inlines_hidden))
2500 Opts.InlineVisibilityHidden = 1;
2502 if (Args.hasArg(OPT_fvisibility_global_new_delete_hidden))
2503 Opts.GlobalAllocationFunctionVisibilityHidden = 1;
2505 if (Args.hasArg(OPT_ftrapv)) {
2509 Args.getLastArgValue(OPT_ftrapv_handler);
2511 else if (Args.hasArg(OPT_fwrapv))
2514 Opts.MSVCCompat = Args.hasArg(OPT_fms_compatibility);
2515 Opts.MicrosoftExt = Opts.MSVCCompat || Args.hasArg(OPT_fms_extensions);
2516 Opts.AsmBlocks = Args.hasArg(OPT_fasm_blocks) || Opts.MicrosoftExt;
2517 Opts.MSCompatibilityVersion = 0;
2518 if (
const Arg *A = Args.getLastArg(OPT_fms_compatibility_version)) {
2520 if (VT.tryParse(A->getValue()))
2521 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args)
2523 Opts.MSCompatibilityVersion = VT.getMajor() * 10000000 +
2524 VT.getMinor().getValueOr(0) * 100000 +
2525 VT.getSubminor().getValueOr(0);
2531 Opts.Trigraphs = !Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17;
2533 Args.hasFlag(OPT_ftrigraphs, OPT_fno_trigraphs, Opts.Trigraphs);
2535 Opts.DollarIdents = Args.hasFlag(OPT_fdollars_in_identifiers,
2536 OPT_fno_dollars_in_identifiers,
2538 Opts.PascalStrings = Args.hasArg(OPT_fpascal_strings);
2540 Opts.Borland = Args.hasArg(OPT_fborland_extensions);
2541 Opts.WritableStrings = Args.hasArg(OPT_fwritable_strings);
2542 Opts.ConstStrings = Args.hasFlag(OPT_fconst_strings, OPT_fno_const_strings,
2544 if (Args.hasArg(OPT_fno_lax_vector_conversions))
2545 Opts.LaxVectorConversions = 0;
2546 if (Args.hasArg(OPT_fno_threadsafe_statics))
2547 Opts.ThreadsafeStatics = 0;
2548 Opts.Exceptions = Args.hasArg(OPT_fexceptions);
2549 Opts.ObjCExceptions = Args.hasArg(OPT_fobjc_exceptions);
2550 Opts.CXXExceptions = Args.hasArg(OPT_fcxx_exceptions);
2554 Args.hasFlag(OPT_ffixed_point, OPT_fno_fixed_point,
false) &&
2556 Opts.PaddingOnUnsignedFixedPoint =
2557 Args.hasFlag(OPT_fpadding_on_unsigned_fixed_point,
2558 OPT_fno_padding_on_unsigned_fixed_point,
2563 Arg *A = Args.getLastArg(options::OPT_fsjlj_exceptions,
2564 options::OPT_fseh_exceptions,
2565 options::OPT_fdwarf_exceptions);
2567 const Option &Opt = A->getOption();
2568 llvm::Triple T(TargetOpts.
Triple);
2569 if (T.isWindowsMSVCEnvironment())
2570 Diags.
Report(diag::err_fe_invalid_exception_model)
2571 << Opt.getName() << T.str();
2573 Opts.SjLjExceptions = Opt.matches(options::OPT_fsjlj_exceptions);
2574 Opts.SEHExceptions = Opt.matches(options::OPT_fseh_exceptions);
2575 Opts.DWARFExceptions = Opt.matches(options::OPT_fdwarf_exceptions);
2578 Opts.ExternCNoUnwind = Args.hasArg(OPT_fexternc_nounwind);
2579 Opts.TraditionalCPP = Args.hasArg(OPT_traditional_cpp);
2581 Opts.RTTI = Opts.CPlusPlus && !Args.hasArg(OPT_fno_rtti);
2582 Opts.RTTIData = Opts.RTTI && !Args.hasArg(OPT_fno_rtti_data);
2583 Opts.Blocks = Args.hasArg(OPT_fblocks) || (Opts.OpenCL
2584 && Opts.OpenCLVersion == 200);
2585 Opts.BlocksRuntimeOptional = Args.hasArg(OPT_fblocks_runtime_optional);
2586 Opts.CoroutinesTS = Args.hasArg(OPT_fcoroutines_ts);
2589 Opts.DoubleSquareBracketAttributes =
2590 Args.hasFlag(OPT_fdouble_square_bracket_attributes,
2591 OPT_fno_double_square_bracket_attributes, Opts.CPlusPlus11);
2593 Opts.ModulesTS = Args.hasArg(OPT_fmodules_ts);
2594 Opts.Modules = Args.hasArg(OPT_fmodules) || Opts.ModulesTS;
2595 Opts.ModulesStrictDeclUse = Args.hasArg(OPT_fmodules_strict_decluse);
2596 Opts.ModulesDeclUse =
2597 Args.hasArg(OPT_fmodules_decluse) || Opts.ModulesStrictDeclUse;
2598 Opts.ModulesLocalVisibility =
2599 Args.hasArg(OPT_fmodules_local_submodule_visibility) || Opts.ModulesTS;
2600 Opts.ModulesCodegen = Args.hasArg(OPT_fmodules_codegen);
2601 Opts.ModulesDebugInfo = Args.hasArg(OPT_fmodules_debuginfo);
2602 Opts.ModulesSearchAll = Opts.Modules &&
2603 !Args.hasArg(OPT_fno_modules_search_all) &&
2604 Args.hasArg(OPT_fmodules_search_all);
2605 Opts.ModulesErrorRecovery = !Args.hasArg(OPT_fno_modules_error_recovery);
2606 Opts.ImplicitModules = !Args.hasArg(OPT_fno_implicit_modules);
2607 Opts.CharIsSigned = Opts.OpenCL || !Args.hasArg(OPT_fno_signed_char);
2608 Opts.WChar = Opts.CPlusPlus && !Args.hasArg(OPT_fno_wchar);
2609 Opts.Char8 = Args.hasFlag(OPT_fchar8__t, OPT_fno_char8__t, Opts.CPlusPlus2a);
2610 if (
const Arg *A = Args.getLastArg(OPT_fwchar_type_EQ)) {
2611 Opts.WCharSize = llvm::StringSwitch<unsigned>(A->getValue())
2616 if (Opts.WCharSize == 0)
2617 Diags.
Report(diag::err_fe_invalid_wchar_type) << A->getValue();
2619 Opts.WCharIsSigned = Args.hasFlag(OPT_fsigned_wchar, OPT_fno_signed_wchar,
true);
2620 Opts.ShortEnums = Args.hasArg(OPT_fshort_enums);
2621 Opts.Freestanding = Args.hasArg(OPT_ffreestanding);
2622 Opts.NoBuiltin = Args.hasArg(OPT_fno_builtin) || Opts.Freestanding;
2623 if (!Opts.NoBuiltin)
2625 Opts.NoMathBuiltin = Args.hasArg(OPT_fno_math_builtin);
2626 Opts.RelaxedTemplateTemplateArgs =
2627 Args.hasArg(OPT_frelaxed_template_template_args);
2628 Opts.SizedDeallocation = Args.hasArg(OPT_fsized_deallocation);
2629 Opts.AlignedAllocation =
2630 Args.hasFlag(OPT_faligned_allocation, OPT_fno_aligned_allocation,
2631 Opts.AlignedAllocation);
2632 Opts.AlignedAllocationUnavailable =
2633 Opts.AlignedAllocation && Args.hasArg(OPT_aligned_alloc_unavailable);
2634 Opts.NewAlignOverride =
2636 if (Opts.NewAlignOverride && !llvm::isPowerOf2_32(Opts.NewAlignOverride)) {
2637 Arg *A = Args.getLastArg(OPT_fnew_alignment_EQ);
2638 Diags.
Report(diag::err_fe_invalid_alignment) << A->getAsString(Args)
2640 Opts.NewAlignOverride = 0;
2642 Opts.ConceptsTS = Args.hasArg(OPT_fconcepts_ts);
2643 Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions);
2644 Opts.AccessControl = !Args.hasArg(OPT_fno_access_control);
2645 Opts.ElideConstructors = !Args.hasArg(OPT_fno_elide_constructors);
2646 Opts.MathErrno = !Opts.OpenCL && Args.hasArg(OPT_fmath_errno);
2647 Opts.InstantiationDepth =
2651 Opts.ConstexprCallDepth =
2653 Opts.ConstexprStepLimit =
2656 Opts.DelayedTemplateParsing = Args.hasArg(OPT_fdelayed_template_parsing);
2657 Opts.NumLargeByValueCopy =
2659 Opts.MSBitfields = Args.hasArg(OPT_mms_bitfields);
2661 Args.getLastArgValue(OPT_fconstant_string_class);
2662 Opts.ObjCDefaultSynthProperties =
2663 !Args.hasArg(OPT_disable_objc_default_synthesize_properties);
2664 Opts.EncodeExtendedBlockSig =
2665 Args.hasArg(OPT_fencode_extended_block_signature);
2666 Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls);
2669 Opts.AlignDouble = Args.hasArg(OPT_malign_double);
2671 Opts.PIE = Args.hasArg(OPT_pic_is_pie);
2672 Opts.Static = Args.hasArg(OPT_static_define);
2673 Opts.DumpRecordLayoutsSimple = Args.hasArg(OPT_fdump_record_layouts_simple);
2674 Opts.DumpRecordLayouts = Opts.DumpRecordLayoutsSimple
2675 || Args.hasArg(OPT_fdump_record_layouts);
2676 Opts.DumpVTableLayouts = Args.hasArg(OPT_fdump_vtable_layouts);
2677 Opts.SpellChecking = !Args.hasArg(OPT_fno_spell_checking);
2678 Opts.NoBitFieldTypeAlign = Args.hasArg(OPT_fno_bitfield_type_align);
2679 Opts.SinglePrecisionConstants = Args.hasArg(OPT_cl_single_precision_constant);
2680 Opts.FastRelaxedMath = Args.hasArg(OPT_cl_fast_relaxed_math);
2681 Opts.HexagonQdsp6Compat = Args.hasArg(OPT_mqdsp6_compat);
2682 Opts.FakeAddressSpaceMap = Args.hasArg(OPT_ffake_address_space_map);
2683 Opts.ParseUnknownAnytype = Args.hasArg(OPT_funknown_anytype);
2684 Opts.DebuggerSupport = Args.hasArg(OPT_fdebugger_support);
2685 Opts.DebuggerCastResultToId = Args.hasArg(OPT_fdebugger_cast_result_to_id);
2686 Opts.DebuggerObjCLiteral = Args.hasArg(OPT_fdebugger_objc_literal);
2687 Opts.ApplePragmaPack = Args.hasArg(OPT_fapple_pragma_pack);
2688 Opts.
ModuleName = Args.getLastArgValue(OPT_fmodule_name_EQ);
2690 Opts.AppExt = Args.hasArg(OPT_fapplication_extension);
2693 Opts.NativeHalfType |= Args.hasArg(OPT_fnative_half_type);
2694 Opts.NativeHalfArgsAndReturns |= Args.hasArg(OPT_fnative_half_arguments_and_returns);
2697 Opts.HalfArgsAndReturns = Args.hasArg(OPT_fallow_half_arguments_and_returns)
2698 | Opts.NativeHalfArgsAndReturns;
2699 Opts.GNUAsm = !Args.hasArg(OPT_fno_gnu_inline_asm);
2709 Opts.DeclSpecKeyword =
2710 Args.hasFlag(OPT_fdeclspec, OPT_fno_declspec,
2711 (Opts.MicrosoftExt || Opts.Borland || Opts.CUDA));
2713 if (Arg *A = Args.getLastArg(OPT_faddress_space_map_mangling_EQ)) {
2714 switch (llvm::StringSwitch<unsigned>(A->getValue())
2720 Diags.
Report(diag::err_drv_invalid_value)
2721 <<
"-faddress-space-map-mangling=" << A->getValue();
2735 if (Arg *A = Args.getLastArg(OPT_fms_memptr_rep_EQ)) {
2737 llvm::StringSwitch<LangOptions::PragmaMSPointersToMembersKind>(
2747 Diags.
Report(diag::err_drv_invalid_value)
2748 <<
"-fms-memptr-rep=" << A->getValue();
2750 Opts.setMSPointerToMemberRepresentationMethod(InheritanceModel);
2754 if (Arg *A = Args.getLastArg(OPT_fdefault_calling_conv_EQ)) {
2756 llvm::StringSwitch<LangOptions::DefaultCallingConvention>(A->getValue())
2764 Diags.
Report(diag::err_drv_invalid_value)
2765 <<
"-fdefault-calling-conv=" << A->getValue();
2767 llvm::Triple T(TargetOpts.
Triple);
2768 llvm::Triple::ArchType Arch = T.getArch();
2771 Arch != llvm::Triple::x86;
2774 !(Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64);
2776 Diags.
Report(diag::err_drv_argument_not_allowed_with)
2777 << A->getSpelling() << T.getTriple();
2779 Opts.setDefaultCallingConv(DefaultCC);
2783 if (Arg *A = Args.getLastArg(OPT_mrtd)) {
2785 Diags.
Report(diag::err_drv_argument_not_allowed_with)
2786 << A->getSpelling() <<
"-fdefault-calling-conv";
2788 llvm::Triple T(TargetOpts.
Triple);
2789 if (T.getArch() != llvm::Triple::x86)
2790 Diags.
Report(diag::err_drv_argument_not_allowed_with)
2791 << A->getSpelling() << T.getTriple();
2798 Opts.OpenMP = Args.hasArg(options::OPT_fopenmp) ? 1 : 0;
2800 bool IsSimdSpecified =
2801 Args.hasFlag(options::OPT_fopenmp_simd, options::OPT_fno_openmp_simd,
2803 Opts.OpenMPSimd = !Opts.OpenMP && IsSimdSpecified;
2805 Opts.OpenMP && !Args.hasArg(options::OPT_fnoopenmp_use_tls);
2806 Opts.OpenMPIsDevice =
2807 Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_is_device);
2808 bool IsTargetSpecified =
2809 Opts.OpenMPIsDevice || Args.hasArg(options::OPT_fopenmp_targets_EQ);
2811 if (Opts.OpenMP || Opts.OpenMPSimd) {
2813 Args, OPT_fopenmp_version_EQ,
2814 (IsSimdSpecified || IsTargetSpecified) ? 45 : Opts.OpenMP, Diags))
2815 Opts.OpenMP = Version;
2816 else if (IsSimdSpecified || IsTargetSpecified)
2820 if (!Opts.OpenMPIsDevice) {
2821 switch (T.getArch()) {
2825 case llvm::Triple::nvptx:
2826 case llvm::Triple::nvptx64:
2827 Diags.
Report(diag::err_drv_omp_host_target_not_supported)
2836 Opts.OpenMPHostCXXExceptions = Opts.Exceptions && Opts.CXXExceptions;
2837 if ((Opts.OpenMPIsDevice && T.isNVPTX()) || Opts.OpenCLCPlusPlus) {
2838 Opts.Exceptions = 0;
2839 Opts.CXXExceptions = 0;
2841 if (Opts.OpenMPIsDevice && T.isNVPTX()) {
2842 Opts.OpenMPCUDANumSMs =
2844 Opts.OpenMPCUDANumSMs, Diags);
2845 Opts.OpenMPCUDABlocksPerSM =
2847 Opts.OpenMPCUDABlocksPerSM, Diags);
2852 Opts.OpenMPOptimisticCollapse =
2853 Args.hasArg(options::OPT_fopenmp_optimistic_collapse) ? 1 : 0;
2856 if (Arg *A = Args.getLastArg(options::OPT_fopenmp_targets_EQ)) {
2858 for (
unsigned i = 0; i < A->getNumValues(); ++i) {
2859 llvm::Triple TT(A->getValue(i));
2861 if (TT.getArch() == llvm::Triple::UnknownArch ||
2862 !(TT.getArch() == llvm::Triple::ppc ||
2863 TT.getArch() == llvm::Triple::ppc64 ||
2864 TT.getArch() == llvm::Triple::ppc64le ||
2865 TT.getArch() == llvm::Triple::nvptx ||
2866 TT.getArch() == llvm::Triple::nvptx64 ||
2867 TT.getArch() == llvm::Triple::x86 ||
2868 TT.getArch() == llvm::Triple::x86_64))
2869 Diags.
Report(diag::err_drv_invalid_omp_target) << A->getValue(i);
2877 if (Arg *A = Args.getLastArg(options::OPT_fopenmp_host_ir_file_path)) {
2880 Diags.
Report(diag::err_drv_omp_host_ir_file_not_found)
2885 Opts.OpenMPCUDAMode = Opts.OpenMPIsDevice && T.isNVPTX() &&
2886 Args.hasArg(options::OPT_fopenmp_cuda_mode);
2889 Opts.OpenMPCUDAForceFullRuntime =
2890 Opts.OpenMPIsDevice && T.isNVPTX() &&
2891 Args.hasArg(options::OPT_fopenmp_cuda_force_full_runtime);
2894 Opts.Deprecated = Args.hasFlag(OPT_fdeprecated_macro,
2895 OPT_fno_deprecated_macro,
2901 Opts.Optimize = Opt != 0;
2902 Opts.OptimizeSize = OptSize != 0;
2907 Opts.NoInlineDefine = !Opts.Optimize;
2908 if (Arg *InlineArg = Args.getLastArg(
2909 options::OPT_finline_functions, options::OPT_finline_hint_functions,
2910 options::OPT_fno_inline_functions, options::OPT_fno_inline))
2911 if (InlineArg->getOption().matches(options::OPT_fno_inline))
2912 Opts.NoInlineDefine =
true;
2914 Opts.FastMath = Args.hasArg(OPT_ffast_math) ||
2915 Args.hasArg(OPT_cl_fast_relaxed_math);
2916 Opts.FiniteMathOnly = Args.hasArg(OPT_ffinite_math_only) ||
2917 Args.hasArg(OPT_cl_finite_math_only) ||
2918 Args.hasArg(OPT_cl_fast_relaxed_math);
2919 Opts.UnsafeFPMath = Args.hasArg(OPT_menable_unsafe_fp_math) ||
2920 Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
2921 Args.hasArg(OPT_cl_fast_relaxed_math);
2923 if (Arg *A = Args.getLastArg(OPT_ffp_contract)) {
2924 StringRef Val = A->getValue();
2927 else if (Val ==
"on")
2929 else if (Val ==
"off")
2932 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
2935 Opts.RetainCommentsFromSystemHeaders =
2936 Args.hasArg(OPT_fretain_comments_from_system_headers);
2941 Diags.
Report(diag::err_drv_invalid_value)
2942 << Args.getLastArg(OPT_stack_protector)->getAsString(Args) << SSP;
2950 if (Arg *A = Args.getLastArg(OPT_ftrivial_auto_var_init)) {
2951 StringRef Val = A->getValue();
2952 if (Val ==
"uninitialized")
2953 Opts.setTrivialAutoVarInit(
2955 else if (Val ==
"zero")
2957 else if (Val ==
"pattern")
2960 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
2967 Opts.SanitizeAddressFieldPadding =
2972 Opts.XRayInstrument =
2973 Args.hasFlag(OPT_fxray_instrument, OPT_fnoxray_instrument,
false);
2976 Opts.XRayAlwaysEmitCustomEvents =
2977 Args.hasFlag(OPT_fxray_always_emit_customevents,
2978 OPT_fnoxray_always_emit_customevents,
false);
2981 Opts.XRayAlwaysEmitTypedEvents =
2982 Args.hasFlag(OPT_fxray_always_emit_typedevents,
2983 OPT_fnoxray_always_emit_customevents,
false);
2987 Args.getAllArgValues(OPT_fxray_always_instrument);
2989 Args.getAllArgValues(OPT_fxray_never_instrument);
2993 Opts.ForceEmitVTables = Args.hasArg(OPT_fforce_emit_vtables);
2996 Opts.AllowEditorPlaceholders = Args.hasArg(OPT_fallow_editor_placeholders);
2998 Opts.RegisterStaticDestructors = !Args.hasArg(OPT_fno_cxx_static_destructors);
3000 if (Arg *A = Args.getLastArg(OPT_fclang_abi_compat_EQ)) {
3003 StringRef Ver = A->getValue();
3004 std::pair<StringRef, StringRef> VerParts = Ver.split(
'.');
3005 unsigned Major, Minor = 0;
3009 if (!VerParts.first.startswith(
"0") &&
3010 !VerParts.first.getAsInteger(10, Major) &&
3011 3 <= Major && Major <= CLANG_VERSION_MAJOR &&
3012 (Major == 3 ? VerParts.second.size() == 1 &&
3013 !VerParts.second.getAsInteger(10, Minor)
3014 : VerParts.first.size() == Ver.size() ||
3015 VerParts.second ==
"0")) {
3017 if (Major == 3 && Minor <= 8)
3019 else if (Major <= 4)
3021 else if (Major <= 6)
3023 else if (Major <= 7)
3025 }
else if (Ver !=
"latest") {
3026 Diags.
Report(diag::err_drv_invalid_value)
3027 << A->getAsString(Args) << A->getValue();
3031 Opts.CompleteMemberPointers = Args.hasArg(OPT_fcomplete_member_pointers);
3032 Opts.BuildingPCHWithObjectFile = Args.hasArg(OPT_building_pch_with_obj);
3074 llvm_unreachable(
"invalid frontend action");
3081 Opts.
PCHWithHdrStop = Args.hasArg(OPT_pch_through_hdrstop_create) ||
3082 Args.hasArg(OPT_pch_through_hdrstop_use);
3086 Opts.
DetailedRecord = Args.hasArg(OPT_detailed_preprocessing_record);
3091 for (
const auto *A : Args.filtered(OPT_error_on_deserialized_pch_decl))
3094 if (
const Arg *A = Args.getLastArg(OPT_preamble_bytes_EQ)) {
3095 StringRef
Value(A->getValue());
3098 unsigned EndOfLine = 0;
3100 if (Comma == StringRef::npos ||
3101 Value.substr(0, Comma).getAsInteger(10, Bytes) ||
3102 Value.substr(Comma + 1).getAsInteger(10, EndOfLine))
3103 Diags.
Report(diag::err_drv_preamble_format);
3111 if (
const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
3112 StringRef Name = A->getValue();
3113 if (Name ==
"branch")
3115 else if (Name ==
"return")
3117 else if (Name ==
"full")
3122 for (
const auto *A : Args.filtered(OPT_D, OPT_U)) {
3123 if (A->getOption().matches(OPT_D))
3132 for (
const auto *A : Args.filtered(OPT_include))
3133 Opts.
Includes.emplace_back(A->getValue());
3135 for (
const auto *A : Args.filtered(OPT_chain_include))
3138 for (
const auto *A : Args.filtered(OPT_remap_file)) {
3139 std::pair<StringRef, StringRef>
Split = StringRef(A->getValue()).split(
';');
3141 if (Split.second.empty()) {
3142 Diags.
Report(diag::err_drv_invalid_remap_file) << A->getAsString(Args);
3149 if (Arg *A = Args.getLastArg(OPT_fobjc_arc_cxxlib_EQ)) {
3150 StringRef Name = A->getValue();
3151 unsigned Library = llvm::StringSwitch<unsigned>(Name)
3157 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
3173 Opts.
ShowCPP = !Args.hasArg(OPT_dM);
3180 Opts.
ShowMacros = Args.hasArg(OPT_dM) || Args.hasArg(OPT_dD);
3190 Opts.
ABI = Args.getLastArgValue(OPT_target_abi);
3191 if (Arg *A = Args.getLastArg(OPT_meabi)) {
3192 StringRef
Value = A->getValue();
3193 llvm::EABI EABIVersion = llvm::StringSwitch<llvm::EABI>(
Value)
3194 .Case(
"default", llvm::EABI::Default)
3195 .Case(
"4", llvm::EABI::EABI4)
3196 .Case(
"5", llvm::EABI::EABI5)
3197 .Case(
"gnu", llvm::EABI::GNU)
3200 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args)
3205 Opts.
CPU = Args.getLastArgValue(OPT_target_cpu);
3206 Opts.
FPMath = Args.getLastArgValue(OPT_mfpmath);
3208 Opts.
LinkerVersion = Args.getLastArgValue(OPT_target_linker_version);
3209 Opts.
Triple = Args.getLastArgValue(OPT_triple);
3212 Opts.
Triple = llvm::sys::getDefaultTargetTriple();
3217 options::OPT_fcuda_short_ptr, options::OPT_fno_cuda_short_ptr,
false);
3218 if (Arg *A = Args.getLastArg(options::OPT_target_sdk_version_EQ)) {
3219 llvm::VersionTuple Version;
3220 if (Version.tryParse(A->getValue()))
3221 Diags.
Report(diag::err_drv_invalid_value)
3222 << A->getAsString(Args) << A->getValue();
3229 const char *
const *ArgBegin,
3230 const char *
const *ArgEnd,
3232 bool Success =
true;
3237 unsigned MissingArgIndex, MissingArgCount;
3239 Opts->ParseArgs(llvm::makeArrayRef(ArgBegin, ArgEnd), MissingArgIndex,
3240 MissingArgCount, IncludedFlagsBitmask);
3244 if (MissingArgCount) {
3245 Diags.
Report(diag::err_drv_missing_argument)
3246 << Args.getArgString(MissingArgIndex) << MissingArgCount;
3251 for (
const auto *A : Args.filtered(OPT_UNKNOWN)) {
3252 auto ArgString = A->getAsString(Args);
3253 std::string Nearest;
3254 if (Opts->findNearest(ArgString, Nearest, IncludedFlagsBitmask) > 1)
3255 Diags.
Report(diag::err_drv_unknown_argument) << ArgString;
3257 Diags.
Report(diag::err_drv_unknown_argument_with_suggestion)
3258 << ArgString << Nearest;
3284 if (Args.hasArg(OPT_fobjc_arc))
3285 LangOpts.ObjCAutoRefCount = 1;
3289 LangOpts.PIE = Args.hasArg(OPT_pic_is_pie);
3298 LangOpts.ObjCExceptions = 1;
3299 if (T.isOSDarwin() && DashX.isPreprocessed()) {
3307 LangOpts.FunctionAlignment =
3310 if (LangOpts.CUDA) {
3313 if (LangOpts.CUDAIsDevice)
3318 if (LangOpts.OpenMPIsDevice)
3326 !LangOpts.
Sanitize.
has(SanitizerKind::KernelAddress) &&
3328 !LangOpts.
Sanitize.
has(SanitizerKind::KernelMemory);
3336 auto Arch = T.getArch();
3337 if (Arch == llvm::Triple::spir || Arch == llvm::Triple::spir64) {
3345 Diags.Report(diag::warn_drv_fine_grained_bitfield_accesses_ignored);
3353 using llvm::hash_code;
3354 using llvm::hash_value;
3363 #define LANGOPT(Name, Bits, Default, Description) \ 3364 code = hash_combine(code, LangOpts->Name); 3365 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 3366 code = hash_combine(code, static_cast<unsigned>(LangOpts->get##Name())); 3367 #define BENIGN_LANGOPT(Name, Bits, Default, Description) 3368 #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) 3369 #include "clang/Basic/LangOptions.def" 3371 for (StringRef Feature :
LangOpts->ModuleFeatures)
3377 for (
const auto &FeatureAsWritten :
TargetOpts->FeaturesAsWritten)
3390 StringRef MacroDef = I.first;
3392 llvm::CachedHashString(MacroDef.split(
'=').first)))
3416 code = ext->hashExtension(code);
3421 if (getCodeGenOpts().DebugTypeExtRefs)
3422 for (
const auto &KeyValue : getCodeGenOpts().DebugPrefixMap)
3423 code =
hash_combine(code, KeyValue.first, KeyValue.second);
3429 if (!SanHash.
empty())
3432 return llvm::APInt(64, code).toString(36,
false);
3435 template<
typename IntTy>
3440 if (Arg *A = Args.getLastArg(Id)) {
3441 if (StringRef(A->getValue()).getAsInteger(10, Res)) {
3443 Diags->
Report(diag::err_drv_invalid_int_value) << A->getAsString(Args)
3455 return getLastArgIntValueImpl<int>(Args,
Id,
Default, Diags);
3461 return getLastArgIntValueImpl<uint64_t>(Args,
Id,
Default, Diags);
3468 llvm::vfs::getRealFileSystem());
3480 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buffer =
3481 Result->getBufferForFile(File);
3483 Diags.
Report(diag::err_missing_vfs_overlay_file) << File;
3488 std::move(Buffer.get()),
nullptr, File,
3491 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
Enable migration to modern ObjC readwrite property.
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()
Enable migration to modern ObjC readonly property.
Parse and perform semantic analysis.
ObjCXXARCStandardLibraryKind
Enumerate the kinds of standard library that.
static StringRef getCodeModel(ArgList &Args, DiagnosticsEngine &Diags)
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.
std::shared_ptr< llvm::Regex > OptimizationRemarkMissedPattern
Regular expression to select optimizations for which we should enable missed optimization remarks...
use NS_NONATOMIC_IOSONLY for property 'atomic' attribute
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.
static bool isBuiltinFunc(const char *Name)
Returns true if this is a libc/libm function without the '__builtin_' prefix.
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 FPDenormalMode
The floating-point denormal mode to use.
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.
static bool CreateFromArgs(CompilerInvocation &Res, const char *const *ArgBegin, const char *const *ArgEnd, DiagnosticsEngine &Diags)
Create a compiler invocation from a list of input options.
#define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATFN)
std::shared_ptr< LangOptions > LangOpts
Options controlling the language variant.
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)
InputKind::Language getLanguage() const
Get the language that this standard describes.
std::string ASTDumpFilter
If given, filter dumped AST Decl nodes by this substring.
Objects with "hidden" visibility are not seen by the dynamic linker.
static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args, const std::string &WorkingDir)
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 that we'll break out.
Like System, but searched after the system directories.
std::string DebugPass
Enable additional debugging information.
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.
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).
Enable migration to modern ObjC literals.
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].
unsigned IncludeSystemHeaders
Include system header dependencies.
ShowIncludesDestination ShowIncludesDest
Destination of cl.exe style /showIncludes info.
Translate input source into HTML.
static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, DiagnosticsEngine &Diags, const TargetOptions &TargetOpts, const FrontendOptions &FrontendOpts)
Interoperability with the Swift 4.1 runtime.
SanitizerMask Mask
Bitmask of enabled sanitizers.
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.
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.
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 location information but do not generate debug info in the output.
static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args, DiagnosticsEngine &Diags)
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).
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.
std::unique_ptr< llvm::opt::OptTable > createDriverOptTable()
std::string FullCompilerInvocation
Store full compiler invocation for reproducible instructions in the generated report.
std::vector< std::string > Warnings
The list of -W...
std::vector< std::pair< std::string, bool > > CheckersControlList
Pair of checker name and enable/disable.
AnalysisStores
AnalysisStores - Set of available analysis store models.
constexpr XRayInstrMask All
bool isCPlusPlus() const
isCPlusPlus - Language is a C++ variant.
Enable migration of ObjC methods to 'instancetype'.
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.
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.
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
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.
for(unsigned I=0, E=TL.getNumArgs();I !=E;++I)
uint64_t getLastArgUInt64Value(const llvm::opt::ArgList &Args, llvm::opt::OptSpecifier Id, uint64_t Default, DiagnosticsEngine *Diags=nullptr)
#define LANGSTANDARD(id, name, lang, desc, features)
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.
Enable migration to add conforming protocols.
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).
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...
Emit only debug info necessary for generating line number tables (-gline-tables-only).
static IntTy getLastArgIntValueImpl(const ArgList &Args, OptSpecifier Id, IntTy Default, DiagnosticsEngine *Diags)
unsigned ShowEnabledCheckerList
std::string WorkingDir
If set, paths are resolved as if the working directory was set to the value of WorkingDir.
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...
unsigned RewriteIncludes
Preprocess include directives only.
unsigned ShowTimers
Show timers for individual actions.
std::string LinkerVersion
If given, the version string of the linker in use.
Only execute frontend initialization.
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.
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
AnalysisInliningMode
AnalysisInlineFunctionSelection - Set of inlining function selection heuristics.
Objects with "protected" visibility are seen by the dynamic linker but always dynamically resolve to ...
Enable annotation of ObjCMethods of all kinds.
unsigned ShowMacros
Print macro definitions.
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
bool ForceEnableInt128
If given, enables support for __int128_t and __uint128_t types.
The result type of a method or function.
Attempt to be ABI-compatible with code generated by Clang 3.8.x (SVN r257626).
enum clang::FrontendOptions::@191 ARCMTAction
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.
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
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.
prefer 'atomic' property over 'nonatomic'.
std::string ImplicitPCHInclude
The implicit PCH included at the start of the translation unit, or empty.
Limit generated debug info to reduce size (-fno-standalone-debug).
Options for controlling the compiler diagnostics engine.
std::vector< FrontendInputFile > Inputs
The input files and their types.
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.
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::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
Enable inferring NS_DESIGNATED_INITIALIZER for ObjC methods.
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.
annotate property with NS_RETURNS_INNER_POINTER
Load and verify that a PCH file is usable.
std::shared_ptr< TargetOptions > TargetOpts
Options controlling the target.
Enable migration to modern ObjC property.
std::string ModuleName
The module currently being compiled as speficied 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.
Enable converting setter/getter expressions to property-dot syntx.
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.
unsigned maxBlockVisitOnPath
The maximum number of times the analyzer visits a block.
unsigned DisableAllChecks
Disable all analyzer checks.
std::string OutputFile
The file to write dependency output to.
bool allowsARC() const
Does this runtime allow ARC at all?
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.
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
IntrusiveRefCntPtr< llvm::vfs::FileSystem > createVFSFromCompilerInvocation(const CompilerInvocation &CI, DiagnosticsEngine &Diags)
std::string PreferVectorWidth
The preferred width for auto-vectorization transforms.
Emit only debug directives with the line numbers data.
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.
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)
Enable migration to modern ObjC subscripting.
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.
Parse ASTs and dump them.
Don't generate debug info.
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.
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.
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.
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.
Generate pre-compiled module from a set of header files.
int getLastArgIntValue(const llvm::opt::ArgList &Args, llvm::opt::OptSpecifier Id, int Default, DiagnosticsEngine *Diags=nullptr)
Return the value of the last argument as an integer, or a default.
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.
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.
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.
bool isCPlusPlus17() const
isCPlusPlus17 - Language is a C++17 variant (or later).
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.
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...
std::string InstrProfileOutput
Name of the profile file to use as output for -fprofile-instr-generate and -fprofile-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.
Dump information about a module file.
Enable migration to NS_ENUM/NS_OPTIONS macros.
std::string OptRecordFile
The name of the file to which the backend should save YAML optimization records.
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...
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)
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.
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.