llvm-project/clang-tools-extra/clangd/index
Eric Liu 02ce01f1e8 [clangd] Not collect include headers for dynamic index for now.
Summary:
The new behaviors introduced by this patch:
o When include collection is enabled, we always set IncludeHeader field in Symbol
even if it's the same as FileURI in decl.
o Disable include collection in FileIndex which is currently only used to build
dynamic index. We should revisit when we actually want to use FileIndex to global
index.
o Code-completion only uses IncludeHeader to insert headers but not FileURI in
CanonicalDeclaration. This ensures that inserted headers are always canonicalized.
Note that include insertion can still be triggered for symbols that are already
included if they are merged from dynamic index and static index, but we would
only use includes that are already canonicalized (e.g. from static index).

Reason for change:
Collecting header includes in dynamic index enables inserting includes for headers
that are not indexed but opened in the editor. Comparing to inserting includes for
symbols in global/static index, this is nice-to-have but would probably require
non-trivial amount of work to get right. For example:
o Currently it's not easy to fully support CanonicalIncludes in dynamic index, given the way
we run dynamic index.
o It's also harder to reason about the correctness of include canonicalization for dynamic index
(i.e. symbols in the current file/TU) than static index where symbols are collected
offline and sanity check is possible before shipping to production.
o We have less control/flexibility over symbol info in the dynamic index
(e.g. URIs, path normalization), which could be used to help make decision when inserting includes.

As header collection (especially canonicalization) is relatively new, and enabling
it for dynamic index would immediately affect current users with only dynamic
index support, I propose we disable it for dynamic index for now to avoid
compromising other hot features like code completion and only support it for
static index where include insertion would likely to bring more value.

Reviewers: ilya-biryukov, sammccall, hokein

Subscribers: klimek, jkorous-apple, cfe-commits

Differential Revision: https://reviews.llvm.org/D43550

llvm-svn: 325764
2018-02-22 10:14:05 +00:00
..
CanonicalIncludes.cpp [clangd] Update canonical header mapping for STL 2018-02-21 16:17:25 +00:00
CanonicalIncludes.h [clangd] Fixes for #include insertion. 2018-02-19 18:48:44 +00:00
FileIndex.cpp [clangd] Not collect include headers for dynamic index for now. 2018-02-22 10:14:05 +00:00
FileIndex.h [clangd] Pass Context implicitly using TLS. 2018-01-31 13:40:48 +00:00
Index.cpp [clangd] collect symbol #include & insert #include in global code completion. 2018-02-16 14:15:55 +00:00
Index.h [clangd] Not collect include headers for dynamic index for now. 2018-02-22 10:14:05 +00:00
MemIndex.cpp [clangd] Pass Context implicitly using TLS. 2018-01-31 13:40:48 +00:00
MemIndex.h [clangd] Pass Context implicitly using TLS. 2018-01-31 13:40:48 +00:00
Merge.cpp [clangd] Invert return value of fuzzyFind() (fix MemIndex's return value) 2018-02-19 13:04:41 +00:00
Merge.h [clangd] Merge results from static/dynamic index. 2018-01-15 12:33:00 +00:00
SymbolCollector.cpp [clangd] Not collect include headers for dynamic index for now. 2018-02-22 10:14:05 +00:00
SymbolCollector.h [clangd] collect symbol #include & insert #include in global code completion. 2018-02-16 14:15:55 +00:00
SymbolYAML.cpp [clangd] Fix use-after-free in SymbolYAML: strings are owned by yaml::Input! 2018-02-19 09:31:26 +00:00
SymbolYAML.h [clangd] Fix use-after-free in SymbolYAML: strings are owned by yaml::Input! 2018-02-19 09:31:26 +00:00