[llvm] f4aa2a4 - [llvm-profgen] ProfiledBinary::load - use cast<> instead of dyn_cast<> to avoid dereference of nullptr
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 14 07:51:51 PST 2022
Author: Simon Pilgrim
Date: 2022-01-14T15:51:21Z
New Revision: f4aa2a42edacda61563a33a355dbd9bb22644bf5
URL: https://github.com/llvm/llvm-project/commit/f4aa2a42edacda61563a33a355dbd9bb22644bf5
DIFF: https://github.com/llvm/llvm-project/commit/f4aa2a42edacda61563a33a355dbd9bb22644bf5.diff
LOG: [llvm-profgen] ProfiledBinary::load - use cast<> instead of dyn_cast<> to avoid dereference of nullptr
The pointer is always dereferenced immediately, so assert the cast is correct instead of returning nullptr
Added:
Modified:
llvm/tools/llvm-profgen/ProfiledBinary.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.cpp b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
index aa4dd426f66d..6dc0d2604367 100644
--- a/llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -206,7 +206,7 @@ void ProfiledBinary::load() {
decodePseudoProbe(Obj);
// Load debug info of subprograms from DWARF section.
- loadSymbolsFromDWARF(*dyn_cast<ObjectFile>(&Binary));
+ loadSymbolsFromDWARF(*cast<ObjectFile>(&Binary));
// Disassemble the text sections.
disassemble(Obj);
More information about the llvm-commits
mailing list