Skip to content

Commit a0f1f17

Browse files
committed
DebugInfo: Stop modifying Operation::Error inside of verify()
The only caller of Operation::verify() is DWARFExpression::verify(), which iterates past the (ephemeral) Operation immediately after. - Stop setting Operation::Error because the mutation will never be observed. - Change verify() to a static function to be sure all callers are updated. Differential Revision: https://reviews.llvm.org/D113957
1 parent 5ed404a commit a0f1f17

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ class DWARFExpression {
9797
bool print(raw_ostream &OS, DIDumpOptions DumpOpts,
9898
const DWARFExpression *Expr, const MCRegisterInfo *RegInfo,
9999
DWARFUnit *U, bool isEH) const;
100-
bool verify(DWARFUnit *U);
100+
101+
/// Verify \p Op. Does not affect the return of \a isError().
102+
static bool verify(const Operation &Op, DWARFUnit *U);
101103

102104
private:
103105
bool extract(DataExtractor Data, uint8_t AddressSize, uint64_t Offset,

llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,9 @@ void DWARFExpression::print(raw_ostream &OS, DIDumpOptions DumpOpts,
357357
}
358358
}
359359

360-
bool DWARFExpression::Operation::verify(DWARFUnit *U) {
361-
360+
bool DWARFExpression::Operation::verify(const Operation &Op, DWARFUnit *U) {
362361
for (unsigned Operand = 0; Operand < 2; ++Operand) {
363-
unsigned Size = Desc.Op[Operand];
362+
unsigned Size = Op.Desc.Op[Operand];
364363

365364
if (Size == Operation::SizeNA)
366365
break;
@@ -370,13 +369,11 @@ bool DWARFExpression::Operation::verify(DWARFUnit *U) {
370369
// the generic type should be done, so don't look up a base type in that
371370
// case. The same holds for DW_OP_reinterpret, which is currently not
372371
// supported.
373-
if (Opcode == DW_OP_convert && Operands[Operand] == 0)
372+
if (Op.Opcode == DW_OP_convert && Op.Operands[Operand] == 0)
374373
continue;
375-
auto Die = U->getDIEForOffset(U->getOffset() + Operands[Operand]);
376-
if (!Die || Die.getTag() != dwarf::DW_TAG_base_type) {
377-
Error = true;
374+
auto Die = U->getDIEForOffset(U->getOffset() + Op.Operands[Operand]);
375+
if (!Die || Die.getTag() != dwarf::DW_TAG_base_type)
378376
return false;
379-
}
380377
}
381378
}
382379

@@ -385,7 +382,7 @@ bool DWARFExpression::Operation::verify(DWARFUnit *U) {
385382

386383
bool DWARFExpression::verify(DWARFUnit *U) {
387384
for (auto &Op : *this)
388-
if (!Op.verify(U))
385+
if (!Operation::verify(Op, U))
389386
return false;
390387

391388
return true;

0 commit comments

Comments
 (0)