This is an archive of the discontinued LLVM Phabricator instance.

Support: Make VarStreamArrayIterator::operator*() const-qualified
AbandonedPublic

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

Details

Summary

VarStreamArrayIterator returns a reference to a just-computed internal
value; since it's an iterator over ValueType, change operator*() to
always return ValueType&.

This patch is conservative in case it's useful to std::move() out an
extracted value...

But another option is to change it to iterate over const ValueType
and always return const ValueType&:

... : iterator_facade_base<..., const ValueType>

It only requires a one-line change to ExplainOutputStyle.cpp to get tests
compiling and passing:

-  DbiModuleDescriptor &Descriptor = *Prev;
+  const DbiModuleDescriptor &Descriptor = *Prev;

Based on 175d70ee5c2f03f640151488f5f33b7bd9b96f8d, perhaps that would
better match the original intent? @amccarth, @zturner, thoughts?

Diff Detail

Event Timeline

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

Since Phab didn't seem to turn 175d70ee5c2f03f640151488f5f33b7bd9b96f8d into a link, that was reviewed in https://reviews.llvm.org/D32235.

Just posted the alternative at https://reviews.llvm.org/D113797. It seems cleaner to me; basically a fix-up for 175d70ee5c2f03f640151488f5f33b7bd9b96f8d.

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

Yeah, I'd take the const ValueType option, with the one extra fix.

This revision is now accepted and ready to land.Nov 12 2021, 1:59 PM
dblaikie requested changes to this revision.Nov 12 2021, 2:00 PM

Yeah, I'd take the const ValueType option, with the one extra fix.

Oh, I see you posted that separately in D113797 so approving that one instead.

This revision now requires changes to proceed.Nov 12 2021, 2:00 PM
dexonsmith abandoned this revision.Nov 12 2021, 2:05 PM