This is an archive of the discontinued LLVM Phabricator instance.

[clangd] NFC: Add using directives to avoid spelling out llvm::sys::path
ClosedPublic

Authored by kbobyrev on Oct 23 2020, 2:20 AM.

Details

Summary

llvm::sys::path is used a lot in the remote index marshalling code. We can save space by avoiding spelling it out explicitly for most functions and times.

Diff Detail

Event Timeline

kbobyrev created this revision.Oct 23 2020, 2:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 23 2020, 2:20 AM
kbobyrev requested review of this revision.Oct 23 2020, 2:20 AM
ArcsinX added inline comments.Oct 23 2020, 2:54 AM
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
61–62

llvm::sys::path::is_absolute(RemoteIndexRoot) => is_absolute(RemoteIndexRoot) ?

68–69

llvm::sys::path::is_absolute(LocalIndexRoot) => is_absolute(LocalIndexRoot) ?

318

llvm::sys::path::convert_to_slash(RelativePath) => convert_to_slash(RelativePath) ?

The ones you proposed would not work without using llvm::sys::path::* which I avoid :( They have to have an argument from llvm::sys::path:: in order for the lookup to be performed correctly.

The ones you proposed would not work without using llvm::sys::path::* which I avoid :( They have to have an argument from llvm::sys::path:: in order for the lookup to be performed correctly.

Ah, sorry, got it.

kbobyrev marked 3 inline comments as done.Oct 23 2020, 3:16 AM

I am not really keen about trusting ADL for these, as it makes the code less explicit for reader, especially as it is not something we commonly depend on clangd so readers/reviewers would not be expecting that. So I believe we should not stray away from the general project style in here.

Though I am a fan of not spelling llvm::sys::path bazillion times. What about having either a using namepsace for it or, using declarations for the individual symbols we are using (e.g. Style, covnert_to_slash and is_absolute)? This would also help with not spelling qualifiers over and over again in the argument names.

kbobyrev updated this revision to Diff 300222.Oct 23 2020, 4:21 AM

Add using directives for llvm::sys::path functions used more than once.

kadircet accepted this revision.Oct 23 2020, 5:19 AM
kadircet added inline comments.
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
31

nit: I would move those into clang::clangd::remote (i.e. between namespace remote { and namespace {.

This revision is now accepted and ready to land.Oct 23 2020, 5:19 AM
kbobyrev updated this revision to Diff 300249.Oct 23 2020, 5:29 AM
kbobyrev marked an inline comment as done.

Resolve the comment

kbobyrev retitled this revision from [clangd] NFC: Rely on ADL in llvm::sys::path calls in marshalling to [clangd] NFC: Add using directives to avoid spelling out llvm::sys::path.Oct 23 2020, 5:37 AM
kbobyrev edited the summary of this revision. (Show Details)
This revision was landed with ongoing or failed builds.Oct 23 2020, 5:38 AM
This revision was automatically updated to reflect the committed changes.