This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objdump] Replace cast<> by dyn_cast<>
AbandonedPublic

Authored by Higuoxing on Nov 15 2018, 5:05 AM.

Details

Summary

cast<> can cause assertion failure, so the else routine is unreachable.

Diff Detail

Event Timeline

Higuoxing created this revision.Nov 15 2018, 5:05 AM
Higuoxing abandoned this revision.Nov 15 2018, 5:09 AM

Seems there are some legacy codes, like:

if (auto *ELF32LE = dyn_cast<ELF32LEObjectFile>(Obj))
  return getRelocationValueString(ELF32LE, Rel, Result);
if (auto *ELF64LE = dyn_cast<ELF64LEObjectFile>(Obj))
  return getRelocationValueString(ELF64LE, Rel, Result);
if (auto *ELF32BE = dyn_cast<ELF32BEObjectFile>(Obj))
  return getRelocationValueString(ELF32BE, Rel, Result);
auto *ELF64BE = cast<ELF64BEObjectFile>(Obj);
return getRelocationValueString(ELF64BE, Rel, Result);