Skip to content

Commit c0b6ddf

Browse files
[AMDGPU] Simplify "class HasMember##member" with llvm::is_detected (NFC) (llvm#160037)
"class HasMember##member" detects a specific member with a complex SFINAE logic involving multiple inheritance. This patch simplifies that by switching to llvm::is_detected.
1 parent 7818089 commit c0b6ddf

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

llvm/lib/Target/AMDGPU/Utils/AMDKernelCodeTUtils.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,12 @@ using namespace llvm::AMDGPU;
4040
// returns.
4141
#define GEN_HAS_MEMBER(member) \
4242
class HasMember##member { \
43-
private: \
44-
struct KnownWithMember { \
45-
int member; \
46-
}; \
47-
class AmbiguousDerived : public AMDGPUMCKernelCodeT, \
48-
public KnownWithMember {}; \
4943
template <typename U> \
50-
static constexpr std::false_type Test(decltype(U::member) *); \
51-
template <typename U> static constexpr std::true_type Test(...); \
44+
using check_member = decltype(std::declval<U>().member); \
5245
\
5346
public: \
5447
static constexpr bool RESULT = \
55-
std::is_same_v<decltype(Test<AmbiguousDerived>(nullptr)), \
56-
std::true_type>; \
48+
llvm::is_detected<check_member, AMDGPUMCKernelCodeT>::value; \
5749
}; \
5850
class IsMCExpr##member { \
5951
template <typename U> \

0 commit comments

Comments
 (0)