Skip to content

Commit bf94062

Browse files
[DWARF] hoist nullptr checks. NFC
Summary: 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. Reviewers: JDevlieghere, probinson Reviewed By: JDevlieghere Subscribers: RKSimon, hiraditya, llvm-commits, srhines Tags: #llvm Differential Revision: https://reviews.llvm.org/D62118 llvm-svn: 361176
1 parent b93f8ae commit bf94062

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,14 @@ void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
401401
case DW_FORM_addrx3:
402402
case DW_FORM_addrx4:
403403
case DW_FORM_GNU_addr_index: {
404+
if (U == nullptr) {
405+
OS << "<invalid dwarf unit>";
406+
break;
407+
}
404408
Optional<object::SectionedAddress> A = U->getAddrOffsetSectionItem(UValue);
405409
if (!A || DumpOpts.Verbose)
406410
AddrOS << format("indexed (%8.8x) address = ", (uint32_t)UValue);
407-
if (U == nullptr)
408-
OS << "<invalid dwarf unit>";
409-
else if (A)
411+
if (A)
410412
dumpSectionedAddress(AddrOS, DumpOpts, *A);
411413
else
412414
OS << "<no .debug_addr section>";

0 commit comments

Comments
 (0)