This is an archive of the discontinued LLVM Phabricator instance.

[clangd] SelectionTree should prefer lexical declcontext
ClosedPublic

Authored by kadircet on Oct 28 2021, 5:58 AM.

Details

Summary

This is important especially for code that tries to traverse scopes as
written in code, which is the contract SelectionTree tries to satisfy.

Related https://github.com/clangd/clangd/issues/900.

Diff Detail

Event Timeline

kadircet created this revision.Oct 28 2021, 5:58 AM
kadircet requested review of this revision.Oct 28 2021, 5:58 AM
sammccall accepted this revision.Oct 28 2021, 6:59 AM
sammccall added inline comments.
clang-tools-extra/clangd/Selection.cpp
893

Maybe insert the word "lexical" into the doc comment for this function

clang-tools-extra/clangd/unittests/SelectionTests.cpp
742

Nit: call the case DeclContextIsLexical to make the point clearer?

751

I'd probably use makeSelectionTree(Test.code(), AST) for brevity and only test the #2 case, but up to you

This revision is now accepted and ready to land.Oct 28 2021, 6:59 AM
kadircet marked 3 inline comments as done.Oct 28 2021, 8:40 AM
kadircet added inline comments.
clang-tools-extra/clangd/unittests/SelectionTests.cpp
751

i'd rather keep both, just to make sure we are not accidentally regressing the other case.

This revision was automatically updated to reflect the committed changes.
kadircet marked an inline comment as done.