This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Heuristically resolve dependent call through smart pointer type
ClosedPublic

Authored by nridge on Dec 17 2019, 8:29 PM.

Event Timeline

nridge created this revision.Dec 17 2019, 8:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 17 2019, 8:29 PM
nridge marked an inline comment as done.Dec 17 2019, 8:33 PM
nridge added inline comments.
clang-tools-extra/clangd/FindTarget.cpp
116

I don't intend for this function to be in the final patch.

Rather, I'm wondering: am I missing some obvious general way to recover the ASTContext from a Type (or a Stmt)?

If not, I think we'll need to modify targetDecl(), allTargetDecls(), findExplicitReferences() etc. to have their callers pass in an ASTContext?

nridge edited reviewers, added: ilya-biryukov, kadircet, hokein; removed: sammccall.Dec 19 2019, 1:14 PM

Shopping around to other reviewers while Sam's OOO.

sammccall accepted this revision.Jan 3 2020, 9:17 AM
sammccall added a subscriber: sammccall.

This is great! Thank you!

clang-tools-extra/clangd/FindTarget.cpp
116

Haha, I see what you mean. There isn't a general way, but I think your hack is better than changing the public API, and we can improve it a little.

By the time you actually do the lookup, you have a CXXRecordDecl you're going to look into, and decls have a pointer to the ASTContext. So instead of a DeclarationName, you could pass a function_ref<const DeclarationName&(ASTContext&)> or such into getMembersReferencedViaDependentName, and have that function lazily call the factory to get the DeclarationName to use. Still hacky, but it's an internal function, and we don't have the weird parallel codepath...

clang-tools-extra/clangd/unittests/XRefsTests.cpp
503

you can remove the FIXME

This revision is now accepted and ready to land.Jan 3 2020, 9:17 AM
nridge updated this revision to Diff 236621.Jan 7 2020, 9:51 AM

Address review comments

This revision was automatically updated to reflect the committed changes.