[PATCH] D125609: [ADT] Adopt the new casting infrastructure for PointerUnion

Aman LaChapelle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 14 17:25:03 PDT 2022


bzcheeseman added inline comments.


================
Comment at: llvm/include/llvm/ADT/PointerUnion.h:212
+struct CastInfo<To, PointerUnion<PTs...>>
+    : CastIsPossible<To, PointerUnion<PTs...>> {
+  using From = PointerUnion<PTs...>;
----------------
CastIsPossible inheritance is not necessary since you define isPossible below.


================
Comment at: llvm/include/llvm/ADT/PointerUnion.h:215
+
+  static inline bool isPossible(From &f) { return f.template is<To>(); }
+
----------------
Out of curiosity, does it make sense to implement `PointerUnion::is<T>` in terms of `isa<T>` rather than the other way around? And same for doCast below?


================
Comment at: llvm/include/llvm/ADT/PointerUnion.h:223
+
+  static To castFailed() { return nullptr; }
+
----------------
You can inherit from the NullableValueCastFailed cast trait to get this


================
Comment at: llvm/include/llvm/ADT/PointerUnion.h:225
+
+  static To doCastIfPossible(From &f) {
+    if (isPossible(f))
----------------
You can inherit from the DefaultDoCastIfPossible cast trait to get this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125609



More information about the llvm-commits mailing list