diff options
author | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2018-06-18 14:34:13 +0200 |
---|---|---|
committer | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2018-06-21 08:44:37 +0000 |
commit | 43ac160b1aa4d98ad07f1e8dde5e445593dc8d91 (patch) | |
tree | 6f33e2af21b7bd1b987e668d64c74627da5675db /include | |
parent | 7e438f61d9caa617562cd650bf6578be64be94ac (diff) |
[Frontend] Share global completions cache
Append ASTUnit cache with global completions cache.
In case of multiple translation units for the same file
reduces the memory consumption and save completions cache
generation time.
Change-Id: I9acd8734f81f622fedd3aac08dbd45e208a70918
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/Frontend/ASTUnit.h | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h index 896cb31680..232f9406be 100644 --- a/include/clang/Frontend/ASTUnit.h +++ b/include/clang/Frontend/ASTUnit.h @@ -289,6 +289,9 @@ public: /// of that loading. It must be cleared when preamble is recreated. llvm::StringMap<SourceLocation> PreambleSrcLocCache; + /// \brief The set of cached code-completion results. + std::vector<CachedCodeCompletionResult> CachedCompletionResults; + /// \brief Counter that determines when we want to try building a /// precompiled preamble. /// @@ -306,6 +309,13 @@ public: /// This hash value is used to determine when we need to refresh the /// global code-completion cache after a rebuild of the precompiled preamble. unsigned PreambleTopLevelHashValue = 0; + + /// \brief A string hash of the top-level declaration and macro definition + /// names processed the last time that we reparsed the file. + /// + /// This hash value is used to determine when we need to refresh the + /// global code-completion cache. + unsigned CompletionCacheTopLevelHashValue = 0; }; void initCache(); @@ -340,20 +350,10 @@ private: std::unique_ptr<CodeCompletionTUInfo> CCTUInfo; - /// \brief The set of cached code-completion results. - std::vector<CachedCodeCompletionResult> CachedCompletionResults; - /// \brief A mapping from the formatted type name to a unique number for that /// type, which is used for type equality comparisons. llvm::StringMap<unsigned> CachedCompletionTypes; - /// \brief A string hash of the top-level declaration and macro definition - /// names processed the last time that we reparsed the file. - /// - /// This hash value is used to determine when we need to refresh the - /// global code-completion cache. - unsigned CompletionCacheTopLevelHashValue = 0; - /// \brief The current hash value for the top-level declaration and macro /// definition names unsigned CurrentTopLevelHashValue; @@ -609,15 +609,15 @@ public: cached_completion_iterator; cached_completion_iterator cached_completion_begin() { - return CachedCompletionResults.begin(); + return ASTUnitCacheMap[getMainFileName()].CachedCompletionResults.begin(); } cached_completion_iterator cached_completion_end() { - return CachedCompletionResults.end(); + return ASTUnitCacheMap[getMainFileName()].CachedCompletionResults.end(); } unsigned cached_completion_size() const { - return CachedCompletionResults.size(); + return ASTUnitCacheMap[getMainFileName()].CachedCompletionResults.size(); } /// \brief Returns an iterator range for the local preprocessing entities |