From b63c35ebf76ca0ac89405aeadee2b98a0e91e05e Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Tue, 10 Dec 2019 10:08:39 +0100 Subject: [clangd] Simplify code using findName. NFC `findName` was always used in conjuction with `spellingLocIfSpelled`. This patch replaces patterns of the form: spellingLocIfSpelled(findName(&ND), SM) With a new helper function: nameLocation(ND, SM) And removes `spellingLocIfSpelled` and `findName`. Both are never used anywhere else and the latter is an equivalent of `Decl::getLocation` if we ever need it again. --- clang-tools-extra/clangd/SourceCode.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'clang-tools-extra/clangd/SourceCode.cpp') diff --git a/clang-tools-extra/clangd/SourceCode.cpp b/clang-tools-extra/clangd/SourceCode.cpp index b36d11d64a3..15403d215fc 100644 --- a/clang-tools-extra/clangd/SourceCode.cpp +++ b/clang-tools-extra/clangd/SourceCode.cpp @@ -224,14 +224,6 @@ bool isSpelledInSource(SourceLocation Loc, const SourceManager &SM) { return true; } -SourceLocation spellingLocIfSpelled(SourceLocation Loc, - const SourceManager &SM) { - if (!isSpelledInSource(Loc, SM)) - // Use the expansion location as spelling location is not interesting. - return SM.getExpansionRange(Loc).getBegin(); - return SM.getSpellingLoc(Loc); -} - llvm::Optional getTokenRange(const SourceManager &SM, const LangOptions &LangOpts, SourceLocation TokLoc) { -- cgit v1.2.3