[PATCH] D17578: [OpenCL]Allowing explicit conversion of "0" to event_t type

Xiuli PAN via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 24 22:42:50 PST 2016


pxli168 added a comment.

  foo((event_t)0);

Is above use have been hint by some test cases?


================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7679
@@ -7678,2 +7678,3 @@
 def err_wrong_sampler_addressspace: Error<
-  "sampler type cannot be used with the __local and __global address space qualifiers">;
+  "sampler type cannot be used with the __local and __global address space qualifiers">;
+def error_opencl_cast_non_zero_to_event_t : Error<
----------------
Please do not use DOS format.

================
Comment at: lib/Sema/SemaCast.cpp:2316
@@ -2315,1 +2315,3 @@
 
+    // for OpenCL, allow casts from '0' to event_t type
+    if ((Self.getLangOpts().OpenCL) && DestType->isEventT()) {
----------------
1. Comments start with capital.
2. End a sentence with a period.
3. Give spec reference here, start with:
OpenCL v2.0 s6.13.10 - ....

================
Comment at: lib/Sema/SemaCast.cpp:2317
@@ +2316,3 @@
+    // for OpenCL, allow casts from '0' to event_t type
+    if ((Self.getLangOpts().OpenCL) && DestType->isEventT()) {
+          llvm::APSInt intValue;
----------------
(Self.getLangOpts().OpenCL) -> Self.getLangOpts().OpenCL

================
Comment at: lib/Sema/SemaCast.cpp:2318
@@ +2317,3 @@
+    if ((Self.getLangOpts().OpenCL) && DestType->isEventT()) {
+          llvm::APSInt intValue;
+      if(SrcExpr.get()->EvaluateAsInt(intValue, Self.getASTContext())) {
----------------
Indent.

================
Comment at: lib/Sema/SemaCast.cpp:2319
@@ +2318,3 @@
+          llvm::APSInt intValue;
+      if(SrcExpr.get()->EvaluateAsInt(intValue, Self.getASTContext())) {
+        if(0 == intValue) {
----------------
Sema has a context.
Self.getASTContext() ->Self.Context

================
Comment at: lib/Sema/SemaCast.cpp:2321
@@ +2320,3 @@
+        if(0 == intValue) {
+          Kind = CK_IntegralToPointer;
+          return;
----------------
There is a CK_ZeroToOCLEvent, why not use that?

================
Comment at: lib/Sema/SemaCast.cpp:2324-2328
@@ +2323,7 @@
+        } else {
+        Self.Diag(OpRange.getBegin(),
+                  diag::error_opencl_cast_non_zero_to_event_t)
+                  << intValue.toString(10) << SrcExpr.get()->getSourceRange();
+        SrcExpr = ExprError();
+        return;
+        }
----------------
Indent.
You can try to use clang-format to help keep these right.


http://reviews.llvm.org/D17578





More information about the cfe-commits mailing list