summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp412
1 files changed, 213 insertions, 199 deletions
diff --git a/contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp b/contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp
index 54025b0..8546763 100644
--- a/contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp
@@ -126,7 +126,7 @@ static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group,
} else {
// Otherwise, add its value (for OPT_W_Joined and similar).
for (const char *Arg : A->getValues())
- Diagnostics.push_back(Arg);
+ Diagnostics.emplace_back(Arg);
}
}
}
@@ -239,10 +239,8 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
Opts.InlineMaxStackDepth, Diags);
Opts.CheckersControlList.clear();
- for (arg_iterator it = Args.filtered_begin(OPT_analyzer_checker,
- OPT_analyzer_disable_checker),
- ie = Args.filtered_end(); it != ie; ++it) {
- const Arg *A = *it;
+ for (const Arg *A :
+ Args.filtered(OPT_analyzer_checker, OPT_analyzer_disable_checker)) {
A->claim();
bool enable = (A->getOption().getID() == OPT_analyzer_checker);
// We can have a list of comma separated checker names, e.g:
@@ -250,14 +248,12 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
StringRef checkerList = A->getValue();
SmallVector<StringRef, 4> checkers;
checkerList.split(checkers, ",");
- for (unsigned i = 0, e = checkers.size(); i != e; ++i)
- Opts.CheckersControlList.push_back(std::make_pair(checkers[i], enable));
+ for (StringRef checker : checkers)
+ Opts.CheckersControlList.emplace_back(checker, enable);
}
-
+
// Go through the analyzer configuration options.
- for (arg_iterator it = Args.filtered_begin(OPT_analyzer_config),
- ie = Args.filtered_end(); it != ie; ++it) {
- const Arg *A = *it;
+ for (const Arg *A : Args.filtered(OPT_analyzer_config)) {
A->claim();
// We can have a list of comma separated config names, e.g:
// '-analyzer-config key1=val1,key2=val2'
@@ -325,15 +321,35 @@ GenerateOptimizationRemarkRegex(DiagnosticsEngine &Diags, ArgList &Args,
return Pattern;
}
+static bool parseDiagnosticLevelMask(StringRef FlagName,
+ const std::vector<std::string> &Levels,
+ DiagnosticsEngine *Diags,
+ DiagnosticLevelMask &M) {
+ bool Success = true;
+ for (const auto &Level : Levels) {
+ DiagnosticLevelMask const PM =
+ llvm::StringSwitch<DiagnosticLevelMask>(Level)
+ .Case("note", DiagnosticLevelMask::Note)
+ .Case("remark", DiagnosticLevelMask::Remark)
+ .Case("warning", DiagnosticLevelMask::Warning)
+ .Case("error", DiagnosticLevelMask::Error)
+ .Default(DiagnosticLevelMask::None);
+ if (PM == DiagnosticLevelMask::None) {
+ Success = false;
+ if (Diags)
+ Diags->Report(diag::err_drv_invalid_value) << FlagName << Level;
+ }
+ M = M | PM;
+ }
+ return Success;
+}
+
static void parseSanitizerKinds(StringRef FlagName,
const std::vector<std::string> &Sanitizers,
DiagnosticsEngine &Diags, SanitizerSet &S) {
for (const auto &Sanitizer : Sanitizers) {
- SanitizerKind K = llvm::StringSwitch<SanitizerKind>(Sanitizer)
-#define SANITIZER(NAME, ID) .Case(NAME, SanitizerKind::ID)
-#include "clang/Basic/Sanitizers.def"
- .Default(SanitizerKind::Unknown);
- if (K == SanitizerKind::Unknown)
+ SanitizerMask K = parseSanitizerValue(Sanitizer, /*AllowGroups=*/false);
+ if (K == 0)
Diags.Report(diag::err_drv_invalid_value) << FlagName << Sanitizer;
else
S.set(K, true);
@@ -367,6 +383,16 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.setInlining(Args.hasArg(OPT_fno_inline_functions) ?
CodeGenOptions::OnlyAlwaysInlining : Opts.getInlining());
+ if (Arg *A = Args.getLastArg(OPT_fveclib)) {
+ StringRef Name = A->getValue();
+ if (Name == "Accelerate")
+ Opts.setVecLib(CodeGenOptions::Accelerate);
+ else if (Name == "none")
+ Opts.setVecLib(CodeGenOptions::NoLibrary);
+ else
+ Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;
+ }
+
if (Args.hasArg(OPT_gline_tables_only)) {
Opts.setDebugInfo(CodeGenOptions::DebugLineTablesOnly);
} else if (Args.hasArg(OPT_g_Flag) || Args.hasArg(OPT_gdwarf_2) ||
@@ -395,6 +421,10 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
// Default Dwarf version is 4 if we are generating debug information.
Opts.DwarfVersion = 4;
+ if (const Arg *A =
+ Args.getLastArg(OPT_emit_llvm_uselists, OPT_no_emit_llvm_uselists))
+ Opts.EmitLLVMUseLists = A->getOption().getID() == OPT_emit_llvm_uselists;
+
Opts.DisableLLVMOpts = Args.hasArg(OPT_disable_llvm_optzns);
Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
Opts.ForbidGuardVariables = Args.hasArg(OPT_fforbid_guard_variables);
@@ -417,13 +447,14 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
Opts.Autolink = !Args.hasArg(OPT_fno_autolink);
Opts.SampleProfileFile = Args.getLastArgValue(OPT_fprofile_sample_use_EQ);
- Opts.ProfileInstrGenerate = Args.hasArg(OPT_fprofile_instr_generate);
+ Opts.ProfileInstrGenerate = Args.hasArg(OPT_fprofile_instr_generate) ||
+ Args.hasArg(OPT_fprofile_instr_generate_EQ);
+ Opts.InstrProfileOutput = Args.getLastArgValue(OPT_fprofile_instr_generate_EQ);
Opts.InstrProfileInput = Args.getLastArgValue(OPT_fprofile_instr_use_EQ);
Opts.CoverageMapping = Args.hasArg(OPT_fcoverage_mapping);
Opts.DumpCoverageMapping = Args.hasArg(OPT_dump_coverage_mapping);
Opts.AsmVerbose = Args.hasArg(OPT_masm_verbose);
Opts.ObjCAutoRefCountExceptions = Args.hasArg(OPT_fobjc_arc_exceptions);
- Opts.CUDAIsDevice = Args.hasArg(OPT_fcuda_is_device);
Opts.CXAAtExit = !Args.hasArg(OPT_fno_use_cxa_atexit);
Opts.CXXCtorDtorAliases = Args.hasArg(OPT_mconstructor_aliases);
Opts.CodeModel = getCodeModel(Args, Diags);
@@ -441,11 +472,11 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
Args.hasArg(OPT_cl_finite_math_only) ||
Args.hasArg(OPT_cl_fast_relaxed_math));
- Opts.NoSignedZeros = Args.hasArg(OPT_cl_no_signed_zeros);
+ Opts.NoSignedZeros = Args.hasArg(OPT_fno_signed_zeros);
+ Opts.ReciprocalMath = Args.hasArg(OPT_freciprocal_math);
Opts.NoZeroInitializedInBSS = Args.hasArg(OPT_mno_zero_initialized_in_bss);
Opts.BackendOptions = Args.getAllArgValues(OPT_backend_option);
Opts.NumRegisterParameters = getLastArgIntValue(Args, OPT_mregparm, 0, Diags);
- Opts.NoGlobalMerge = Args.hasArg(OPT_mno_global_merge);
Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
Opts.EnableSegmentedStacks = Args.hasArg(OPT_split_stacks);
@@ -472,8 +503,13 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
OPT_fno_function_sections, false);
Opts.DataSections = Args.hasFlag(OPT_fdata_sections,
OPT_fno_data_sections, false);
+ Opts.UniqueSectionNames = Args.hasFlag(OPT_funique_section_names,
+ OPT_fno_unique_section_names, true);
+
Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions);
+ Opts.MSVolatile = Args.hasArg(OPT_fms_volatile);
+
Opts.VectorizeBB = Args.hasArg(OPT_vectorize_slp_aggressive);
Opts.VectorizeLoop = Args.hasArg(OPT_vectorize_loops);
Opts.VectorizeSLP = Args.hasArg(OPT_vectorize_slp);
@@ -489,6 +525,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.CoverageExtraChecksum = Args.hasArg(OPT_coverage_cfg_checksum);
Opts.CoverageNoFunctionNamesInData =
Args.hasArg(OPT_coverage_no_function_names_in_data);
+ Opts.CoverageExitBlockBeforeBody =
+ Args.hasArg(OPT_coverage_exit_block_before_body);
if (Args.hasArg(OPT_coverage_version_EQ)) {
StringRef CoverageVersion = Args.getLastArgValue(OPT_coverage_version_EQ);
if (CoverageVersion.size() != 4) {
@@ -507,12 +545,16 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.CompressDebugSections = Args.hasArg(OPT_compress_debug_sections);
Opts.DebugCompilationDir = Args.getLastArgValue(OPT_fdebug_compilation_dir);
Opts.LinkBitcodeFile = Args.getLastArgValue(OPT_mlink_bitcode_file);
- Opts.SanitizeCoverage =
- getLastArgIntValue(Args, OPT_fsanitize_coverage, 0, Diags);
+ Opts.SanitizeCoverageType =
+ getLastArgIntValue(Args, OPT_fsanitize_coverage_type, 0, Diags);
+ Opts.SanitizeCoverageIndirectCalls =
+ Args.hasArg(OPT_fsanitize_coverage_indirect_calls);
+ Opts.SanitizeCoverageTraceBB = Args.hasArg(OPT_fsanitize_coverage_trace_bb);
+ Opts.SanitizeCoverageTraceCmp = Args.hasArg(OPT_fsanitize_coverage_trace_cmp);
+ Opts.SanitizeCoverage8bitCounters =
+ Args.hasArg(OPT_fsanitize_coverage_8bit_counters);
Opts.SanitizeMemoryTrackOrigins =
getLastArgIntValue(Args, OPT_fsanitize_memory_track_origins_EQ, 0, Diags);
- Opts.SanitizeUndefinedTrapOnError =
- Args.hasArg(OPT_fsanitize_undefined_trap_on_error);
Opts.SSPBufferSize =
getLastArgIntValue(Args, OPT_stack_protector_buffer_size, 8, Diags);
Opts.StackRealignment = Args.hasArg(OPT_mstackrealign);
@@ -523,6 +565,13 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.StackAlignment = StackAlignment;
}
+ if (Arg *A = Args.getLastArg(OPT_mstack_probe_size)) {
+ StringRef Val = A->getValue();
+ unsigned StackProbeSize = Opts.StackProbeSize;
+ Val.getAsInteger(0, StackProbeSize);
+ Opts.StackProbeSize = StackProbeSize;
+ }
+
if (Arg *A = Args.getLastArg(OPT_fobjc_dispatch_method_EQ)) {
StringRef Name = A->getValue();
unsigned Method = llvm::StringSwitch<unsigned>(Name)
@@ -615,6 +664,12 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
parseSanitizerKinds("-fsanitize-recover=",
Args.getAllArgValues(OPT_fsanitize_recover_EQ), Diags,
Opts.SanitizeRecover);
+ parseSanitizerKinds("-fsanitize-trap=",
+ Args.getAllArgValues(OPT_fsanitize_trap_EQ), Diags,
+ Opts.SanitizeTrap);
+
+ Opts.CudaGpuBinaryFileNames =
+ Args.getAllArgValues(OPT_fcuda_include_gpubinary);
return Success;
}
@@ -634,6 +689,8 @@ static void ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
Opts.DOTOutputFile = Args.getLastArgValue(OPT_dependency_dot);
Opts.ModuleDependencyOutputDir =
Args.getLastArgValue(OPT_module_dependency_dir);
+ if (Args.hasArg(OPT_MV))
+ Opts.OutputFormat = DependencyOutputFormat::NMake;
}
bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
@@ -702,9 +759,9 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
if (Format == "clang")
Opts.setFormat(DiagnosticOptions::Clang);
else if (Format == "msvc")
- Opts.setFormat(DiagnosticOptions::Msvc);
+ Opts.setFormat(DiagnosticOptions::MSVC);
else if (Format == "msvc-fallback") {
- Opts.setFormat(DiagnosticOptions::Msvc);
+ Opts.setFormat(DiagnosticOptions::MSVC);
Opts.CLFallbackMode = true;
} else if (Format == "vi")
Opts.setFormat(DiagnosticOptions::Vi);
@@ -715,11 +772,18 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
<< Args.getLastArg(OPT_fdiagnostics_format)->getAsString(Args)
<< Format;
}
-
+
Opts.ShowSourceRanges = Args.hasArg(OPT_fdiagnostics_print_source_range_info);
Opts.ShowParseableFixits = Args.hasArg(OPT_fdiagnostics_parseable_fixits);
Opts.ShowPresumedLoc = !Args.hasArg(OPT_fno_diagnostics_use_presumed_location);
Opts.VerifyDiagnostics = Args.hasArg(OPT_verify);
+ DiagnosticLevelMask DiagMask = DiagnosticLevelMask::None;
+ Success &= parseDiagnosticLevelMask("-verify-ignore-unexpected=",
+ Args.getAllArgValues(OPT_verify_ignore_unexpected_EQ),
+ Diags, DiagMask);
+ if (Args.hasArg(OPT_verify_ignore_unexpected))
+ DiagMask = DiagnosticLevelMask::All;
+ Opts.setVerifyIgnoreUnexpected(DiagMask);
Opts.ElideType = !Args.hasArg(OPT_fno_elide_type);
Opts.ShowTemplateTree = Args.hasArg(OPT_fdiagnostics_show_template_tree);
Opts.ErrorLimit = getLastArgIntValue(Args, OPT_ferror_limit, 0, Diags);
@@ -830,26 +894,21 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
}
if (const Arg* A = Args.getLastArg(OPT_plugin)) {
- Opts.Plugins.push_back(A->getValue(0));
+ Opts.Plugins.emplace_back(A->getValue(0));
Opts.ProgramAction = frontend::PluginAction;
Opts.ActionName = A->getValue();
- for (arg_iterator it = Args.filtered_begin(OPT_plugin_arg),
- end = Args.filtered_end(); it != end; ++it) {
- if ((*it)->getValue(0) == Opts.ActionName)
- Opts.PluginArgs.push_back((*it)->getValue(1));
- }
+ for (const Arg *AA : Args.filtered(OPT_plugin_arg))
+ if (AA->getValue(0) == Opts.ActionName)
+ Opts.PluginArgs.emplace_back(AA->getValue(1));
}
Opts.AddPluginActions = Args.getAllArgValues(OPT_add_plugin);
Opts.AddPluginArgs.resize(Opts.AddPluginActions.size());
- for (int i = 0, e = Opts.AddPluginActions.size(); i != e; ++i) {
- for (arg_iterator it = Args.filtered_begin(OPT_plugin_arg),
- end = Args.filtered_end(); it != end; ++it) {
- if ((*it)->getValue(0) == Opts.AddPluginActions[i])
- Opts.AddPluginArgs[i].push_back((*it)->getValue(1));
- }
- }
+ for (int i = 0, e = Opts.AddPluginActions.size(); i != e; ++i)
+ for (const Arg *A : Args.filtered(OPT_plugin_arg))
+ if (A->getValue(0) == Opts.AddPluginActions[i])
+ Opts.AddPluginArgs[i].emplace_back(A->getValue(1));
if (const Arg *A = Args.getLastArg(OPT_code_completion_at)) {
Opts.CodeCompletionAt =
@@ -966,6 +1025,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
.Case("cpp-output", IK_PreprocessedC)
.Case("assembler-with-cpp", IK_Asm)
.Case("c++-cpp-output", IK_PreprocessedCXX)
+ .Case("cuda-cpp-output", IK_PreprocessedCuda)
.Case("objective-c-cpp-output", IK_PreprocessedObjC)
.Case("objc-cpp-output", IK_PreprocessedObjC)
.Case("objective-c++-cpp-output", IK_PreprocessedObjCXX)
@@ -997,7 +1057,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
if (i == 0)
DashX = IK;
}
- Opts.Inputs.push_back(FrontendInputFile(Inputs[i], IK));
+ Opts.Inputs.emplace_back(std::move(Inputs[i]), IK);
}
return DashX;
@@ -1036,8 +1096,7 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) {
Opts.ModuleCachePath = Args.getLastArgValue(OPT_fmodules_cache_path);
Opts.ModuleUserBuildPath = Args.getLastArgValue(OPT_fmodules_user_build_path);
Opts.DisableModuleHash = Args.hasArg(OPT_fdisable_module_hash);
- // -fmodules implies -fmodule-maps
- Opts.ModuleMaps = Args.hasArg(OPT_fmodule_maps) || Args.hasArg(OPT_fmodules);
+ Opts.ImplicitModuleMaps = Args.hasArg(OPT_fimplicit_module_maps);
Opts.ModuleMapFileHomeIsCwd = Args.hasArg(OPT_fmodule_map_file_home_is_cwd);
Opts.ModuleCachePruneInterval =
getLastArgIntValue(Args, OPT_fmodules_prune_interval, 7 * 24 * 60 * 60);
@@ -1050,98 +1109,77 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) {
Opts.ModulesValidateSystemHeaders =
Args.hasArg(OPT_fmodules_validate_system_headers);
- for (arg_iterator it = Args.filtered_begin(OPT_fmodules_ignore_macro),
- ie = Args.filtered_end();
- it != ie; ++it) {
- StringRef MacroDef = (*it)->getValue();
+ for (const Arg *A : Args.filtered(OPT_fmodules_ignore_macro)) {
+ StringRef MacroDef = A->getValue();
Opts.ModulesIgnoreMacros.insert(MacroDef.split('=').first);
}
// Add -I..., -F..., and -index-header-map options in order.
bool IsIndexHeaderMap = false;
- for (arg_iterator it = Args.filtered_begin(OPT_I, OPT_F,
- OPT_index_header_map),
- ie = Args.filtered_end(); it != ie; ++it) {
- if ((*it)->getOption().matches(OPT_index_header_map)) {
+ for (const Arg *A : Args.filtered(OPT_I, OPT_F, OPT_index_header_map)) {
+ if (A->getOption().matches(OPT_index_header_map)) {
// -index-header-map applies to the next -I or -F.
IsIndexHeaderMap = true;
continue;
}
-
- frontend::IncludeDirGroup Group
- = IsIndexHeaderMap? frontend::IndexHeaderMap : frontend::Angled;
-
- Opts.AddPath((*it)->getValue(), Group,
- /*IsFramework=*/ (*it)->getOption().matches(OPT_F), true);
+
+ frontend::IncludeDirGroup Group =
+ IsIndexHeaderMap ? frontend::IndexHeaderMap : frontend::Angled;
+
+ Opts.AddPath(A->getValue(), Group,
+ /*IsFramework=*/A->getOption().matches(OPT_F), true);
IsIndexHeaderMap = false;
}
// Add -iprefix/-iwithprefix/-iwithprefixbefore options.
StringRef Prefix = ""; // FIXME: This isn't the correct default prefix.
- for (arg_iterator it = Args.filtered_begin(OPT_iprefix, OPT_iwithprefix,
- OPT_iwithprefixbefore),
- ie = Args.filtered_end(); it != ie; ++it) {
- const Arg *A = *it;
+ for (const Arg *A :
+ Args.filtered(OPT_iprefix, OPT_iwithprefix, OPT_iwithprefixbefore)) {
if (A->getOption().matches(OPT_iprefix))
Prefix = A->getValue();
else if (A->getOption().matches(OPT_iwithprefix))
- Opts.AddPath(Prefix.str() + A->getValue(),
- frontend::After, false, true);
+ Opts.AddPath(Prefix.str() + A->getValue(), frontend::After, false, true);
else
- Opts.AddPath(Prefix.str() + A->getValue(),
- frontend::Angled, false, true);
- }
-
- for (arg_iterator it = Args.filtered_begin(OPT_idirafter),
- ie = Args.filtered_end(); it != ie; ++it)
- Opts.AddPath((*it)->getValue(), frontend::After, false, true);
- for (arg_iterator it = Args.filtered_begin(OPT_iquote),
- ie = Args.filtered_end(); it != ie; ++it)
- Opts.AddPath((*it)->getValue(), frontend::Quoted, false, true);
- for (arg_iterator it = Args.filtered_begin(OPT_isystem,
- OPT_iwithsysroot), ie = Args.filtered_end(); it != ie; ++it)
- Opts.AddPath((*it)->getValue(), frontend::System, false,
- !(*it)->getOption().matches(OPT_iwithsysroot));
- for (arg_iterator it = Args.filtered_begin(OPT_iframework),
- ie = Args.filtered_end(); it != ie; ++it)
- Opts.AddPath((*it)->getValue(), frontend::System, true, true);
+ Opts.AddPath(Prefix.str() + A->getValue(), frontend::Angled, false, true);
+ }
+
+ for (const Arg *A : Args.filtered(OPT_idirafter))
+ Opts.AddPath(A->getValue(), frontend::After, false, true);
+ for (const Arg *A : Args.filtered(OPT_iquote))
+ Opts.AddPath(A->getValue(), frontend::Quoted, false, true);
+ for (const Arg *A : Args.filtered(OPT_isystem, OPT_iwithsysroot))
+ Opts.AddPath(A->getValue(), frontend::System, false,
+ !A->getOption().matches(OPT_iwithsysroot));
+ for (const Arg *A : Args.filtered(OPT_iframework))
+ Opts.AddPath(A->getValue(), frontend::System, true, true);
// Add the paths for the various language specific isystem flags.
- for (arg_iterator it = Args.filtered_begin(OPT_c_isystem),
- ie = Args.filtered_end(); it != ie; ++it)
- Opts.AddPath((*it)->getValue(), frontend::CSystem, false, true);
- for (arg_iterator it = Args.filtered_begin(OPT_cxx_isystem),
- ie = Args.filtered_end(); it != ie; ++it)
- Opts.AddPath((*it)->getValue(), frontend::CXXSystem, false, true);
- for (arg_iterator it = Args.filtered_begin(OPT_objc_isystem),
- ie = Args.filtered_end(); it != ie; ++it)
- Opts.AddPath((*it)->getValue(), frontend::ObjCSystem, false,true);
- for (arg_iterator it = Args.filtered_begin(OPT_objcxx_isystem),
- ie = Args.filtered_end(); it != ie; ++it)
- Opts.AddPath((*it)->getValue(), frontend::ObjCXXSystem, false, true);
+ for (const Arg *A : Args.filtered(OPT_c_isystem))
+ Opts.AddPath(A->getValue(), frontend::CSystem, false, true);
+ for (const Arg *A : Args.filtered(OPT_cxx_isystem))
+ Opts.AddPath(A->getValue(), frontend::CXXSystem, false, true);
+ for (const Arg *A : Args.filtered(OPT_objc_isystem))
+ Opts.AddPath(A->getValue(), frontend::ObjCSystem, false,true);
+ for (const Arg *A : Args.filtered(OPT_objcxx_isystem))
+ Opts.AddPath(A->getValue(), frontend::ObjCXXSystem, false, true);
// Add the internal paths from a driver that detects standard include paths.
- for (arg_iterator I = Args.filtered_begin(OPT_internal_isystem,
- OPT_internal_externc_isystem),
- E = Args.filtered_end();
- I != E; ++I) {
+ for (const Arg *A :
+ Args.filtered(OPT_internal_isystem, OPT_internal_externc_isystem)) {
frontend::IncludeDirGroup Group = frontend::System;
- if ((*I)->getOption().matches(OPT_internal_externc_isystem))
+ if (A->getOption().matches(OPT_internal_externc_isystem))
Group = frontend::ExternCSystem;
- Opts.AddPath((*I)->getValue(), Group, false, true);
+ Opts.AddPath(A->getValue(), Group, false, true);
}
// Add the path prefixes which are implicitly treated as being system headers.
- for (arg_iterator I = Args.filtered_begin(OPT_system_header_prefix,
- OPT_no_system_header_prefix),
- E = Args.filtered_end();
- I != E; ++I)
+ for (const Arg *A :
+ Args.filtered(OPT_system_header_prefix, OPT_no_system_header_prefix))
Opts.AddSystemHeaderPrefix(
- (*I)->getValue(), (*I)->getOption().matches(OPT_system_header_prefix));
+ A->getValue(), A->getOption().matches(OPT_system_header_prefix));
- for (arg_iterator I = Args.filtered_begin(OPT_ivfsoverlay),
- E = Args.filtered_end(); I != E; ++I)
- Opts.AddVFSOverlayFile((*I)->getValue());
+ for (const Arg *A : Args.filtered(OPT_ivfsoverlay))
+ Opts.AddVFSOverlayFile(A->getValue());
}
void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
@@ -1169,6 +1207,7 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
LangStd = LangStandard::lang_opencl;
break;
case IK_CUDA:
+ case IK_PreprocessedCuda:
LangStd = LangStandard::lang_cuda;
break;
case IK_Asm:
@@ -1197,7 +1236,7 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
Opts.CPlusPlus1z = Std.isCPlusPlus1z();
Opts.Digraphs = Std.hasDigraphs();
Opts.GNUMode = Std.isGNUMode();
- Opts.GNUInline = !Std.isC99();
+ Opts.GNUInline = Std.isC89();
Opts.HexFloats = Std.hasHexFloats();
Opts.ImplicitInt = Std.hasImplicitInt();
@@ -1221,7 +1260,8 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
Opts.NativeHalfType = 1;
}
- Opts.CUDA = LangStd == LangStandard::lang_cuda || IK == IK_CUDA;
+ Opts.CUDA = IK == IK_CUDA || IK == IK_PreprocessedCuda ||
+ LangStd == LangStandard::lang_cuda;
// OpenCL and C++ both have bool, true, false keywords.
Opts.Bool = Opts.OpenCL || Opts.CPlusPlus;
@@ -1236,9 +1276,6 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
Opts.CXXOperatorNames = Opts.CPlusPlus;
Opts.DollarIdents = !Opts.AsmPreprocessor;
-
- // C++14 onwards has sized global deallocation functions.
- Opts.SizedDeallocation = Opts.CPlusPlus14;
}
/// Attempt to parse a visibility value out of the given argument.
@@ -1259,43 +1296,6 @@ static Visibility parseVisibility(Arg *arg, ArgList &args,
return DefaultVisibility;
}
-static unsigned parseMSCVersion(ArgList &Args, DiagnosticsEngine &Diags) {
- auto Arg = Args.getLastArg(OPT_fms_compatibility_version);
- if (!Arg)
- return 0;
-
- // The MSC versioning scheme involves four versioning components:
- // - Major
- // - Minor
- // - Build
- // - Patch
- //
- // We accept either the old style (_MSC_VER) value, or a _MSC_FULL_VER value.
- // Additionally, the value may be provided in the form of a more readable
- // MM.mm.bbbbb.pp version.
- //
- // Unfortunately, due to the bit-width limitations, we cannot currently encode
- // the value for the patch level.
-
- unsigned VC[4] = {0};
- StringRef Value = Arg->getValue();
- SmallVector<StringRef, 4> Components;
-
- Value.split(Components, ".", llvm::array_lengthof(VC));
- for (unsigned CI = 0,
- CE = std::min(Components.size(), llvm::array_lengthof(VC));
- CI < CE; ++CI) {
- if (Components[CI].getAsInteger(10, VC[CI])) {
- Diags.Report(diag::err_drv_invalid_value)
- << Arg->getAsString(Args) << Value;
- return 0;
- }
- }
-
- // FIXME we cannot encode the patch level
- return VC[0] * 10000000 + VC[1] * 100000 + VC[2];
-}
-
static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
DiagnosticsEngine &Diags) {
// FIXME: Cleanup per-file based stuff.
@@ -1336,6 +1336,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
<< A->getAsString(Args) << "OpenCL";
break;
case IK_CUDA:
+ case IK_PreprocessedCuda:
if (!Std.isCPlusPlus())
Diags.Report(diag::err_drv_argument_not_allowed_with)
<< A->getAsString(Args) << "CUDA";
@@ -1381,6 +1382,12 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
if (Args.hasArg(OPT_fcuda_is_device))
Opts.CUDAIsDevice = 1;
+ if (Args.hasArg(OPT_fcuda_allow_host_calls_from_host_device))
+ Opts.CUDAAllowHostCallsFromHostDevice = 1;
+
+ if (Args.hasArg(OPT_fcuda_disable_target_call_checks))
+ Opts.CUDADisableTargetCallChecks = 1;
+
if (Opts.ObjC1) {
if (Arg *arg = Args.getLastArg(OPT_fobjc_runtime_EQ)) {
StringRef value = arg->getValue();
@@ -1412,8 +1419,13 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
(Opts.ObjCRuntime.getKind() == ObjCRuntime::FragileMacOSX);
}
- if (Args.hasArg(OPT_fgnu89_inline))
- Opts.GNUInline = 1;
+ if (Args.hasArg(OPT_fgnu89_inline)) {
+ if (Opts.CPlusPlus)
+ Diags.Report(diag::err_drv_argument_not_allowed_with) << "-fgnu89-inline"
+ << "C++/ObjC++";
+ else
+ Opts.GNUInline = 1;
+ }
if (Args.hasArg(OPT_fapple_kext)) {
if (!Opts.CPlusPlus)
@@ -1462,7 +1474,16 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Opts.MSVCCompat = Args.hasArg(OPT_fms_compatibility);
Opts.MicrosoftExt = Opts.MSVCCompat || Args.hasArg(OPT_fms_extensions);
Opts.AsmBlocks = Args.hasArg(OPT_fasm_blocks) || Opts.MicrosoftExt;
- Opts.MSCompatibilityVersion = parseMSCVersion(Args, Diags);
+ Opts.MSCompatibilityVersion = 0;
+ if (const Arg *A = Args.getLastArg(OPT_fms_compatibility_version)) {
+ VersionTuple VT;
+ if (VT.tryParse(A->getValue()))
+ Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
+ << A->getValue();
+ Opts.MSCompatibilityVersion = VT.getMajor() * 10000000 +
+ VT.getMinor().getValueOr(0) * 100000 +
+ VT.getSubminor().getValueOr(0);
+ }
// Mimicing gcc's behavior, trigraphs are only enabled if -trigraphs
// is specified, or -std is set to a conforming mode.
@@ -1498,12 +1519,13 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Opts.ModulesStrictDeclUse = Args.hasArg(OPT_fmodules_strict_decluse);
Opts.ModulesDeclUse =
Args.hasArg(OPT_fmodules_decluse) || Opts.ModulesStrictDeclUse;
+ Opts.ModulesLocalVisibility =
+ Args.hasArg(OPT_fmodules_local_submodule_visibility);
Opts.ModulesSearchAll = Opts.Modules &&
!Args.hasArg(OPT_fno_modules_search_all) &&
Args.hasArg(OPT_fmodules_search_all);
Opts.ModulesErrorRecovery = !Args.hasArg(OPT_fno_modules_error_recovery);
- Opts.ModulesImplicitMaps = Args.hasFlag(OPT_fmodules_implicit_maps,
- OPT_fno_modules_implicit_maps, true);
+ Opts.ImplicitModules = !Args.hasArg(OPT_fno_implicit_modules);
Opts.CharIsSigned = Opts.OpenCL || !Args.hasArg(OPT_fno_signed_char);
Opts.WChar = Opts.CPlusPlus && !Args.hasArg(OPT_fno_wchar);
Opts.ShortWChar = Args.hasFlag(OPT_fshort_wchar, OPT_fno_short_wchar, false);
@@ -1512,7 +1534,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Opts.NoBuiltin = Args.hasArg(OPT_fno_builtin) || Opts.Freestanding;
Opts.NoMathBuiltin = Args.hasArg(OPT_fno_math_builtin);
Opts.AssumeSaneOperatorNew = !Args.hasArg(OPT_fno_assume_sane_operator_new);
- Opts.SizedDeallocation |= Args.hasArg(OPT_fsized_deallocation);
+ Opts.SizedDeallocation = Args.hasArg(OPT_fsized_deallocation);
+ Opts.ConceptsTS = Args.hasArg(OPT_fconcepts_ts);
Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions);
Opts.AccessControl = !Args.hasArg(OPT_fno_access_control);
Opts.ElideConstructors = !Args.hasArg(OPT_fno_elide_constructors);
@@ -1559,10 +1582,13 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Opts.DebuggerObjCLiteral = Args.hasArg(OPT_fdebugger_objc_literal);
Opts.ApplePragmaPack = Args.hasArg(OPT_fapple_pragma_pack);
Opts.CurrentModule = Args.getLastArgValue(OPT_fmodule_name);
+ Opts.AppExt = Args.hasArg(OPT_fapplication_extension);
Opts.ImplementationOfModule =
Args.getLastArgValue(OPT_fmodule_implementation_of);
- Opts.NativeHalfType = Opts.NativeHalfType;
+ Opts.ModuleFeatures = Args.getAllArgValues(OPT_fmodule_feature);
+ Opts.NativeHalfType |= Args.hasArg(OPT_fnative_half_type);
Opts.HalfArgsAndReturns = Args.hasArg(OPT_fallow_half_arguments_and_returns);
+ Opts.GNUAsm = !Args.hasArg(OPT_fno_gnu_inline_asm);
if (!Opts.CurrentModule.empty() && !Opts.ImplementationOfModule.empty() &&
Opts.CurrentModule != Opts.ImplementationOfModule) {
@@ -1570,6 +1596,12 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
<< Opts.CurrentModule << Opts.ImplementationOfModule;
}
+ // For now, we only support local submodule visibility in C++ (because we
+ // heavily depend on the ODR for merging redefinitions).
+ if (Opts.ModulesLocalVisibility && !Opts.CPlusPlus)
+ Diags.Report(diag::err_drv_argument_not_allowed_with)
+ << "-fmodules-local-submodule-visibility" << "C";
+
if (Arg *A = Args.getLastArg(OPT_faddress_space_map_mangling_EQ)) {
switch (llvm::StringSwitch<unsigned>(A->getValue())
.Case("target", LangOptions::ASMM_Target)
@@ -1610,12 +1642,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Opts.setMSPointerToMemberRepresentationMethod(InheritanceModel);
}
- // Check if -fopenmp= is specified.
- if (const Arg *A = Args.getLastArg(options::OPT_fopenmp_EQ)) {
- Opts.OpenMP = llvm::StringSwitch<bool>(A->getValue())
- .Case("libiomp5", true)
- .Default(false);
- }
+ // Check if -fopenmp is specified.
+ Opts.OpenMP = Args.hasArg(options::OPT_fopenmp);
// Record whether the __DEPRECATED define was requested.
Opts.Deprecated = Args.hasFlag(OPT_fdeprecated_macro,
@@ -1660,7 +1688,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
// -fsanitize-address-field-padding=N has to be a LangOpt, parse it here.
Opts.SanitizeAddressFieldPadding =
getLastArgIntValue(Args, OPT_fsanitize_address_field_padding, 0, Diags);
- Opts.SanitizerBlacklistFile = Args.getLastArgValue(OPT_fsanitize_blacklist);
+ Opts.SanitizerBlacklistFiles = Args.getAllArgValues(OPT_fsanitize_blacklist);
}
static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
@@ -1678,11 +1706,8 @@ static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
Opts.DisablePCHValidation = Args.hasArg(OPT_fno_validate_pch);
Opts.DumpDeserializedPCHDecls = Args.hasArg(OPT_dump_deserialized_pch_decls);
- for (arg_iterator it = Args.filtered_begin(OPT_error_on_deserialized_pch_decl),
- ie = Args.filtered_end(); it != ie; ++it) {
- const Arg *A = *it;
+ for (const Arg *A : Args.filtered(OPT_error_on_deserialized_pch_decl))
Opts.DeserializedPCHDeclsToErrorOn.insert(A->getValue());
- }
if (const Arg *A = Args.getLastArg(OPT_preamble_bytes_EQ)) {
StringRef Value(A->getValue());
@@ -1701,38 +1726,28 @@ static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
}
// Add macros from the command line.
- for (arg_iterator it = Args.filtered_begin(OPT_D, OPT_U),
- ie = Args.filtered_end(); it != ie; ++it) {
- if ((*it)->getOption().matches(OPT_D))
- Opts.addMacroDef((*it)->getValue());
+ for (const Arg *A : Args.filtered(OPT_D, OPT_U)) {
+ if (A->getOption().matches(OPT_D))
+ Opts.addMacroDef(A->getValue());
else
- Opts.addMacroUndef((*it)->getValue());
+ Opts.addMacroUndef(A->getValue());
}
Opts.MacroIncludes = Args.getAllArgValues(OPT_imacros);
// Add the ordered list of -includes.
- for (arg_iterator it = Args.filtered_begin(OPT_include),
- ie = Args.filtered_end(); it != ie; ++it) {
- const Arg *A = *it;
- Opts.Includes.push_back(A->getValue());
- }
+ for (const Arg *A : Args.filtered(OPT_include))
+ Opts.Includes.emplace_back(A->getValue());
- for (arg_iterator it = Args.filtered_begin(OPT_chain_include),
- ie = Args.filtered_end(); it != ie; ++it) {
- const Arg *A = *it;
- Opts.ChainedIncludes.push_back(A->getValue());
- }
+ for (const Arg *A : Args.filtered(OPT_chain_include))
+ Opts.ChainedIncludes.emplace_back(A->getValue());
// Include 'altivec.h' if -faltivec option present
if (Args.hasArg(OPT_faltivec))
- Opts.Includes.push_back("altivec.h");
+ Opts.Includes.emplace_back("altivec.h");
- for (arg_iterator it = Args.filtered_begin(OPT_remap_file),
- ie = Args.filtered_end(); it != ie; ++it) {
- const Arg *A = *it;
- std::pair<StringRef,StringRef> Split =
- StringRef(A->getValue()).split(';');
+ for (const Arg *A : Args.filtered(OPT_remap_file)) {
+ std::pair<StringRef, StringRef> Split = StringRef(A->getValue()).split(';');
if (Split.second.empty()) {
Diags.Report(diag::err_drv_invalid_remap_file) << A->getAsString(Args);
@@ -1741,7 +1756,7 @@ static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
Opts.addRemappedFile(Split.first, Split.second);
}
-
+
if (Arg *A = Args.getLastArg(OPT_fobjc_arc_cxxlib_EQ)) {
StringRef Name = A->getValue();
unsigned Library = llvm::StringSwitch<unsigned>(Name)
@@ -1805,6 +1820,7 @@ static void ParsePreprocessorOutputArgs(PreprocessorOutputOptions &Opts,
Opts.ShowMacroComments = Args.hasArg(OPT_CC);
Opts.ShowMacros = Args.hasArg(OPT_dM) || Args.hasArg(OPT_dD);
Opts.RewriteIncludes = Args.hasArg(OPT_frewrite_includes);
+ Opts.UseLineDirectives = Args.hasArg(OPT_fuse_line_directives);
}
static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args) {
@@ -1815,7 +1831,7 @@ static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args) {
Opts.FeaturesAsWritten = Args.getAllArgValues(OPT_target_feature);
Opts.LinkerVersion = Args.getLastArgValue(OPT_target_linker_version);
Opts.Triple = llvm::Triple::normalize(Args.getLastArgValue(OPT_triple));
-
+ Opts.Reciprocals = Args.getAllArgValues(OPT_mrecip_EQ);
// Use the default target triple if unspecified.
if (Opts.Triple.empty())
Opts.Triple = llvm::sys::getDefaultTargetTriple();
@@ -1843,24 +1859,22 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
}
// Issue errors on unknown arguments.
- for (arg_iterator it = Args->filtered_begin(OPT_UNKNOWN),
- ie = Args->filtered_end(); it != ie; ++it) {
- Diags.Report(diag::err_drv_unknown_argument) << (*it)->getAsString(*Args);
+ for (const Arg *A : Args->filtered(OPT_UNKNOWN)) {
+ Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(*Args);
Success = false;
}
- Success = ParseAnalyzerArgs(*Res.getAnalyzerOpts(), *Args, Diags) && Success;
- Success = ParseMigratorArgs(Res.getMigratorOpts(), *Args) && Success;
+ Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), *Args, Diags);
+ Success &= ParseMigratorArgs(Res.getMigratorOpts(), *Args);
ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), *Args);
- Success = ParseDiagnosticArgs(Res.getDiagnosticOpts(), *Args, &Diags)
- && Success;
+ Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), *Args, &Diags);
ParseCommentArgs(Res.getLangOpts()->CommentOpts, *Args);
ParseFileSystemArgs(Res.getFileSystemOpts(), *Args);
// FIXME: We shouldn't have to pass the DashX option around here
InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), *Args, Diags);
ParseTargetArgs(Res.getTargetOpts(), *Args);
- Success = ParseCodeGenArgs(Res.getCodeGenOpts(), *Args, DashX, Diags,
- Res.getTargetOpts()) && Success;
+ Success &= ParseCodeGenArgs(Res.getCodeGenOpts(), *Args, DashX, Diags,
+ Res.getTargetOpts());
ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), *Args);
if (DashX != IK_AST && DashX != IK_LLVM_IR) {
ParseLangArgs(*Res.getLangOpts(), *Args, DashX, Diags);
@@ -2002,7 +2016,7 @@ std::string CompilerInvocation::getModuleHash() const {
llvm::sys::path::append(systemVersionFile, "SystemVersion.plist");
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> buffer =
- llvm::MemoryBuffer::getFile(systemVersionFile.str());
+ llvm::MemoryBuffer::getFile(systemVersionFile);
if (buffer) {
code = hash_combine(code, buffer.get()->getBuffer());
OpenPOWER on IntegriCloud