Skip to content

Commit

Permalink
[clang] Mark __builtin_convertvector and __builtin_shufflevector
Browse files Browse the repository at this point in the history
…as `constexpr`. (llvm#112129)

Closes llvm#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.
  • Loading branch information
c8ef authored and DanielCChen committed Oct 16, 2024
1 parent d182e9c commit 9d2ae5b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions clang/include/clang/Basic/Builtins.td
Original file line number Diff line number Diff line change
Expand Up @@ -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(...)";
}

Expand Down
8 changes: 8 additions & 0 deletions clang/test/Preprocessor/feature_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9d2ae5b

Please sign in to comment.