[clang-tools-extra] 836f937 - [clangd] Add more error details on the remote index server side
Kirill Bobyrev via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 9 13:13:14 PDT 2020
Author: Kirill Bobyrev
Date: 2020-08-09T22:12:56+02:00
New Revision: 836f937a1f1150d81c0bf2b6a14872146da5b89e
URL: https://github.com/llvm/llvm-project/commit/836f937a1f1150d81c0bf2b6a14872146da5b89e
DIFF: https://github.com/llvm/llvm-project/commit/836f937a1f1150d81c0bf2b6a14872146da5b89e.diff
LOG: [clangd] Add more error details on the remote index server side
Reviewed By: kadircet
Differential Revision: https://reviews.llvm.org/D85502
Added:
Modified:
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
index bac5b7e6e958..dbda5bf24aa3 100644
--- a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -23,6 +23,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
+#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/StringSaver.h"
@@ -303,7 +304,8 @@ Marshaller::relativePathToURI(llvm::StringRef RelativePath) {
if (RelativePath.empty())
return makeStringError("Empty relative path.");
if (llvm::sys::path::is_absolute(RelativePath))
- return makeStringError("RelativePath is absolute.");
+ return makeStringError(
+ llvm::formatv("RelativePath '{0}' is absolute.", RelativePath).str());
llvm::SmallString<256> FullPath = llvm::StringRef(*LocalIndexRoot);
llvm::sys::path::append(FullPath, RelativePath);
auto Result = URI::createFile(FullPath);
@@ -316,10 +318,16 @@ llvm::Expected<std::string> Marshaller::uriToRelativePath(llvm::StringRef URI) {
if (!ParsedURI)
return ParsedURI.takeError();
if (ParsedURI->scheme() != "file")
- return makeStringError("Can not use URI schemes other than file.");
+ return makeStringError(
+ llvm::formatv("Can not use URI schemes other than file, given: '{0}'.",
+ URI)
+ .str());
llvm::SmallString<256> Result = ParsedURI->body();
if (!llvm::sys::path::replace_path_prefix(Result, *RemoteIndexRoot, ""))
- return makeStringError("File path doesn't start with RemoteIndexRoot.");
+ return makeStringError(
+ llvm::formatv("File path '{0}' doesn't start with '{1}'.", Result.str(),
+ *RemoteIndexRoot)
+ .str());
// Make sure the result has UNIX slashes.
return llvm::sys::path::convert_to_slash(Result,
llvm::sys::path::Style::posix);
More information about the cfe-commits
mailing list