[clang] [clang-tools-extra] clangd: Extend reference search with constructor calls through forwarding (PR #169742)
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 16 22:55:03 PST 2025
================
@@ -2713,6 +2714,91 @@ TEST(FindReferences, NoQueryForLocalSymbols) {
}
}
+TEST(FindReferences, ForwardingInAST) {
+ Annotations Main(R"cpp(
+ namespace std {
+ template <class T> T &&forward(T &t);
+ template <class T, class... Args> T *make_unique(Args &&...args) {
+ return new T(std::forward<Args>(args)...);
+ }
+ }
+
+ struct Test {
+ $Constructor[[T^est]](){}
+ };
+
+ int main() {
+ auto a = std::$Caller[[make_unique]]<Test>();
+ }
+ )cpp");
+ TestTU TU;
+ TU.Code = std::string(Main.code());
+ auto AST = TU.build();
+
+ EXPECT_THAT(findReferences(AST, Main.point(), 0).References,
+ ElementsAre(rangeIs(Main.range("Constructor")),
+ rangeIs(Main.range("Caller"))));
+}
+
+TEST(FindReferences, ForwardingInASTTwice) {
----------------
HighCommander4 wrote:
nit: `ForwardingInASTChained` would read as a bit more descriptive to me
https://github.com/llvm/llvm-project/pull/169742
More information about the cfe-commits
mailing list