Index: llvm/include/llvm/Support/Casting.h =================================================================== --- llvm/include/llvm/Support/Casting.h +++ llvm/include/llvm/Support/Casting.h @@ -570,21 +570,25 @@ template LLVM_NODISCARD inline decltype(auto) cast(const From &Val) { + assert(isa(Val) && "cast() argument of incompatible type!"); return CastInfo::doCast(Val); } template LLVM_NODISCARD inline decltype(auto) cast(From &Val) { + assert(isa(Val) && "cast() argument of incompatible type!"); return CastInfo::doCast(Val); } template LLVM_NODISCARD inline decltype(auto) cast(From *Val) { + assert(isa(Val) && "cast() argument of incompatible type!"); return CastInfo::doCast(Val); } template LLVM_NODISCARD inline decltype(auto) cast(std::unique_ptr &&Val) { + assert(isa(Val) && "cast() argument of incompatible type!"); return CastInfo>::doCast(std::move(Val)); }