diff options
author | Sam McCall <sam.mccall@gmail.com> | 2018-01-12 14:51:47 +0000 |
---|---|---|
committer | Sam McCall <sam.mccall@gmail.com> | 2018-01-12 14:51:47 +0000 |
commit | 3ee4cc4acfa675c8cace6b05f2b41ed45a6a1033 (patch) | |
tree | eafc3fc139c8fdbb56ec595c61ed608af8af505b /include | |
parent | 780143bbd516aa39d754e5cab50955321b71fba0 (diff) | |
download | clang-3ee4cc4acfa675c8cace6b05f2b41ed45a6a1033.tar.gz |
[CodeComplete] Add an option to omit results from the preamble.
Summary:
Enumerating the contents of a namespace or global scope will omit any
decls that aren't already loaded, instead of deserializing them from the
PCH.
This allows a fast hybrid code completion where symbols from headers are
provided by an external index. (Sema already exposes the information
needed to do a reasonabl job of filtering them).
Clangd plans to implement this hybrid.
This option is just a hint - callers still need to postfilter results if
they want to *avoid* completing decls outside the main file.
Reviewers: bkramer, ilya-biryukov
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D41989
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322371 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang-c/Index.h | 9 | ||||
-rw-r--r-- | include/clang/Sema/CodeCompleteConsumer.h | 6 | ||||
-rw-r--r-- | include/clang/Sema/CodeCompleteOptions.h | 7 | ||||
-rw-r--r-- | include/clang/Sema/Sema.h | 6 |
4 files changed, 24 insertions, 4 deletions
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index a0c4dc98ad..775b7acc94 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -5161,7 +5161,14 @@ enum CXCodeComplete_Flags { * \brief Whether to include brief documentation within the set of code * completions returned. */ - CXCodeComplete_IncludeBriefComments = 0x04 + CXCodeComplete_IncludeBriefComments = 0x04, + + /** + * \brief Whether to speed up completion by omitting some entities which are + * defined in the preamble. There's no guarantee any particular entity will + * be omitted. This may be useful if the headers are indexed externally. + */ + CXCodeComplete_SkipPreamble = 0x08 }; /** diff --git a/include/clang/Sema/CodeCompleteConsumer.h b/include/clang/Sema/CodeCompleteConsumer.h index 5d280b5608..e8db3ec237 100644 --- a/include/clang/Sema/CodeCompleteConsumer.h +++ b/include/clang/Sema/CodeCompleteConsumer.h @@ -934,6 +934,12 @@ public: return CodeCompleteOpts.IncludeBriefComments; } + /// \brief Hint whether to load data from the external AST in order to provide + /// full results. If false, declarations from the preamble may be omitted. + bool loadExternal() const { + return CodeCompleteOpts.LoadExternal; + } + /// \brief Determine whether the output of this consumer is binary. bool isOutputBinary() const { return OutputIsBinary; } diff --git a/include/clang/Sema/CodeCompleteOptions.h b/include/clang/Sema/CodeCompleteOptions.h index 091d8ca605..bfba2be3ec 100644 --- a/include/clang/Sema/CodeCompleteOptions.h +++ b/include/clang/Sema/CodeCompleteOptions.h @@ -35,9 +35,14 @@ public: /// Show brief documentation comments in code completion results. unsigned IncludeBriefComments : 1; + /// Hint whether to load data from the external AST in order to provide + /// full results. If false, declarations from the preamble may be omitted. + unsigned LoadExternal : 1; + CodeCompleteOptions() : IncludeMacros(0), IncludeCodePatterns(0), IncludeGlobals(1), - IncludeNamespaceLevelDecls(1), IncludeBriefComments(0) {} + IncludeNamespaceLevelDecls(1), IncludeBriefComments(0), + LoadExternal(1) {} }; } // namespace clang diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index b4afd073c6..23aa3565d1 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -3199,11 +3199,13 @@ public: void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, - bool IncludeGlobalScope = true); + bool IncludeGlobalScope = true, + bool LoadExternal = true); void LookupVisibleDecls(DeclContext *Ctx, LookupNameKind Kind, VisibleDeclConsumer &Consumer, bool IncludeGlobalScope = true, - bool IncludeDependentBases = false); + bool IncludeDependentBases = false, + bool LoadExternal = true); enum CorrectTypoKind { CTK_NonError, // CorrectTypo used in a non error recovery situation. |