[PATCH] D57824: [OpenCL][PR40603] Align the use of extensions in C++ to be backwards compatible with OpenCL C v2.0

Sven van Haastregt via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 7 02:58:34 PST 2019


svenvh added inline comments.


================
Comment at: lib/Frontend/InitPreprocessor.cpp:1063
+    auto OpenCLVersion =
+        LangOpts.OpenCLCPlusPlus ? 200 : LangOpts.OpenCLVersion;
+#define OPENCLEXT(Ext)                                                         \
----------------
Why not set `OpenCLVersion` in `lib/Frontend/CompilerInvocation.cpp` instead?  Then you wouldn't have to "override" the version in multiple places (which increases the risk of missing one or more places).


================
Comment at: lib/Sema/Sema.cpp:265
     addImplicitTypedef("event_t", Context.OCLEventTy);
-    if (getLangOpts().OpenCLVersion >= 200) {
+    if (getLangOpts().OpenCLCPlusPlus || getLangOpts().OpenCLVersion >= 200) {
       addImplicitTypedef("clk_event_t", Context.OCLClkEventTy);
----------------
This also exposes the OpenCL 2.0 types in OpenCL C++ mode; it would be good to mention that in the commit message.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57824/new/

https://reviews.llvm.org/D57824





More information about the cfe-commits mailing list