[llvm] ff05b93 - [llvm-objdump] Use cast<> instead of dyn_cast<> to avoid dereference of nullptr
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 23 04:50:57 PST 2022
Author: Simon Pilgrim
Date: 2022-01-23T12:45:12Z
New Revision: ff05b93a02d18c3b388658de2186f570d725ec71
URL: https://github.com/llvm/llvm-project/commit/ff05b93a02d18c3b388658de2186f570d725ec71
DIFF: https://github.com/llvm/llvm-project/commit/ff05b93a02d18c3b388658de2186f570d725ec71.diff
LOG: [llvm-objdump] Use cast<> instead of dyn_cast<> to avoid dereference of nullptr
The pointers are always dereferenced immediately, so assert the cast is correct instead of returning nullptr
Added:
Modified:
llvm/tools/llvm-objdump/MachODump.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp
index 193ba2da19410..31867625f0e5e 100644
--- a/llvm/tools/llvm-objdump/MachODump.cpp
+++ b/llvm/tools/llvm-objdump/MachODump.cpp
@@ -10231,12 +10231,12 @@ static void PrintMachHeader(const MachOObjectFile *Obj, bool verbose) {
}
void objdump::printMachOFileHeader(const object::ObjectFile *Obj) {
- const MachOObjectFile *file = dyn_cast<const MachOObjectFile>(Obj);
+ const MachOObjectFile *file = cast<const MachOObjectFile>(Obj);
PrintMachHeader(file, Verbose);
}
void objdump::printMachOLoadCommands(const object::ObjectFile *Obj) {
- const MachOObjectFile *file = dyn_cast<const MachOObjectFile>(Obj);
+ const MachOObjectFile *file = cast<const MachOObjectFile>(Obj);
uint32_t filetype = 0;
uint32_t cputype = 0;
if (file->is64Bit()) {
More information about the llvm-commits
mailing list