[PATCH] D75166: [clangd] Clean-up XRefs.cpp from Lexer usages and unnecessary SourceLoc transformations

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 26 08:05:00 PST 2020


kadircet added inline comments.


================
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);
 
----------------
sammccall wrote:
> apparently we don't have tests for non-identifier cases, but they did work. let's keep them working for now :) CurLoc here
also get rid of the bail-out when no tokens were touched. (which means we can now possibly trigger on `^~Foo()`.)


================
Comment at: clang-tools-extra/clangd/XRefs.cpp:503
+    auto Decls =
+        getDeclAtPosition(AST, IdentifierAtCursor->location(), Relations);
 
----------------
sammccall wrote:
> again, CurLoc?
ah thanks for catching this one especially, it also means we don't need to bail out when there are no identifiers touching cursor(it is only necessary for macros).
Updated it to do that, PTAL.


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