This is an archive of the discontinued LLVM Phabricator instance.

Move DWARFUnitSection from the vector API to something more semantically accurate.
Needs ReviewPublic

Authored by friss on Sep 16 2014, 8:19 AM.

Details

Summary

This just introduces a bunch of wrapper methods that make more sense than push_back or operator[]. NFC.

Diff Detail

Event Timeline

friss updated this revision to Diff 13752.Sep 16 2014, 8:19 AM
friss retitled this revision from to Move DWARFUnitSection from the vector API to something more semantically accurate..
friss added reviewers: samsonov, dblaikie, aprantl, echristo.
friss updated this object.
friss added a subscriber: Unknown Object (MLST).
dblaikie edited edge metadata.Sep 16 2014, 2:38 PM

Alexey - I'm assuming this wasn't quite what you had in mind?

I'm not sure of the merits of having a non-container like API if we're exposing this as a range of things, etc.

But we could reduce code duplication by rolling some operations into this type (things like parsing and dumping - which we unnecessarily duplicate for DWO and non-DWO cases) then we wouldn't have to expose such a broad interface (eg: we could probably avoid exposing addUnit).

Personally I'd rather the thing be a range (by having begin/end), if that's what it is, rather than having a "units()" range accessor, but I don't hold strongly to the notion.

"getAddressByteSize" could probably be a first-class operation on a DWARFUnitSection so clients don't have to do the "is !empty then get the address byte size of the first unit"

But this is more Alexey's code than it is mine, in any case.

lib/DebugInfo/DWARFUnit.h
77

Why the null pointer check?

I'd probably just have this return by reference, personally.

80

Pass unique_ptrs (& other movable types) by value when passing ownership.

The Units method was suggested by Alexey I have no strong feeling either way. With this patch applied, the inheritance of SmallVector isn't necessary anymore, I didn't fold the move from inheritance to composition in this patch, but it could be done.

The next step for me is to factor the the parsing code into this class. There is an intermediate step though: the actual code is semantically wrong when it comes to type units. Type units might come from different sections, but we put them all in the same DWARFUnitSection object. Once this is fixed, we can move parsing into DWARFUnitSection and remove at least the addUnit method.

Once this is done a bunch of accessors from the context can go away also.