[clang] [clang-tools-extra] [clangd] Support parsing comments without ASTContext (PR #78491)
HighCommander4 wrote: > What's "ping PR"? Do you mean pinging the LLVM organization? It just means posting a comment on the PR that says "ping", as a reminder for reviewers. (But please only do that if you're the patch author, or, in the case of a patch author who's not active any more, if you're volunteering to take over the patch from the patch author and do the work of addressing any remaining review comments.) >> What's preventing this PR from being merged right now? All checks seem to >> have passed. > PRs need to be reviewed before they can be merged. Yes, code reviewer bandwidth is the bottleneck for clangd patches at the moment. I have some other patches in my review queue which I've been trying to get to (and unfortunately haven't had much time to spend on them), so I'm hoping Kadir can review this one, especially as he has reviewed earlier versions of this and related patches and has more familiarity with the affected code areas. But if no one else gets to this, I would like to at some point. https://github.com/llvm/llvm-project/pull/78491 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clangd] Support parsing comments without ASTContext (PR #78491)
aaronliu0130 wrote: What's "ping PR"? Do you mean pinging the LLVM organization? https://github.com/llvm/llvm-project/pull/78491 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clangd] Support parsing comments without ASTContext (PR #78491)
cor3ntin wrote: PRs need to be reviewed before they can be merged. Feel free to ping PR once a week (at most) if no one gets to it. This seem to have flown under the radar. sorry about that https://github.com/llvm/llvm-project/pull/78491 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clangd] Support parsing comments without ASTContext (PR #78491)
aaronliu0130 wrote: LLVM has 2.5k PRs to review while working on their own changes https://github.com/llvm/llvm-project/pull/78491 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clangd] Support parsing comments without ASTContext (PR #78491)
tfninjadoom wrote: I'm new to the processes of open-source software, so pardon my confusion. I just read through [this](https://github.com/clangd/clangd/issues/529) issue and am wondering: What's preventing this PR from being merged right now? All checks seem to have passed. https://github.com/llvm/llvm-project/pull/78491 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clangd] Support parsing comments without ASTContext (PR #78491)
aaronliu0130 wrote: As mentioned in https://github.com/clangd/clangd/issues/529#issuecomment-1938730781, they're [here](https://aur.archlinux.org/cgit/aur.git/tree/hover-doxygen-trunk.patch?h=clangd-opt-git). Hopefully you can follow [the build instructions](https://github.com/llvm/llvm-project/tree/main/clang-tools-extra/clangd#readme). https://github.com/llvm/llvm-project/pull/78491 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clangd] Support parsing comments without ASTContext (PR #78491)
trustytrojan wrote: @aaronliu0130 Do you know if a patch for this exists? https://github.com/llvm/llvm-project/pull/78491 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clangd] Support parsing comments without ASTContext (PR #78491)
aaronliu0130 wrote: Well, the last ready-to-go PR was from September (#65448), so probably a while. https://github.com/llvm/llvm-project/pull/78491 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clangd] Support parsing comments without ASTContext (PR #78491)
trustytrojan wrote: When will this ever get merged? Would really like to see `vscode-clangd` finally be able to render Doxygen comments and/or Markdown comments. https://github.com/llvm/llvm-project/pull/78491 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clangd] Support parsing comments without ASTContext (PR #78491)
https://github.com/tom-anders updated https://github.com/llvm/llvm-project/pull/78491 >From 640318fcf475a82b5483889795e2bd906b7b3c9c Mon Sep 17 00:00:00 2001 From: Tom Praschan <13141438+tom-and...@users.noreply.github.com> Date: Sat, 18 Feb 2023 15:54:09 +0100 Subject: [PATCH] [clangd] Support parsing comments without ASTContext This is in preparation for implementing doxygen parsing, see discussion in https://github.com/clangd/clangd/issues/529. Differential Revision: https://reviews.llvm.org/D143112 --- .../clangd/CodeCompletionStrings.cpp | 24 +++ .../clangd/CodeCompletionStrings.h| 11 + clang/include/clang/Basic/SourceManager.h | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/clang-tools-extra/clangd/CodeCompletionStrings.cpp b/clang-tools-extra/clangd/CodeCompletionStrings.cpp index 2075e5965f181ed..540eaa9a3eb6d74 100644 --- a/clang-tools-extra/clangd/CodeCompletionStrings.cpp +++ b/clang-tools-extra/clangd/CodeCompletionStrings.cpp @@ -9,6 +9,9 @@ #include "CodeCompletionStrings.h" #include "clang-c/Index.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/CommentLexer.h" +#include "clang/AST/CommentParser.h" +#include "clang/AST/CommentSema.h" #include "clang/AST/RawCommentList.h" #include "clang/Basic/SourceManager.h" #include "clang/Sema/CodeCompleteConsumer.h" @@ -316,5 +319,26 @@ std::string getReturnType(const CodeCompletionString ) { return ""; } +comments::FullComment *parseComment(llvm::StringRef Comment, +llvm::BumpPtrAllocator , +comments::CommandTraits ) { + // The comment lexer expects markers, so add them back + auto CommentWithMarkers = "/*" + Comment.str() + "*/"; + + SourceManagerForFile SourceMgrForFile("mock_file.cpp", CommentWithMarkers); + SourceManager = SourceMgrForFile.get(); + + comments::Lexer L(Allocator, SourceMgr.getDiagnostics(), Traits, +SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID()), +CommentWithMarkers.data(), +CommentWithMarkers.data() + CommentWithMarkers.size()); + comments::Sema S(Allocator, SourceMgr, SourceMgr.getDiagnostics(), Traits, + nullptr); + comments::Parser P(L, S, Allocator, SourceMgr, SourceMgr.getDiagnostics(), + Traits); + + return P.parseFullComment(); +} + } // namespace clangd } // namespace clang diff --git a/clang-tools-extra/clangd/CodeCompletionStrings.h b/clang-tools-extra/clangd/CodeCompletionStrings.h index fa81ad64d406c3b..b93420c68f32dba 100644 --- a/clang-tools-extra/clangd/CodeCompletionStrings.h +++ b/clang-tools-extra/clangd/CodeCompletionStrings.h @@ -19,6 +19,11 @@ namespace clang { class ASTContext; +namespace comments { +class CommandTraits; +class FullComment; +} // namespace comments + namespace clangd { /// Gets a minimally formatted documentation comment of \p Result, with comment @@ -67,6 +72,12 @@ std::string formatDocumentation(const CodeCompletionString , /// is usually the return type of a function. std::string getReturnType(const CodeCompletionString ); +/// Parse the \p Comment, storing the result in \p Allocator, assuming +/// that comment markers have already been stripped (e.g. via getDocComment()) +comments::FullComment *parseComment(llvm::StringRef Comment, +llvm::BumpPtrAllocator , +comments::CommandTraits ); + } // namespace clangd } // namespace clang diff --git a/clang/include/clang/Basic/SourceManager.h b/clang/include/clang/Basic/SourceManager.h index d2ece14da0b11ab..07e3fca1641c738 100644 --- a/clang/include/clang/Basic/SourceManager.h +++ b/clang/include/clang/Basic/SourceManager.h @@ -1971,7 +1971,7 @@ class BeforeThanCompare { }; /// SourceManager and necessary dependencies (e.g. VFS, FileManager) for a -/// single in-memorty file. +/// single in-memory file. class SourceManagerForFile { public: /// Creates SourceManager and necessary dependencies (e.g. VFS, FileManager). ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clangd] Support parsing comments without ASTContext (PR #78491)
llvmbot wrote: @llvm/pr-subscribers-clang @llvm/pr-subscribers-clangd Author: Tom Praschan (tom-anders) Changes This is in preparation for implementing doxygen parsing, see discussion in https://github.com/clangd/clangd/issues/529. (Old Phabricator review: https://reviews.llvm.org/D143112) --- Full diff: https://github.com/llvm/llvm-project/pull/78491.diff 3 Files Affected: - (modified) clang-tools-extra/clangd/CodeCompletionStrings.cpp (+24) - (modified) clang-tools-extra/clangd/CodeCompletionStrings.h (+11) - (modified) clang/include/clang/Basic/SourceManager.h (+1-1) ``diff diff --git a/clang-tools-extra/clangd/CodeCompletionStrings.cpp b/clang-tools-extra/clangd/CodeCompletionStrings.cpp index 2075e5965f181e..540eaa9a3eb6d7 100644 --- a/clang-tools-extra/clangd/CodeCompletionStrings.cpp +++ b/clang-tools-extra/clangd/CodeCompletionStrings.cpp @@ -9,6 +9,9 @@ #include "CodeCompletionStrings.h" #include "clang-c/Index.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/CommentLexer.h" +#include "clang/AST/CommentParser.h" +#include "clang/AST/CommentSema.h" #include "clang/AST/RawCommentList.h" #include "clang/Basic/SourceManager.h" #include "clang/Sema/CodeCompleteConsumer.h" @@ -316,5 +319,26 @@ std::string getReturnType(const CodeCompletionString ) { return ""; } +comments::FullComment *parseComment(llvm::StringRef Comment, +llvm::BumpPtrAllocator , +comments::CommandTraits ) { + // The comment lexer expects markers, so add them back + auto CommentWithMarkers = "/*" + Comment.str() + "*/"; + + SourceManagerForFile SourceMgrForFile("mock_file.cpp", CommentWithMarkers); + SourceManager = SourceMgrForFile.get(); + + comments::Lexer L(Allocator, SourceMgr.getDiagnostics(), Traits, +SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID()), +CommentWithMarkers.data(), +CommentWithMarkers.data() + CommentWithMarkers.size()); + comments::Sema S(Allocator, SourceMgr, SourceMgr.getDiagnostics(), Traits, + nullptr); + comments::Parser P(L, S, Allocator, SourceMgr, SourceMgr.getDiagnostics(), + Traits); + + return P.parseFullComment(); +} + } // namespace clangd } // namespace clang diff --git a/clang-tools-extra/clangd/CodeCompletionStrings.h b/clang-tools-extra/clangd/CodeCompletionStrings.h index fa81ad64d406c3..b93420c68f32db 100644 --- a/clang-tools-extra/clangd/CodeCompletionStrings.h +++ b/clang-tools-extra/clangd/CodeCompletionStrings.h @@ -19,6 +19,11 @@ namespace clang { class ASTContext; +namespace comments { +class CommandTraits; +class FullComment; +} // namespace comments + namespace clangd { /// Gets a minimally formatted documentation comment of \p Result, with comment @@ -67,6 +72,12 @@ std::string formatDocumentation(const CodeCompletionString , /// is usually the return type of a function. std::string getReturnType(const CodeCompletionString ); +/// Parse the \p Comment, storing the result in \p Allocator, assuming +/// that comment markers have already been stripped (e.g. via getDocComment()) +comments::FullComment *parseComment(llvm::StringRef Comment, +llvm::BumpPtrAllocator , +comments::CommandTraits ); + } // namespace clangd } // namespace clang diff --git a/clang/include/clang/Basic/SourceManager.h b/clang/include/clang/Basic/SourceManager.h index d2ece14da0b11a..07e3fca1641c73 100644 --- a/clang/include/clang/Basic/SourceManager.h +++ b/clang/include/clang/Basic/SourceManager.h @@ -1971,7 +1971,7 @@ class BeforeThanCompare { }; /// SourceManager and necessary dependencies (e.g. VFS, FileManager) for a -/// single in-memorty file. +/// single in-memory file. class SourceManagerForFile { public: /// Creates SourceManager and necessary dependencies (e.g. VFS, FileManager). `` https://github.com/llvm/llvm-project/pull/78491 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits