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 @@ -563,21 +563,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)); }