[llvm] 9031e51 - [llvm-rc] Use cast<> instead of dyn_cast<> to avoid dereference of nullptr
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 2 07:41:30 PST 2022
Author: Simon Pilgrim
Date: 2022-02-02T15:36:01Z
New Revision: 9031e5113c47b41eb265f954d53efcef5ec626be
URL: https://github.com/llvm/llvm-project/commit/9031e5113c47b41eb265f954d53efcef5ec626be
DIFF: https://github.com/llvm/llvm-project/commit/9031e5113c47b41eb265f954d53efcef5ec626be.diff
LOG: [llvm-rc] Use cast<> instead of dyn_cast<> to avoid dereference of nullptr
The pointer is dereferenced immediately, so assert the cast is correct instead of returning nullptr
Added:
Modified:
llvm/tools/llvm-rc/ResourceFileWriter.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-rc/ResourceFileWriter.cpp b/llvm/tools/llvm-rc/ResourceFileWriter.cpp
index 60287a37f0b1e..866232080575c 100644
--- a/llvm/tools/llvm-rc/ResourceFileWriter.cpp
+++ b/llvm/tools/llvm-rc/ResourceFileWriter.cpp
@@ -875,7 +875,7 @@ Error ResourceFileWriter::visitIconOrCursorResource(const RCResource *Base) {
FileStr = IconRes->IconLoc;
Type = IconCursorGroupType::Icon;
} else {
- auto *CursorRes = dyn_cast<CursorResource>(Base);
+ auto *CursorRes = cast<CursorResource>(Base);
FileStr = CursorRes->CursorLoc;
Type = IconCursorGroupType::Cursor;
}
More information about the llvm-commits
mailing list