This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Add a helper for extracting nonlocal decls in a FunctionDecl
ClosedPublic

Authored by kadircet on Sep 18 2019, 11:50 PM.

Details

Summary

To be used by define-inline code action to determine whether the
function/method body will still be valid in another context.

Traverses clang-ast to find all decl nodes under the function decl and stores
the non-local ones.

Diff Detail

Repository
rL LLVM

Event Timeline

kadircet created this revision.Sep 18 2019, 11:50 PM

I think the helper is only used by the defineInline tweak? not sure XRef.h is the best place for putting these helpers.
Will we have more helpers in the future? If so, we may put them all in a new file.

clang-tools-extra/clangd/unittests/XRefsTests.cpp
2258 ↗(On Diff #220817)

nit: use SourceLocation SL = cantfail( sourceLocationInMainFile(AST.getSourceManager(), File.point()); .

kadircet updated this revision to Diff 221272.Sep 23 2019, 2:30 AM
kadircet marked an inline comment as done.
  • Address comments

As discussed offline, we decided to change the file once we have more helpers.

hokein accepted this revision.Sep 23 2019, 5:04 AM

I think in the future (after https://reviews.llvm.org/D67826), we can use the findExplicitReferences to implement it.

This revision is now accepted and ready to land.Sep 23 2019, 5:04 AM
kadircet updated this revision to Diff 221313.Sep 23 2019, 5:55 AM
  • Use findExplicitReferences instead of libIndex.
kadircet updated this revision to Diff 221772.Sep 25 2019, 7:55 AM
  • Use Decl overload of findExplicitReferences
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 26 2019, 12:27 AM