This is an archive of the discontinued LLVM Phabricator instance.

DWARFAcceleratorTable: Add an iterator-based api for accessing names in the index
ClosedPublic

Authored by labath on May 31 2018, 7:41 AM.

Details

Summary

Back when we were introducing the DWARF v5 name index, there was a
short discussion whether we shouldn't have a nicer api for iterating
over the index. At that time, I did not find it necessary since the
iteration over names was done only from within the index itself (and I
figured the internal implementation can deal with a slightly rough
interface).

However, now I ran into a use for this kind of API in LLDB (for finding
all names matching a regular expression), so it looked like a nice
opportunity to introduce one. To make the API more useful, I've made the
NameTableEntry class a bit smarter: it now stores the string section
reference (so it can return its name) and its position in the name index
(mainly useful for dumping/logging).

I also convert the internal users to use the new API, which should also
give test coverage for the added code.

Diff Detail

Repository
rL LLVM

Event Timeline

labath created this revision.May 31 2018, 7:41 AM
JDevlieghere accepted this revision.May 31 2018, 8:26 AM

Look fine to me

include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
376 ↗(On Diff #149293)

Have you considered wrapping this in a StringRef?

535 ↗(On Diff #149293)

CurrentName being an int feels weird, but it's consistent with the other iterator and I don't have a better suggestion.

This revision is now accepted and ready to land.May 31 2018, 8:26 AM
labath added inline comments.Jun 1 2018, 3:28 AM
include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
376 ↗(On Diff #149293)

Yes. My reasoning for not doing that is that it allows you to distinguish between the "string not found" and "empty string" cases. Though I could be easily convinced to add a StringRef version for users which don't care about the distinction.

This revision was automatically updated to reflect the committed changes.