[llvm] r361176 - [DWARF] hoist nullptr checks. NFC
Nick Desaulniers via llvm-commits
llvm-commits at lists.llvm.org
Mon May 20 09:59:00 PDT 2019
Author: nickdesaulniers
Date: Mon May 20 09:58:59 2019
New Revision: 361176
URL: http://llvm.org/viewvc/llvm-project?rev=361176&view=rev
Log:
[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
Modified:
llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp?rev=361176&r1=361175&r2=361176&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp Mon May 20 09:58:59 2019
@@ -401,12 +401,14 @@ void DWARFFormValue::dump(raw_ostream &O
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>";
More information about the llvm-commits
mailing list