[PATCH] D122046: [clang] Remove Address::deprecated from MveEmitter

Arthur Eubanks via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 21 09:39:06 PDT 2022


aeubanks added inline comments.


================
Comment at: clang/utils/TableGen/MveEmitter.cpp:1197
+    const Type *Ty = nullptr;
+    if (auto *DI = dyn_cast<DagInit>(D->getArg(0))->getOperator())
+      if (auto *PTy = dyn_cast<PointerType>(getType(DI, Param)))
----------------
simon_tatham wrote:
> dblaikie wrote:
> > nikic wrote:
> > > Should be either `cast` or check for nullptr before dereferencing?
> > Not sure I follow the question - which variable are you pointing to that needs a null check before its use?
> Oh yes, good point, I see it. `dyn_cast<DagInit>(D->getArg(0))` might return nullptr, because the point of `dyn_cast` is that the thing you're casting might not have the right type. So you should check the return from `dyn_cast` before you dereference it to call its `getOperator` method.
> 
> (Alternatively, as @nikic hints, if you think that in this case the cast //cannot// fail, then you can change it to a straight `cast` which doesn't do the runtime check.)
the parentheses were confusing, fixed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122046



More information about the cfe-commits mailing list