diff options
author | Yaxun Liu <Yaxun.Liu@amd.com> | 2016-06-20 19:26:00 +0000 |
---|---|---|
committer | Yaxun Liu <Yaxun.Liu@amd.com> | 2016-06-20 19:26:00 +0000 |
commit | 143f083e4bd0f98f34ce62b53e6008b9e5f9e319 (patch) | |
tree | a68e54c524fd82e492a221f1ee68927653dcc636 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 98780e6eff69866bbbebd0b0082b6863219e9ae3 (diff) | |
download | bcm5719-llvm-143f083e4bd0f98f34ce62b53e6008b9e5f9e319.tar.gz bcm5719-llvm-143f083e4bd0f98f34ce62b53e6008b9e5f9e319.zip |
[OpenCL] Include opencl-c.h by default as a clang module
Include opencl-c.h by default as a module to utilize the automatic AST caching mechanism of clang modules.
Add an option -finclude-default-header to enable default header for OpenCL, which is off by default.
Differential Revision: http://reviews.llvm.org/D20444
llvm-svn: 273191
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 0854abedfe6..4a3c31b1d19 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1459,6 +1459,7 @@ bool isOpenCL(LangStandard::Kind LangStd) { void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, const llvm::Triple &T, + PreprocessorOptions &PPOpts, 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 @@ -1543,6 +1544,10 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, Opts.DefaultFPContract = 1; Opts.NativeHalfType = 1; Opts.NativeHalfArgsAndReturns = 1; + // Include default header file for OpenCL. + if (Opts.IncludeDefaultHeader) { + PPOpts.Includes.push_back("opencl-c.h"); + } } Opts.CUDA = IK == IK_CUDA || IK == IK_PreprocessedCuda || @@ -1589,6 +1594,7 @@ static Visibility parseVisibility(Arg *arg, ArgList &args, static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, const TargetOptions &TargetOpts, + PreprocessorOptions &PPOpts, DiagnosticsEngine &Diags) { // FIXME: Cleanup per-file based stuff. LangStandard::Kind LangStd = LangStandard::lang_unspecified; @@ -1660,8 +1666,10 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, LangStd = OpenCLLangStd; } + Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header); + 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 // keywords. This behavior is provided by GCC's poorly named '-fasm' flag, @@ -2331,7 +2339,8 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, Diags, LangOpts.Sanitize); } else { // 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) LangOpts.ObjCExceptions = 1; } |