Changeset View
Changeset View
Standalone View
Standalone View
lib/Frontend/CompilerInvocation.cpp
Show First 20 Lines • Show All 992 Lines • ▼ Show 20 Lines | |||||
A->getValue(), A->getOption().matches(OPT_system_header_prefix)); | A->getValue(), A->getOption().matches(OPT_system_header_prefix)); | ||||
for (const Arg *A : Args.filtered(OPT_ivfsoverlay)) | for (const Arg *A : Args.filtered(OPT_ivfsoverlay)) | ||||
Opts.AddVFSOverlayFile(A->getValue()); | Opts.AddVFSOverlayFile(A->getValue()); | ||||
} | } | ||||
void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, | void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, | ||||
const llvm::Triple &T, | const llvm::Triple &T, | ||||
PreprocessorOptions &PPOpts, | |||||
LangStandard::Kind LangStd) { | LangStandard::Kind LangStd) { | ||||
// Set some properties which depend solely on the input kind; it would be nice | // Set some properties which depend solely on the input kind; it would be nice | ||||
// to move these to the language standard, and have the driver resolve the | // to move these to the language standard, and have the driver resolve the | ||||
// input kind + language standard. | // input kind + language standard. | ||||
if (IK == IK_Asm) { | if (IK == IK_Asm) { | ||||
Opts.AsmPreprocessor = 1; | Opts.AsmPreprocessor = 1; | ||||
} else if (IK == IK_ObjC || | } else if (IK == IK_ObjC || | ||||
IK == IK_ObjCXX || | IK == IK_ObjCXX || | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | |||||
if (Opts.OpenCL) { | if (Opts.OpenCL) { | ||||
Opts.AltiVec = 0; | Opts.AltiVec = 0; | ||||
Opts.ZVector = 0; | Opts.ZVector = 0; | ||||
Opts.CXXOperatorNames = 1; | Opts.CXXOperatorNames = 1; | ||||
Opts.LaxVectorConversions = 0; | Opts.LaxVectorConversions = 0; | ||||
Opts.DefaultFPContract = 1; | Opts.DefaultFPContract = 1; | ||||
Opts.NativeHalfType = 1; | Opts.NativeHalfType = 1; | ||||
Opts.NativeHalfArgsAndReturns = 1; | Opts.NativeHalfArgsAndReturns = 1; | ||||
// Include default header file for OpenCL. | |||||
if (!Opts.NoDefaultHeader) | |||||
PPOpts.Includes.push_back("opencl-c.h"); | |||||
} | } | ||||
Opts.CUDA = IK == IK_CUDA || IK == IK_PreprocessedCuda || | Opts.CUDA = IK == IK_CUDA || IK == IK_PreprocessedCuda || | ||||
LangStd == LangStandard::lang_cuda; | LangStd == LangStandard::lang_cuda; | ||||
// OpenCL and C++ both have bool, true, false keywords. | // OpenCL and C++ both have bool, true, false keywords. | ||||
Opts.Bool = Opts.OpenCL || Opts.CPlusPlus; | Opts.Bool = Opts.OpenCL || Opts.CPlusPlus; | ||||
Show All 24 Lines | |||||
diags.Report(diag::err_drv_invalid_value) | diags.Report(diag::err_drv_invalid_value) | ||||
<< arg->getAsString(args) << value; | << arg->getAsString(args) << value; | ||||
return DefaultVisibility; | return DefaultVisibility; | ||||
} | } | ||||
static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, | static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, | ||||
const TargetOptions &TargetOpts, | const TargetOptions &TargetOpts, | ||||
PreprocessorOptions &PPOpts, | |||||
DiagnosticsEngine &Diags) { | DiagnosticsEngine &Diags) { | ||||
// FIXME: Cleanup per-file based stuff. | // FIXME: Cleanup per-file based stuff. | ||||
LangStandard::Kind LangStd = LangStandard::lang_unspecified; | LangStandard::Kind LangStd = LangStandard::lang_unspecified; | ||||
if (const Arg *A = Args.getLastArg(OPT_std_EQ)) { | if (const Arg *A = Args.getLastArg(OPT_std_EQ)) { | ||||
LangStd = llvm::StringSwitch<LangStandard::Kind>(A->getValue()) | LangStd = llvm::StringSwitch<LangStandard::Kind>(A->getValue()) | ||||
#define LANGSTANDARD(id, name, desc, features) \ | #define LANGSTANDARD(id, name, desc, features) \ | ||||
.Case(name, LangStandard::lang_##id) | .Case(name, LangStandard::lang_##id) | ||||
#include "clang/Frontend/LangStandards.def" | #include "clang/Frontend/LangStandards.def" | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
if (OpenCLLangStd == LangStandard::lang_unspecified) { | if (OpenCLLangStd == LangStandard::lang_unspecified) { | ||||
Diags.Report(diag::err_drv_invalid_value) | Diags.Report(diag::err_drv_invalid_value) | ||||
<< A->getAsString(Args) << A->getValue(); | << A->getAsString(Args) << A->getValue(); | ||||
} | } | ||||
else | else | ||||
LangStd = OpenCLLangStd; | LangStd = OpenCLLangStd; | ||||
} | } | ||||
Opts.NoDefaultHeader = Args.hasArg(OPT_fno_default_header); | |||||
llvm::Triple T(TargetOpts.Triple); | llvm::Triple T(TargetOpts.Triple); | ||||
CompilerInvocation::setLangDefaults(Opts, IK, T, LangStd); | CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd); | ||||
// We abuse '-f[no-]gnu-keywords' to force overriding all GNU-extension | // We abuse '-f[no-]gnu-keywords' to force overriding all GNU-extension | ||||
// keywords. This behavior is provided by GCC's poorly named '-fasm' flag, | // keywords. This behavior is provided by GCC's poorly named '-fasm' flag, | ||||
// while a subset (the non-C++ GNU keywords) is provided by GCC's | // while a subset (the non-C++ GNU keywords) is provided by GCC's | ||||
// '-fgnu-keywords'. Clang conflates the two for simplicity under the single | // '-fgnu-keywords'. Clang conflates the two for simplicity under the single | ||||
// name, as it doesn't seem a useful distinction. | // name, as it doesn't seem a useful distinction. | ||||
Opts.GNUKeywords = Args.hasFlag(OPT_fgnu_keywords, OPT_fno_gnu_keywords, | Opts.GNUKeywords = Args.hasFlag(OPT_fgnu_keywords, OPT_fno_gnu_keywords, | ||||
Opts.GNUKeywords); | Opts.GNUKeywords); | ||||
▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | |||||
Opts.ObjCExceptions = Args.hasArg(OPT_fobjc_exceptions); | Opts.ObjCExceptions = Args.hasArg(OPT_fobjc_exceptions); | ||||
Opts.CXXExceptions = Args.hasArg(OPT_fcxx_exceptions); | Opts.CXXExceptions = Args.hasArg(OPT_fcxx_exceptions); | ||||
Opts.SjLjExceptions = Args.hasArg(OPT_fsjlj_exceptions); | Opts.SjLjExceptions = Args.hasArg(OPT_fsjlj_exceptions); | ||||
Opts.ExternCNoUnwind = Args.hasArg(OPT_fexternc_nounwind); | Opts.ExternCNoUnwind = Args.hasArg(OPT_fexternc_nounwind); | ||||
Opts.TraditionalCPP = Args.hasArg(OPT_traditional_cpp); | Opts.TraditionalCPP = Args.hasArg(OPT_traditional_cpp); | ||||
Opts.RTTI = Opts.CPlusPlus && !Args.hasArg(OPT_fno_rtti); | Opts.RTTI = Opts.CPlusPlus && !Args.hasArg(OPT_fno_rtti); | ||||
Opts.RTTIData = Opts.RTTI && !Args.hasArg(OPT_fno_rtti_data); | Opts.RTTIData = Opts.RTTI && !Args.hasArg(OPT_fno_rtti_data); | ||||
Opts.Blocks = Args.hasArg(OPT_fblocks); | Opts.Blocks = Args.hasArg(OPT_fblocks) || (Opts.OpenCL | ||||
&& Opts.OpenCLVersion >= 200 && !Args.hasArg(OPT_fno_blocks)); | |||||
Opts.BlocksRuntimeOptional = Args.hasArg(OPT_fblocks_runtime_optional); | Opts.BlocksRuntimeOptional = Args.hasArg(OPT_fblocks_runtime_optional); | ||||
Opts.Coroutines = Args.hasArg(OPT_fcoroutines); | Opts.Coroutines = Args.hasArg(OPT_fcoroutines); | ||||
Opts.Modules = Args.hasArg(OPT_fmodules); | Opts.Modules = Args.hasArg(OPT_fmodules); | ||||
Opts.ModulesStrictDeclUse = Args.hasArg(OPT_fmodules_strict_decluse); | Opts.ModulesStrictDeclUse = Args.hasArg(OPT_fmodules_strict_decluse); | ||||
Opts.ModulesDeclUse = | Opts.ModulesDeclUse = | ||||
Args.hasArg(OPT_fmodules_decluse) || Opts.ModulesStrictDeclUse; | Args.hasArg(OPT_fmodules_decluse) || Opts.ModulesStrictDeclUse; | ||||
Opts.ModulesLocalVisibility = | Opts.ModulesLocalVisibility = | ||||
Args.hasArg(OPT_fmodules_local_submodule_visibility); | Args.hasArg(OPT_fmodules_local_submodule_visibility); | ||||
Anastasia: Is this change being tested somewhere? | |||||
Opts.ModulesSearchAll = Opts.Modules && | Opts.ModulesSearchAll = Opts.Modules && | ||||
!Args.hasArg(OPT_fno_modules_search_all) && | !Args.hasArg(OPT_fno_modules_search_all) && | ||||
Args.hasArg(OPT_fmodules_search_all); | Args.hasArg(OPT_fmodules_search_all); | ||||
Opts.ModulesErrorRecovery = !Args.hasArg(OPT_fno_modules_error_recovery); | Opts.ModulesErrorRecovery = !Args.hasArg(OPT_fno_modules_error_recovery); | ||||
Opts.ImplicitModules = !Args.hasArg(OPT_fno_implicit_modules); | Opts.ImplicitModules = !Args.hasArg(OPT_fno_implicit_modules); | ||||
Opts.CharIsSigned = Opts.OpenCL || !Args.hasArg(OPT_fno_signed_char); | Opts.CharIsSigned = Opts.OpenCL || !Args.hasArg(OPT_fno_signed_char); | ||||
Opts.WChar = Opts.CPlusPlus && !Args.hasArg(OPT_fno_wchar); | Opts.WChar = Opts.CPlusPlus && !Args.hasArg(OPT_fno_wchar); | ||||
Opts.ShortWChar = Args.hasFlag(OPT_fshort_wchar, OPT_fno_short_wchar, false); | Opts.ShortWChar = Args.hasFlag(OPT_fshort_wchar, OPT_fno_short_wchar, false); | ||||
▲ Show 20 Lines • Show All 461 Lines • ▼ Show 20 Lines | |||||
// PIClevel and PIELevel are needed during code generation and this should be | // PIClevel and PIELevel are needed during code generation and this should be | ||||
// set regardless of the input type. | // set regardless of the input type. | ||||
LangOpts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags); | LangOpts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags); | ||||
LangOpts.PIELevel = getLastArgIntValue(Args, OPT_pie_level, 0, Diags); | LangOpts.PIELevel = getLastArgIntValue(Args, OPT_pie_level, 0, Diags); | ||||
parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ), | parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ), | ||||
Diags, LangOpts.Sanitize); | Diags, LangOpts.Sanitize); | ||||
} else { | } else { | ||||
// Other LangOpts are only initialzed when the input is not AST or LLVM IR. | // Other LangOpts are only initialzed when the input is not AST or LLVM IR. | ||||
ParseLangArgs(LangOpts, Args, DashX, Res.getTargetOpts(), Diags); | ParseLangArgs(LangOpts, Args, DashX, Res.getTargetOpts(), | ||||
Res.getPreprocessorOpts(), Diags); | |||||
if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC) | if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC) | ||||
LangOpts.ObjCExceptions = 1; | LangOpts.ObjCExceptions = 1; | ||||
} | } | ||||
// During CUDA device-side compilation, the aux triple is the triple used for | // During CUDA device-side compilation, the aux triple is the triple used for | ||||
// host compilation. | // host compilation. | ||||
if (LangOpts.CUDA && LangOpts.CUDAIsDevice) { | if (LangOpts.CUDA && LangOpts.CUDAIsDevice) { | ||||
Res.getTargetOpts().HostTriple = Res.getFrontendOpts().AuxTriple; | Res.getTargetOpts().HostTriple = Res.getFrontendOpts().AuxTriple; | ||||
▲ Show 20 Lines • Show All 242 Lines • Show Last 20 Lines |
Is this change being tested somewhere?