[clang] [clang] Mark `__builtin_convertvector` and `__builtin_shufflevector` as `constexpr`. (PR #112129)

via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 14 06:26:59 PDT 2024


https://github.com/c8ef updated https://github.com/llvm/llvm-project/pull/112129

>From 34518391101653e9ef84d8a80b70ae2df8551b3d Mon Sep 17 00:00:00 2001
From: c8ef <c8ef at outlook.com>
Date: Sun, 13 Oct 2024 19:16:57 +0800
Subject: [PATCH 1/2] Update Builtins.td

---
 clang/include/clang/Basic/Builtins.td | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td
index 7068473a0e12ac..362de6cfa9d0e1 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -1186,13 +1186,13 @@ def AllowRuntimeCheck : Builtin {
 
 def ShuffleVector : Builtin {
   let Spellings = ["__builtin_shufflevector"];
-  let Attributes = [NoThrow, Const, CustomTypeChecking];
+  let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
   let Prototype = "void(...)";
 }
 
 def ConvertVector : Builtin {
   let Spellings = ["__builtin_convertvector"];
-  let Attributes = [NoThrow, Const, CustomTypeChecking];
+  let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
   let Prototype = "void(...)";
 }
 

>From 116cd9c38406b6b1f4d6d7330ffb630b5543d20d Mon Sep 17 00:00:00 2001
From: c8ef <c8ef at outlook.com>
Date: Mon, 14 Oct 2024 21:26:50 +0800
Subject: [PATCH 2/2] Update feature_tests.cpp

---
 clang/test/Preprocessor/feature_tests.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/clang/test/Preprocessor/feature_tests.cpp b/clang/test/Preprocessor/feature_tests.cpp
index 3bda3db70ed0da..029f446113af45 100644
--- a/clang/test/Preprocessor/feature_tests.cpp
+++ b/clang/test/Preprocessor/feature_tests.cpp
@@ -64,6 +64,14 @@
 #error Clang should have these constexpr builtins
 #endif
 
+#if !__has_constexpr_builtin(__builtin_convertvector)
+#error Clang should have these constexpr builtins
+#endif
+
+#if !__has_constexpr_builtin(__builtin_shufflevector)
+#error Clang should have these constexpr builtins
+#endif
+
 #if  __has_constexpr_builtin(__builtin_cbrt)
 #error This builtin should not be constexpr in Clang
 #endif



More information about the cfe-commits mailing list