From af1c230e70aeb72ec9d6363f8d91e3c7db3ef9f2 Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Wed, 19 Jun 2019 12:48:22 +0000 Subject: [OpenCL] Split type and macro definitions into opencl-c-base.h Using the -fdeclare-opencl-builtins option will require a way to predefine types and macros such as `int4`, `CLK_GLOBAL_MEM_FENCE`, etc. Move these out of opencl-c.h into opencl-c-base.h such that the latter can be shared by -fdeclare-opencl-builtins and -finclude-default-header. This changes the behaviour of -finclude-default-header when -fdeclare-opencl-builtins is specified: instead of including the full header, it will include the header with only the base definitions. Differential revision: https://reviews.llvm.org/D63256 llvm-svn: 363794 --- clang/lib/Frontend/CompilerInvocation.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index fc49aa6..d36af28 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2194,9 +2194,15 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, Opts.NativeHalfType = 1; Opts.NativeHalfArgsAndReturns = 1; Opts.OpenCLCPlusPlus = Opts.CPlusPlus; + // Include default header file for OpenCL. - if (Opts.IncludeDefaultHeader && !Opts.DeclareOpenCLBuiltins) { - PPOpts.Includes.push_back("opencl-c.h"); + if (Opts.IncludeDefaultHeader) { + if (Opts.DeclareOpenCLBuiltins) { + // Only include base header file for builtin types and constants. + PPOpts.Includes.push_back("opencl-c-base.h"); + } else { + PPOpts.Includes.push_back("opencl-c.h"); + } } } -- cgit v1.1