[PATCH] D139452: [LLVM] Use dyn_cast instead of cast for objects that require it
Alf via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 6 12:50:24 PST 2022
gAlfonso-bit created this revision.
gAlfonso-bit added a reviewer: MaskRay.
gAlfonso-bit added a project: LLVM.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
gAlfonso-bit requested review of this revision.
Herald added a subscriber: llvm-commits.
These places should use dyn_cast instead of cast as they are inside conditionals and have dyn_cast used on them in other places
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D139452
Files:
llvm/lib/MC/MCExpr.cpp
llvm/lib/Object/ELFObjectFile.cpp
llvm/utils/TableGen/DecoderEmitter.cpp
Index: llvm/utils/TableGen/DecoderEmitter.cpp
===================================================================
--- llvm/utils/TableGen/DecoderEmitter.cpp
+++ llvm/utils/TableGen/DecoderEmitter.cpp
@@ -2108,7 +2108,7 @@
if (Decoder == "" && CGI.Operands[SO.first].MIOperandInfo &&
CGI.Operands[SO.first].MIOperandInfo->getNumArgs()) {
Init *Arg = CGI.Operands[SO.first].MIOperandInfo->getArg(SO.second);
- if (DefInit *DI = cast<DefInit>(Arg))
+ if (DefInit *DI = dyn_cast<DefInit>(Arg))
TypeRecord = DI->getDef();
}
Index: llvm/lib/Object/ELFObjectFile.cpp
===================================================================
--- llvm/lib/Object/ELFObjectFile.cpp
+++ llvm/lib/Object/ELFObjectFile.cpp
@@ -800,7 +800,7 @@
return readBBAddrMapImpl(Obj->getELFFile(), TextSectionIndex);
if (const auto *Obj = dyn_cast<ELF32BEObjectFile>(this))
return readBBAddrMapImpl(Obj->getELFFile(), TextSectionIndex);
- if (const auto *Obj = cast<ELF64BEObjectFile>(this))
+ if (const auto *Obj = dyn_cast<ELF64BEObjectFile>(this))
return readBBAddrMapImpl(Obj->getELFFile(), TextSectionIndex);
else
llvm_unreachable("Unsupported binary format");
Index: llvm/lib/MC/MCExpr.cpp
===================================================================
--- llvm/lib/MC/MCExpr.cpp
+++ llvm/lib/MC/MCExpr.cpp
@@ -886,7 +886,7 @@
Addrs, InSet)) {
// Check if both are Target Expressions, see if we can compare them.
if (const MCTargetExpr *L = dyn_cast<MCTargetExpr>(ABE->getLHS()))
- if (const MCTargetExpr *R = cast<MCTargetExpr>(ABE->getRHS())) {
+ if (const MCTargetExpr *R = dyn_cast<MCTargetExpr>(ABE->getRHS())) {
switch (ABE->getOpcode()) {
case MCBinaryExpr::EQ:
Res = MCValue::get((L->isEqualTo(R)) ? -1 : 0);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139452.480585.patch
Type: text/x-patch
Size: 1915 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221206/d6e6866c/attachment.bin>
More information about the llvm-commits
mailing list