[clang] 3a29ac2 - [OpenCL] Fix missing const attributes for get_image_ builtins

Sven van Haastregt via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 11 05:07:06 PST 2021


Author: Sven van Haastregt
Date: 2021-02-11T13:05:26Z
New Revision: 3a29ac2a61f78aae049a46369203757ece315e23

URL: https://github.com/llvm/llvm-project/commit/3a29ac2a61f78aae049a46369203757ece315e23
DIFF: https://github.com/llvm/llvm-project/commit/3a29ac2a61f78aae049a46369203757ece315e23.diff

LOG: [OpenCL] Fix missing const attributes for get_image_ builtins

Various get_image builtin function declarations did not have the const
attribute.  Bring the const attributes of `-fdeclare-opencl-builtins`
more in sync with `opencl-c.h`.

Added: 
    

Modified: 
    clang/lib/Sema/OpenCLBuiltins.td

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/OpenCLBuiltins.td b/clang/lib/Sema/OpenCLBuiltins.td
index b78a1812748b..7f32be6cc8e8 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -1163,21 +1163,21 @@ foreach aQual = ["RO", "WO", "RW"] in {
                    Image2dArrayDepth] in {
     foreach name = ["get_image_width", "get_image_channel_data_type",
                     "get_image_channel_order"] in {
-      def : Builtin<name, [Int, ImageType<imgTy, aQual>]>;
+      def : Builtin<name, [Int, ImageType<imgTy, aQual>], Attr.Const>;
     }
   }
   foreach imgTy = [Image2d, Image3d, Image2dArray, Image2dDepth,
                    Image2dArrayDepth] in {
-    def : Builtin<"get_image_height", [Int, ImageType<imgTy, aQual>]>;
+    def : Builtin<"get_image_height", [Int, ImageType<imgTy, aQual>], Attr.Const>;
   }
-  def : Builtin<"get_image_depth", [Int, ImageType<Image3d, aQual>]>;
+  def : Builtin<"get_image_depth", [Int, ImageType<Image3d, aQual>], Attr.Const>;
   foreach imgTy = [Image2d, Image2dArray, Image2dDepth,
                    Image2dArrayDepth] in {
-    def : Builtin<"get_image_dim", [VectorType<Int, 2>, ImageType<imgTy, aQual>]>;
+    def : Builtin<"get_image_dim", [VectorType<Int, 2>, ImageType<imgTy, aQual>], Attr.Const>;
   }
-  def : Builtin<"get_image_dim", [VectorType<Int, 4>, ImageType<Image3d, aQual>]>;
+  def : Builtin<"get_image_dim", [VectorType<Int, 4>, ImageType<Image3d, aQual>], Attr.Const>;
   foreach imgTy = [Image1dArray, Image2dArray, Image2dArrayDepth] in {
-    def : Builtin<"get_image_array_size", [Size, ImageType<imgTy, aQual>]>;
+    def : Builtin<"get_image_array_size", [Size, ImageType<imgTy, aQual>], Attr.Const>;
   }
 }
 


        


More information about the cfe-commits mailing list