[PATCH] D62118: [DWARF] hoist nullptr checks. NFC
Nick Desaulniers via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun May 19 19:32:20 PDT 2019
nickdesaulniers created this revision.
nickdesaulniers added reviewers: JDevlieghere, probinson.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
This was flagged in https://www.viva64.com/en/b/0629/ under "Snippet No.
15" (see under #13). It looks like PVS studio flags nullptr checks where
the ptr is used inbetween creation and checking against nullptr.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D62118
Files:
llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
Index: llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
@@ -401,12 +401,14 @@
case DW_FORM_addrx3:
case DW_FORM_addrx4:
case DW_FORM_GNU_addr_index: {
+ if (U == nullptr) {
+ OS << "<invalid dwarf unit>";
+ break;
+ }
Optional<object::SectionedAddress> A = U->getAddrOffsetSectionItem(UValue);
if (!A || DumpOpts.Verbose)
AddrOS << format("indexed (%8.8x) address = ", (uint32_t)UValue);
- if (U == nullptr)
- OS << "<invalid dwarf unit>";
- else if (A)
+ if (A)
dumpSectionedAddress(AddrOS, DumpOpts, *A);
else
OS << "<no .debug_addr section>";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62118.200198.patch
Type: text/x-patch
Size: 780 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190520/f9877487/attachment.bin>
More information about the llvm-commits
mailing list