This is an archive of the discontinued LLVM Phabricator instance.

Move DWARFUnitSection from inheriting SmallVector to holding an instance.
AbandonedPublic

Authored by friss on Sep 15 2014, 5:31 AM.

Details

Summary

This introduces all the proxy methods that make DWARFUnitSection behave
like the vector it was before. It has no functional change, but it moves
away from the multiple inheritance that everybody dislikes.

Follow-up patches will progressively move the interface away from the
vector interface to something that is closer to the intended semantics
of the data structure.

Diff Detail

Event Timeline

friss updated this revision to Diff 13703.Sep 15 2014, 5:31 AM
friss retitled this revision from to Move DWARFUnitSection from inheriting SmallVector to holding an instance..
friss added reviewers: dblaikie, samsonov, echristo, aprantl.
friss updated this object.
friss added a subscriber: Unknown Object (MLST).
samsonov edited edge metadata.Sep 15 2014, 10:42 AM

Are you sure you need all these methods? For instance, can you introduce

iterator_range units() {
  return iterator_range(Units.begin(), Units.end());
}

and use this method in DWARFContext methods getNumCompileUnits(), getNumTypeUnits(), etc. In this case there will be no need for exposing begin()/end() methods directly. Same for operator[] - IMO it makes more sense to have a method "UnitType* getUnitAtIndex()" than "std::unique_ptr<UnitType>& operator[]", and make caller call get().

As it is explained in the commit log, this patch only moves from inheritance to composition, and the goal is to design a new interface better suited to DWARFUnitSection. This step is arguably what I should have posted first, the inheritance step wasn't really necessary. Now I could modify a lot more things in one go, but I usually get asked to split functional steps more not less :-)

friss abandoned this revision.Sep 16 2014, 8:20 AM

Abandoned in favour of D5369