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

Simon Tatham via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 21 07:59:19 PDT 2022


simon_tatham 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)))
----------------
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.)


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