diff options
Diffstat (limited to 'clang-tools-extra/clangd/index/FileIndex.h')
-rw-r--r-- | clang-tools-extra/clangd/index/FileIndex.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/clang-tools-extra/clangd/index/FileIndex.h b/clang-tools-extra/clangd/index/FileIndex.h index d9bee8885d1..87abd0089c0 100644 --- a/clang-tools-extra/clangd/index/FileIndex.h +++ b/clang-tools-extra/clangd/index/FileIndex.h @@ -60,21 +60,29 @@ class FileSymbols { public: /// Updates all symbols and refs in a file. /// If either is nullptr, corresponding data for \p Path will be removed. + /// If CountReferences is true, \p Refs will be used for counting References + /// during merging. void update(PathRef Path, std::unique_ptr<SymbolSlab> Slab, - std::unique_ptr<RefSlab> Refs); + std::unique_ptr<RefSlab> Refs, bool CountReferences); - // The index keeps the symbols alive. + /// The index keeps the symbols alive. + /// Will count Symbol::References based on number of references in the main + /// files, while building the index with DuplicateHandling::Merge option. std::unique_ptr<SymbolIndex> buildIndex(IndexType, DuplicateHandling DuplicateHandle = DuplicateHandling::PickOne); private: + struct RefSlabAndCountReferences { + std::shared_ptr<RefSlab> Slab; + bool CountReferences = false; + }; mutable std::mutex Mutex; /// Stores the latest symbol snapshots for all active files. llvm::StringMap<std::shared_ptr<SymbolSlab>> FileToSymbols; /// Stores the latest ref snapshots for all active files. - llvm::StringMap<std::shared_ptr<RefSlab>> FileToRefs; + llvm::StringMap<RefSlabAndCountReferences> FileToRefs; }; /// This manages symbols from files and an in-memory index on all symbols. |