[clang-tools-extra] [clangd] Store documentation when indexing standard library (PR #133681)
kadir çetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Sun May 4 23:21:22 PDT 2025
================
@@ -158,6 +158,43 @@ TEST(StdLibTests, EndToEnd) {
UnorderedElementsAre(StdlibSymbol("list"), StdlibSymbol("vector")));
}
+TEST(StdLibTests, StdLibDocComments) {
+ Config Cfg;
+ Cfg.Index.StandardLibrary = true;
+ WithContextValue Enabled(Config::Key, std::move(Cfg));
+
+ MockFS FS;
+ FS.Files["stdlib/vector"] = R"cpp(
+ namespace std {
+ template <typename T>
+ class vector {
+ public:
+ /**doc comment*/
+ unsigned int size() const;
+ };
+ }
+ )cpp";
+ MockCompilationDatabase CDB;
+ CDB.ExtraClangFlags.push_back("-isystem" + testPath("stdlib"));
+ ClangdServer::Options Opts = ClangdServer::optsForTest();
+ Opts.BuildDynamicSymbolIndex = true; // also used for stdlib index
+ ClangdServer Server(CDB, FS, Opts);
+
+ Annotations A(R"cpp(
+ #include <vector>
+ void foo() {
+ std::vector<int> v;
+ v.si^ze();
+ }
+ )cpp");
+
+ Server.addDocument(testPath("foo.cc"), A.code());
+ ASSERT_TRUE(Server.blockUntilIdleForTest());
----------------
kadircet wrote:
> Makes sense, but unfortunately workspace symbols do not include documentation.
oops, i was hoping that we return a full symbol :/
> Instead, I added a function to ClangdServer to expose the index for test use, and ran a FuzzyFind operation on it directly. Let me know if that's reasonable; I'm open to other suggestions if not.
i think we can use clangserver's custom action endpoint instead, left a separate comment for that.
https://github.com/llvm/llvm-project/pull/133681
More information about the cfe-commits
mailing list