[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.
This commit is contained in:
c8ef
2024-10-15 00:09:36 +08:00
committed by GitHub
parent cf456ed2a4
commit ab6ec7ab14
2 changed files with 10 additions and 2 deletions

View File

@@ -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(...)";
}

View File

@@ -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