This is an archive of the discontinued LLVM Phabricator instance.

Generalize FindTypes with CompilerContext to support fuzzy lookup
ClosedPublic

Authored by aprantl on Aug 20 2019, 4:43 PM.

Details

Summary

This patch generalizes the FindTypes with CompilerContext interface to support looking up a type of unknown kind by name, as well as looking up a type inside an unspecified submodule. These features are motivated by the Swift branch, but are fully tested via unit tests and lldb-test on llvm.org.
Specifically, this patch adds an AnyModule and an AnyType CompilerContext kind.

Diff Detail

Event Timeline

aprantl created this revision.Aug 20 2019, 4:43 PM

I don't have any context or opinion on the high level functionality, but can we please not use inheritance in this way? Though I have done similar things in the past, I am not really proud of them. It looks like the matching code can be just as easily be implemented as a free function...

lldb/source/Symbol/Type.cpp
54–60

it looks like you should use context_chain.end() instead of end().
Also, all of this probably boils down to it = std::find_if(it, context_chain.end(), [](??? cc) { return cc.kind != Module; });

aprantl updated this revision to Diff 216425.Aug 21 2019, 10:04 AM

Address feedback from Pavel.

JDevlieghere accepted this revision.Aug 21 2019, 10:31 AM

LGTM

lldb/include/lldb/Symbol/Type.h
42

nit: reflow

This revision is now accepted and ready to land.Aug 21 2019, 10:31 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 21 2019, 11:06 AM