[PATCH] D75166: [clangd] Clean-up XRefs.cpp from Lexer usages and unnecessary SourceLoc transformations
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 26 07:45:25 PST 2020
sammccall added inline comments.
================
Comment at: clang-tools-extra/clangd/XRefs.cpp:225
+
+ const auto &TB = AST.getTokens();
// Macros are simple: there's no declaration/definition distinction.
----------------
used only once - inline?
================
Comment at: clang-tools-extra/clangd/XRefs.cpp:229
std::vector<LocatedSymbol> Result;
- if (auto M = locateMacroAt(IdentStartLoc, AST.getPreprocessor())) {
- if (auto Loc = makeLocation(AST.getASTContext(),
- M->Info->getDefinitionLoc(), *MainFilePath)) {
- LocatedSymbol Macro;
- Macro.Name = std::string(M->Name);
- Macro.PreferredDeclaration = *Loc;
- Macro.Definition = Loc;
- Result.push_back(std::move(Macro));
-
- // Don't look at the AST or index if we have a macro result.
- // (We'd just return declarations referenced from the macro's
- // expansion.)
- return Result;
+ const auto *IdentifierCoveringCursor =
+ syntax::spelledIdentifierTouching(*CurLoc, TB);
----------------
covering->touching
or just TouchedIdentifier for brevity
================
Comment at: clang-tools-extra/clangd/XRefs.cpp:432
auto References = findRefs(
- getDeclAtPosition(AST,
- SM.getMacroArgExpandedLocation(getBeginningOfIdentifier(
- Pos, SM, AST.getLangOpts())),
- Relations),
- AST);
+ getDeclAtPosition(AST, IdentifierAtCursor->location(), Relations), AST);
----------------
apparently we don't have tests for non-identifier cases, but they did work. let's keep them working for now :) CurLoc here
================
Comment at: clang-tools-extra/clangd/XRefs.cpp:503
+ auto Decls =
+ getDeclAtPosition(AST, IdentifierAtCursor->location(), Relations);
----------------
again, CurLoc?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75166/new/
https://reviews.llvm.org/D75166
More information about the cfe-commits
mailing list