[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 17:03:10 PST 2022
gAlfonso-bit updated this revision to Diff 480705.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139452/new/
https://reviews.llvm.org/D139452
Files:
llvm/lib/MC/MCExpr.cpp
llvm/lib/Object/ELFObjectFile.cpp
Index: llvm/lib/Object/ELFObjectFile.cpp
===================================================================
--- llvm/lib/Object/ELFObjectFile.cpp
+++ llvm/lib/Object/ELFObjectFile.cpp
@@ -800,8 +800,6 @@
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))
- return readBBAddrMapImpl(Obj->getELFFile(), TextSectionIndex);
- else
- llvm_unreachable("Unsupported binary format");
+ const auto *Obj = cast<ELF64BEObjectFile>(this);
+ return readBBAddrMapImpl(Obj->getELFFile(), TextSectionIndex);
}
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.480705.patch
Type: text/x-patch
Size: 1382 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221207/a88e73ff/attachment.bin>
More information about the llvm-commits
mailing list