This is an archive of the discontinued LLVM Phabricator instance.

[Object][NFC] Remove unneeded llvm_unreachable
ClosedPublic

Authored by gAlfonso-bit on Dec 6 2022, 12:50 PM.

Details

Summary

The structure of this method now matches the one above it.

Diff Detail

Event Timeline

gAlfonso-bit created this revision.Dec 6 2022, 12:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 6 2022, 12:50 PM
gAlfonso-bit requested review of this revision.Dec 6 2022, 12:50 PM

I agree that the call site uses are somewhat problematic, but cast has stronger guarantee. Do you have a test case to trigger a code path that dyn_cast returns nullptr? If not, the if statement should just be replaced with unconditional cast.

llvm/lib/Object/ELFObjectFile.cpp
785–786

This can just used cast and delete llvm_unreachable

This comment was removed by gAlfonso-bit.
gAlfonso-bit marked an inline comment as done.Dec 6 2022, 3:54 PM
MaskRay added inline comments.Dec 6 2022, 3:57 PM
llvm/utils/TableGen/DecoderEmitter.cpp
2111 ↗(On Diff #480661)

See the reverted ba59ec2843f99f19d55d7cd9f9ac536fb038fdab: this change seems wrong.

This comment was removed by gAlfonso-bit.
gAlfonso-bit marked an inline comment as done.Dec 6 2022, 5:03 PM
craig.topper added inline comments.
llvm/lib/MC/MCExpr.cpp
889

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.

gAlfonso-bit retitled this revision from [LLVM] Use dyn_cast instead of cast for objects that require it to [LLVM][NFC] Remove unneeded llvm_unreachable.Feb 16 2023, 8:10 AM
gAlfonso-bit edited the summary of this revision. (Show Details)
This comment was removed by gAlfonso-bit.
MaskRay accepted this revision.Feb 16 2023, 9:51 AM
MaskRay retitled this revision from [LLVM][NFC] Remove unneeded llvm_unreachable to [Object][NFC] Remove unneeded llvm_unreachable.
This revision is now accepted and ready to land.Feb 16 2023, 9:51 AM
This comment was removed by gAlfonso-bit.

@MaskRay Can I have commit permissions please

I'll land this patch for you. Your previous changes are all about this kind of NFC cleanup. I think I only want to endorse people with contributions like bug fixing or useful feature requests...

This revision was automatically updated to reflect the committed changes.