This is an archive of the discontinued LLVM Phabricator instance.

Support: Make VarStreamArrayIterator iterate over const values
ClosedPublic

Authored by dexonsmith on Nov 12 2021, 12:30 PM.

Details

Summary

VarStreamArrayIterator returns a reference to a just-computed internal
value. Change it to iterate over const ValueType to avoid allowing
clients to mutate the internal state, and to drop the
non-const-qualified operator*().

The removed operator*() was from 175d70ee5c2f03f6 to get
iterator_facade_base::operator->() working, and this fixes the root
cause instead: setting T to const ValueType causes
iterator_facade_base to infer PointerT as const ValueType*.

Ironically, this is the last blocker for removing the const-incorrect
overload of iterator_facade_base::operator->(), whose presence
triggered adding the workaround in the first place :).

This is an alternative to https://reviews.llvm.org/D113796.

Diff Detail

Event Timeline

dexonsmith requested review of this revision.Nov 12 2021, 12:30 PM
dexonsmith created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptNov 12 2021, 12:30 PM
dexonsmith edited the summary of this revision. (Show Details)Nov 12 2021, 12:34 PM
dblaikie accepted this revision.Nov 12 2021, 2:00 PM

Oh, I see, didn't realize this was posted as a separate alternative patch. Approving this direction over D113796

This revision is now accepted and ready to land.Nov 12 2021, 2:00 PM
dexonsmith edited the summary of this revision. (Show Details)

Just triggering CI after pushing 9a2b54af221717bf71040b530c4ac8043e1db23a, which added const to some range-based for loops in lld.