diff options
| author | Eric Liu <ioeric@google.com> | 2019-04-11 09:36:36 +0000 |
|---|---|---|
| committer | Eric Liu <ioeric@google.com> | 2019-04-11 09:36:36 +0000 |
| commit | 00d99bd1c4ad80dc909c74c39681978f843a44c6 (patch) | |
| tree | f2bf9490f522f1fccb11a4e65e75a2d6c8db7d1a /clang-tools-extra/clangd/Headers.cpp | |
| parent | 6ef53b3bf2fcccfc97e9a47d17c44cbe1f2b4481 (diff) | |
| download | bcm5719-llvm-00d99bd1c4ad80dc909c74c39681978f843a44c6.tar.gz bcm5719-llvm-00d99bd1c4ad80dc909c74c39681978f843a44c6.zip | |
[clangd] Use identifiers in file as completion candidates when build is not ready.
Summary:
o Lex the code to get the identifiers and put them into a "symbol" index.
o Adds a new completion mode without compilation/sema into code completion workflow.
o Make IncludeInserter work even when no compile command is present, by avoiding
inserting non-verbatim headers.
Reviewers: sammccall
Reviewed By: sammccall
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D60126
llvm-svn: 358159
Diffstat (limited to 'clang-tools-extra/clangd/Headers.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/Headers.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang-tools-extra/clangd/Headers.cpp b/clang-tools-extra/clangd/Headers.cpp index a5759a4ef7c..d4c304fe63b 100644 --- a/clang-tools-extra/clangd/Headers.cpp +++ b/clang-tools-extra/clangd/Headers.cpp @@ -175,6 +175,8 @@ void IncludeInserter::addExisting(const Inclusion &Inc) { bool IncludeInserter::shouldInsertInclude( const HeaderFile &DeclaringHeader, const HeaderFile &InsertedHeader) const { assert(DeclaringHeader.valid() && InsertedHeader.valid()); + if (!HeaderSearchInfo && !InsertedHeader.Verbatim) + return false; if (FileName == DeclaringHeader.File || FileName == InsertedHeader.File) return false; auto Included = [&](llvm::StringRef Header) { @@ -190,7 +192,9 @@ IncludeInserter::calculateIncludePath(const HeaderFile &DeclaringHeader, if (InsertedHeader.Verbatim) return InsertedHeader.File; bool IsSystem = false; - std::string Suggested = HeaderSearchInfo.suggestPathToFileForDiagnostics( + if (!HeaderSearchInfo) + return "\"" + InsertedHeader.File + "\""; + std::string Suggested = HeaderSearchInfo->suggestPathToFileForDiagnostics( InsertedHeader.File, BuildDir, &IsSystem); if (IsSystem) Suggested = "<" + Suggested + ">"; |

