15 #include "clang/Config/config.h" 26 #include "llvm/ADT/Hashing.h" 27 #include "llvm/ADT/STLExtras.h" 28 #include "llvm/ADT/SmallVector.h" 29 #include "llvm/ADT/StringExtras.h" 30 #include "llvm/ADT/StringSwitch.h" 31 #include "llvm/ADT/Triple.h" 32 #include "llvm/Linker/Linker.h" 33 #include "llvm/Option/Arg.h" 34 #include "llvm/Option/ArgList.h" 35 #include "llvm/Option/OptTable.h" 36 #include "llvm/Option/Option.h" 37 #include "llvm/ProfileData/InstrProfReader.h" 38 #include "llvm/Support/CodeGen.h" 39 #include "llvm/Support/ErrorHandling.h" 40 #include "llvm/Support/FileSystem.h" 41 #include "llvm/Support/Host.h" 42 #include "llvm/Support/Path.h" 43 #include "llvm/Support/Process.h" 44 #include "llvm/Target/TargetOptions.h" 45 #include "llvm/Support/ScopedPrinter.h" 49 #include <system_error> 50 using namespace clang;
83 unsigned DefaultOpt = 0;
87 if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
88 if (A->getOption().matches(options::OPT_O0))
91 if (A->getOption().matches(options::OPT_Ofast))
94 assert (A->getOption().matches(options::OPT_O));
96 StringRef S(A->getValue());
97 if (S ==
"s" || S ==
"z" || S.empty())
110 if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
111 if (A->getOption().matches(options::OPT_O)) {
112 switch (A->getValue()[0]) {
126 OptSpecifier GroupWithValue,
127 std::vector<std::string> &Diagnostics) {
128 for (Arg *A : Args.filtered(Group)) {
129 if (A->getOption().getKind() == Option::FlagClass) {
132 Diagnostics.push_back(A->getOption().getName().drop_front(1));
133 }
else if (A->getOption().matches(GroupWithValue)) {
135 Diagnostics.push_back(A->getOption().getName().drop_front(1).rtrim(
"=-"));
138 for (
const char *Arg : A->getValues())
139 Diagnostics.emplace_back(Arg);
145 std::vector<std::string> &Funcs) {
147 for (
const auto &Arg : Args) {
148 const Option &O = Arg->getOption();
149 if (O.matches(options::OPT_fno_builtin_)) {
150 const char *FuncName = Arg->getValue();
152 Values.push_back(FuncName);
155 Funcs.insert(Funcs.end(), Values.begin(), Values.end());
160 using namespace options;
162 if (Arg *A = Args.getLastArg(OPT_analyzer_store)) {
163 StringRef Name = A->getValue();
166 .Case(CMDFLAG, NAME##Model)
167 #include "clang/StaticAnalyzer/Core/Analyses.def" 170 Diags.
Report(diag::err_drv_invalid_value)
171 << A->getAsString(Args) << Name;
178 if (Arg *A = Args.getLastArg(OPT_analyzer_constraints)) {
179 StringRef Name = A->getValue();
182 .Case(CMDFLAG, NAME##Model)
183 #include "clang/StaticAnalyzer/Core/Analyses.def" 186 Diags.
Report(diag::err_drv_invalid_value)
187 << A->getAsString(Args) << Name;
194 if (Arg *A = Args.getLastArg(OPT_analyzer_output)) {
195 StringRef Name = A->getValue();
198 .Case(CMDFLAG, PD_##NAME)
199 #include "clang/StaticAnalyzer/Core/Analyses.def" 202 Diags.
Report(diag::err_drv_invalid_value)
203 << A->getAsString(Args) << Name;
210 if (Arg *A = Args.getLastArg(OPT_analyzer_purge)) {
211 StringRef Name = A->getValue();
215 #include "clang/StaticAnalyzer/Core/Analyses.def" 218 Diags.
Report(diag::err_drv_invalid_value)
219 << A->getAsString(Args) << Name;
226 if (Arg *A = Args.getLastArg(OPT_analyzer_inlining_mode)) {
227 StringRef Name = A->getValue();
231 #include "clang/StaticAnalyzer/Core/Analyses.def" 234 Diags.
Report(diag::err_drv_invalid_value)
235 << A->getAsString(Args) << Name;
247 Args.hasArg(OPT_analyzer_viz_egraph_graphviz);
249 Args.hasArg(OPT_analyzer_viz_egraph_ubigraph);
251 Opts.
AnalyzeAll = Args.hasArg(OPT_analyzer_opt_analyze_headers);
254 Args.hasArg(OPT_analyzer_opt_analyze_nested_blocks);
258 Opts.
TrimGraph = Args.hasArg(OPT_trim_egraph);
261 Opts.
PrintStats = Args.hasArg(OPT_analyzer_stats);
268 Args.filtered(OPT_analyzer_checker, OPT_analyzer_disable_checker)) {
270 bool enable = (A->getOption().getID() == OPT_analyzer_checker);
273 StringRef checkerList = A->getValue();
275 checkerList.split(checkers,
",");
276 for (StringRef checker : checkers)
281 for (
const Arg *A : Args.filtered(OPT_analyzer_config)) {
285 StringRef configList = A->getValue();
287 configList.split(configVals,
",");
288 for (
unsigned i = 0, e = configVals.size(); i != e; ++i) {
290 std::tie(key, val) = configVals[i].split(
"=");
293 diag::err_analyzer_config_no_value) << configVals[i];
297 if (val.find(
'=') != StringRef::npos) {
299 diag::err_analyzer_config_multiple_values)
323 if (Arg *A = Args.getLastArg(OPT_mcode_model)) {
324 StringRef
Value = A->getValue();
325 if (Value ==
"small" || Value ==
"kernel" || Value ==
"medium" ||
328 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) <<
Value;
334 if (Arg *A = Args.getLastArg(OPT_mrelocation_model)) {
335 StringRef
Value = A->getValue();
336 if (Value ==
"static" || Value ==
"pic" || Value ==
"ropi" ||
337 Value ==
"rwpi" || Value ==
"ropi-rwpi" || Value ==
"dynamic-no-pic")
339 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) <<
Value;
346 static std::shared_ptr<llvm::Regex>
349 StringRef Val = RpassArg->getValue();
350 std::string RegexError;
351 std::shared_ptr<llvm::Regex> Pattern = std::make_shared<llvm::Regex>(Val);
352 if (!Pattern->isValid(RegexError)) {
353 Diags.
Report(diag::err_drv_optimization_remark_pattern)
354 << RegexError << RpassArg->getAsString(Args);
361 const std::vector<std::string> &Levels,
365 for (
const auto &
Level : Levels) {
367 llvm::StringSwitch<DiagnosticLevelMask>(
Level)
376 Diags->
Report(diag::err_drv_invalid_value) << FlagName <<
Level;
384 const std::vector<std::string> &Sanitizers,
386 for (
const auto &Sanitizer : Sanitizers) {
389 Diags.
Report(diag::err_drv_invalid_value) << FlagName << Sanitizer;
398 Arg *A = Args.getLastArg(OPT_fprofile_instrument_EQ);
401 StringRef S = A->getValue();
402 unsigned I = llvm::StringSwitch<unsigned>(S)
408 Diags.
Report(diag::err_drv_invalid_pgo_instrumentor) << A->getAsString(Args)
414 Opts.setProfileInstr(Instrumentor);
419 const Twine &ProfileName) {
422 if (
auto E = ReaderOrErr.takeError()) {
423 llvm::consumeError(std::move(E));
427 std::unique_ptr<llvm::IndexedInstrProfReader> PGOReader =
428 std::move(ReaderOrErr.get());
429 if (PGOReader->isIRLevelProfile())
438 using namespace options;
440 llvm::Triple Triple = llvm::Triple(TargetOpts.
Triple);
444 unsigned MaxOptLevel = 3;
445 if (OptimizationLevel > MaxOptLevel) {
448 Diags.
Report(diag::warn_drv_optimization_value)
449 << Args.getLastArg(OPT_O)->getAsString(Args) <<
"-O" << MaxOptLevel;
450 OptimizationLevel = MaxOptLevel;
452 Opts.OptimizationLevel = OptimizationLevel;
456 Opts.setInlining((Opts.OptimizationLevel == 0)
461 if (Arg *InlineArg = Args.getLastArg(
462 options::OPT_finline_functions, options::OPT_finline_hint_functions,
463 options::OPT_fno_inline_functions, options::OPT_fno_inline)) {
464 if (Opts.OptimizationLevel > 0) {
465 const Option &InlineOpt = InlineArg->getOption();
466 if (InlineOpt.matches(options::OPT_finline_functions))
467 Opts.setInlining(CodeGenOptions::NormalInlining);
468 else if (InlineOpt.matches(options::OPT_finline_hint_functions))
475 Opts.ExperimentalNewPassManager = Args.hasFlag(
476 OPT_fexperimental_new_pass_manager, OPT_fno_experimental_new_pass_manager,
479 Opts.DebugPassManager =
480 Args.hasFlag(OPT_fdebug_pass_manager, OPT_fno_debug_pass_manager,
483 if (Arg *A = Args.getLastArg(OPT_fveclib)) {
484 StringRef Name = A->getValue();
485 if (Name ==
"Accelerate")
487 else if (Name ==
"SVML")
489 else if (Name ==
"none")
492 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
495 if (Arg *A = Args.getLastArg(OPT_debug_info_kind_EQ)) {
497 llvm::StringSwitch<unsigned>(A->getValue())
503 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args)
506 Opts.setDebugInfo(static_cast<codegenoptions::DebugInfoKind>(Val));
508 if (Arg *A = Args.getLastArg(OPT_debugger_tuning_EQ)) {
509 unsigned Val = llvm::StringSwitch<unsigned>(A->getValue())
510 .Case(
"gdb",
unsigned(llvm::DebuggerKind::GDB))
511 .Case(
"lldb",
unsigned(llvm::DebuggerKind::LLDB))
512 .Case(
"sce",
unsigned(llvm::DebuggerKind::SCE))
515 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args)
518 Opts.setDebuggerTuning(static_cast<llvm::DebuggerKind>(Val));
521 Opts.DebugColumnInfo = Args.hasArg(OPT_dwarf_column_info);
522 Opts.EmitCodeView = Args.hasArg(OPT_gcodeview);
523 Opts.MacroDebugInfo = Args.hasArg(OPT_debug_info_macro);
524 Opts.WholeProgramVTables = Args.hasArg(OPT_fwhole_program_vtables);
525 Opts.LTOVisibilityPublicStd = Args.hasArg(OPT_flto_visibility_public_std);
526 Opts.EnableSplitDwarf = Args.hasArg(OPT_enable_split_dwarf);
528 Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining);
529 Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
530 Opts.DebugExplicitImport = Args.hasArg(OPT_dwarf_explicit_import);
531 Opts.DebugFwdTemplateParams = Args.hasArg(OPT_debug_forward_template_params);
533 for (
const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ))
537 Args.getLastArg(OPT_emit_llvm_uselists, OPT_no_emit_llvm_uselists))
538 Opts.EmitLLVMUseLists = A->getOption().getID() == OPT_emit_llvm_uselists;
540 Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
541 Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
542 Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
543 Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
544 Opts.ForbidGuardVariables = Args.hasArg(OPT_fforbid_guard_variables);
545 Opts.UseRegisterSizedBitfieldAccess = Args.hasArg(
546 OPT_fuse_register_sized_bitfield_access);
547 Opts.RelaxedAliasing = Args.hasArg(OPT_relaxed_aliasing);
548 Opts.StructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa);
549 Opts.NewStructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa) &&
550 Args.hasArg(OPT_new_struct_path_tbaa);
551 Opts.FineGrainedBitfieldAccesses =
552 Args.hasFlag(OPT_ffine_grained_bitfield_accesses,
553 OPT_fno_fine_grained_bitfield_accesses,
false);
555 Opts.MergeAllConstants = !Args.hasArg(OPT_fno_merge_all_constants);
556 Opts.NoCommon = Args.hasArg(OPT_fno_common);
557 Opts.NoImplicitFloat = Args.hasArg(OPT_no_implicit_float);
559 Opts.SimplifyLibCalls = !(Args.hasArg(OPT_fno_builtin) ||
560 Args.hasArg(OPT_ffreestanding));
561 if (Opts.SimplifyLibCalls)
564 Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops,
565 (Opts.OptimizationLevel > 1));
566 Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
568 Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
569 Opts.Autolink = !Args.hasArg(OPT_fno_autolink);
571 Opts.DebugInfoForProfiling = Args.hasFlag(
572 OPT_fdebug_info_for_profiling, OPT_fno_debug_info_for_profiling,
false);
573 Opts.GnuPubnames = Args.hasArg(OPT_ggnu_pubnames);
577 Args.getLastArgValue(OPT_fprofile_instrument_path_EQ);
579 Args.getLastArgValue(OPT_fprofile_instrument_use_path_EQ);
583 if (Arg *A = Args.getLastArg(OPT_fclang_abi_compat_EQ)) {
586 StringRef Ver = A->getValue();
587 std::pair<StringRef, StringRef> VerParts = Ver.split(
'.');
588 unsigned Major, Minor = 0;
592 if (!VerParts.first.startswith(
"0") &&
593 !VerParts.first.getAsInteger(10, Major) &&
594 3 <= Major && Major <= CLANG_VERSION_MAJOR &&
595 (Major == 3 ? VerParts.second.size() == 1 &&
596 !VerParts.second.getAsInteger(10, Minor)
597 : VerParts.first.size() == Ver.size() ||
598 VerParts.second ==
"0")) {
600 if (Major == 3 && Minor <= 8)
604 }
else if (Ver !=
"latest") {
605 Diags.
Report(diag::err_drv_invalid_value)
606 << A->getAsString(Args) << A->getValue();
610 Opts.CoverageMapping =
611 Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping,
false);
612 Opts.DumpCoverageMapping = Args.hasArg(OPT_dump_coverage_mapping);
613 Opts.AsmVerbose = Args.hasArg(OPT_masm_verbose);
614 Opts.PreserveAsmComments = !Args.hasArg(OPT_fno_preserve_as_comments);
615 Opts.AssumeSaneOperatorNew = !Args.hasArg(OPT_fno_assume_sane_operator_new);
616 Opts.ObjCAutoRefCountExceptions = Args.hasArg(OPT_fobjc_arc_exceptions);
617 Opts.CXAAtExit = !Args.hasArg(OPT_fno_use_cxa_atexit);
618 Opts.CXXCtorDtorAliases = Args.hasArg(OPT_mconstructor_aliases);
620 Opts.
DebugPass = Args.getLastArgValue(OPT_mdebug_pass);
622 (Args.hasArg(OPT_mdisable_fp_elim) || Args.hasArg(OPT_pg));
623 Opts.DisableFree = Args.hasArg(OPT_disable_free);
624 Opts.DiscardValueNames = Args.hasArg(OPT_discard_value_names);
625 Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
626 Opts.
FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
627 Opts.LessPreciseFPMAD = Args.hasArg(OPT_cl_mad_enable) ||
628 Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
629 Args.hasArg(OPT_cl_fast_relaxed_math);
631 Opts.NoInfsFPMath = (Args.hasArg(OPT_menable_no_infinities) ||
632 Args.hasArg(OPT_cl_finite_math_only) ||
633 Args.hasArg(OPT_cl_fast_relaxed_math));
634 Opts.NoNaNsFPMath = (Args.hasArg(OPT_menable_no_nans) ||
635 Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
636 Args.hasArg(OPT_cl_finite_math_only) ||
637 Args.hasArg(OPT_cl_fast_relaxed_math));
638 Opts.NoSignedZeros = (Args.hasArg(OPT_fno_signed_zeros) ||
639 Args.hasArg(OPT_cl_no_signed_zeros) ||
640 Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
641 Args.hasArg(OPT_cl_fast_relaxed_math));
642 Opts.Reassociate = Args.hasArg(OPT_mreassociate);
643 Opts.FlushDenorm = Args.hasArg(OPT_cl_denorms_are_zero);
644 Opts.CorrectlyRoundedDivSqrt =
645 Args.hasArg(OPT_cl_fp32_correctly_rounded_divide_sqrt);
646 Opts.
Reciprocals = Args.getAllArgValues(OPT_mrecip_EQ);
647 Opts.ReciprocalMath = Args.hasArg(OPT_freciprocal_math);
648 Opts.NoTrappingMath = Args.hasArg(OPT_fno_trapping_math);
649 Opts.NoZeroInitializedInBSS = Args.hasArg(OPT_mno_zero_initialized_in_bss);
652 Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
653 Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
654 Opts.EnableSegmentedStacks = Args.hasArg(OPT_split_stacks);
655 Opts.RelaxAll = Args.hasArg(OPT_mrelax_all);
656 Opts.IncrementalLinkerCompatible =
657 Args.hasArg(OPT_mincremental_linker_compatible);
658 Opts.PIECopyRelocations =
659 Args.hasArg(OPT_mpie_copy_relocations);
660 Opts.NoPLT = Args.hasArg(OPT_fno_plt);
661 Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer);
662 Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels);
663 Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm);
664 Opts.SoftFloat = Args.hasArg(OPT_msoft_float);
665 Opts.StrictEnums = Args.hasArg(OPT_fstrict_enums);
666 Opts.StrictReturn = !Args.hasArg(OPT_fno_strict_return);
667 Opts.StrictVTablePointers = Args.hasArg(OPT_fstrict_vtable_pointers);
668 Opts.UnsafeFPMath = Args.hasArg(OPT_menable_unsafe_fp_math) ||
669 Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
670 Args.hasArg(OPT_cl_fast_relaxed_math);
671 Opts.UnwindTables = Args.hasArg(OPT_munwind_tables);
673 Opts.
ThreadModel = Args.getLastArgValue(OPT_mthread_model,
"posix");
675 Diags.
Report(diag::err_drv_invalid_value)
676 << Args.getLastArg(OPT_mthread_model)->getAsString(Args)
678 Opts.
TrapFuncName = Args.getLastArgValue(OPT_ftrap_function_EQ);
679 Opts.UseInitArray = Args.hasArg(OPT_fuse_init_array);
681 Opts.FunctionSections = Args.hasFlag(OPT_ffunction_sections,
682 OPT_fno_function_sections,
false);
683 Opts.DataSections = Args.hasFlag(OPT_fdata_sections,
684 OPT_fno_data_sections,
false);
685 Opts.UniqueSectionNames = Args.hasFlag(OPT_funique_section_names,
686 OPT_fno_unique_section_names,
true);
688 Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions);
690 Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
692 Opts.ProfileSampleAccurate = Args.hasArg(OPT_fprofile_sample_accurate);
694 Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
695 Opts.EmitSummaryIndex =
false;
696 if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
697 StringRef S = A->getValue();
699 Opts.EmitSummaryIndex =
true;
700 else if (S !=
"full")
701 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << S;
703 Opts.LTOUnit = Args.hasFlag(OPT_flto_unit, OPT_fno_lto_unit,
false);
704 if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) {
706 Diags.
Report(diag::err_drv_argument_only_allowed_with)
707 << A->getAsString(Args) <<
"-x ir";
712 Opts.MSVolatile = Args.hasArg(OPT_fms_volatile);
714 Opts.VectorizeLoop = Args.hasArg(OPT_vectorize_loops);
715 Opts.VectorizeSLP = Args.hasArg(OPT_vectorize_slp);
719 Opts.
MainFileName = Args.getLastArgValue(OPT_main_file_name);
720 Opts.VerifyModule = !Args.hasArg(OPT_disable_llvm_verifier);
722 Opts.DisableGCov = Args.hasArg(OPT_test_coverage);
723 Opts.EmitGcovArcs = Args.hasArg(OPT_femit_coverage_data);
724 Opts.EmitGcovNotes = Args.hasArg(OPT_femit_coverage_notes);
725 if (Opts.EmitGcovArcs || Opts.EmitGcovNotes) {
728 Opts.CoverageExtraChecksum = Args.hasArg(OPT_coverage_cfg_checksum);
729 Opts.CoverageNoFunctionNamesInData =
730 Args.hasArg(OPT_coverage_no_function_names_in_data);
731 Opts.CoverageExitBlockBeforeBody =
732 Args.hasArg(OPT_coverage_exit_block_before_body);
733 if (Args.hasArg(OPT_coverage_version_EQ)) {
734 StringRef CoverageVersion = Args.getLastArgValue(OPT_coverage_version_EQ);
735 if (CoverageVersion.size() != 4) {
736 Diags.
Report(diag::err_drv_invalid_value)
737 << Args.getLastArg(OPT_coverage_version_EQ)->getAsString(Args)
745 if (Arg *A = Args.getLastArg(OPT_fembed_bitcode_EQ)) {
746 StringRef Name = A->getValue();
747 unsigned Model = llvm::StringSwitch<unsigned>(Name)
754 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
757 Opts.setEmbedBitcode(
758 static_cast<CodeGenOptions::EmbedBitcodeKind>(Model));
764 for (
const auto &A : Args) {
766 if (A->getOption().getID() == options::OPT_o ||
767 A->getOption().getID() == options::OPT_INPUT ||
768 A->getOption().getID() == options::OPT_x ||
769 A->getOption().getID() == options::OPT_fembed_bitcode ||
770 (A->getOption().getGroup().isValid() &&
771 A->getOption().getGroup().getID() == options::OPT_W_Group))
774 A->render(Args, ASL);
775 for (
const auto &arg : ASL) {
776 StringRef ArgStr(arg);
777 Opts.
CmdArgs.insert(Opts.
CmdArgs.end(), ArgStr.begin(), ArgStr.end());
784 Opts.PreserveVec3Type = Args.hasArg(OPT_fpreserve_vec3_type);
785 Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
786 Opts.InstrumentFunctionsAfterInlining =
787 Args.hasArg(OPT_finstrument_functions_after_inlining);
788 Opts.InstrumentFunctionEntryBare =
789 Args.hasArg(OPT_finstrument_function_entry_bare);
790 Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
791 Opts.XRayAlwaysEmitCustomEvents =
792 Args.hasArg(OPT_fxray_always_emit_customevents);
793 Opts.XRayInstructionThreshold =
795 Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
796 Opts.CallFEntry = Args.hasArg(OPT_mfentry);
797 Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
799 if (
const Arg *A = Args.getLastArg(OPT_compress_debug_sections,
800 OPT_compress_debug_sections_EQ)) {
801 if (A->getOption().getID() == OPT_compress_debug_sections) {
803 Opts.setCompressDebugSections(llvm::DebugCompressionType::GNU);
805 auto DCT = llvm::StringSwitch<llvm::DebugCompressionType>(A->getValue())
807 .Case(
"zlib", llvm::DebugCompressionType::Z)
808 .Case(
"zlib-gnu", llvm::DebugCompressionType::GNU)
810 Opts.setCompressDebugSections(DCT);
814 Opts.RelaxELFRelocations = Args.hasArg(OPT_mrelax_relocations);
816 for (
auto A : Args.filtered(OPT_mlink_bitcode_file, OPT_mlink_cuda_bitcode)) {
819 if (A->getOption().matches(OPT_mlink_cuda_bitcode)) {
820 F.
LinkFlags = llvm::Linker::Flags::LinkOnlyNeeded;
828 Opts.SanitizeCoverageType =
830 Opts.SanitizeCoverageIndirectCalls =
831 Args.hasArg(OPT_fsanitize_coverage_indirect_calls);
832 Opts.SanitizeCoverageTraceBB = Args.hasArg(OPT_fsanitize_coverage_trace_bb);
833 Opts.SanitizeCoverageTraceCmp = Args.hasArg(OPT_fsanitize_coverage_trace_cmp);
834 Opts.SanitizeCoverageTraceDiv = Args.hasArg(OPT_fsanitize_coverage_trace_div);
835 Opts.SanitizeCoverageTraceGep = Args.hasArg(OPT_fsanitize_coverage_trace_gep);
836 Opts.SanitizeCoverage8bitCounters =
837 Args.hasArg(OPT_fsanitize_coverage_8bit_counters);
838 Opts.SanitizeCoverageTracePC = Args.hasArg(OPT_fsanitize_coverage_trace_pc);
839 Opts.SanitizeCoverageTracePCGuard =
840 Args.hasArg(OPT_fsanitize_coverage_trace_pc_guard);
841 Opts.SanitizeCoverageNoPrune = Args.hasArg(OPT_fsanitize_coverage_no_prune);
842 Opts.SanitizeCoverageInline8bitCounters =
843 Args.hasArg(OPT_fsanitize_coverage_inline_8bit_counters);
844 Opts.SanitizeCoveragePCTable = Args.hasArg(OPT_fsanitize_coverage_pc_table);
845 Opts.SanitizeCoverageStackDepth =
846 Args.hasArg(OPT_fsanitize_coverage_stack_depth);
847 Opts.SanitizeMemoryTrackOrigins =
849 Opts.SanitizeMemoryUseAfterDtor =
850 Args.hasFlag(OPT_fsanitize_memory_use_after_dtor,
851 OPT_fno_sanitize_memory_use_after_dtor,
853 Opts.SanitizeMinimalRuntime = Args.hasArg(OPT_fsanitize_minimal_runtime);
854 Opts.SanitizeCfiCrossDso = Args.hasArg(OPT_fsanitize_cfi_cross_dso);
855 Opts.SanitizeCfiICallGeneralizePointers =
856 Args.hasArg(OPT_fsanitize_cfi_icall_generalize_pointers);
857 Opts.SanitizeStats = Args.hasArg(OPT_fsanitize_stats);
858 if (Arg *A = Args.getLastArg(OPT_fsanitize_address_use_after_scope,
859 OPT_fno_sanitize_address_use_after_scope)) {
860 Opts.SanitizeAddressUseAfterScope =
861 A->getOption().getID() == OPT_fsanitize_address_use_after_scope;
863 Opts.SanitizeAddressGlobalsDeadStripping =
864 Args.hasArg(OPT_fsanitize_address_globals_dead_stripping);
867 Opts.StackRealignment = Args.hasArg(OPT_mstackrealign);
868 if (Arg *A = Args.getLastArg(OPT_mstack_alignment)) {
869 StringRef Val = A->getValue();
870 unsigned StackAlignment = Opts.StackAlignment;
871 Val.getAsInteger(10, StackAlignment);
872 Opts.StackAlignment = StackAlignment;
875 if (Arg *A = Args.getLastArg(OPT_mstack_probe_size)) {
876 StringRef Val = A->getValue();
877 unsigned StackProbeSize = Opts.StackProbeSize;
878 Val.getAsInteger(0, StackProbeSize);
879 Opts.StackProbeSize = StackProbeSize;
882 if (Arg *A = Args.getLastArg(OPT_fobjc_dispatch_method_EQ)) {
883 StringRef Name = A->getValue();
884 unsigned Method = llvm::StringSwitch<unsigned>(Name)
890 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
893 Opts.setObjCDispatchMethod(
894 static_cast<CodeGenOptions::ObjCDispatchMethodKind>(Method));
899 Args.hasFlag(OPT_femulated_tls, OPT_fno_emulated_tls,
false);
901 if (Arg *A = Args.getLastArg(OPT_ftlsmodel_EQ)) {
902 StringRef Name = A->getValue();
903 unsigned Model = llvm::StringSwitch<unsigned>(Name)
910 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
913 Opts.setDefaultTLSModel(static_cast<CodeGenOptions::TLSModel>(Model));
917 if (Arg *A = Args.getLastArg(OPT_fdenormal_fp_math_EQ)) {
918 StringRef Val = A->getValue();
921 else if (Val ==
"preserve-sign")
923 else if (Val ==
"positive-zero")
926 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
929 if (Arg *A = Args.getLastArg(OPT_fpcc_struct_return, OPT_freg_struct_return)) {
930 if (A->getOption().matches(OPT_fpcc_struct_return)) {
933 assert(A->getOption().matches(OPT_freg_struct_return));
939 Opts.
LinkerOptions = Args.getAllArgValues(OPT_linker_option);
940 bool NeedLocTracking =
false;
942 Opts.
OptRecordFile = Args.getLastArgValue(OPT_opt_record_file);
944 NeedLocTracking =
true;
946 if (Arg *A = Args.getLastArg(OPT_Rpass_EQ)) {
949 NeedLocTracking =
true;
952 if (Arg *A = Args.getLastArg(OPT_Rpass_missed_EQ)) {
955 NeedLocTracking =
true;
958 if (Arg *A = Args.getLastArg(OPT_Rpass_analysis_EQ)) {
961 NeedLocTracking =
true;
964 Opts.DiagnosticsWithHotness =
965 Args.hasArg(options::OPT_fdiagnostics_show_hotness);
967 bool UsingProfile = UsingSampleProfile ||
970 if (Opts.DiagnosticsWithHotness && !UsingProfile)
971 Diags.
Report(diag::warn_drv_diagnostics_hotness_requires_pgo)
972 <<
"-fdiagnostics-show-hotness";
975 Args, options::OPT_fdiagnostics_hotness_threshold_EQ, 0);
976 if (Opts.DiagnosticsHotnessThreshold > 0 && !UsingProfile)
977 Diags.
Report(diag::warn_drv_diagnostics_hotness_requires_pgo)
978 <<
"-fdiagnostics-hotness-threshold=";
983 if (UsingSampleProfile)
984 NeedLocTracking =
true;
996 Args.getAllArgValues(OPT_fsanitize_recover_EQ), Diags,
999 Args.getAllArgValues(OPT_fsanitize_trap_EQ), Diags,
1003 Args.getAllArgValues(OPT_fcuda_include_gpubinary);
1005 Opts.Backchain = Args.hasArg(OPT_mbackchain);
1008 Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags);
1015 using namespace options;
1016 Opts.
OutputFile = Args.getLastArgValue(OPT_dependency_file);
1017 Opts.
Targets = Args.getAllArgValues(OPT_MT);
1025 Opts.
DOTOutputFile = Args.getLastArgValue(OPT_dependency_dot);
1027 Args.getLastArgValue(OPT_module_dependency_dir);
1028 if (Args.hasArg(OPT_MV))
1033 Opts.
ExtraDeps = Args.getAllArgValues(OPT_fdepfile_entry);
1035 for (
const Arg *A : Args.filtered(OPT_fmodule_file)) {
1036 StringRef Val = A->getValue();
1037 if (Val.find(
'=') == StringRef::npos)
1051 } ShowColors = DefaultColor ? Colors_Auto : Colors_Off;
1052 for (Arg *A : Args) {
1053 const Option &O = A->getOption();
1054 if (O.matches(options::OPT_fcolor_diagnostics) ||
1055 O.matches(options::OPT_fdiagnostics_color)) {
1056 ShowColors = Colors_On;
1057 }
else if (O.matches(options::OPT_fno_color_diagnostics) ||
1058 O.matches(options::OPT_fno_diagnostics_color)) {
1059 ShowColors = Colors_Off;
1060 }
else if (O.matches(options::OPT_fdiagnostics_color_EQ)) {
1061 StringRef
Value(A->getValue());
1062 if (
Value ==
"always")
1063 ShowColors = Colors_On;
1064 else if (
Value ==
"never")
1065 ShowColors = Colors_Off;
1066 else if (
Value ==
"auto")
1067 ShowColors = Colors_Auto;
1070 return ShowColors == Colors_On ||
1071 (ShowColors == Colors_Auto &&
1072 llvm::sys::Process::StandardErrHasColors());
1077 bool Success =
true;
1078 for (
const auto &Prefix : VerifyPrefixes) {
1081 auto BadChar = std::find_if(Prefix.begin(), Prefix.end(),
1083 &&
C !=
'-' &&
C !=
'_';});
1084 if (BadChar != Prefix.end() || !
isLetter(Prefix[0])) {
1087 Diags->
Report(diag::err_drv_invalid_value) <<
"-verify=" << Prefix;
1088 Diags->
Report(diag::note_drv_verify_prefix_spelling);
1097 bool DefaultDiagColor,
bool DefaultShowOpt) {
1098 using namespace options;
1099 bool Success =
true;
1103 Args.getLastArg(OPT_diagnostic_serialized_file, OPT__serialize_diags))
1105 Opts.IgnoreWarnings = Args.hasArg(OPT_w);
1106 Opts.NoRewriteMacros = Args.hasArg(OPT_Wno_rewrite_macros);
1107 Opts.Pedantic = Args.hasArg(OPT_pedantic);
1108 Opts.PedanticErrors = Args.hasArg(OPT_pedantic_errors);
1109 Opts.ShowCarets = !Args.hasArg(OPT_fno_caret_diagnostics);
1111 Opts.ShowColumn = Args.hasFlag(OPT_fshow_column,
1112 OPT_fno_show_column,
1114 Opts.ShowFixits = !Args.hasArg(OPT_fno_diagnostics_fixit_info);
1115 Opts.ShowLocation = !Args.hasArg(OPT_fno_show_source_location);
1116 Opts.AbsolutePath = Args.hasArg(OPT_fdiagnostics_absolute_paths);
1117 Opts.ShowOptionNames =
1118 Args.hasFlag(OPT_fdiagnostics_show_option,
1119 OPT_fno_diagnostics_show_option, DefaultShowOpt);
1121 llvm::sys::Process::UseANSIEscapeCodes(Args.hasArg(OPT_fansi_escape_codes));
1124 Opts.ShowNoteIncludeStack =
false;
1125 if (Arg *A = Args.getLastArg(OPT_fdiagnostics_show_note_include_stack,
1126 OPT_fno_diagnostics_show_note_include_stack))
1127 if (A->getOption().matches(OPT_fdiagnostics_show_note_include_stack))
1128 Opts.ShowNoteIncludeStack =
true;
1130 StringRef ShowOverloads =
1131 Args.getLastArgValue(OPT_fshow_overloads_EQ,
"all");
1132 if (ShowOverloads ==
"best")
1134 else if (ShowOverloads ==
"all")
1135 Opts.setShowOverloads(
Ovl_All);
1139 Diags->
Report(diag::err_drv_invalid_value)
1140 << Args.getLastArg(OPT_fshow_overloads_EQ)->getAsString(Args)
1144 StringRef ShowCategory =
1145 Args.getLastArgValue(OPT_fdiagnostics_show_category,
"none");
1146 if (ShowCategory ==
"none")
1147 Opts.ShowCategories = 0;
1148 else if (ShowCategory ==
"id")
1149 Opts.ShowCategories = 1;
1150 else if (ShowCategory ==
"name")
1151 Opts.ShowCategories = 2;
1155 Diags->
Report(diag::err_drv_invalid_value)
1156 << Args.getLastArg(OPT_fdiagnostics_show_category)->getAsString(Args)
1161 Args.getLastArgValue(OPT_fdiagnostics_format,
"clang");
1162 if (Format ==
"clang")
1164 else if (Format ==
"msvc")
1166 else if (Format ==
"msvc-fallback") {
1168 Opts.CLFallbackMode =
true;
1169 }
else if (Format ==
"vi")
1174 Diags->
Report(diag::err_drv_invalid_value)
1175 << Args.getLastArg(OPT_fdiagnostics_format)->getAsString(Args)
1179 Opts.ShowSourceRanges = Args.hasArg(OPT_fdiagnostics_print_source_range_info);
1180 Opts.ShowParseableFixits = Args.hasArg(OPT_fdiagnostics_parseable_fixits);
1181 Opts.ShowPresumedLoc = !Args.hasArg(OPT_fno_diagnostics_use_presumed_location);
1182 Opts.VerifyDiagnostics = Args.hasArg(OPT_verify) || Args.hasArg(OPT_verify_EQ);
1184 if (Args.hasArg(OPT_verify))
1189 Opts.VerifyDiagnostics =
false;
1196 Args.getAllArgValues(OPT_verify_ignore_unexpected_EQ),
1198 if (Args.hasArg(OPT_verify_ignore_unexpected))
1200 Opts.setVerifyIgnoreUnexpected(DiagMask);
1201 Opts.ElideType = !Args.hasArg(OPT_fno_elide_type);
1202 Opts.ShowTemplateTree = Args.hasArg(OPT_fdiagnostics_show_template_tree);
1204 Opts.MacroBacktraceLimit =
1208 Args, OPT_ftemplate_backtrace_limit,
1211 Args, OPT_fconstexpr_backtrace_limit,
1214 Args, OPT_fspell_checking_limit,
1217 Args, OPT_fcaret_diagnostics_max_lines,
1224 Diags->
Report(diag::warn_ignoring_ftabstop_value)
1235 Opts.
WorkingDir = Args.getLastArgValue(OPT_working_directory);
1243 std::string &BlockName,
1244 unsigned &MajorVersion,
1245 unsigned &MinorVersion,
1247 std::string &UserInfo) {
1249 Arg.split(Args,
':', 5);
1250 if (Args.size() < 5)
1253 BlockName = Args[0];
1254 if (Args[1].getAsInteger(10, MajorVersion))
return true;
1255 if (Args[2].getAsInteger(10, MinorVersion))
return true;
1256 if (Args[3].getAsInteger(2, Hashed))
return true;
1257 if (Args.size() > 4)
1265 using namespace options;
1267 if (
const Arg *A = Args.getLastArg(OPT_Action_Group)) {
1268 switch (A->getOption().getID()) {
1270 llvm_unreachable(
"Invalid option in group!");
1274 case OPT_ast_dump_all:
1275 case OPT_ast_dump_lookups:
1281 case OPT_dump_raw_tokens:
1283 case OPT_dump_tokens:
1287 case OPT_emit_llvm_bc:
1293 case OPT_emit_llvm_only:
1295 case OPT_emit_codegen_only:
1304 case OPT_emit_module:
1306 case OPT_emit_module_interface:
1314 case OPT_fsyntax_only:
1316 case OPT_module_file_info:
1318 case OPT_verify_pch:
1320 case OPT_print_decl_contexts:
1322 case OPT_print_preamble:
1326 case OPT_rewrite_macros:
1328 case OPT_rewrite_objc:
1330 case OPT_rewrite_test:
1341 if (
const Arg* A = Args.getLastArg(OPT_plugin)) {
1342 Opts.
Plugins.emplace_back(A->getValue(0));
1347 for (
const Arg *AA : Args.filtered(OPT_plugin_arg))
1348 Opts.
PluginArgs[AA->getValue(0)].emplace_back(AA->getValue(1));
1350 for (
const std::string &Arg :
1351 Args.getAllArgValues(OPT_ftest_module_file_extension_EQ)) {
1352 std::string BlockName;
1353 unsigned MajorVersion;
1354 unsigned MinorVersion;
1356 std::string UserInfo;
1358 MinorVersion, Hashed, UserInfo)) {
1359 Diags.
Report(diag::err_test_module_file_extension_format) << Arg;
1366 std::make_shared<TestModuleFileExtension>(
1367 BlockName, MajorVersion, MinorVersion, Hashed, UserInfo));
1370 if (
const Arg *A = Args.getLastArg(OPT_code_completion_at)) {
1374 Diags.
Report(diag::err_drv_invalid_value)
1375 << A->getAsString(Args) << A->getValue();
1379 Opts.
OutputFile = Args.getLastArgValue(OPT_o);
1380 Opts.
Plugins = Args.getAllArgValues(OPT_load);
1382 Opts.
ShowHelp = Args.hasArg(OPT_help);
1383 Opts.
ShowStats = Args.hasArg(OPT_print_stats);
1384 Opts.
ShowTimers = Args.hasArg(OPT_ftime_report);
1387 Opts.
LLVMArgs = Args.getAllArgValues(OPT_mllvm);
1393 Opts.
ASTDumpAll = Args.hasArg(OPT_ast_dump_all);
1394 Opts.
ASTDumpFilter = Args.getLastArgValue(OPT_ast_dump_filter);
1398 Opts.
ModuleMapFiles = Args.getAllArgValues(OPT_fmodule_map_file);
1400 for (
const Arg *A : Args.filtered(OPT_fmodule_file)) {
1401 StringRef Val = A->getValue();
1402 if (Val.find(
'=') == StringRef::npos)
1410 = Args.hasArg(OPT_code_completion_macros);
1412 = Args.hasArg(OPT_code_completion_patterns);
1414 = !Args.hasArg(OPT_no_code_completion_globals);
1416 = !Args.hasArg(OPT_no_code_completion_ns_level_decls);
1418 = Args.hasArg(OPT_code_completion_brief_comments);
1421 = Args.getLastArgValue(OPT_foverride_record_layout_EQ);
1424 Opts.
FindPchSource = Args.getLastArgValue(OPT_find_pch_source_EQ);
1425 Opts.
StatsFile = Args.getLastArgValue(OPT_stats_file);
1427 if (
const Arg *A = Args.getLastArg(OPT_arcmt_check,
1429 OPT_arcmt_migrate)) {
1430 switch (A->getOption().getID()) {
1432 llvm_unreachable(
"missed a case");
1433 case OPT_arcmt_check:
1436 case OPT_arcmt_modify:
1439 case OPT_arcmt_migrate:
1444 Opts.
MTMigrateDir = Args.getLastArgValue(OPT_mt_migrate_directory);
1446 = Args.getLastArgValue(OPT_arcmt_migrate_report_output);
1448 = Args.hasArg(OPT_arcmt_migrate_emit_arc_errors);
1450 if (Args.hasArg(OPT_objcmt_migrate_literals))
1452 if (Args.hasArg(OPT_objcmt_migrate_subscripting))
1454 if (Args.hasArg(OPT_objcmt_migrate_property_dot_syntax))
1456 if (Args.hasArg(OPT_objcmt_migrate_property))
1458 if (Args.hasArg(OPT_objcmt_migrate_readonly_property))
1460 if (Args.hasArg(OPT_objcmt_migrate_readwrite_property))
1462 if (Args.hasArg(OPT_objcmt_migrate_annotation))
1464 if (Args.hasArg(OPT_objcmt_returns_innerpointer_property))
1466 if (Args.hasArg(OPT_objcmt_migrate_instancetype))
1468 if (Args.hasArg(OPT_objcmt_migrate_nsmacros))
1470 if (Args.hasArg(OPT_objcmt_migrate_protocol_conformance))
1472 if (Args.hasArg(OPT_objcmt_atomic_property))
1474 if (Args.hasArg(OPT_objcmt_ns_nonatomic_iosonly))
1476 if (Args.hasArg(OPT_objcmt_migrate_designated_init))
1478 if (Args.hasArg(OPT_objcmt_migrate_all))
1485 Diags.
Report(diag::err_drv_argument_not_allowed_with)
1486 <<
"ARC migration" <<
"ObjC migration";
1490 if (
const Arg *A = Args.getLastArg(OPT_x)) {
1491 StringRef XValue = A->getValue();
1495 bool Preprocessed = XValue.consume_back(
"-cpp-output");
1496 bool ModuleMap = XValue.consume_back(
"-module-map");
1498 !Preprocessed && !ModuleMap && XValue.consume_back(
"-header");
1501 DashX = llvm::StringSwitch<InputKind>(XValue)
1513 if (DashX.
isUnknown() && Preprocessed && !IsHeaderFile && !ModuleMap)
1514 DashX = llvm::StringSwitch<InputKind>(XValue)
1521 DashX = llvm::StringSwitch<InputKind>(XValue)
1524 .Cases(
"ast",
"pcm",
1530 Diags.
Report(diag::err_drv_invalid_value)
1531 << A->getAsString(Args) << A->getValue();
1540 std::vector<std::string> Inputs = Args.getAllArgValues(OPT_INPUT);
1543 Inputs.push_back(
"-");
1544 for (
unsigned i = 0, e = Inputs.size(); i != e; ++i) {
1548 StringRef(Inputs[i]).rsplit(
'.').second);
1562 Opts.
Inputs.emplace_back(std::move(Inputs[i]), IK);
1570 std::string ClangExecutable =
1571 llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
1572 StringRef Dir = llvm::sys::path::parent_path(ClangExecutable);
1575 StringRef ClangResourceDir(CLANG_RESOURCE_DIR);
1577 if (ClangResourceDir !=
"")
1578 llvm::sys::path::append(P, ClangResourceDir);
1580 llvm::sys::path::append(P,
"..", Twine(
"lib") + CLANG_LIBDIR_SUFFIX,
1581 "clang", CLANG_VERSION_STRING);
1587 const std::string &WorkingDir) {
1588 using namespace options;
1589 Opts.
Sysroot = Args.getLastArgValue(OPT_isysroot,
"/");
1590 Opts.
Verbose = Args.hasArg(OPT_v);
1594 if (
const Arg *A = Args.getLastArg(OPT_stdlib_EQ))
1595 Opts.
UseLibcxx = (strcmp(A->getValue(),
"libc++") == 0);
1596 Opts.
ResourceDir = Args.getLastArgValue(OPT_resource_dir);
1600 if (!(
P.empty() || llvm::sys::path::is_absolute(
P))) {
1601 if (WorkingDir.empty())
1602 llvm::sys::fs::make_absolute(
P);
1604 llvm::sys::fs::make_absolute(WorkingDir,
P);
1606 llvm::sys::path::remove_dots(
P);
1611 for (
const Arg *A : Args.filtered(OPT_fmodule_file)) {
1612 StringRef Val = A->getValue();
1613 if (Val.find(
'=') != StringRef::npos)
1616 for (
const Arg *A : Args.filtered(OPT_fprebuilt_module_path))
1621 !Args.hasArg(OPT_fmodules_disable_diagnostic_validation);
1629 Args.hasArg(OPT_fmodules_validate_once_per_build_session);
1633 Args.hasArg(OPT_fmodules_validate_system_headers);
1634 if (
const Arg *A = Args.getLastArg(OPT_fmodule_format_EQ))
1637 for (
const Arg *A : Args.filtered(OPT_fmodules_ignore_macro)) {
1638 StringRef MacroDef = A->getValue();
1640 llvm::CachedHashString(MacroDef.split(
'=').first));
1644 bool IsIndexHeaderMap =
false;
1645 bool IsSysrootSpecified =
1646 Args.hasArg(OPT__sysroot_EQ) || Args.hasArg(OPT_isysroot);
1647 for (
const Arg *A : Args.filtered(OPT_I, OPT_F, OPT_index_header_map)) {
1648 if (A->getOption().matches(OPT_index_header_map)) {
1650 IsIndexHeaderMap =
true;
1657 bool IsFramework = A->getOption().matches(OPT_F);
1658 std::string Path = A->getValue();
1660 if (IsSysrootSpecified && !IsFramework && A->getValue()[0] ==
'=') {
1662 llvm::sys::path::append(Buffer, Opts.
Sysroot,
1663 llvm::StringRef(A->getValue()).substr(1));
1664 Path = Buffer.str();
1667 Opts.
AddPath(Path, Group, IsFramework,
1669 IsIndexHeaderMap =
false;
1673 StringRef Prefix =
"";
1675 Args.filtered(OPT_iprefix, OPT_iwithprefix, OPT_iwithprefixbefore)) {
1676 if (A->getOption().matches(OPT_iprefix))
1677 Prefix = A->getValue();
1678 else if (A->getOption().matches(OPT_iwithprefix))
1684 for (
const Arg *A : Args.filtered(OPT_idirafter))
1686 for (
const Arg *A : Args.filtered(OPT_iquote))
1688 for (
const Arg *A : Args.filtered(OPT_isystem, OPT_iwithsysroot))
1690 !A->getOption().matches(OPT_iwithsysroot));
1691 for (
const Arg *A : Args.filtered(OPT_iframework))
1693 for (
const Arg *A : Args.filtered(OPT_iframeworkwithsysroot))
1698 for (
const Arg *A : Args.filtered(OPT_c_isystem))
1700 for (
const Arg *A : Args.filtered(OPT_cxx_isystem))
1702 for (
const Arg *A : Args.filtered(OPT_objc_isystem))
1704 for (
const Arg *A : Args.filtered(OPT_objcxx_isystem))
1709 Args.filtered(OPT_internal_isystem, OPT_internal_externc_isystem)) {
1711 if (A->getOption().matches(OPT_internal_externc_isystem))
1713 Opts.
AddPath(A->getValue(), Group,
false,
true);
1718 Args.filtered(OPT_system_header_prefix, OPT_no_system_header_prefix))
1720 A->getValue(), A->getOption().matches(OPT_system_header_prefix));
1722 for (
const Arg *A : Args.filtered(OPT_ivfsoverlay))
1727 const llvm::Triple &
T,
1738 Opts.AsmPreprocessor = 1;
1740 Opts.ObjC1 = Opts.ObjC2 = 1;
1748 llvm_unreachable(
"Invalid input kind!");
1750 LangStd = LangStandard::lang_opencl10;
1753 LangStd = LangStandard::lang_cuda;
1759 LangStd = LangStandard::lang_gnu99;
1761 LangStd = LangStandard::lang_gnu11;
1764 LangStd = LangStandard::lang_gnu11;
1768 LangStd = LangStandard::lang_gnucxx14;
1771 LangStd = LangStandard::lang_c99;
1778 Opts.C99 = Std.
isC99();
1779 Opts.C11 = Std.
isC11();
1780 Opts.C17 = Std.
isC17();
1788 Opts.GNUInline = !Opts.C99 && !Opts.CPlusPlus;
1794 if (LangStd == LangStandard::lang_opencl10)
1795 Opts.OpenCLVersion = 100;
1796 else if (LangStd == LangStandard::lang_opencl11)
1797 Opts.OpenCLVersion = 110;
1798 else if (LangStd == LangStandard::lang_opencl12)
1799 Opts.OpenCLVersion = 120;
1800 else if (LangStd == LangStandard::lang_opencl20)
1801 Opts.OpenCLVersion = 200;
1807 Opts.LaxVectorConversions = 0;
1809 Opts.NativeHalfType = 1;
1810 Opts.NativeHalfArgsAndReturns = 1;
1812 if (Opts.IncludeDefaultHeader) {
1813 PPOpts.
Includes.push_back(
"opencl-c.h");
1823 if (Opts.RenderScript) {
1824 Opts.NativeHalfType = 1;
1825 Opts.NativeHalfArgsAndReturns = 1;
1829 Opts.Bool = Opts.OpenCL || Opts.CPlusPlus;
1832 Opts.Half = Opts.OpenCL;
1835 Opts.WChar = Opts.CPlusPlus;
1837 Opts.GNUKeywords = Opts.GNUMode;
1838 Opts.CXXOperatorNames = Opts.CPlusPlus;
1840 Opts.AlignedAllocation = Opts.CPlusPlus17;
1842 Opts.DollarIdents = !Opts.AsmPreprocessor;
1848 StringRef value = arg->getValue();
1849 if (value ==
"default") {
1851 }
else if (value ==
"hidden" || value ==
"internal") {
1853 }
else if (value ==
"protected") {
1858 diags.
Report(diag::err_drv_invalid_value)
1859 << arg->getAsString(args) << value;
1869 llvm_unreachable(
"should not parse language flags for this input");
1895 llvm_unreachable(
"unexpected input language");
1904 return "Objective-C";
1908 return "Objective-C++";
1914 return "RenderScript";
1924 llvm_unreachable(
"unknown input language");
1933 if (
const Arg *A = Args.getLastArg(OPT_std_EQ)) {
1934 LangStd = llvm::StringSwitch<LangStandard::Kind>(A->getValue())
1936 .Case(name, LangStandard::lang_##
id)
1937 #define LANGSTANDARD_ALIAS(id, alias) \ 1938 .Case(alias, LangStandard::lang_##id) 1939 #include "clang/Frontend/LangStandards.def" 1942 Diags.
Report(diag::err_drv_invalid_value)
1943 << A->getAsString(Args) << A->getValue();
1945 for (
unsigned KindValue = 0;
1949 static_cast<LangStandard::Kind>(KindValue));
1951 auto Diag = Diags.
Report(diag::note_drv_use_standard);
1953 unsigned NumAliases = 0;
1954 #define LANGSTANDARD(id, name, lang, desc, features) 1955 #define LANGSTANDARD_ALIAS(id, alias) \ 1956 if (KindValue == LangStandard::lang_##id) ++NumAliases; 1957 #define LANGSTANDARD_ALIAS_DEPR(id, alias) 1958 #include "clang/Frontend/LangStandards.def" 1960 #define LANGSTANDARD(id, name, lang, desc, features) 1961 #define LANGSTANDARD_ALIAS(id, alias) \ 1962 if (KindValue == LangStandard::lang_##id) Diag << alias; 1963 #define LANGSTANDARD_ALIAS_DEPR(id, alias) 1964 #include "clang/Frontend/LangStandards.def" 1972 Diags.
Report(diag::err_drv_argument_not_allowed_with)
1980 if (
const Arg *A = Args.getLastArg(OPT_cl_std_EQ)) {
1982 = llvm::StringSwitch<LangStandard::Kind>(A->getValue())
1983 .Cases(
"cl",
"CL", LangStandard::lang_opencl10)
1984 .Cases(
"cl1.1",
"CL1.1", LangStandard::lang_opencl11)
1985 .Cases(
"cl1.2",
"CL1.2", LangStandard::lang_opencl12)
1986 .Cases(
"cl2.0",
"CL2.0", LangStandard::lang_opencl20)
1990 Diags.
Report(diag::err_drv_invalid_value)
1991 << A->getAsString(Args) << A->getValue();
1994 LangStd = OpenCLLangStd;
1997 Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
1999 llvm::Triple
T(TargetOpts.
Triple);
2005 if (Args.getLastArg(OPT_cl_strict_aliasing)
2006 && Opts.OpenCLVersion > 100) {
2007 std::string VerSpec = llvm::to_string(Opts.OpenCLVersion / 100) +
2009 llvm::to_string((Opts.OpenCLVersion % 100) / 10);
2010 Diags.
Report(diag::warn_option_invalid_ocl_version)
2011 << VerSpec << Args.getLastArg(OPT_cl_strict_aliasing)->getAsString(Args);
2019 Opts.GNUKeywords = Args.hasFlag(OPT_fgnu_keywords, OPT_fno_gnu_keywords,
2022 if (Args.hasArg(OPT_fno_operator_names))
2023 Opts.CXXOperatorNames = 0;
2025 if (Args.hasArg(OPT_fcuda_is_device))
2026 Opts.CUDAIsDevice = 1;
2028 if (Args.hasArg(OPT_fcuda_allow_variadic_functions))
2029 Opts.CUDAAllowVariadicFunctions = 1;
2031 if (Args.hasArg(OPT_fno_cuda_host_device_constexpr))
2032 Opts.CUDAHostDeviceConstexpr = 0;
2034 if (Opts.CUDAIsDevice && Args.hasArg(OPT_fcuda_flush_denormals_to_zero))
2035 Opts.CUDADeviceFlushDenormalsToZero = 1;
2037 if (Opts.CUDAIsDevice && Args.hasArg(OPT_fcuda_approx_transcendentals))
2038 Opts.CUDADeviceApproxTranscendentals = 1;
2041 if (Arg *arg = Args.getLastArg(OPT_fobjc_runtime_EQ)) {
2042 StringRef value = arg->getValue();
2044 Diags.
Report(diag::err_drv_unknown_objc_runtime) << value;
2047 if (Args.hasArg(OPT_fobjc_gc_only))
2049 else if (Args.hasArg(OPT_fobjc_gc))
2051 else if (Args.hasArg(OPT_fobjc_arc)) {
2052 Opts.ObjCAutoRefCount = 1;
2054 Diags.
Report(diag::err_arc_unsupported_on_runtime);
2061 if (Args.hasArg(OPT_fobjc_runtime_has_weak))
2062 Opts.ObjCWeakRuntime = 1;
2068 if (
auto weakArg = Args.getLastArg(OPT_fobjc_weak, OPT_fno_objc_weak)) {
2069 if (!weakArg->getOption().matches(OPT_fobjc_weak)) {
2070 assert(!Opts.ObjCWeak);
2072 Diags.
Report(diag::err_objc_weak_with_gc);
2073 }
else if (!Opts.ObjCWeakRuntime) {
2074 Diags.
Report(diag::err_objc_weak_unsupported);
2078 }
else if (Opts.ObjCAutoRefCount) {
2079 Opts.ObjCWeak = Opts.ObjCWeakRuntime;
2082 if (Args.hasArg(OPT_fno_objc_infer_related_result_type))
2083 Opts.ObjCInferRelatedResultType = 0;
2085 if (Args.hasArg(OPT_fobjc_subscripting_legacy_runtime))
2086 Opts.ObjCSubscriptingLegacyRuntime =
2090 if (Args.hasArg(OPT_fgnu89_inline)) {
2092 Diags.
Report(diag::err_drv_argument_not_allowed_with)
2098 if (Args.hasArg(OPT_fapple_kext)) {
2099 if (!Opts.CPlusPlus)
2100 Diags.
Report(diag::warn_c_kext);
2105 if (Args.hasArg(OPT_print_ivar_layout))
2106 Opts.ObjCGCBitmapPrint = 1;
2107 if (Args.hasArg(OPT_fno_constant_cfstrings))
2108 Opts.NoConstantCFStrings = 1;
2110 if (Args.hasArg(OPT_fzvector))
2113 if (Args.hasArg(OPT_pthread))
2114 Opts.POSIXThreads = 1;
2117 if (Arg *visOpt = Args.getLastArg(OPT_fvisibility)) {
2124 if (Arg *typeVisOpt = Args.getLastArg(OPT_ftype_visibility)) {
2127 Opts.setTypeVisibilityMode(Opts.getValueVisibilityMode());
2130 if (Args.hasArg(OPT_fvisibility_inlines_hidden))
2131 Opts.InlineVisibilityHidden = 1;
2133 if (Args.hasArg(OPT_ftrapv)) {
2137 Args.getLastArgValue(OPT_ftrapv_handler);
2139 else if (Args.hasArg(OPT_fwrapv))
2142 Opts.MSVCCompat = Args.hasArg(OPT_fms_compatibility);
2143 Opts.MicrosoftExt = Opts.MSVCCompat || Args.hasArg(OPT_fms_extensions);
2144 Opts.AsmBlocks = Args.hasArg(OPT_fasm_blocks) || Opts.MicrosoftExt;
2145 Opts.MSCompatibilityVersion = 0;
2146 if (
const Arg *A = Args.getLastArg(OPT_fms_compatibility_version)) {
2149 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args)
2151 Opts.MSCompatibilityVersion = VT.
getMajor() * 10000000 +
2152 VT.
getMinor().getValueOr(0) * 100000 +
2159 Opts.Trigraphs = !Opts.GNUMode && !Opts.MSVCCompat && !Opts.CPlusPlus17;
2161 Args.hasFlag(OPT_ftrigraphs, OPT_fno_trigraphs, Opts.Trigraphs);
2163 Opts.DollarIdents = Args.hasFlag(OPT_fdollars_in_identifiers,
2164 OPT_fno_dollars_in_identifiers,
2166 Opts.PascalStrings = Args.hasArg(OPT_fpascal_strings);
2168 Opts.Borland = Args.hasArg(OPT_fborland_extensions);
2169 Opts.WritableStrings = Args.hasArg(OPT_fwritable_strings);
2170 Opts.ConstStrings = Args.hasFlag(OPT_fconst_strings, OPT_fno_const_strings,
2172 if (Args.hasArg(OPT_fno_lax_vector_conversions))
2173 Opts.LaxVectorConversions = 0;
2174 if (Args.hasArg(OPT_fno_threadsafe_statics))
2175 Opts.ThreadsafeStatics = 0;
2176 Opts.Exceptions = Args.hasArg(OPT_fexceptions);
2177 Opts.ObjCExceptions = Args.hasArg(OPT_fobjc_exceptions);
2178 Opts.CXXExceptions = Args.hasArg(OPT_fcxx_exceptions);
2181 Arg *A = Args.getLastArg(options::OPT_fsjlj_exceptions,
2182 options::OPT_fseh_exceptions,
2183 options::OPT_fdwarf_exceptions);
2185 const Option &Opt = A->getOption();
2186 Opts.SjLjExceptions = Opt.matches(options::OPT_fsjlj_exceptions);
2187 Opts.SEHExceptions = Opt.matches(options::OPT_fseh_exceptions);
2188 Opts.DWARFExceptions = Opt.matches(options::OPT_fdwarf_exceptions);
2191 Opts.ExternCNoUnwind = Args.hasArg(OPT_fexternc_nounwind);
2192 Opts.TraditionalCPP = Args.hasArg(OPT_traditional_cpp);
2194 Opts.RTTI = Opts.CPlusPlus && !Args.hasArg(OPT_fno_rtti);
2195 Opts.RTTIData = Opts.RTTI && !Args.hasArg(OPT_fno_rtti_data);
2196 Opts.Blocks = Args.hasArg(OPT_fblocks) || (Opts.OpenCL
2197 && Opts.OpenCLVersion >= 200);
2198 Opts.BlocksRuntimeOptional = Args.hasArg(OPT_fblocks_runtime_optional);
2199 Opts.CoroutinesTS = Args.hasArg(OPT_fcoroutines_ts);
2202 Opts.DoubleSquareBracketAttributes =
2203 Args.hasFlag(OPT_fdouble_square_bracket_attributes,
2204 OPT_fno_double_square_bracket_attributes, Opts.CPlusPlus11);
2206 Opts.ModulesTS = Args.hasArg(OPT_fmodules_ts);
2207 Opts.Modules = Args.hasArg(OPT_fmodules) || Opts.ModulesTS;
2208 Opts.ModulesStrictDeclUse = Args.hasArg(OPT_fmodules_strict_decluse);
2209 Opts.ModulesDeclUse =
2210 Args.hasArg(OPT_fmodules_decluse) || Opts.ModulesStrictDeclUse;
2211 Opts.ModulesLocalVisibility =
2212 Args.hasArg(OPT_fmodules_local_submodule_visibility) || Opts.ModulesTS;
2213 Opts.ModulesCodegen = Args.hasArg(OPT_fmodules_codegen);
2214 Opts.ModulesDebugInfo = Args.hasArg(OPT_fmodules_debuginfo);
2215 Opts.ModulesSearchAll = Opts.Modules &&
2216 !Args.hasArg(OPT_fno_modules_search_all) &&
2217 Args.hasArg(OPT_fmodules_search_all);
2218 Opts.ModulesErrorRecovery = !Args.hasArg(OPT_fno_modules_error_recovery);
2219 Opts.ImplicitModules = !Args.hasArg(OPT_fno_implicit_modules);
2220 Opts.CharIsSigned = Opts.OpenCL || !Args.hasArg(OPT_fno_signed_char);
2221 Opts.WChar = Opts.CPlusPlus && !Args.hasArg(OPT_fno_wchar);
2222 if (
const Arg *A = Args.getLastArg(OPT_fwchar_type_EQ)) {
2223 Opts.WCharSize = llvm::StringSwitch<unsigned>(A->getValue())
2228 if (Opts.WCharSize == 0)
2229 Diags.
Report(diag::err_fe_invalid_wchar_type) << A->getValue();
2231 Opts.WCharIsSigned = Args.hasFlag(OPT_fsigned_wchar, OPT_fno_signed_wchar,
true);
2232 Opts.ShortEnums = Args.hasArg(OPT_fshort_enums);
2233 Opts.Freestanding = Args.hasArg(OPT_ffreestanding);
2234 Opts.NoBuiltin = Args.hasArg(OPT_fno_builtin) || Opts.Freestanding;
2235 if (!Opts.NoBuiltin)
2237 Opts.NoMathBuiltin = Args.hasArg(OPT_fno_math_builtin);
2238 Opts.RelaxedTemplateTemplateArgs =
2239 Args.hasArg(OPT_frelaxed_template_template_args);
2240 Opts.SizedDeallocation = Args.hasArg(OPT_fsized_deallocation);
2241 Opts.AlignedAllocation =
2242 Args.hasFlag(OPT_faligned_allocation, OPT_fno_aligned_allocation,
2243 Opts.AlignedAllocation);
2244 Opts.AlignedAllocationUnavailable =
2245 Opts.AlignedAllocation && Args.hasArg(OPT_aligned_alloc_unavailable);
2246 Opts.NewAlignOverride =
2248 if (Opts.NewAlignOverride && !llvm::isPowerOf2_32(Opts.NewAlignOverride)) {
2249 Arg *A = Args.getLastArg(OPT_fnew_alignment_EQ);
2250 Diags.
Report(diag::err_fe_invalid_alignment) << A->getAsString(Args)
2252 Opts.NewAlignOverride = 0;
2254 Opts.ConceptsTS = Args.hasArg(OPT_fconcepts_ts);
2255 Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions);
2256 Opts.AccessControl = !Args.hasArg(OPT_fno_access_control);
2257 Opts.ElideConstructors = !Args.hasArg(OPT_fno_elide_constructors);
2258 Opts.MathErrno = !Opts.OpenCL && Args.hasArg(OPT_fmath_errno);
2259 Opts.InstantiationDepth =
2263 Opts.ConstexprCallDepth =
2265 Opts.ConstexprStepLimit =
2268 Opts.DelayedTemplateParsing = Args.hasArg(OPT_fdelayed_template_parsing);
2269 Opts.NumLargeByValueCopy =
2271 Opts.MSBitfields = Args.hasArg(OPT_mms_bitfields);
2273 Args.getLastArgValue(OPT_fconstant_string_class);
2274 Opts.ObjCDefaultSynthProperties =
2275 !Args.hasArg(OPT_disable_objc_default_synthesize_properties);
2276 Opts.EncodeExtendedBlockSig =
2277 Args.hasArg(OPT_fencode_extended_block_signature);
2278 Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls);
2281 Opts.AlignDouble = Args.hasArg(OPT_malign_double);
2283 Opts.PIE = Args.hasArg(OPT_pic_is_pie);
2284 Opts.Static = Args.hasArg(OPT_static_define);
2285 Opts.DumpRecordLayoutsSimple = Args.hasArg(OPT_fdump_record_layouts_simple);
2286 Opts.DumpRecordLayouts = Opts.DumpRecordLayoutsSimple
2287 || Args.hasArg(OPT_fdump_record_layouts);
2288 Opts.DumpVTableLayouts = Args.hasArg(OPT_fdump_vtable_layouts);
2289 Opts.SpellChecking = !Args.hasArg(OPT_fno_spell_checking);
2290 Opts.NoBitFieldTypeAlign = Args.hasArg(OPT_fno_bitfield_type_align);
2291 Opts.SinglePrecisionConstants = Args.hasArg(OPT_cl_single_precision_constant);
2292 Opts.FastRelaxedMath = Args.hasArg(OPT_cl_fast_relaxed_math);
2293 Opts.HexagonQdsp6Compat = Args.hasArg(OPT_mqdsp6_compat);
2294 Opts.FakeAddressSpaceMap = Args.hasArg(OPT_ffake_address_space_map);
2295 Opts.ParseUnknownAnytype = Args.hasArg(OPT_funknown_anytype);
2296 Opts.DebuggerSupport = Args.hasArg(OPT_fdebugger_support);
2297 Opts.DebuggerCastResultToId = Args.hasArg(OPT_fdebugger_cast_result_to_id);
2298 Opts.DebuggerObjCLiteral = Args.hasArg(OPT_fdebugger_objc_literal);
2299 Opts.ApplePragmaPack = Args.hasArg(OPT_fapple_pragma_pack);
2300 Opts.
CurrentModule = Args.getLastArgValue(OPT_fmodule_name_EQ);
2301 Opts.AppExt = Args.hasArg(OPT_fapplication_extension);
2304 Opts.NativeHalfType |= Args.hasArg(OPT_fnative_half_type);
2305 Opts.NativeHalfArgsAndReturns |= Args.hasArg(OPT_fnative_half_arguments_and_returns);
2308 Opts.HalfArgsAndReturns = Args.hasArg(OPT_fallow_half_arguments_and_returns)
2309 | Opts.NativeHalfArgsAndReturns;
2310 Opts.GNUAsm = !Args.hasArg(OPT_fno_gnu_inline_asm);
2320 Opts.DeclSpecKeyword =
2321 Args.hasFlag(OPT_fdeclspec, OPT_fno_declspec,
2322 (Opts.MicrosoftExt || Opts.Borland || Opts.CUDA));
2324 if (Arg *A = Args.getLastArg(OPT_faddress_space_map_mangling_EQ)) {
2325 switch (llvm::StringSwitch<unsigned>(A->getValue())
2331 Diags.
Report(diag::err_drv_invalid_value)
2332 <<
"-faddress-space-map-mangling=" << A->getValue();
2346 if (Arg *A = Args.getLastArg(OPT_fms_memptr_rep_EQ)) {
2348 llvm::StringSwitch<LangOptions::PragmaMSPointersToMembersKind>(
2358 Diags.
Report(diag::err_drv_invalid_value)
2359 <<
"-fms-memptr-rep=" << A->getValue();
2361 Opts.setMSPointerToMemberRepresentationMethod(InheritanceModel);
2365 if (Arg *A = Args.getLastArg(OPT_fdefault_calling_conv_EQ)) {
2367 llvm::StringSwitch<LangOptions::DefaultCallingConvention>(A->getValue())
2375 Diags.
Report(diag::err_drv_invalid_value)
2376 <<
"-fdefault-calling-conv=" << A->getValue();
2378 llvm::Triple
T(TargetOpts.
Triple);
2379 llvm::Triple::ArchType Arch = T.getArch();
2382 Arch != llvm::Triple::x86;
2385 !(Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64);
2387 Diags.
Report(diag::err_drv_argument_not_allowed_with)
2388 << A->getSpelling() << T.getTriple();
2390 Opts.setDefaultCallingConv(DefaultCC);
2394 if (Arg *A = Args.getLastArg(OPT_mrtd)) {
2396 Diags.
Report(diag::err_drv_argument_not_allowed_with)
2397 << A->getSpelling() <<
"-fdefault-calling-conv";
2399 llvm::Triple
T(TargetOpts.
Triple);
2400 if (T.getArch() != llvm::Triple::x86)
2401 Diags.
Report(diag::err_drv_argument_not_allowed_with)
2402 << A->getSpelling() << T.getTriple();
2409 Opts.OpenMP = Args.hasArg(options::OPT_fopenmp) ? 1 : 0;
2411 Opts.OpenMPSimd = !Opts.OpenMP && Args.hasFlag(options::OPT_fopenmp_simd,
2412 options::OPT_fno_openmp_simd,
2415 Opts.OpenMP && !Args.hasArg(options::OPT_fnoopenmp_use_tls);
2416 Opts.OpenMPIsDevice =
2417 Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_is_device);
2419 if (Opts.OpenMP || Opts.OpenMPSimd) {
2422 Opts.OpenMPSimd ? 45 : Opts.OpenMP, Diags))
2423 Opts.OpenMP = Version;
2424 else if (Opts.OpenMPSimd)
2428 if (!Opts.OpenMPIsDevice) {
2429 switch (T.getArch()) {
2433 case llvm::Triple::nvptx:
2434 case llvm::Triple::nvptx64:
2435 Diags.
Report(clang::diag::err_drv_omp_host_target_not_supported)
2444 if (Opts.OpenMPIsDevice && T.isNVPTX()) {
2445 Opts.Exceptions = 0;
2446 Opts.CXXExceptions = 0;
2450 if (Arg *A = Args.getLastArg(options::OPT_fopenmp_targets_EQ)) {
2452 for (
unsigned i = 0; i < A->getNumValues(); ++i) {
2453 llvm::Triple TT(A->getValue(i));
2455 if (TT.getArch() == llvm::Triple::UnknownArch ||
2456 !(TT.getArch() == llvm::Triple::ppc ||
2457 TT.getArch() == llvm::Triple::ppc64 ||
2458 TT.getArch() == llvm::Triple::ppc64le ||
2459 TT.getArch() == llvm::Triple::nvptx ||
2460 TT.getArch() == llvm::Triple::nvptx64 ||
2461 TT.getArch() == llvm::Triple::x86 ||
2462 TT.getArch() == llvm::Triple::x86_64))
2463 Diags.
Report(clang::diag::err_drv_invalid_omp_target) << A->getValue(i);
2471 if (Arg *A = Args.getLastArg(options::OPT_fopenmp_host_ir_file_path)) {
2474 Diags.
Report(clang::diag::err_drv_omp_host_ir_file_not_found)
2479 Opts.Deprecated = Args.hasFlag(OPT_fdeprecated_macro,
2480 OPT_fno_deprecated_macro,
2486 Opts.Optimize = Opt != 0;
2487 Opts.OptimizeSize = OptSize != 0;
2492 Opts.NoInlineDefine = !Opts.Optimize;
2493 if (Arg *InlineArg = Args.getLastArg(
2494 options::OPT_finline_functions, options::OPT_finline_hint_functions,
2495 options::OPT_fno_inline_functions, options::OPT_fno_inline))
2496 if (InlineArg->getOption().matches(options::OPT_fno_inline))
2497 Opts.NoInlineDefine =
true;
2499 Opts.FastMath = Args.hasArg(OPT_ffast_math) ||
2500 Args.hasArg(OPT_cl_fast_relaxed_math);
2501 Opts.FiniteMathOnly = Args.hasArg(OPT_ffinite_math_only) ||
2502 Args.hasArg(OPT_cl_finite_math_only) ||
2503 Args.hasArg(OPT_cl_fast_relaxed_math);
2504 Opts.UnsafeFPMath = Args.hasArg(OPT_menable_unsafe_fp_math) ||
2505 Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
2506 Args.hasArg(OPT_cl_fast_relaxed_math);
2508 if (Arg *A = Args.getLastArg(OPT_ffp_contract)) {
2509 StringRef Val = A->getValue();
2512 else if (Val ==
"on")
2514 else if (Val ==
"off")
2517 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
2520 Opts.RetainCommentsFromSystemHeaders =
2521 Args.hasArg(OPT_fretain_comments_from_system_headers);
2526 Diags.
Report(diag::err_drv_invalid_value)
2527 << Args.getLastArg(OPT_stack_protector)->getAsString(Args) << SSP;
2539 Opts.SanitizeAddressFieldPadding =
2544 Opts.XRayInstrument =
2545 Args.hasFlag(OPT_fxray_instrument, OPT_fnoxray_instrument,
false);
2548 Opts.XRayAlwaysEmitCustomEvents =
2549 Args.hasFlag(OPT_fxray_always_emit_customevents,
2550 OPT_fnoxray_always_emit_customevents,
false);
2554 Args.getAllArgValues(OPT_fxray_always_instrument);
2556 Args.getAllArgValues(OPT_fxray_never_instrument);
2559 Opts.AllowEditorPlaceholders = Args.hasArg(OPT_fallow_editor_placeholders);
2600 llvm_unreachable(
"invalid frontend action");
2607 using namespace options;
2610 if (
const Arg *A = Args.getLastArg(OPT_token_cache))
2615 Opts.
DetailedRecord = Args.hasArg(OPT_detailed_preprocessing_record);
2620 for (
const Arg *A : Args.filtered(OPT_error_on_deserialized_pch_decl))
2623 if (
const Arg *A = Args.getLastArg(OPT_preamble_bytes_EQ)) {
2624 StringRef
Value(A->getValue());
2627 unsigned EndOfLine = 0;
2629 if (Comma == StringRef::npos ||
2630 Value.substr(0, Comma).getAsInteger(10, Bytes) ||
2631 Value.substr(Comma + 1).getAsInteger(10, EndOfLine))
2632 Diags.
Report(diag::err_drv_preamble_format);
2640 for (
const Arg *A : Args.filtered(OPT_D, OPT_U)) {
2641 if (A->getOption().matches(OPT_D))
2650 for (
const Arg *A : Args.filtered(OPT_include))
2651 Opts.
Includes.emplace_back(A->getValue());
2653 for (
const Arg *A : Args.filtered(OPT_chain_include))
2656 for (
const Arg *A : Args.filtered(OPT_remap_file)) {
2657 std::pair<StringRef, StringRef> Split = StringRef(A->getValue()).split(
';');
2659 if (Split.second.empty()) {
2660 Diags.
Report(diag::err_drv_invalid_remap_file) << A->getAsString(Args);
2667 if (Arg *A = Args.getLastArg(OPT_fobjc_arc_cxxlib_EQ)) {
2668 StringRef Name = A->getValue();
2669 unsigned Library = llvm::StringSwitch<unsigned>(Name)
2675 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
2690 using namespace options;
2693 Opts.
ShowCPP = !Args.hasArg(OPT_dM);
2700 Opts.
ShowMacros = Args.hasArg(OPT_dM) || Args.hasArg(OPT_dD);
2709 using namespace options;
2710 Opts.
ABI = Args.getLastArgValue(OPT_target_abi);
2711 if (Arg *A = Args.getLastArg(OPT_meabi)) {
2712 StringRef
Value = A->getValue();
2713 llvm::EABI EABIVersion = llvm::StringSwitch<llvm::EABI>(
Value)
2714 .Case(
"default", llvm::EABI::Default)
2715 .Case(
"4", llvm::EABI::EABI4)
2716 .Case(
"5", llvm::EABI::EABI5)
2717 .Case(
"gnu", llvm::EABI::GNU)
2720 Diags.
Report(diag::err_drv_invalid_value) << A->getAsString(Args)
2725 Opts.
CPU = Args.getLastArgValue(OPT_target_cpu);
2726 Opts.
FPMath = Args.getLastArgValue(OPT_mfpmath);
2728 Opts.
LinkerVersion = Args.getLastArgValue(OPT_target_linker_version);
2732 Opts.
Triple = llvm::sys::getDefaultTargetTriple();
2737 const char *
const *ArgBegin,
2738 const char *
const *ArgEnd,
2740 bool Success =
true;
2745 unsigned MissingArgIndex, MissingArgCount;
2747 Opts->ParseArgs(llvm::makeArrayRef(ArgBegin, ArgEnd), MissingArgIndex,
2748 MissingArgCount, IncludedFlagsBitmask);
2752 if (MissingArgCount) {
2753 Diags.
Report(diag::err_drv_missing_argument)
2754 << Args.getArgString(MissingArgIndex) << MissingArgCount;
2759 for (
const Arg *A : Args.filtered(OPT_UNKNOWN)) {
2760 Diags.
Report(diag::err_drv_unknown_argument) << A->getAsString(Args);
2785 if (Args.hasArg(OPT_fobjc_arc))
2786 LangOpts.ObjCAutoRefCount = 1;
2790 LangOpts.PIE = Args.hasArg(OPT_pic_is_pie);
2799 LangOpts.ObjCExceptions = 1;
2802 if (LangOpts.CUDA) {
2805 if (LangOpts.CUDAIsDevice)
2810 if (LangOpts.OpenMPIsDevice)
2832 auto Arch =
T.getArch();
2833 if (Arch == llvm::Triple::spir || Arch == llvm::Triple::spir64) {
2841 Diags.Report(diag::warn_drv_fine_grained_bitfield_accesses_ignored);
2849 using llvm::hash_code;
2850 using llvm::hash_value;
2859 #define LANGOPT(Name, Bits, Default, Description) \ 2860 code = hash_combine(code, LangOpts->Name); 2861 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 2862 code = hash_combine(code, static_cast<unsigned>(LangOpts->get##Name())); 2863 #define BENIGN_LANGOPT(Name, Bits, Default, Description) 2864 #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) 2865 #include "clang/Basic/LangOptions.def" 2867 for (StringRef Feature :
LangOpts->ModuleFeatures)
2873 for (
unsigned i = 0, n =
TargetOpts->FeaturesAsWritten.size(); i != n; ++i)
2881 for (std::vector<std::pair<std::string, bool/*isUndef*/>>::const_iterator
2889 StringRef MacroDef = I->first;
2891 llvm::CachedHashString(MacroDef.split(
'=').first)))
2915 code = ext->hashExtension(code);
2922 if (!SanHash.
empty())
2925 return llvm::APInt(64, code).toString(36,
false);
2930 template<
typename IntTy>
2935 if (Arg *A = Args.getLastArg(Id)) {
2936 if (StringRef(A->getValue()).getAsInteger(10, Res)) {
2938 Diags->
Report(diag::err_drv_invalid_int_value) << A->getAsString(Args)
2949 return getLastArgIntValueImpl<int>(Args,
Id,
Default, Diags);
2955 return getLastArgIntValueImpl<uint64_t>(Args,
Id,
Default, Diags);
2964 static const size_t kGraveYardMaxSize = 16;
2965 LLVM_ATTRIBUTE_UNUSED
static const void *GraveYard[kGraveYardMaxSize];
2966 static std::atomic<unsigned> GraveYardSize;
2967 unsigned Idx = GraveYardSize++;
2968 if (Idx >= kGraveYardMaxSize)
2970 GraveYard[Idx] = Ptr;
2990 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buffer =
2991 BaseFS->getBufferForFile(File);
2993 Diags.
Report(diag::err_missing_vfs_overlay_file) << File;
2998 std::move(Buffer.get()),
nullptr, File);
3000 Diags.
Report(diag::err_invalid_vfs_overlay) << File;
3003 Overlay->pushOverlay(FS);
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
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)
std::vector< std::pair< std::string, bool > > Macros
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.
Conform to the underlying platform's C and C++ ABIs as closely as we can.
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.
Represents a version number in the form major[.minor[.subminor[.build]]].
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)
Implements support for file system lookup, file system caching, and directory search management...
TargetOptions & getTargetOpts()
Defines the clang::FileManager interface and associated types.
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.
IntrusiveRefCntPtr< FileSystem > getRealFileSystem()
Gets an vfs::FileSystem for the 'real' file system, as seen by the operating system.
std::shared_ptr< llvm::Regex > OptimizationRemarkMissedPattern
Regular expression to select optimizations for which we should enable missed optimization remarks...
static unsigned getOptimizationLevel(ArgList &Args, InputKind IK, DiagnosticsEngine &Diags)
LangStandard - Information about the properties of a particular language standard.
Enable migration to modern ObjC subscripting.
static bool isBuiltinFunc(const char *Name)
Returns true if this is a libc/libm function without the '__builtin_' prefix.
unsigned IncludeModuleFiles
Include module file dependencies.
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.
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...
static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, DiagnosticsEngine &Diags, const TargetOptions &TargetOpts)
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.
enum clang::FrontendOptions::@168 ARCMTAction
Objects with "hidden" visibility are not seen by the dynamic linker.
static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args, const std::string &WorkingDir)
std::string ImplicitPTHInclude
The implicit PTH input included at the start of the translation unit, or empty.
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)
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.
Attempt to be ABI-compatible with code generated by Clang 4.0.x (SVN r291814).
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.
std::vector< std::string > CudaGpuBinaryFileNames
A list of file names passed with -fcuda-include-gpubinary options to forward to CUDA runtime back-end...
std::string FindPchSource
If non-empty, search the pch input file as if it was a header included by this file.
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).
use NS_NONATOMIC_IOSONLY for property 'atomic' attribute
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.
IntrusiveRefCntPtr< FileSystem > getVFSFromYAML(std::unique_ptr< llvm::MemoryBuffer > Buffer, llvm::SourceMgr::DiagHandlerTy DiagHandler, StringRef YAMLFilePath, void *DiagContext=nullptr, IntrusiveRefCntPtr< FileSystem > ExternalFS=getRealFileSystem())
Gets a FileSystem for a virtual file system described in YAML format.
Translate input source into HTML.
Enable migration to modern ObjC readwrite property.
SanitizerMask Mask
Bitmask of enabled sanitizers.
std::vector< uint8_t > CmdArgs
List of backend command-line options for -fembed-bitcode.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
unsigned eagerlyAssumeBinOpBifurcation
The flag regulates if we should eagerly assume evaluations of conditionals, thus, bifurcating the pat...
std::vector< std::string > ASTMergeFiles
The list of AST files to merge.
std::string CodeModel
The code model to use (-mcmodel).
Print DeclContext and their Decls.
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.
A file system that allows overlaying one AbstractFileSystem on top of another.
Generate LLVM IR, but do not emit anything.
static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args, DiagnosticsEngine &Diags)
CodeGenOptions & getCodeGenOpts()
bool hasLineComments() const
Language supports '//' comments.
unsigned ShowStats
Show frontend performance metrics and statistics.
Enable migration to NS_ENUM/NS_OPTIONS macros.
static void ParseDependencyOutputArgs(DependencyOutputOptions &Opts, ArgList &Args)
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.
Optional< unsigned > getMinor() const
Retrieve the minor version number, if provided.
unsigned FixWhatYouCan
Apply fixes even if there are unfixable errors.
std::unique_ptr< llvm::opt::OptTable > createDriverOptTable()
std::vector< std::string > Warnings
The list of -W...
static StringRef getRelocModel(ArgList &Args, DiagnosticsEngine &Diags)
std::vector< std::pair< std::string, bool > > CheckersControlList
Pair of checker name and enable/disable.
AnalysisStores
AnalysisStores - Set of available analysis store models.
bool isCPlusPlus() const
isCPlusPlus - Language is a C++ variant.
bool DisablePCHValidation
When true, disables most of the normal validation performed on precompiled headers.
static void setPGOUseInstrumentor(CodeGenOptions &Opts, const Twine &ProfileName)
unsigned FixAndRecompile
Apply fixes and recompile.
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.
Enable annotation of ObjCMethods of all kinds.
bool DetailedRecord
Whether we should maintain a detailed record of all macro definitions and expansions.
static IntTy getLastArgIntValueImpl(const ArgList &Args, OptSpecifier Id, IntTy Default, DiagnosticsEngine *Diags)
MigratorOptions & getMigratorOpts()
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.
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.
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.
annotate property with NS_RETURNS_INNER_POINTER
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).
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).
const FunctionProtoType * T
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.
std::string RelocationModel
The name of the relocation model to use.
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.
IntrusiveRefCntPtr< vfs::FileSystem > createVFSFromCompilerInvocation(const CompilerInvocation &CI, DiagnosticsEngine &Diags)
bool tryParse(StringRef input)
Try to parse an Objective-C runtime specification from the given string.
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.
Enable migration to add conforming protocols.
AnalysisInliningMode
AnalysisInlineFunctionSelection - Set of inlining function selection heuristics.
Objects with "protected" visibility are seen by the dynamic linker but always dynamically resolve to ...
unsigned ShowMacros
Print macro definitions.
clang::ObjCRuntime ObjCRuntime
static void ParsePreprocessorOutputArgs(PreprocessorOutputOptions &Opts, ArgList &Args, frontend::ActionKind Action)
unsigned FixOnlyWarnings
Apply fixes only for warnings.
unsigned NoNSAllocReallocError
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.
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
Enable inferring NS_DESIGNATED_INITIALIZER for ObjC methods.
void set(SanitizerMask K, bool Value)
Enable or disable a certain (single) sanitizer.
std::string ABI
If given, the name of the target ABI to use.
AnalysisConstraints
AnalysisConstraints - Set of available constraint models.
AnalyzerOptionsRef getAnalyzerOpts() const
AnalysisStores AnalysisStoreOpt
Encodes a location in the source.
Generate machine code, but don't emit anything.
std::vector< std::string > ModuleFiles
The list of additional prebuilt module files to load before processing the input. ...
ParsedSourceLocation CodeCompletionAt
If given, enable code completion at the provided location.
std::string ImplicitPCHInclude
The implicit PCH included at the start of the translation unit, or empty.
Limit generated debug info to reduce size (-fno-standalone-debug).
Options for controlling the compiler diagnostics engine.
Enable migration to modern ObjC literals.
std::vector< FrontendInputFile > Inputs
The input files and their types.
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.
unsigned visualizeExplodedGraphWithUbiGraph
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)
std::unordered_map< std::string, std::vector< std::string > > PluginArgs
Args to pass to the plugins.
DiagnosticOptions & getDiagnosticOpts() const
DependencyOutputOptions - Options for controlling the compiler dependency file generation.
unsigned ASTDumpLookups
Whether we include lookup table dumps in AST dumps.
std::vector< std::string > ExtraDeps
A list of filenames to be used as extra dependencies for every target.
Load and verify that a PCH file is usable.
std::shared_ptr< TargetOptions > TargetOpts
Options controlling the target.
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.
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...
std::vector< BitcodeFileToLink > LinkBitcodeFiles
The files specified here are linked in to the module before optimizations.
PragmaMSPointersToMembersKind
unsigned GenerateGlobalModuleIndex
Whether we can generate the global module index if needed.
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.
Dataflow Directional Tag Classes.
Optional< unsigned > getSubminor() const
Retrieve the subminor version number, if provided.
std::string OverflowHandler
The name of the handler function to be called when -ftrapv is specified.
bool tryParse(StringRef string)
Try to parse the given string as a version number.
static ParsedSourceLocation FromString(StringRef Str)
Construct a parsed source location from a string; the Filename is empty on error. ...
PreprocessorOptions & getPreprocessorOpts()
bool UsePredefines
Initialize the preprocessor with the compiler and target specific predefines.
frontend::ActionKind ProgramAction
The frontend action to perform.
std::vector< llvm::Triple > OMPTargetTriples
Triples of the OpenMP targets that the host code codegen should take into account in order to generat...
std::vector< std::string > VerifyPrefixes
The prefixes for comment directives sought by -verify ("expected" by default).
std::string ARCMTMigrateReportOut
std::string PreferVectorWidth
The preferred width for auto-vectorization transforms.
Emit location information but do not generate debug info in the output.
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 at least one sanitizer is enabled.
unsigned UseGlobalModuleIndex
Whether we can use the global module index if available.
unsigned getMajor() const
Retrieve the major version number.
AnalysisConstraints AnalysisConstraintsOpt
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)
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.
prefer 'atomic' property over 'nonatomic'.
Enable migration of ObjC methods to 'instancetype'.
void BuryPointer(const void *Ptr)
Parse ASTs and dump them.
Don't generate debug info.
std::string CoverageDataFile
The filename with path we use for coverage data files.
std::vector< std::string > LinkerOptions
A list of linker options to embed in the object file.
Enable migration to modern ObjC readonly property.
static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args, FileManager &FileMgr, DiagnosticsEngine &Diags, frontend::ActionKind Action)
Enable converting setter/getter expressions to property-dot syntx.
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.
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.
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.
unsigned AnalyzeNestedBlocks
unsigned NoRetryExhausted
Do not re-analyze paths leading to exhausted nodes with a different strategy.
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.
Enable migration to modern ObjC property.
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)
bool isC99() const
isC99 - Language is a superset of C99.
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.
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.
std::vector< std::string > BackendOptions
A list of command-line options to forward to the LLVM backend.
Like Angled, but marks header maps used when building frameworks.
Generate pre-tokenized header.
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()
unsigned PrintShowIncludes
Print cl.exe style /showIncludes info.
bool DumpDeserializedPCHDecls
Dump declarations that are deserialized from PCH, for testing.
AnalysisDiagClients
AnalysisDiagClients - Set of available diagnostic clients for rendering analysis results.
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?
Attempt to be ABI-compatible with code generated by Clang 3.8.x (SVN r257626).
std::string DiagnosticLogFile
The file to log diagnostic output to.
std::string TokenCache
If given, a PTH cache file to use for speeding up header parsing.
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.