summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/CodeComplete.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [clangd] Don't assert when completing a lambda variable inside the lambda.Sam McCall2020-06-101-4/+9
| | | | | | | | | | | | | | | | | | | Summary: This is a fairly ugly hack - we back off several features for any variable whose type isn't deduced, to avoid computing/caching linkage. Better suggestions welcome. Fixes https://github.com/clangd/clangd/issues/274 Reviewers: kadircet, kbobyrev Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73960 (cherry picked from commit 2629035a009095f62f48413e175437261165ecd7)
* [clangd] Expose Code Completion score to the clientKirill Bobyrev2020-02-131-0/+2
| | | | | | | | | | | | | | | | Summary: Make it possible for the client to adjust the ranking by using the score Clangd calculates for the completion items. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D74547 (cherry picked from commit ff7b5bac04fa4946935ea45214e29f267d6c1d7b)
* NFC: Fix trivial typos in commentsKazuaki Ishizaki2020-01-041-1/+1
|
* [NFC] Fix typos in Clangd and ClangKirill Bobyrev2019-12-161-4/+4
| | | | | | Reviewed by: Jim Differential Revision: https://reviews.llvm.org/D71455
* [clangd] Use name of Macro to compute its SymbolID, NFC.Utkarsh Saxena2019-11-111-1/+1
| | | | | | | | | | | | | | | | | | | Summary: We use the name from the IdentifierInfo of the Macro to compute its SymbolID. It is better to just take the Name as a parameter to avoid storing the IdentifierInfo whenever we need the SymbolID for the Macro. Patch by UTKARSH SAXENA! Reviewers: hokein Reviewed By: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69937
* [clangd] Do not insert parentheses when completing a using declarationIlya Biryukov2019-10-281-5/+15
| | | | | | | | | | | | | | | | | | Summary: Would be nice to also fix this in clang, but that looks like more work if we want to preserve signatures in informative chunks. Fixes https://github.com/clangd/clangd/issues/118 Reviewers: kadircet Reviewed By: kadircet Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69382
* [clangd] Collect macros in the preamble region of the main fileHaojian Wu2019-09-241-2/+2
| | | | | | | | | | | | | | | | Summary: - store all macro references in the ParsedAST; - unify the two variants of CollectMainFileMacros; Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, mgrang, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67496 llvm-svn: 372725
* [clangd] Simplify the callside of URI::resolve, NFC.Haojian Wu2019-09-231-5/+2
| | | | | | | | | | | | | | | | Summary: - Add a overrloded URI::resolve, which accepts a string URI; - also fixed some callside that don't check the error; Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67916 llvm-svn: 372617
* [clangd] Add TUScheduler.h to CodeComplete.cpp to unbreak buildsKadir Cetinkaya2019-09-041-0/+1
| | | | llvm-svn: 370895
* [clangd] Move threading helper to more appropriate header. NFCSam McCall2019-09-041-1/+1
| | | | llvm-svn: 370864
* [clangd] Split Preamble.h out of ClangdUnit.h. NFCSam McCall2019-09-041-1/+1
| | | | | | | | | | | | | | Summary: Add comment describing use of preamble in clangd. Remove deps on ClangdUnit.h where possible. Subscribers: mgorny, ilya-biryukov, javed.absar, MaskRay, jkorous, mgrang, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67117 llvm-svn: 370843
* [clangd] Surface errors from command-line parsingIlya Biryukov2019-08-281-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Those errors are exposed at the first character of a file, for a lack of a better place. Previously, all errors were stored inside the AST and report accordingly. However, errors in command-line argument parsing could result in failure to produce the AST, so we need an alternative ways to report those errors. We take the following approach in this patch: - buildCompilerInvocation() now requires an explicit DiagnosticConsumer. - TUScheduler and TestTU now collect the diagnostics produced when parsing command line arguments. If pasing of the AST failed, diagnostics are reported via a new ParsingCallbacks::onFailedAST method. If parsing of the AST succeeded, any errors produced during command-line parsing are stored alongside the AST inside the ParsedAST instance and reported as previously by calling the ParsingCallbacks::onMainAST method; - The client code that uses ClangdServer's DiagnosticConsumer does not need to change, it will receive new diagnostics in the onDiagnosticsReady() callback Errors produced when parsing command-line arguments are collected using the same StoreDiags class that is used to collect all other errors. They are recognized by their location being invalid. IIUC, the location is invalid as there is no source manager at this point, it is created at a later stage. Although technically we might also get diagnostics that mention the command-line arguments FileID with after the source manager was created (and they have valid source locations), we choose to not handle those and they are dropped as not coming from the main file. AFAICT, those diagnostics should always be notes, therefore it's safe to drop them without loosing too much information. Reviewers: kadircet Reviewed By: kadircet Subscribers: nridge, javed.absar, MaskRay, jkorous, arphaman, cfe-commits, gribozavr Tags: #clang Differential Revision: https://reviews.llvm.org/D66759 llvm-svn: 370177
* [clang-tools-extra] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-2/+2
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368944
* [clangd] Fix implicit template instatiations appearing as topLevelDecls.Johan Vikstrom2019-08-081-10/+1
| | | | | | | | | | | | | | Summary: The parser gives implicit template instantiations to the action's HandleTopLevelDecls callback. This makes semantic highlighting highlight these templated functions multiple times. Fixed by filtering on if a Decl is an implicit function/variable/class instantiation. Also added a testcase to semantic highlighting on this. Reviewers: hokein, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65510 llvm-svn: 368261
* [clangd] Fix off-by-one in CodeComplete and assertion in DexSam McCall2019-07-121-2/+2
| | | | llvm-svn: 365955
* [clangd] Consume error to avoid assertion failuresIlya Biryukov2019-07-101-2/+3
| | | | | | | When we fail to calculate #include insertion for a completion item. Note that this change does not add a test, although that would be good. llvm-svn: 365606
* [clangd] Don't insert absolute paths, give up instead.Sam McCall2019-07-081-1/+5
| | | | | | | | | | | | | | Summary: Also implement resolution of paths relative to mainfile without HeaderSearchInfo. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64293 llvm-svn: 365364
* [clangd] Use -completion-style=bundled by default if signature help is availableSam McCall2019-07-081-1/+1
| | | | | | | | | | | | | | | | Summary: I didn't manage to find something nicer than optional<bool>, but at least I found a sneakier comment. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64216 llvm-svn: 365356
* [clang][HeaderSearch] Shorten paths for includes in mainfile's directoryKadir Cetinkaya2019-07-031-1/+1
| | | | | | | | | | | | | | | | | | Summary: Currently HeaderSearch only looks at SearchDir's passed into it, but in addition to those paths headers can be relative to including file's directory. This patch makes sure that is taken into account. Reviewers: gribozavr Subscribers: jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63295 llvm-svn: 365005
* BitStream reader: propagate errorsJF Bastien2019-06-261-2/+3
| | | | | | | | | | | | | | | | | | | | | | The bitstream reader handles errors poorly. This has two effects: * Bugs in file handling (especially modules) manifest as an "unexpected end of file" crash * Users of clang as a library end up aborting because the code unconditionally calls `report_fatal_error` The bitstream reader should be more resilient and return Expected / Error as soon as an error is encountered, not way late like it does now. This patch starts doing so and adopting the error handling where I think it makes sense. There's plenty more to do: this patch propagates errors to be minimally useful, and follow-ups will propagate them further and improve diagnostics. https://bugs.llvm.org/show_bug.cgi?id=42311 <rdar://problem/33159405> Differential Revision: https://reviews.llvm.org/D63518 llvm-svn: 364464
* [clangd] Remove unused signature help quality signal. NFCIlya Biryukov2019-06-061-6/+3
| | | | | | | | ContainsActiveParameter is not used anywhere, set incorrectly (see the removed FIXME) and has no unit tests. Removing it to simplify the code. llvm-svn: 362686
* [clangd] Support offsets for parameters in signatureHelpIlya Biryukov2019-06-041-61/+54
| | | | | | | | | | | | | | | | Summary: Added to LSP in version 3.14 Reviewers: hokein Reviewed By: hokein Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62476 llvm-svn: 362481
* [clangd] Map typedefs to the same LSP completion kind as VSCodeIlya Biryukov2019-05-291-2/+5
| | | | | | For consistency and, more importantly, to get a nicer icon for those in VSCode. llvm-svn: 361969
* [clangd] Place cursor better after completing patternsIlya Biryukov2019-05-281-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Summary: By producing the $0 marker in the snippets at the last placeholder. This produces nicer results in most cases, e.g. for namespace <#name#> { <#decls#> } we now produce ${0:decls} instead of ${2:decls} and the final cursor placement is more convenient. Reviewers: hokein Reviewed By: hokein Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62389 llvm-svn: 361841
* [clangd] Turn no-parse-completion on by when preamble isn't ready. Add flag ↵Sam McCall2019-05-211-3/+4
| | | | | | | | | | | | | | to force it. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62135 llvm-svn: 361258
* [clangd] Expose whether no-compile completion was used.Sam McCall2019-05-061-0/+1
| | | | | | | | | | | | | | Summary: Embedding clients want to experiment with showing such results in e.g. a different color. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61588 llvm-svn: 360039
* [clangd] Boost code completion results that were named in the last few lines.Sam McCall2019-05-061-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The hope is this will catch a few patterns with repetition: SomeClass* S = ^SomeClass::Create() int getFrobnicator() { return ^frobnicator_; } // discard the factory, it's no longer valid. ^MyFactory.reset(); Without triggering antipatterns too often: return Point(x.first, x.^second); I'm going to gather some data on whether this turns out to be a win overall. Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, jfb, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61537 llvm-svn: 360030
* Reapply r359778: [clangd] Fix code completion of macros defined in the ↵Sam McCall2019-05-021-3/+31
| | | | | | | | | preamble region of the main file. The bad assert has been removed, and updateOutOfDateIdentifier has been guarded. This reverts commit r359796. llvm-svn: 359799
* Revert rL359778 : [clangd] Fix code completion of macros defined in the ↵Simon Pilgrim2019-05-021-30/+3
| | | | | | | | | | | | | | | | | | | | | | preamble region of the main file. Summary: This is a tricky case (we baked the assumption that symbols come from the preamble xor mainfile pretty deeply) and the fix is a bit of a hack: We look at the code to guess the macro names, and deserialize them from the preamble "by hand". Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60937 ........ Fix buildbots http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/47684/ llvm-svn: 359796
* [clangd] Fix code completion of macros defined in the preamble region of the ↵Sam McCall2019-05-021-3/+30
| | | | | | | | | | | | | | | | | | | | main file. Summary: This is a tricky case (we baked the assumption that symbols come from the preamble xor mainfile pretty deeply) and the fix is a bit of a hack: We look at the code to guess the macro names, and deserialize them from the preamble "by hand". Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60937 llvm-svn: 359778
* Fix Wpedantic "default argument specified for lambda parameter" warning. NFCI.Simon Pilgrim2019-04-301-3/+3
| | | | llvm-svn: 359548
* [clangd] Query index in code completion no-compile mode.Sam McCall2019-04-261-13/+35
| | | | | | | | | | | | | | Summary: We scrape the enclosing scopes from the source file, and use them in the query. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61077 llvm-svn: 359284
* [CodeComplete] Remove obsolete isOutputBinary().Sam McCall2019-04-181-4/+2
| | | | | | | | | | | | | | | | Summary: It's never set to true. Its only effect would be to set stdout to binary mode. Hopefully we have better ways of doing this by now :-) Reviewers: hokein Subscribers: jkorous, arphaman, kadircet, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60871 llvm-svn: 358696
* [clangd] Check file path of declaring header when deciding whether to insert ↵Eric Liu2019-04-161-3/+6
| | | | | | | | | | | | | | | | | | | include. Summary: Previously, we would use include spelling of the declaring header to check whether the inserted header is the same as the main file. This doesn't help because we only have file path of the main file. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60687 llvm-svn: 358496
* [clangd] Use identifiers in file as completion candidates when build is not ↵Eric Liu2019-04-111-45/+137
| | | | | | | | | | | | | | | | | | | | | | 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
* clangd: repair the build after SVN r358091Saleem Abdulrasool2019-04-101-1/+1
| | | | | | Fix the name of the variable being checked. NFCI. llvm-svn: 358093
* [clangd] Don't insert extra namespace qualifiers when Sema gets lost.Sam McCall2019-04-101-65/+72
| | | | | | | | | | | | | | | | | | | | | | | | Summary: There are cases where Sema can't tell that "foo" in foo::Bar is a namespace qualifier, like in incomplete macro expansions. After this patch, if sema reports no specifier but it looks like there's one in the source code, then we take it into account. Reworked structure and comments in getQueryScopes to try to fight creeping complexity - unsure if I succeeded. I made the test harder (the original version also passes). Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60503 llvm-svn: 358091
* [clangd] Add -header-insertion=never flag to disable include insertion in ↵Sam McCall2019-04-101-7/+11
| | | | | | | | | | | | | | | | code completion Summary: One clear use case: use with an editor that reacts poorly to edits above the cursor. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60409 llvm-svn: 358075
* [clangd] Refactor speculateCompletionFilter and also extract scope.Sam McCall2019-04-101-29/+25
| | | | | | | | | | | | | | | | | | | Summary: Intent is to use the heuristically-parsed scope in cases where we get bogus results from sema, such as in complex macro expansions. Added a motivating testcase we currently get wrong. Name changed because we (already) use this for things other than speculation. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60500 llvm-svn: 358074
* [clangd] Stop passing around PCHContainerOperations, just create it in ↵Sam McCall2019-04-041-9/+3
| | | | | | place. NFC llvm-svn: 357689
* [clangd] Store explicit template specializations in index for code ↵Kadir Cetinkaya2019-03-141-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | navigation purposes Summary: This introduces ~4k new symbols, and ~10k refs for LLVM. We need that information for providing better code navigation support: - When references for a class template is requested, we should return these specializations as well. - When children of a specialization is requested, we should be able to query for those symbols(instead of just class template) Number of symbols: 378574 -> 382784 Number of refs: 5098857 -> 5110689 Reviewers: hokein, gribozavr Reviewed By: gribozavr Subscribers: nridge, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59083 llvm-svn: 356125
* Moved Symbol into its own header and implementation fileDmitri Gribenko2019-02-281-0/+1
| | | | | | | | | | | | Reviewers: ioeric Subscribers: mgorny, jkorous, arphaman, kadircet, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58774 llvm-svn: 355088
* [clangd] Improve global code completion when scope specifier is unresolved.Eric Liu2019-02-271-9/+9
| | | | | | | | | | | | | | | | | | | | | | | Summary: Suppose `clangd::` is unresolved in the following example. Currently, we simply use "clangd::" as the query scope. We can do better by combining with accessible scopes in the context. The query scopes can be `{clangd::, clang::clangd::}`. ``` namespace clang { clangd::^ } ``` Reviewers: ilya-biryukov, sammccall, hokein, kadircet Reviewed By: kadircet Subscribers: MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58448 llvm-svn: 354963
* [clangd] Add type boost to fuzzy find in Dex.Eric Liu2019-02-061-0/+2
| | | | | | | | | | | | | | | | | | Summary: No noticeable impact on code completions overall except some improvement on cross-namespace completion. Reviewers: sammccall, ilya-biryukov Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57815 llvm-svn: 353310
* [clangd] Suggest adding missing includes for incomplete type diagnostics.Eric Liu2019-01-281-55/+9
| | | | | | | | | | | | | | | | | | | Summary: This enables clangd to intercept compiler diagnostics and attach fixes (e.g. by querying index). This patch adds missing includes for incomplete types e.g. member access into class with only forward declaration. This would allow adding missing includes for user-typed symbol names that are missing declarations (e.g. typos) in the future. Reviewers: sammccall Reviewed By: sammccall Subscribers: mgorny, ilya-biryukov, javed.absar, MaskRay, jkorous, mgrang, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D56903 llvm-svn: 352361
* [clangd] NFC: fix clang-tidy warnings.Haojian Wu2019-01-251-4/+4
| | | | | | | Most are about llvm code style violation (found via readability-identifier-naming check). llvm-svn: 352205
* [clangd] Followup fix of rL351818Haojian Wu2019-01-221-3/+5
| | | | | | | | | ClangTidyOptions::getDefaults is not free, it will initialize all clang-tidy modules to get check-specific options, and we don't use this information in CodeComplete, so using an empty one (constructed by default constructor) is sufficient. llvm-svn: 351826
* Fix "missing field 'ClangTidyOpts' initializer" warning. NFCI.Simon Pilgrim2019-01-221-2/+3
| | | | llvm-svn: 351818
* [clangd] NFC: Use buildCompilerInvocation in CodeCompleteKadir Cetinkaya2019-01-221-18/+3
| | | | | | | | | | | | Reviewers: ilya-biryukov, sammccall Reviewed By: sammccall Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D56860 llvm-svn: 351793
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
OpenPOWER on IntegriCloud