diff --git a/llvm/include/llvm/Support/Casting.h b/llvm/include/llvm/Support/Casting.h --- a/llvm/include/llvm/Support/Casting.h +++ b/llvm/include/llvm/Support/Casting.h @@ -525,6 +525,14 @@ } }; +/// Provides a self-cast that simply returns whatever is given. This doesn't +/// provide `castFailed` because a cast from T to T should never fail. +template struct CastInfo { + static bool isPossible(const T &t) { return true; } + static decltype(auto) doCast(const T &t) { return t; } + static decltype(auto) doCastIfPossible(const T &t) { return t; } +}; + //===----------------------------------------------------------------------===// // Pre-specialized CastInfo //===----------------------------------------------------------------------===//