[PATCH] D146377: [clangd] Remove reundant use of getSpellingLoc()
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 19 01:04:54 PDT 2023
nridge created this revision.
nridge added reviewers: hokein, kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
nridge requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
getFileLoc() is guaranteed to return a file loc, and getSpellingLoc()
on a file loc is a no-op.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D146377
Files:
clang-tools-extra/clangd/FindSymbols.cpp
clang-tools-extra/clangd/XRefs.cpp
Index: clang-tools-extra/clangd/XRefs.cpp
===================================================================
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1611,8 +1611,8 @@
ASTContext &Ctx = ND.getASTContext();
auto &SM = Ctx.getSourceManager();
SourceLocation NameLoc = nameLocation(ND, Ctx.getSourceManager());
- SourceLocation BeginLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getBeginLoc()));
- SourceLocation EndLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getEndLoc()));
+ SourceLocation BeginLoc = SM.getFileLoc(ND.getBeginLoc());
+ SourceLocation EndLoc = SM.getFileLoc(ND.getEndLoc());
const auto DeclRange =
toHalfOpenFileRange(SM, Ctx.getLangOpts(), {BeginLoc, EndLoc});
if (!DeclRange)
Index: clang-tools-extra/clangd/FindSymbols.cpp
===================================================================
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -223,8 +223,8 @@
std::optional<DocumentSymbol> declToSym(ASTContext &Ctx, const NamedDecl &ND) {
auto &SM = Ctx.getSourceManager();
- SourceLocation BeginLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getBeginLoc()));
- SourceLocation EndLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getEndLoc()));
+ SourceLocation BeginLoc = SM.getFileLoc(ND.getBeginLoc());
+ SourceLocation EndLoc = SM.getFileLoc(ND.getEndLoc());
const auto SymbolRange =
toHalfOpenFileRange(SM, Ctx.getLangOpts(), {BeginLoc, EndLoc});
if (!SymbolRange)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146377.506356.patch
Type: text/x-patch
Size: 1498 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230319/61a8ef58/attachment.bin>
More information about the cfe-commits
mailing list