Index: clangd/XRefs.cpp =================================================================== --- clangd/XRefs.cpp +++ clangd/XRefs.cpp @@ -51,7 +51,7 @@ unsigned Offset, index::IndexDataConsumer::ASTNodeInfo ASTNode) override { if (isSearchedLocation(FID, Offset)) - Decls.push_back(D); + Decls.push_back(ASTNode.OrigD); return true; } Index: unittests/clangd/XRefsTests.cpp =================================================================== --- unittests/clangd/XRefsTests.cpp +++ unittests/clangd/XRefsTests.cpp @@ -203,6 +203,12 @@ #define MACRO 2 #undef macro )cpp", + + R"cpp(// Forward class declaration + class Foo; + [[class Foo {}]]; + F^oo* foo(); + )cpp", }; for (const char *Test : Tests) { Annotations T(Test);