[clang-tools-extra] r365955 - [clangd] Fix off-by-one in CodeComplete and assertion in Dex
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 12 13:35:41 PDT 2019
Author: sammccall
Date: Fri Jul 12 13:35:41 2019
New Revision: 365955
URL: http://llvm.org/viewvc/llvm-project?rev=365955&view=rev
Log:
[clangd] Fix off-by-one in CodeComplete and assertion in Dex
Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=365955&r1=365954&r2=365955&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Fri Jul 12 13:35:41 2019
@@ -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));
Modified: clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/Dex.cpp?rev=365955&r1=365954&r2=365955&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/dex/Dex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/dex/Dex.cpp Fri Jul 12 13:35:41 2019
@@ -316,9 +316,9 @@ std::vector<std::string> generateProximi
// 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;
}
More information about the cfe-commits
mailing list