This is an archive of the discontinued LLVM Phabricator instance.

[clangd-remote] Replace YAML serialization with proper Protobuf messages
ClosedPublic

Authored by kbobyrev on May 13 2020, 7:19 AM.

Details

Summary

YAML serialization was used in the Proof of Concept for simplicity.
This patch replaces implements Protobuf (de) serialization of almost all
types that need to be transferred over the protocol.

Diff Detail

Event Timeline

kbobyrev created this revision.May 13 2020, 7:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2020, 7:19 AM

It's tedious, but we really should have tests for this now.

clang-tools-extra/clangd/index/remote/Index.proto
68–113

somewhere in this file there should be a hint that semantics of all fields matches those in the structs in Index/

70

sigh, I wish we'd managed to get rid of this struct by now :-(
Maybe we can still do it before the 11 release

kbobyrev updated this revision to Diff 264190.May 15 2020, 2:23 AM
kbobyrev marked an inline comment as done.

Add tests for Protobuf (de)serialization.

kbobyrev updated this revision to Diff 264205.May 15 2020, 4:54 AM

Simplify test setup and rebase on top of master.

sammccall added inline comments.May 15 2020, 5:31 AM
clang-tools-extra/clangd/unittests/TestTU.h
1

This header provides a widely used abstraction and has a clear scope, please don't dump things here.

90

I don't think the API of this class has been thought through well enough to share.

Why do you need it? Can't you just use TestTU::headerSymbols() (if you need Refs and such as well, just copy its implementation - it's 2 lines long)

kbobyrev updated this revision to Diff 264553.May 18 2020, 12:59 AM

Don't complicate SymbolCollectorTest, use TestTU.

kbobyrev marked 2 inline comments as done.May 18 2020, 1:00 AM
kbobyrev updated this revision to Diff 264554.May 18 2020, 1:01 AM

Inline HeaderCode and MainCode.

kbobyrev updated this revision to Diff 264633.May 18 2020, 8:22 AM

Rebase on top of master.

Just more stuff about simplifying the tests :-(

This is really just about converting between a struct and a proto, if we have to add indexing-related fixtures to shared libraries something seems to have gone a bit off the rails.
In the worst case we could just create a few symbols with fields populated by hand, it's probably easier to see what parts of the code are being covered by the test...

clang-tools-extra/clangd/unittests/TestTU.cpp
129

can you structure the tests to avoid doing this (untested) merge?

Why do we need the example symbols split over multiple files at all?
If we need such symbols can we just construct them manually instead?

clang-tools-extra/clangd/unittests/TestTU.h
73

please don't add these for a single test, we can do this inline in the test unless it becomes a common thing

clang-tools-extra/clangd/unittests/remote/CMakeLists.txt
2 ↗(On Diff #264633)

Can we conditionally include these tests into the main ClangdTests, instead of setting up another set of targets?

18 ↗(On Diff #264633)

I don't think including the same source files in multiple targets is a great path to go down.

clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
21

Using inheritance to define test *cases* is a bit of a trap, and not particularly idiomatic.
Can we just write a function indexSampleData() that returns a SlabTuple, and call it from the tests?

63

similarly i'd consider just inlining the stringsaver/arena into the tests, seems easier to read

67

if you want to define the symbols indirectly like this, you probably also want to assert that there are more than 5 or something, to guard against the test fixture being broken

kbobyrev updated this revision to Diff 264873.May 19 2020, 5:59 AM
kbobyrev marked 6 inline comments as done.

Address some comments.

clang-tools-extra/clangd/unittests/remote/CMakeLists.txt
2 ↗(On Diff #264633)

I can do that, although I saw that XPC has their own set of tests if I am correct, so I thought this should be OK.

Conditionally including tests into the main ClangdTests is not super easy because... CMake stuff. But I. can look into that.

kbobyrev updated this revision to Diff 264874.May 19 2020, 6:11 AM
kbobyrev marked 3 inline comments as done.

Move remote tests into all Clangd tests

clang-tools-extra/clangd/unittests/remote/CMakeLists.txt
2 ↗(On Diff #264633)

Actually, nevermind, it looks pretty straightforward.

kbobyrev updated this revision to Diff 264877.May 19 2020, 6:15 AM

Move a comment to the line it corresponds to.

sammccall accepted this revision.May 19 2020, 7:12 AM

Thanks! Sorry about the hassle with the tests.

clang-tools-extra/clangd/unittests/remote/CMakeLists.txt
2 ↗(On Diff #264633)

Yeah we have to pay the cost of *some* cmake stuff either way, this looks like a bit less work.

XPC... yeah, I wish there was less CMake stuff going on there. But in practice, the majority of maintenance in the two dirs has been disjoint sets of people, so it has its advantages to...

This revision is now accepted and ready to land.May 19 2020, 7:12 AM

Thanks! Sorry about the hassle with the tests.

No worries, I think it looks cleaner and simpler which is important.

Thanks for the review!

This revision was automatically updated to reflect the committed changes.