[PATCH] D127231: Restore isa<Ty>(X) asserts inside cast<Ty>(X)

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 7 12:52:26 PDT 2022


reames added inline comments.


================
Comment at: llvm/include/llvm/Support/Casting.h:585
 LLVM_NODISCARD inline decltype(auto) cast(From *Val) {
+  assert(isa<To>(Val) && "cast<Ty>() argument of incompatible type!");
   return CastInfo<To, From *>::doCast(Val);
----------------
craig.topper wrote:
> craig.topper wrote:
> > craig.topper wrote:
> > > It doesn't look like there is an implementation of isa that takes From *. It fails to compile on a Casting unittest.
> > ```
> > llvm/include/llvm/Support/Casting.h: In instantiation of ‘static bool llvm::isa_impl<To, From, Enabler>::doit(const From&) [with To = llvm::bar*; From = llvm::bar; Enabler = void]’:
> > llvm/include/llvm/Support/Casting.h:110:36:   required from ‘static bool llvm::isa_impl_cl<To, const From*>::doit(const From*) [with To = llvm::bar*; From = llvm::bar]’
> > llvm/include/llvm/Support/Casting.h:137:41:   required from ‘static bool llvm::isa_impl_wrap<To, FromTy, FromTy>::doit(const FromTy&) [with To = llvm::bar*; FromTy = const llvm::bar*]’
> > llvm/include/llvm/Support/Casting.h:129:13:   required from ‘static bool llvm::isa_impl_wrap<To, From, SimpleFrom>::doit(const From&) [with To = llvm::bar*; From = const llvm::bar* const; SimpleFrom = const llvm::bar*]’
> > llvm/include/llvm/Support/Casting.h:263:62:   required from ‘static bool llvm::CastIsPossible<To, From, Enable>::isPossible(const From&) [with To = llvm::bar*; From = const llvm::bar*; Enable = void]’
> > llvm/include/llvm/Support/Casting.h:517:38:   required from ‘static bool llvm::CastInfo<To, From, typename std::enable_if<(! llvm::is_simple_type<From>::value), void>::type>::isPossible(From&) [with To = llvm::bar*; From = llvm::bar* const]’
> > llvm/include/llvm/Support/Casting.h:556:46:   required from ‘bool llvm::isa(const From&) [with To = llvm::bar*; From = llvm::bar*]’
> > llvm/include/llvm/Support/Casting.h:585:3:   required from ‘decltype(auto) llvm::cast(From*) [with To = llvm::bar*; From = llvm::bar]’
> > llvm/unittests/Support/Casting.cpp:181:27:   required from here
> > llvm/include/llvm/Support/Casting.h:64:64: error: ‘classof’ is not a member of ‘llvm::bar*’
> >    static inline bool doit(const From &Val) { return To::classof(&Val); }
> > ```
> Nevermind. I think this is fixed by the reverting of 0809f63826d36c89574d6ac056ebf46a4b6f29ff that you mentioned in your email.
Yep, exactly.  I just pushed that as 781de11f.

This got slightly delayed from when I'd expected as my build infrastructure went down for a bit.  We should now be fully clean build (if not test) on ToT.  


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127231/new/

https://reviews.llvm.org/D127231



More information about the llvm-commits mailing list