diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp --- a/clang-tools-extra/clangd/CodeComplete.cpp +++ b/clang-tools-extra/clangd/CodeComplete.cpp @@ -403,8 +403,9 @@ if (C.IndexResult) { SetDoc(C.IndexResult->Documentation); } else if (C.SemaResult) { - SetDoc(getDocComment(*ASTCtx, *C.SemaResult, - /*CommentsFromHeader=*/false)); + const auto DocComment = getDocComment(*ASTCtx, *C.SemaResult, + /*CommentsFromHeader=*/false); + SetDoc(formatDocumentation(*SemaCCS, DocComment)); } } if (Completion.Deprecated) { diff --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp --- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp +++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp @@ -907,7 +907,7 @@ auto Results = completions( R"cpp( // Non-doxygen comment. - int foo(); + __attribute__((annotate("custom_annotation"))) int foo(); /// Doxygen comment. /// \param int a int bar(int a); @@ -919,7 +919,8 @@ int x = ^ )cpp"); EXPECT_THAT(Results.Completions, - Contains(AllOf(Named("foo"), Doc("Non-doxygen comment.")))); + Contains(AllOf(Named("foo"), + Doc("Annotation: custom_annotation\nNon-doxygen comment.")))); EXPECT_THAT( Results.Completions, Contains(AllOf(Named("bar"), Doc("Doxygen comment.\n\\param int a"))));