[OpenCL] Allow undefining header-only features
authorSven van Haastregt <sven.vanhaastregt@arm.com>
Mon, 16 Jan 2023 11:32:12 +0000 (11:32 +0000)
committerSven van Haastregt <sven.vanhaastregt@arm.com>
Mon, 16 Jan 2023 11:32:12 +0000 (11:32 +0000)
commita60b8f468119065f8a6cb4a16598263cb00de0b5
treef7020c44c6540fe4a411e0f0c2ce9e6d50495510
parent15ad244670a9ef0bf93b7c8a598586d4a841b197
[OpenCL] Allow undefining header-only features

`opencl-c-base.h` always defines 5 particular feature macros for
SPIR-V, making it impossible to disable those features.

To allow disabling any of those features, let the header recognize
`__undef_<feature>` macros.  The user can then pass the
`-D__undef_<feature>` flag on the command line to disable a specific
feature.  The __undef macro could potentially also be set from
`-cl-ext=-feature`, but for now only change the header and only
provide __undef macros for the 5 features that are always enabled in
`opencl-c-base.h`.

Differential Revision: https://reviews.llvm.org/D141297
clang/lib/Headers/opencl-c-base.h
clang/test/SemaOpenCL/features.cl