[PATCH] D139452: [LLVM] Use dyn_cast instead of cast for objects that require it
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 15 19:26:32 PST 2023
craig.topper added inline comments.
================
Comment at: llvm/lib/MC/MCExpr.cpp:889
if (const MCTargetExpr *L = dyn_cast<MCTargetExpr>(ABE->getLHS())) {
- const MCTargetExpr *R = cast<MCTargetExpr>(ABE->getRHS());
+ const MCTargetExpr *R = dyn_cast<MCTargetExpr>(ABE->getRHS());
switch (ABE->getOpcode()) {
----------------
R isn't checked for null after this so if the dynamic cast fails it will dereference a null point. `cast` would have generated an assert on assertion builds.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139452/new/
https://reviews.llvm.org/D139452
More information about the llvm-commits
mailing list