================
@@ -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;
----------------
timon-ul wrote:

Overall this section looks very much like the (below called) function 
`getDeclAtPositionWithRelations`, basically only the lambda differs. So maybe 
it makes sense to first think about combining this section into that function 
(and just adjusting the lambda). 

Also just wondering if you stumbled upon the code that actually does todays 
"`Abc^()` goes to constructor" behaviour, because I think looking at that might 
give some clues as to where we should put the new code (and maybe some 
inspirations about how to do so). Otherwise I will have to go check for myself 
later, because I honestly do not know either, but I feel like I should have had 
a look to better judge your changes.

https://github.com/llvm/llvm-project/pull/199480
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to