Modifying DWARFFormValue to remember the DWARFUnit that it was encoded with can simplify the usage of instances of this class. Previously users would have to try and pass in the same DWARFUnit that was used to decode the form value and there was a possibility that a different DWARFUnit might be supplied to the functions that extract values (strings, CU relative references, addresses) and cause problems. This fixes this potential issue by storing the DWARFUnit inside the DWARFFormValue so that this mistake can't be made. Instances of DWARFFormValue are not stored permanently and are used as temporary values, so the increase in size of an instance of DWARFFormValue isn't a big deal. This makes decoding form values more bullet proof and is a change that will be used by future modifications.
Can you say anything about the impact this change has on the memory footprint? Do we typically keep many DWARFFormValues around?
You can doxygen'ify this by using
dwarf::Form Form; ///< Form for this value.
/// Form for this value. dwarf::Form Form;
A DataExtractor is only a StringRef + 2x uint8_t. Are we saving anything by passing it by reference?
All DWARFFormValue objects are temporaries. I mentioned in the original description that this won't affect memory because of this.
This is how it was, I didn't change it, but I can add the doxygen /// if desired.
It just avoids the copy. It passes one pointer for the reference versus 2 pointers + 2 uint8_t values.
Looks globally good. Some nits:
llvm-dsymutil has a helper that does the same computation. Please add this helper and remove dsymutil's one in a preliminary commit.
If the FormValue holds the Unit, let's stop passing it around in small helpers like this. RefValue->getUnit() can be used below.
U is just unused here AFAICS, just remove it.
I will fix the one issue Fred Riss asked for and commit.
I will fix this.
I will fix this in a commit that is coming up soon. I am going to make a DWARFDIE class that encapsulates both the DwarfUnit and the DWARFDebugInfoEntryMinimal into one unit so all raw DWARFUnit objects will no longer be passed around. So I am going to defer fixing this until that patch since the new patch will take care of this.