This is an archive of the discontinued LLVM Phabricator instance.

DebugInfo: Stop modifying Operation::Error inside of verify()
ClosedPublic

Authored by dexonsmith on Nov 15 2021, 5:37 PM.

Details

Summary

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.

This is motivated by a follow-up patch, which will make
DWARFExpression::iterator iterate over const Operation.

Diff Detail

Event Timeline

dexonsmith created this revision.Nov 15 2021, 5:37 PM
dexonsmith requested review of this revision.Nov 15 2021, 5:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 15 2021, 5:37 PM

Oh, a couple of comments on alternatives:

  • I considered moving the mutable keyword from iterator::Operation to Operation::Error, just limiting its scope. But since the change is completely ignored and it's reasonable to have a const-qualified verify() function this seems simpler.
  • Another approach would be to make Operation::verify() a static local function private to DWARFExpression.cpp. It accesses private fields, but it'd be easy enough to rewrite it to use accessors.

Thank you! This and the follow-up https://reviews.llvm.org/D113958 look reasonable to me.
Letting the people more familiar with the DebugInfo parts of the codebase have a chance to review.

dblaikie accepted this revision.Nov 16 2021, 9:14 AM

Sounds good!

This revision is now accepted and ready to land.Nov 16 2021, 9:14 AM