[PATCH] D90016: [clangd] NFC: Rely on ADL in llvm::sys::path calls in marshalling
Kirill Bobyrev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 23 02:20:22 PDT 2020
kbobyrev created this revision.
kbobyrev added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
kbobyrev requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Spelling out `llvm::sys::path::` twice does not add much value and can
be omitted thanks to ADL.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D90016
Files:
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
Index: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
===================================================================
--- clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -50,12 +50,11 @@
Marshaller::Marshaller(llvm::StringRef RemoteIndexRoot,
llvm::StringRef LocalIndexRoot)
: Strings(Arena) {
- llvm::StringRef PosixSeparator =
- llvm::sys::path::get_separator(llvm::sys::path::Style::posix);
+ llvm::StringRef PosixSeparator = get_separator(llvm::sys::path::Style::posix);
if (!RemoteIndexRoot.empty()) {
assert(llvm::sys::path::is_absolute(RemoteIndexRoot));
- this->RemoteIndexRoot = llvm::sys::path::convert_to_slash(
- RemoteIndexRoot, llvm::sys::path::Style::windows);
+ this->RemoteIndexRoot =
+ convert_to_slash(RemoteIndexRoot, llvm::sys::path::Style::windows);
llvm::StringRef Path(this->RemoteIndexRoot);
if (!is_separator(this->RemoteIndexRoot.back(),
llvm::sys::path::Style::posix))
@@ -63,8 +62,8 @@
}
if (!LocalIndexRoot.empty()) {
assert(llvm::sys::path::is_absolute(LocalIndexRoot));
- this->LocalIndexRoot = llvm::sys::path::convert_to_slash(
- LocalIndexRoot, llvm::sys::path::Style::windows);
+ this->LocalIndexRoot =
+ convert_to_slash(LocalIndexRoot, llvm::sys::path::Style::windows);
llvm::StringRef Path(this->LocalIndexRoot);
if (!is_separator(this->LocalIndexRoot.back(),
llvm::sys::path::Style::posix))
@@ -218,8 +217,8 @@
for (const auto &Path : From.ProximityPaths) {
llvm::SmallString<256> RelativePath = llvm::StringRef(Path);
if (llvm::sys::path::replace_path_prefix(RelativePath, LocalIndexRoot, ""))
- RPCRequest.add_proximity_paths(llvm::sys::path::convert_to_slash(
- RelativePath, llvm::sys::path::Style::windows));
+ RPCRequest.add_proximity_paths(
+ convert_to_slash(RelativePath, llvm::sys::path::Style::windows));
}
for (const auto &Type : From.PreferredTypes)
RPCRequest.add_preferred_types(Type);
@@ -311,7 +310,7 @@
assert(RelativePath == llvm::sys::path::convert_to_slash(RelativePath));
if (RelativePath.empty())
return error("Empty relative path.");
- if (llvm::sys::path::is_absolute(RelativePath, llvm::sys::path::Style::posix))
+ if (is_absolute(RelativePath, llvm::sys::path::Style::posix))
return error("RelativePath '{0}' is absolute.", RelativePath);
llvm::SmallString<256> FullPath = llvm::StringRef(LocalIndexRoot);
llvm::sys::path::append(FullPath, RelativePath);
@@ -329,14 +328,12 @@
llvm::SmallString<256> Result = ParsedURI->body();
llvm::StringRef Path(Result);
// Check for Windows paths (URI=file:///X:/path => Body=/X:/path)
- if (llvm::sys::path::is_absolute(Path.substr(1),
- llvm::sys::path::Style::windows))
+ if (is_absolute(Path.substr(1), llvm::sys::path::Style::windows))
Result = Path.drop_front();
if (!llvm::sys::path::replace_path_prefix(Result, RemoteIndexRoot, ""))
return error("File path '{0}' doesn't start with '{1}'.", Result.str(),
RemoteIndexRoot);
- assert(Result == llvm::sys::path::convert_to_slash(
- Result, llvm::sys::path::Style::windows));
+ assert(Result == convert_to_slash(Result, llvm::sys::path::Style::windows));
return std::string(Result);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90016.300198.patch
Type: text/x-patch
Size: 3502 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201023/4fec3de2/attachment-0001.bin>
More information about the cfe-commits
mailing list