<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 11, 2014 at 2:03 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Thu, Sep 11, 2014 at 1:21 PM, Alexey Samsonov <span dir="ltr"><<a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">================<br>
Comment at: lib/DebugInfo/DWARFUnit.h:202<br>
@@ +201,3 @@<br>
+template<class UnitType><br>
+class DWARFUnitImpl : public DWARFUnit {<br>
+protected:<br>
----------------<br>
See my suggestion in D5264 review thread. You can introduce a new template class DWARFUnitSection<T>,<br>
which would be a wrapper around SmallVector<std::unique_ptr<T>>, and have<br>
DWARFCompileUnit hold a reference to DWARFUnitSection<DWARFCompileUnit>,<br>
and DWARFTypeUnit hold a reference to DWARFUnitSection<DWARFTypeUnit>.<br>
<br>
Then instead of introducing Unit::getUnitForOffset(), you can have an (abstract) DWARFUnit::getSection(),</blockquote><div><br></div></span><div>Problem here is that getSection would return a different type depending on the DWARFUnit (because it could be a DWARFUnitSection<DWARFCompileUnit> or a DWARFUnitSection<DWARFTypeUnit> - so you'd probably still end up with a CRTP-esque base implementing getUnitForOffset and containing the DWARFUnitSection<DerivedUnitType>&).</div></div></div></div></blockquote><div><br></div><div>Yeah, probably. I'm not opposed to CRTP, I just don't think that unit should have direct access to other units from the same section, and "a collection of units of the same type from the same section" seems like a reasonable abstraction.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> and<br>
DWARFUnitSection::getUnitForOffset().<br>
<br>
<a href="http://reviews.llvm.org/D5310" target="_blank">http://reviews.llvm.org/D5310</a><br>
<br>
<br>
</blockquote></span></div><br></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Alexey Samsonov<br><a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a></div>
</div></div>