Skip to content

Commit 736511a

Browse files
localspookmahesh-attarde
authored andcommitted
[llvm][NFC] Simplify implementation of isa (llvm#161403)
Using a fold instead of template recursion.
1 parent a7b5f5c commit 736511a

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

llvm/include/llvm/Support/Casting.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -544,14 +544,9 @@ struct CastInfo<To, std::optional<From>> : public OptionalValueCast<To, From> {
544544
///
545545
/// if (isa<Type>(myVal)) { ... }
546546
/// if (isa<Type0, Type1, Type2>(myVal)) { ... }
547-
template <typename To, typename From>
548-
[[nodiscard]] inline bool isa(const From &Val) {
549-
return CastInfo<To, const From>::isPossible(Val);
550-
}
551-
552-
template <typename First, typename Second, typename... Rest, typename From>
547+
template <typename... To, typename From>
553548
[[nodiscard]] inline bool isa(const From &Val) {
554-
return isa<First>(Val) || isa<Second, Rest...>(Val);
549+
return (CastInfo<To, const From>::isPossible(Val) || ...);
555550
}
556551

557552
/// cast<X> - Return the argument parameter cast to the specified type. This

0 commit comments

Comments
 (0)