diff --git a/clang/include/clang/Frontend/CompilerInvocation.h b/clang/include/clang/Frontend/CompilerInvocation.h --- a/clang/include/clang/Frontend/CompilerInvocation.h +++ b/clang/include/clang/Frontend/CompilerInvocation.h @@ -176,11 +176,12 @@ /// \param Opts - The LangOptions object to set up. /// \param IK - The input language. /// \param T - The target triple. - /// \param PPOpts - The PreprocessorOptions affected. + /// \param Includes - The affected list of included files. /// \param LangStd - The input language standard. - static void setLangDefaults(LangOptions &Opts, InputKind IK, - const llvm::Triple &T, PreprocessorOptions &PPOpts, - LangStandard::Kind LangStd = LangStandard::lang_unspecified); + static void + setLangDefaults(LangOptions &Opts, InputKind IK, const llvm::Triple &T, + std::vector &Includes, + LangStandard::Kind LangStd = LangStandard::lang_unspecified); /// Retrieve a module hash string that is suitable for uniquely /// identifying the conditions under which the module was built. diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1889,7 +1889,7 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, const llvm::Triple &T, - PreprocessorOptions &PPOpts, + std::vector &Includes, LangStandard::Kind LangStd) { // 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 @@ -2000,9 +2000,9 @@ if (Opts.IncludeDefaultHeader) { if (Opts.DeclareOpenCLBuiltins) { // Only include base header file for builtin types and constants. - PPOpts.Includes.push_back("opencl-c-base.h"); + Includes.push_back("opencl-c-base.h"); } else { - PPOpts.Includes.push_back("opencl-c.h"); + Includes.push_back("opencl-c.h"); } } } @@ -2138,8 +2138,8 @@ } static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, - const TargetOptions &TargetOpts, - PreprocessorOptions &PPOpts, + const llvm::Triple &T, + std::vector &Includes, DiagnosticsEngine &Diags) { // FIXME: Cleanup per-file based stuff. LangStandard::Kind LangStd = LangStandard::lang_unspecified; @@ -2212,8 +2212,7 @@ Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device); - llvm::Triple T(TargetOpts.Triple); - CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd); + CompilerInvocation::setLangDefaults(Opts, IK, T, Includes, LangStd); // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0. // This option should be deprecated for CL > 1.0 because @@ -2490,7 +2489,6 @@ Diags.Report(diag::err_drv_argument_not_allowed_with) << A->getSpelling() << "-fdefault-calling-conv"; else { - llvm::Triple T(TargetOpts.Triple); if (T.getArch() != llvm::Triple::x86) Diags.Report(diag::err_drv_argument_not_allowed_with) << A->getSpelling() << T.getTriple(); @@ -2527,8 +2525,7 @@ // Add unsupported host targets here: case llvm::Triple::nvptx: case llvm::Triple::nvptx64: - Diags.Report(diag::err_drv_omp_host_target_not_supported) - << TargetOpts.Triple; + Diags.Report(diag::err_drv_omp_host_target_not_supported) << T.str(); break; } } @@ -2960,8 +2957,8 @@ } else { // Other LangOpts are only initialized when the input is not AST or LLVM IR. // FIXME: Should we really be calling this for an Language::Asm input? - ParseLangArgs(LangOpts, Args, DashX, Res.getTargetOpts(), - Res.getPreprocessorOpts(), Diags); + ParseLangArgs(LangOpts, Args, DashX, T, Res.getPreprocessorOpts().Includes, + Diags); if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC) LangOpts.ObjCExceptions = 1; if (T.isOSDarwin() && DashX.isPreprocessed()) {