[clang] [clang-tools-extra] [clangd] Support parsing comments without ASTContext (PR #78491)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 14 06:22:35 PDT 2024
================
@@ -316,5 +319,26 @@ std::string getReturnType(const CodeCompletionString &CCS) {
return "";
}
+comments::FullComment *parseComment(llvm::StringRef Comment,
+ llvm::BumpPtrAllocator &Allocator,
+ comments::CommandTraits &Traits) {
+ // The comment lexer expects markers, so add them back
+ auto CommentWithMarkers = "/*" + Comment.str() + "*/";
+
+ SourceManagerForFile SourceMgrForFile("mock_file.cpp", CommentWithMarkers);
+ SourceManager &SourceMgr = SourceMgrForFile.get();
+
+ comments::Lexer L(Allocator, SourceMgr.getDiagnostics(), Traits,
----------------
erichkeane wrote:
The order of these constructors seems odd. I would expect us to build these up in the 'correct' order of dependence/execution/etc. So I think you should swap the `Lexer` and `Sema` lines.
https://github.com/llvm/llvm-project/pull/78491
More information about the cfe-commits
mailing list