Index: clang-tools-extra/trunk/clangd/XRefs.cpp =================================================================== --- clang-tools-extra/trunk/clangd/XRefs.cpp +++ clang-tools-extra/trunk/clangd/XRefs.cpp @@ -715,7 +715,7 @@ HI.Value.emplace(); llvm::raw_string_ostream ValueOS(*HI.Value); Result.Val.printPretty(ValueOS, const_cast(Ctx), - Var->getType()); + Init->getType()); } } } Index: clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp =================================================================== --- clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp +++ clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp @@ -1793,6 +1793,16 @@ "int\n" "]", }, + { + R"cpp(// Should not crash when evaluating the initializer. + struct Test {}; + void test() { Test && te^st = {}; } + )cpp", + "text[Declared in]code[test]\n" + "codeblock(cpp) [\n" + "struct Test &&test = {}\n" + "]", + }, }; // Create a tiny index, so tests above can verify documentation is fetched.