Author: ioeric Date: Tue Sep 18 06:35:16 2018 New Revision: 342473 URL: http://llvm.org/viewvc/llvm-project?rev=342473&view=rev Log: [clangd] Get rid of Decls parameter in indexMainDecls. NFC
It's already available in ParsedAST. Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp clang-tools-extra/trunk/clangd/index/FileIndex.cpp clang-tools-extra/trunk/clangd/index/FileIndex.h clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp clang-tools-extra/trunk/unittests/clangd/TestTU.cpp Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=342473&r1=342472&r2=342473&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue Sep 18 06:35:16 2018 @@ -83,7 +83,7 @@ std::unique_ptr<ParsingCallbacks> makeUp } void onMainAST(PathRef Path, ParsedAST &AST) override { - FIndex->updateMain(Path, AST, AST.getLocalTopLevelDecls()); + FIndex->updateMain(Path, AST); } }; return llvm::make_unique<CB>(FIndex); Modified: clang-tools-extra/trunk/clangd/index/FileIndex.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/FileIndex.cpp?rev=342473&r1=342472&r2=342473&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/index/FileIndex.cpp (original) +++ clang-tools-extra/trunk/clangd/index/FileIndex.cpp Tue Sep 18 06:35:16 2018 @@ -65,10 +65,9 @@ indexSymbols(ASTContext &AST, std::share } std::pair<SymbolSlab, RefSlab> -indexMainDecls(ParsedAST &AST, llvm::ArrayRef<Decl *> TopLevelDecls, - llvm::ArrayRef<std::string> URISchemes) { +indexMainDecls(ParsedAST &AST, llvm::ArrayRef<std::string> URISchemes) { return indexSymbols(AST.getASTContext(), AST.getPreprocessorPtr(), - TopLevelDecls, + AST.getLocalTopLevelDecls(), /*IsIndexMainAST=*/true, URISchemes); } @@ -163,9 +162,8 @@ void FileIndex::updatePreamble(PathRef P PreambleIndex.reset(PreambleSymbols.buildMemIndex()); } -void FileIndex::updateMain(PathRef Path, ParsedAST &AST, - llvm::ArrayRef<Decl *> TopLevelDecls) { - auto Contents = indexMainDecls(AST, TopLevelDecls, URISchemes); +void FileIndex::updateMain(PathRef Path, ParsedAST &AST) { + auto Contents = indexMainDecls(AST, URISchemes); MainFileSymbols.update( Path, llvm::make_unique<SymbolSlab>(std::move(Contents.first)), llvm::make_unique<RefSlab>(std::move(Contents.second))); Modified: clang-tools-extra/trunk/clangd/index/FileIndex.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/FileIndex.h?rev=342473&r1=342472&r2=342473&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/index/FileIndex.h (original) +++ clang-tools-extra/trunk/clangd/index/FileIndex.h Tue Sep 18 06:35:16 2018 @@ -73,9 +73,9 @@ public: void updatePreamble(PathRef Path, ASTContext &AST, std::shared_ptr<Preprocessor> PP); - /// Update symbols from main file \p Path with symbols in \p TopLevelDecls. - void updateMain(PathRef Path, ParsedAST &AST, - llvm::ArrayRef<Decl *> TopLevelDecls); + /// Update symbols and references from main file \p Path with + /// `indexMainDecls`. + void updateMain(PathRef Path, ParsedAST &AST); private: std::vector<std::string> URISchemes; @@ -106,12 +106,12 @@ private: std::unique_ptr<SymbolIndex> MergedIndex; // Merge preamble and main index. }; -/// Retrieves symbols and refs of \p Decls in \p AST. +/// Retrieves symbols and refs of local top level decls in \p AST (i.e. +/// `AST.getLocalTopLevelDecls()`). /// Exposed to assist in unit tests. /// If URISchemes is empty, the default schemes in SymbolCollector will be used. std::pair<SymbolSlab, RefSlab> -indexMainDecls(ParsedAST &AST, llvm::ArrayRef<Decl *> Decls, - llvm::ArrayRef<std::string> URISchemes = {}); +indexMainDecls(ParsedAST &AST, llvm::ArrayRef<std::string> URISchemes = {}); /// Idex declarations from \p AST and macros from \p PP that are declared in /// included headers. Modified: clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp?rev=342473&r1=342472&r2=342473&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp Tue Sep 18 06:35:16 2018 @@ -314,14 +314,14 @@ TEST(FileIndexTest, Refs) { Test.Code = MainCode.code(); Test.Filename = "test.cc"; auto AST = Test.build(); - Index.updateMain(Test.Filename, AST, AST.getLocalTopLevelDecls()); + Index.updateMain(Test.Filename, AST); // Add test2.cc TestTU Test2; Test2.HeaderCode = HeaderCode; Test2.Code = MainCode.code(); Test2.Filename = "test2.cc"; AST = Test2.build(); - Index.updateMain(Test2.Filename, AST, AST.getLocalTopLevelDecls()); + Index.updateMain(Test2.Filename, AST); EXPECT_THAT(getRefs(Index.index(), Foo.ID), RefsAre({AllOf(RefRange(MainCode.range("foo")), Modified: clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp?rev=342473&r1=342472&r2=342473&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp Tue Sep 18 06:35:16 2018 @@ -244,7 +244,7 @@ TEST(MergeIndexTest, Refs) { Test.Code = Test1Code.code(); Test.Filename = "test.cc"; auto AST = Test.build(); - Dyn.updateMain(Test.Filename, AST, AST.getLocalTopLevelDecls()); + Dyn.updateMain(Test.Filename, AST); // Build static index for test.cc. Test.HeaderCode = HeaderCode; @@ -252,8 +252,7 @@ TEST(MergeIndexTest, Refs) { Test.Filename = "test.cc"; auto StaticAST = Test.build(); // Add stale refs for test.cc. - StaticIndex.updateMain(Test.Filename, StaticAST, - StaticAST.getLocalTopLevelDecls()); + StaticIndex.updateMain(Test.Filename, StaticAST); // Add refs for test2.cc Annotations Test2Code(R"(class $Foo[[Foo]] {};)"); @@ -262,8 +261,7 @@ TEST(MergeIndexTest, Refs) { Test2.Code = Test2Code.code(); Test2.Filename = "test2.cc"; StaticAST = Test2.build(); - StaticIndex.updateMain(Test2.Filename, StaticAST, - StaticAST.getLocalTopLevelDecls()); + StaticIndex.updateMain(Test2.Filename, StaticAST); RefsRequest Request; Request.IDs = {Foo.ID}; Modified: clang-tools-extra/trunk/unittests/clangd/TestTU.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/TestTU.cpp?rev=342473&r1=342472&r2=342473&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/TestTU.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/TestTU.cpp Tue Sep 18 06:35:16 2018 @@ -51,7 +51,7 @@ SymbolSlab TestTU::headerSymbols() const // FIXME: This should return a FileIndex with both preamble and main index. std::unique_ptr<SymbolIndex> TestTU::index() const { auto AST = build(); - auto Content = indexMainDecls(AST, AST.getLocalTopLevelDecls()); + auto Content = indexMainDecls(AST); return MemIndex::build(std::move(Content.first), std::move(Content.second)); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits