================ @@ -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()); ---------------- HighCommander4 wrote:
> IIUC we're testing preamble vs stdlib index depending on which one finishes > first here. Good catch! (I was basing the test on `StdLibTests.EndToEnd`, but that has the important difference of operating on a file with no includes, so there's no preamble index.) > I think we can try with a vector implementation like: > > ```c++ > struct vector { > // This shouldn't be indexed for code-completion, hence static-idx wouldn't > have any docs for it. > struct inner {}; > }; > ``` > > afterwards we can add an empty file to clangd, to make sure we only index > `vector` through stdlib-index and not preabmle. > > afterwards we run a workspace symbol query for `vector::inner` and ensure it > has docs. WDYT? Makes sense, but unfortunately workspace symbols do not include documentation. 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. https://github.com/llvm/llvm-project/pull/133681 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits