This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Remove TokenBuffer usage in TypeHierarchy
ClosedPublic

Authored by ArcsinX on Jul 20 2020, 2:21 AM.

Details

Summary

This patch mostly reverts D74850.
We could not use AST.getTokens() here, because it does not have tokens from the preamble.

Diff Detail

Event Timeline

ArcsinX created this revision.Jul 20 2020, 2:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2020, 2:21 AM

ah embarrassing :/ thanks for catching this! It should've been obvious from the fact that there's a "FilePath" and a "TUPath" going on ..

clang-tools-extra/clangd/XRefs.cpp
1191

let's rename it to DeclRange rather than NameRange.

clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
550

you can keep using the TestTU. just provide the header via AdditionalFiles and TU.build should first build a preamble and use it. That way you can get rid of additions to the SyncAPI and usage of ClangdServer in here.

ArcsinX updated this revision to Diff 279168.Jul 20 2020, 3:27 AM

NameRange => DeclRange
Simplify TypeHierarchy.Preamble test.

ArcsinX marked 2 inline comments as done.Jul 20 2020, 3:28 AM
ArcsinX added inline comments.
clang-tools-extra/clangd/XRefs.cpp
1191

Renamed.

clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
550

Thanks, done.

kadircet accepted this revision.Jul 20 2020, 3:37 AM

LGTM, just some improvements to the testing. also please let me know if I should land this for you.

clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
533

this doesn't need to be an Annotation and sorry for missing it in the first pass but since this only has a single header, you can actually do something like:

TestTU TU = TestTU::withCode(SourceAnnotations.code());
TU.HeaderCode = "struct Parent { int a; }";

and also drop the include directive in SourceAnnotations as TU.HeaderCode is implicitly included.

548

could you also make sure selection range is correct at least for Parent (as main file ranges are tested elsewhere already), so that we don't regress it in the future.

This revision is now accepted and ready to land.Jul 20 2020, 3:37 AM
ArcsinX updated this revision to Diff 279174.Jul 20 2020, 3:58 AM

Check source range for Parent

ArcsinX marked 2 inline comments as done.Jul 20 2020, 4:00 AM
ArcsinX added inline comments.
clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
533

Seems now I need it to check selection range.

548

Added Parent selection range check.

also please let me know if I should land this for you.

Yes, could you please land this for me? I do not have commit access.
Aleksandr Platonov <platonov.aleksandr@huawei.com>

kadircet added inline comments.Jul 20 2020, 4:20 AM
clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
533

right, you need annotations for the range, but you still can get away with just setting TU.HeaderCode instead of populating AdditionalFiles and including the header in the source. but not that important.

ArcsinX updated this revision to Diff 279180.Jul 20 2020, 4:26 AM

AdditionalFiles["header_in_preamble.h"] => HeaderCode

ArcsinX marked an inline comment as done.Jul 20 2020, 5:03 AM
ArcsinX added inline comments.
clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
533

Thanks. fixed

This revision was automatically updated to reflect the committed changes.