Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[FIX] Workaround clang __builtin_constant_p
  • Loading branch information
eseiler committed Sep 28, 2023
commit 92380a1e10b4a5e22c12905aed050a66d60c0b1b
6 changes: 5 additions & 1 deletion include/seqan3/utility/type_traits/basic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
* \ingroup utility_type_traits
* \returns true or false.
*/
#define SEQAN3_IS_CONSTEXPR(...) std::integral_constant<bool, __builtin_constant_p((__VA_ARGS__, 0))>::value
#if defined(__clang__) // https://github.com/llvm/llvm-project/issues/58078
# define SEQAN3_IS_CONSTEXPR(...) true
#else
# define SEQAN3_IS_CONSTEXPR(...) std::integral_constant<bool, __builtin_constant_p(((void)__VA_ARGS__, 0))>::value
#endif
//!\endcond

namespace seqan3
Expand Down
4 changes: 4 additions & 0 deletions test/unit/utility/type_traits/basic_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ struct nonconstexpr_void_member_t

TEST(type_trait, is_constexpr_invocable)
{
#if defined(__clang__)
GTEST_SKIP() << "Skipping on clang: https://github.com/llvm/llvm-project/issues/58078";
#else // Whole test is in else/endif block, because i/j would be unused on clang.
int i = 32;
constexpr int j = 42;

Expand All @@ -115,4 +118,5 @@ TEST(type_trait, is_constexpr_invocable)
EXPECT_TRUE((SEQAN3_IS_CONSTEXPR(constexpr_void_member_t{}.get_i(3))));
EXPECT_TRUE((!SEQAN3_IS_CONSTEXPR(nonconstexpr_nonvoid_member_t{}.get_i(3))));
EXPECT_TRUE((!SEQAN3_IS_CONSTEXPR(nonconstexpr_void_member_t{}.get_i(3))));
#endif
}