Skip to content

Commit ab6ec7a

Browse files
authored
[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.
1 parent cf456ed commit ab6ec7a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

clang/include/clang/Basic/Builtins.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,13 +1198,13 @@ def AllowRuntimeCheck : Builtin {
11981198

11991199
def ShuffleVector : Builtin {
12001200
let Spellings = ["__builtin_shufflevector"];
1201-
let Attributes = [NoThrow, Const, CustomTypeChecking];
1201+
let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
12021202
let Prototype = "void(...)";
12031203
}
12041204

12051205
def ConvertVector : Builtin {
12061206
let Spellings = ["__builtin_convertvector"];
1207-
let Attributes = [NoThrow, Const, CustomTypeChecking];
1207+
let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
12081208
let Prototype = "void(...)";
12091209
}
12101210

clang/test/Preprocessor/feature_tests.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@
6464
#error Clang should have these constexpr builtins
6565
#endif
6666

67+
#if !__has_constexpr_builtin(__builtin_convertvector)
68+
#error Clang should have these constexpr builtins
69+
#endif
70+
71+
#if !__has_constexpr_builtin(__builtin_shufflevector)
72+
#error Clang should have these constexpr builtins
73+
#endif
74+
6775
#if __has_constexpr_builtin(__builtin_cbrt)
6876
#error This builtin should not be constexpr in Clang
6977
#endif

0 commit comments

Comments
 (0)