[clang] ab6ec7a - [clang] Mark `__builtin_convertvector` and `__builtin_shufflevector` as `constexpr`. (#112129)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 14 09:09:46 PDT 2024
Author: c8ef
Date: 2024-10-15T00:09:36+08:00
New Revision: ab6ec7ab149ea2c627ed2814c11be33a92171153
URL: https://github.com/llvm/llvm-project/commit/ab6ec7ab149ea2c627ed2814c11be33a92171153
DIFF: https://github.com/llvm/llvm-project/commit/ab6ec7ab149ea2c627ed2814c11be33a92171153.diff
LOG: [clang] Mark `__builtin_convertvector` and `__builtin_shufflevector` as `constexpr`. (#112129)
Closes #107985.
LanguageExtensions.rst states that `__builtin_shufflevector` and
`__builtin_convertvector` can be evaluated as constants, but this is not
reflected in Butiltins.td. This patch aligns these two.
Added:
Modified:
clang/include/clang/Basic/Builtins.td
clang/test/Preprocessor/feature_tests.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td
index a7e2ee30d9d732..bda8a48be92bda 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -1198,13 +1198,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(...)";
}
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