diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h @@ -97,7 +97,9 @@ bool print(raw_ostream &OS, DIDumpOptions DumpOpts, const DWARFExpression *Expr, const MCRegisterInfo *RegInfo, DWARFUnit *U, bool isEH) const; - bool verify(DWARFUnit *U); + + /// Verify \p Op. Does not affect the return of \a isError(). + static bool verify(const Operation &Op, DWARFUnit *U); private: bool extract(DataExtractor Data, uint8_t AddressSize, uint64_t Offset, diff --git a/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp b/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp --- a/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp @@ -357,10 +357,9 @@ } } -bool DWARFExpression::Operation::verify(DWARFUnit *U) { - +bool DWARFExpression::Operation::verify(const Operation &Op, DWARFUnit *U) { for (unsigned Operand = 0; Operand < 2; ++Operand) { - unsigned Size = Desc.Op[Operand]; + unsigned Size = Op.Desc.Op[Operand]; if (Size == Operation::SizeNA) break; @@ -370,13 +369,11 @@ // the generic type should be done, so don't look up a base type in that // case. The same holds for DW_OP_reinterpret, which is currently not // supported. - if (Opcode == DW_OP_convert && Operands[Operand] == 0) + if (Op.Opcode == DW_OP_convert && Op.Operands[Operand] == 0) continue; - auto Die = U->getDIEForOffset(U->getOffset() + Operands[Operand]); - if (!Die || Die.getTag() != dwarf::DW_TAG_base_type) { - Error = true; + auto Die = U->getDIEForOffset(U->getOffset() + Op.Operands[Operand]); + if (!Die || Die.getTag() != dwarf::DW_TAG_base_type) return false; - } } } @@ -385,7 +382,7 @@ bool DWARFExpression::verify(DWARFUnit *U) { for (auto &Op : *this) - if (!Op.verify(U)) + if (!Operation::verify(Op, U)) return false; return true;