From 697de1c24ef2deda5ba5ef9f45a40762c6eed5ff Mon Sep 17 00:00:00 2001 From: Sam McCall Date: Fri, 12 Jul 2019 20:35:41 +0000 Subject: [PATCH] [clangd] Fix off-by-one in CodeComplete and assertion in Dex llvm-svn: 365955 --- clang-tools-extra/clangd/CodeComplete.cpp | 4 ++-- clang-tools-extra/clangd/index/dex/Dex.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp index b2f537c..a3b4d3c 100644 --- a/clang-tools-extra/clangd/CodeComplete.cpp +++ b/clang-tools-extra/clangd/CodeComplete.cpp @@ -1391,12 +1391,12 @@ private: unsigned RangeEnd = HeuristicPrefix.Qualifier.begin() - Content.data(), RangeBegin = RangeEnd; for (size_t I = 0; I < 3 && RangeBegin > 0; ++I) { - auto PrevNL = Content.rfind('\n', RangeBegin - 1); + auto PrevNL = Content.rfind('\n', RangeBegin); if (PrevNL == StringRef::npos) { RangeBegin = 0; break; } - RangeBegin = PrevNL + 1; + RangeBegin = PrevNL; } ContextWords = collectWords(Content.slice(RangeBegin, RangeEnd)); diff --git a/clang-tools-extra/clangd/index/dex/Dex.cpp b/clang-tools-extra/clangd/index/dex/Dex.cpp index 1fb8340..853eb77 100644 --- a/clang-tools-extra/clangd/index/dex/Dex.cpp +++ b/clang-tools-extra/clangd/index/dex/Dex.cpp @@ -316,9 +316,9 @@ std::vector generateProximityURIs(llvm::StringRef URIPath) { // FIXME(kbobyrev): Parsing and encoding path to URIs is not necessary and // could be optimized. Body = llvm::sys::path::parent_path(Body, llvm::sys::path::Style::posix); - URI TokenURI(ParsedURI->scheme(), ParsedURI->authority(), Body); if (!Body.empty()) - Result.emplace_back(TokenURI.toString()); + Result.emplace_back( + URI(ParsedURI->scheme(), ParsedURI->authority(), Body).toString()); } return Result; } -- 2.7.4