[clang-tools-extra] [clangd] Navigate go-to-definition through forwarding wrappers to the constructor (PR #199480)

Yuli Fiterman via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 9 09:08:55 PDT 2026


================
@@ -419,6 +419,44 @@ locateASTReferent(SourceLocation CurLoc, const syntax::Token *TouchedIdentifier,
           AST.getASTContext(), nameLocation(*Def, SM), MainFilePath);
   };
 
+  // Special case: if the cursor lands directly on a call expression (i.e.
+  // its enclosing SelectionTree node is the CallExpr itself, not the callee
+  // identifier or an argument), and the call invokes a forwarding wrapper
+  // such as `std::make_unique<T>(...)`, navigate to the constructor of `T`
+  // that the wrapper ultimately calls. This mirrors the existing
+  // constructor-call behaviour: `Abc^()` jumps to the constructor while
+  // `A^bc()` jumps to the type. The hook does not fire when the cursor is
+  // on the wrapper's identifier; that path continues to navigate to the
+  // wrapper itself via the candidate loop below.
+  {
+    unsigned Offset = SM.getDecomposedSpellingLoc(CurLoc).second;
----------------
fitermay wrote:

Yes, one of the first things I looked for, after you brought up the `Abc^()` behavior, is where it is implemented. It happens to fall out automatically from the nesting of the AST nodes.

https://github.com/llvm/llvm-project/pull/199480


More information about the cfe-commits mailing list