From ab66bf74f91e8fc1a87739911b3a13b795dc54e6 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 27 Apr 2025 15:18:31 -0700 Subject: [PATCH] [CodeGen] Use llvm::is_detected (NFC) --- llvm/include/llvm/CodeGen/ByteProvider.h | 25 +++++++++--------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/llvm/include/llvm/CodeGen/ByteProvider.h b/llvm/include/llvm/CodeGen/ByteProvider.h index b97ff5c1aa039..c00335a216458 100644 --- a/llvm/include/llvm/CodeGen/ByteProvider.h +++ b/llvm/include/llvm/CodeGen/ByteProvider.h @@ -17,6 +17,7 @@ #ifndef LLVM_CODEGEN_BYTEPROVIDER_H #define LLVM_CODEGEN_BYTEPROVIDER_H +#include "llvm/ADT/STLExtras.h" #include "llvm/Support/DataTypes.h" #include #include @@ -35,22 +36,14 @@ template class ByteProvider { // TODO -- use constraint in c++20 // Does this type correspond with an operation in selection DAG - template class is_op { - private: - using yes = std::true_type; - using no = std::false_type; + // Only allow classes with member function getOpcode + template + using check_has_getOpcode = + decltype(std::declval &>().getOpcode()); - // Only allow classes with member function getOpcode - template - static auto test(int) -> decltype(std::declval().getOpcode(), yes()); - - template static no test(...); - - public: - using remove_pointer_t = typename std::remove_pointer::type; - static constexpr bool value = - std::is_same(0)), yes>::value; - }; + template + static constexpr bool has_getOpcode = + is_detected::value; public: // For constant zero providers Src is set to nullopt. For actual providers @@ -66,7 +59,7 @@ template class ByteProvider { static ByteProvider getSrc(std::optional Val, int64_t ByteOffset, int64_t VectorOffset) { - static_assert(is_op().value, + static_assert(has_getOpcode, "ByteProviders must contain an operation in selection DAG."); return ByteProvider(Val, ByteOffset, VectorOffset); }