This is an archive of the discontinued LLVM Phabricator instance.

IR: Fix const-correctness of SwitchInst::CaseIterator and CaseHandle
ClosedPublic

Authored by dexonsmith on Nov 12 2021, 11:34 AM.

Details

Summary

Fix some confusion between the two types of const a pointer/iterator
can have. Users of a SwitchInst::CaseIterator should not (and do not!)
manually mutate the SwitchInst::CaseHandle that tracks its internal
state. Change operator*() to return const CaseHandle&, remove the
non-const-qualified operator*(), and const-qualify
CaseHandle::setValue() and CaseHandle::setSuccessor().

Diff Detail

Event Timeline

dexonsmith requested review of this revision.Nov 12 2021, 11:34 AM
dexonsmith created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptNov 12 2021, 11:34 AM
dexonsmith added a comment.EditedNov 12 2021, 11:34 AM

(This is a follow up to https://reviews.llvm.org/D113158)

Rebase on top of 8b3e1adf2b4a69b6055dc4e07b4e97817208c904, which removed the duplication of findCaseValue().

dblaikie accepted this revision.Nov 12 2021, 1:58 PM

Looks good

This revision is now accepted and ready to land.Nov 12 2021, 1:58 PM