[clang-tools-extra] 63725df - [clangd] Remove unused and underused helpers. NFC
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 16 16:08:42 PDT 2020
Author: Sam McCall
Date: 2020-04-17T01:08:32+02:00
New Revision: 63725df1d66973f623f41bddcaae7a235465ca81
URL: https://github.com/llvm/llvm-project/commit/63725df1d66973f623f41bddcaae7a235465ca81
DIFF: https://github.com/llvm/llvm-project/commit/63725df1d66973f623f41bddcaae7a235465ca81.diff
LOG: [clangd] Remove unused and underused helpers. NFC
Added:
Modified:
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/SourceCode.cpp
clang-tools-extra/clangd/SourceCode.h
clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp
index b544510ecea1..7dbb4f5b78a3 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -1836,7 +1836,7 @@ CompletionItem CodeCompletion::render(const CodeCompleteOptions &Opts) const {
// is mainly to help LSP clients again, so that changes do not effect each
// other.
for (const auto &FixIt : FixIts) {
- if (isRangeConsecutive(FixIt.range, LSP.textEdit->range)) {
+ if (FixIt.range.end == LSP.textEdit->range.start) {
LSP.textEdit->newText = FixIt.newText + LSP.textEdit->newText;
LSP.textEdit->range.start = FixIt.range.start;
} else {
diff --git a/clang-tools-extra/clangd/SourceCode.cpp b/clang-tools-extra/clangd/SourceCode.cpp
index a722ae9b0663..1943784bfd18 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -240,26 +240,6 @@ bool isValidFileRange(const SourceManager &Mgr, SourceRange R) {
return BeginFID.isValid() && BeginFID == EndFID && BeginOffset <= EndOffset;
}
-bool halfOpenRangeContains(const SourceManager &Mgr, SourceRange R,
- SourceLocation L) {
- assert(isValidFileRange(Mgr, R));
-
- FileID BeginFID;
- size_t BeginOffset = 0;
- std::tie(BeginFID, BeginOffset) = Mgr.getDecomposedLoc(R.getBegin());
- size_t EndOffset = Mgr.getFileOffset(R.getEnd());
-
- FileID LFid;
- size_t LOffset;
- std::tie(LFid, LOffset) = Mgr.getDecomposedLoc(L);
- return BeginFID == LFid && BeginOffset <= LOffset && LOffset < EndOffset;
-}
-
-bool halfOpenRangeTouches(const SourceManager &Mgr, SourceRange R,
- SourceLocation L) {
- return L == R.getEnd() || halfOpenRangeContains(Mgr, R, L);
-}
-
SourceLocation includeHashLoc(FileID IncludedFile, const SourceManager &SM) {
assert(SM.getLocForEndOfFile(IncludedFile).isFileID());
FileID IncludingFile;
@@ -558,11 +538,6 @@ TextEdit toTextEdit(const FixItHint &FixIt, const SourceManager &M,
return Result;
}
-bool isRangeConsecutive(const Range &Left, const Range &Right) {
- return Left.end.line == Right.start.line &&
- Left.end.character == Right.start.character;
-}
-
FileDigest digest(llvm::StringRef Content) {
uint64_t Hash{llvm::xxHash64(Content)};
FileDigest Result;
diff --git a/clang-tools-extra/clangd/SourceCode.h b/clang-tools-extra/clangd/SourceCode.h
index 8328685022de..dfa685fdd795 100644
--- a/clang-tools-extra/clangd/SourceCode.h
+++ b/clang-tools-extra/clangd/SourceCode.h
@@ -120,17 +120,6 @@ llvm::Optional<SourceRange> toHalfOpenFileRange(const SourceManager &Mgr,
/// FIXME: introduce a type for source range with this invariant.
bool isValidFileRange(const SourceManager &Mgr, SourceRange R);
-/// Returns true iff \p L is contained in \p R.
-/// EXPECTS: isValidFileRange(R) == true, L is a file location.
-bool halfOpenRangeContains(const SourceManager &Mgr, SourceRange R,
- SourceLocation L);
-
-/// Returns true iff \p L is contained in \p R or \p L is equal to the end point
-/// of \p R.
-/// EXPECTS: isValidFileRange(R) == true, L is a file location.
-bool halfOpenRangeTouches(const SourceManager &Mgr, SourceRange R,
- SourceLocation L);
-
/// Returns the source code covered by the source range.
/// EXPECTS: isValidFileRange(R) == true.
llvm::StringRef toSourceCode(const SourceManager &SM, SourceRange R);
@@ -171,8 +160,6 @@ TextEdit toTextEdit(const FixItHint &FixIt, const SourceManager &M,
llvm::Optional<std::string> getCanonicalPath(const FileEntry *F,
const SourceManager &SourceMgr);
-bool isRangeConsecutive(const Range &Left, const Range &Right);
-
/// Choose the clang-format style we should apply to a certain file.
/// This will usually use FS to look for .clang-format directories.
/// FIXME: should we be caching the .clang-format file search?
diff --git a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
index 3bc953ad2f3a..76a3a3cac267 100644
--- a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -42,13 +42,6 @@ Position position(int Line, int Character) {
return Pos;
}
-Range range(const std::pair<int, int> &P1, const std::pair<int, int> &P2) {
- Range Range;
- Range.start = position(P1.first, P1.second);
- Range.end = position(P2.first, P2.second);
- return Range;
-}
-
TEST(SourceCodeTests, lspLength) {
EXPECT_EQ(lspLength(""), 0UL);
EXPECT_EQ(lspLength("ascii"), 5UL);
@@ -273,14 +266,6 @@ TEST(SourceCodeTests, OffsetToPosition) {
EXPECT_THAT(offsetToPosition(File, 30), Pos(2, 11)) << "out of bounds";
}
-TEST(SourceCodeTests, IsRangeConsecutive) {
- EXPECT_TRUE(isRangeConsecutive(range({2, 2}, {2, 3}), range({2, 3}, {2, 4})));
- EXPECT_FALSE(
- isRangeConsecutive(range({0, 2}, {0, 3}), range({2, 3}, {2, 4})));
- EXPECT_FALSE(
- isRangeConsecutive(range({2, 2}, {2, 3}), range({2, 4}, {2, 5})));
-}
-
TEST(SourceCodeTests, SourceLocationInMainFile) {
Annotations Source(R"cpp(
^in^t ^foo
More information about the cfe-commits
mailing list