diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools-extra/clangd/Hover.cpp @@ -623,7 +623,8 @@ HI.Type = printType(VT->getTemplatedDecl()->getType(), VT->getASTContext(), PP); else if (const auto *TN = dyn_cast(D)) - HI.Type = printType(TN->getUnderlyingType(), TN->getASTContext(), PP); + HI.Type = printType(TN->getUnderlyingType().getDesugaredType(Ctx), + TN->getASTContext(), PP); else if (const auto *TAT = dyn_cast(D)) HI.Type = printType(TAT->getTemplatedDecl()->getUnderlyingType(), TAT->getASTContext(), PP); diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp b/clang-tools-extra/clangd/unittests/HoverTests.cpp --- a/clang-tools-extra/clangd/unittests/HoverTests.cpp +++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -3206,6 +3206,30 @@ ASSERT_TRUE(H); EXPECT_EQ(H->Definition, "int arr[]"); } + +TEST(Hover, Typedefs) { + Annotations T(R"cpp( + template + struct cond { using type = T; }; + template + struct cond { using type = F; }; + + template + using type = typename cond::type; + + void foo() { + using f^oo = type; + } + )cpp"); + + TestTU TU = TestTU::withCode(T.code()); + auto AST = TU.build(); + auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr); + + ASSERT_TRUE(H && H->Type); + EXPECT_EQ(H->Type->Type, "int"); + EXPECT_EQ(H->Definition, "using foo = type"); +} } // namespace } // namespace clangd } // namespace clang