summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeCompletion
Commit message (Collapse)AuthorAgeFilesLines
* [CodeComplete] Suggest 'return nullptr' in functions returning pointersIlya Biryukov2020-01-101-0/+24
| | | | | | | | | | Reviewers: kadircet Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72497
* [clangd] Show lambda signature for lambda autocompletionsKirill Bobyrev2019-11-222-5/+21
| | | | | | | | | | | | | | | | | | | | | | | | The original bug report can be found [here](https://github.com/clangd/clangd/issues/85) Given the following code: ```c++ void function() { auto Lambda = [](int a, double &b) {return 1.f;}; La^ } ``` Triggering the completion at `^` would show `(lambda)` before this patch and would show signature `(int a, double &b) const`, build a snippet etc with this patch. Reviewers: sammccall Reviewed by: sammccall Differential revision: https://reviews.llvm.org/D70445
* [CodeComplete] Constructor overload candidates report as vector(int) instead ↵Sam McCall2019-11-151-1/+8
| | | | | | | | | | | | | | | | | | | of vector<string>(int) Summary: This is shorter, shouldn't be confusing (is consistent with how they're declared), and avoids messy cases that are printed as myclass<type-param-0-0>(int) in the case of partial specialization. Fixes part of https://github.com/clangd/clangd/issues/76 Reviewers: hokein, lh123 Subscribers: ilya-biryukov, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70307
* [CodeComplete] Ensure object is the same in compareOverloads()Ilya Biryukov2019-10-041-0/+13
| | | | | | | | | | | | | | | | | | Summary: This fixes a regression that led to size() not being available in clangd when completing 'deque().^' and using libc++. Reviewers: sammccall Reviewed By: sammccall Subscribers: jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68335 llvm-svn: 373710
* Re-land "[CodeComplete] Improve overload handling for C++ qualified and ↵Sam McCall2019-06-101-0/+63
| | | | | | | | ref-qualified methods." ShadowMapEntry is now really, truly a normal class. llvm-svn: 362950
* Revert "[CodeComplete] Improve overload handling for C++ qualified and ↵Sam McCall2019-06-101-63/+0
| | | | | | | | ref-qualified methods." This reverts commit r362924, which causes a double-free of ShadowMapEntry. llvm-svn: 362944
* Revert "Revert "[CodeComplete] Improve overload handling for C++ qualified ↵Sam McCall2019-06-101-0/+63
| | | | | | | | and ref-qualified methods."" This reverts commit r362830, and relands r362785 with the leak fixed. llvm-svn: 362924
* Revert "[CodeComplete] Improve overload handling for C++ qualified and ↵Vlad Tsyrklevich2019-06-071-63/+0
| | | | | | | | | | ref-qualified methods." This reverts commit f1f6e0fc2468e9c120b22b939507c527d08b8ee8, it was causing LSan failures on the sanitizer bots: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/32809 llvm-svn: 362830
* [CodeComplete] Improve overload handling for C++ qualified and ref-qualified ↵Sam McCall2019-06-071-0/+63
| | | | | | | | | | | | | | | | | | | | | methods. Summary: - when a method is not available because of the target value kind (e.g. an && method on a Foo& variable), then don't offer it. - when a method is effectively shadowed by another method from the same class with a) an identical argument list and b) superior qualifiers, then don't offer it. Reviewers: ilya-biryukov Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62582 llvm-svn: 362785
* [CodeComplete] Include more text into typed chunks of pattern completionsIlya Biryukov2019-06-042-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Summary: To allow filtering on any of the words in the editors. In particular, the following completions were changed: - 'using namespace <#name#>' Typed text before: 'using', after: 'using namespace'. - 'else if (#<condition#>)' Before: 'else', after: 'else if'. - 'using typename <#qualifier#>::<#name#>' Before: 'using', after: 'using typename'. Reviewers: sammccall Reviewed By: sammccall Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62615 llvm-svn: 362479
* [CodeComplete] Add a bit more whitespace to completed patternsIlya Biryukov2019-06-032-25/+25
| | | | | | | | | | | | | | | | | | | | Summary: E.g. we now turn `while(<#cond#>){` into `while (<#cond#>) {` This slightly improves the final output. Should not affect clients that format the result on their own. Reviewers: gribozavr Reviewed By: gribozavr Subscribers: jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62616 llvm-svn: 362363
* [CodeComplete] Add semicolon when completing patterns for 'static_assert' ↵Ilya Biryukov2019-05-293-13/+13
| | | | | | | | | and 'typedef This is a trivial follow-up to r360042, which added semicolons to other pattern completions, so sending without review. llvm-svn: 361974
* [CodeComplete] Consistently break after '{' in multi-line patternsIlya Biryukov2019-05-282-16/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Completion can return multi-line patterns in some cases, e.g. for (<#init#>; <#cond#>; <#inc#>) { <#body#> } However, most patterns break the line only before closing brace, resulting in code like: namespace <#name#> { <#decls#> } While some (e.g. the 'for' example above) are breaking lines after the opening brace too. This change ensures all patterns consistently break after the opening brace, this leads to nicer UX when using those in an actual editor. Reviewers: gribozavr Reviewed By: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62405 llvm-svn: 361829
* [CodeComplete] Complete 'return true/false' in boolean functionsIlya Biryukov2019-05-271-2/+15
| | | | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62391 llvm-svn: 361753
* [CodeComplete] Add whitespace around braces in lambda completionsIlya Biryukov2019-05-241-5/+5
| | | | | | | This produces nicer output. Trivial follow-up to r361461, so sending without review. llvm-svn: 361645
* [CodeComplete] Filter override completions by function nameIlya Biryukov2019-05-241-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | Summary: We put only part of the signature starting with a function name into "typed text" chunks now, previously the whole signature was "typed text". This leads to meaningful fuzzy match scores, giving better signals to compare with other completion items. Ideally, we would not display the result type to the user, but that requires adding a new kind of completion chunk. Reviewers: kadircet Reviewed By: kadircet Subscribers: jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62298 llvm-svn: 361623
* [CodeComplete] Only show lambda completions if patterns are requestedIlya Biryukov2019-05-231-0/+9
| | | | | | This is a trivial follow-up to r361461, so sending without review. llvm-svn: 361510
* [CodeComplete] Complete a lambda when preferred type is a functionIlya Biryukov2019-05-231-0/+53
| | | | | | | | | | | | | | | | Summary: Uses a heuristic to detect std::function and friends. Reviewers: kadircet Reviewed By: kadircet Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62238 llvm-svn: 361461
* [CodeComplete] Complete enumerators when preferred type is an enumIlya Biryukov2019-05-161-0/+24
| | | | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62010 llvm-svn: 360912
* [CodeComplete] Add a trailing semicolons to some pattern completionsIlya Biryukov2019-05-063-19/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Where semicolon is required in any case. Here's a list of completions that now have a semicolon: - namespace <name> = <target>; - using namespace <name>; - using <qualifier>::<name>; - continue; - break; - goto <label>; - return; - return <expression>; Reviewers: gribozavr Reviewed By: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61589 llvm-svn: 360042
* Support framework import/include auto-completionDavid Goldman2019-02-271-0/+29
| | | | | | | | | | | | | | Frameworks filesystem representations: UIKit.framework/Headers/%header% Framework import format: #import <UIKit/%header%> Thus the completion code must map the input format of <UIKit/> to the path of UIKit.framework/Headers as well as strip the ".framework" suffix when auto-completing the framework name. llvm-svn: 355008
* [NFC] Explicitly add -std=c++14 option to tests that rely on the C++14 defaultNemanja Ivanovic2019-02-052-2/+2
| | | | | | | | | | | When Clang/LLVM is built with the CLANG_DEFAULT_STD_CXX CMake macro that sets the default standard to something other than C++14, there are a number of lit tests that fail as they rely on the C++14 default. This patch just adds the language standard option explicitly to such test cases. Differential revision: https://reviews.llvm.org/D57581 llvm-svn: 353163
* [CodeComplete] [clangd] Fix crash on ValueDecl with a null typeIlya Biryukov2019-01-241-0/+8
| | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D57093 llvm-svn: 352040
* Refactor the way we handle diagnosing unused expression results.Aaron Ballman2019-01-041-1/+1
| | | | | | | | Rather than sprinkle calls to DiagnoseUnusedExprResult() around in places where we want diagnostics, we now diagnose unused expression statements and full expressions in a more generic way when acting on the final expression statement. This results in more appropriate diagnostics for [[nodiscard]] where we were previously lacking them, such as when the body of a for loop is not a compound statement. This patch fixes PR39837. llvm-svn: 350404
* [CodeComplete] Properly determine qualifiers of 'this' in a lambdaIlya Biryukov2018-12-191-0/+21
| | | | | | | | | | | | | | | | | Summary: The clang used to pick up the qualifiers of the lamba's call operator (which is always const) and fail to show non-const methods of 'this' in completion results. Reviewers: kadircet Reviewed By: kadircet Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55885 llvm-svn: 349655
* [CodeComplete] Set preferred type to bool on conditionsIlya Biryukov2018-12-131-0/+15
| | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55431 llvm-svn: 349050
* Pass PartialOverloading argument to the correct corresponding parameterEric Fiselier2018-12-111-0/+16
| | | | llvm-svn: 348864
* [CodeComplete] Fix assertion failureIlya Biryukov2018-12-071-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: ...that fires when running completion inside an argument of UnresolvedMemberExpr (see the added test). The assertion that fires is from Sema::TryObjectArgumentInitialization: assert(FromClassification.isLValue()); This happens because Sema::AddFunctionCandidates does not account for object types which are pointers. It ends up classifying them incorrectly. All usages of the function outside code completion are used to run overload resolution for operators. In those cases the object type being passed is always a non-pointer type, so it's not surprising the function did not expect a pointer in the object argument. However, code completion reuses the same function and calls it with the object argument coming from UnresolvedMemberExpr, which can be a pointer if the member expr is an arrow ('->') access. Extending AddFunctionCandidates to allow pointer object types does not seem too crazy since all the functions down the call chain can properly handle pointer object types if we properly classify the object argument as an l-value, i.e. the classification of the implicitly dereferenced pointer. Reviewers: kadircet Reviewed By: kadircet Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55331 llvm-svn: 348590
* [CodeComplete] Fix a crash in access checks of inner classesIlya Biryukov2018-12-051-0/+49
| | | | | | | | | | | | | | Summary: The crash was introduced in r348135. Reviewers: kadircet Reviewed By: kadircet Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55260 llvm-svn: 348387
* [CodeComplete] Cleanup access checking in code completionIlya Biryukov2018-12-032-0/+96
| | | | | | | | | | | | | | Summary: Also fixes a crash (see the added 'accessibility-crash.cpp' test). Reviewers: ioeric, kadircet Reviewed By: kadircet Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55124 llvm-svn: 348135
* [CodeComplete] Penalize inherited ObjC properties for auto-completionSam McCall2018-11-201-2/+2
| | | | | | | | | | | | | | | | | | | | | Summary: Similar to auto-completion for ObjC methods, inherited properties should be penalized / direct class and category properties should be prioritized. Note that currently, the penalty for using a result from a base class (CCD_InBaseClass) is equal to the penalty for using a method as a property (CCD_MethodAsProperty). Reviewers: jkorous, sammccall, akyrtzi, arphaman, benlangmuir Reviewed By: sammccall, akyrtzi Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53900 llvm-svn: 347352
* [CodeComplete] Do not complete self-initializationsIlya Biryukov2018-11-073-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Removes references to initialized variable from the following completions: int x = ^; Handles only the trivial cases where the variable name is completed immediately at the start of initializer or assignment, more complicated cases aren't covered, e.g. these completions still contain 'x': // More complicated expressions. int x = foo(^); int x = 10 + ^; // Other kinds of initialization. int x{^}; int x(^); // Constructor initializers. struct Foo { Foo() : x(^) {} int x; }; We should address those in the future, but they are outside of the scope of this initial change. Reviewers: sammccall Reviewed By: sammccall Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D54156 llvm-svn: 346301
* [clang] Improve ctor initializer completions.Kadir Cetinkaya2018-11-011-30/+45
| | | | | | | | | | | | | | | | Summary: Instead of providing generic "args" for member and base class initializers, tries to fetch relevant constructors and show their signatures. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: ZaMaZaN4iK, eraman, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53654 llvm-svn: 345844
* [CodeComplete] Expose InBaseClass signal in code completion results.Eric Liu2018-10-242-36/+36
| | | | | | | | | | | | | | | | | Summary: No new tests as the existing tests for result priority should give us coverage. Also as the new flag is trivial enough, I'm reluctant to plumb the flag to c-index-test output. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D53635 llvm-svn: 345135
* [CodeComplete] Fix crash when completing params function declarations.Sam McCall2018-10-101-0/+5
| | | | | | | | | | | | | | | | | | Summary: In a decl like `int AA(BB cc)` where BB isn't defined, we end up trying to parse `BB cc` as an expression (vexing parse) and end up triggering the parser's "recovery-in-function" completion with no actual function scope. This patch avoids the assumption that such a scope exists in this context. Reviewers: kadircet Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D53070 llvm-svn: 344133
* [clang] Implement Override Suggestions in Sema.Kadir Cetinkaya2018-10-021-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: In clangd we had a new type of completion suggestions for cpp class/struct/unions that will show override signatures for virtual methods in base classes. This patch implements it in sema because it is hard to deduce more info about completion token outside of Sema and handle itchy cases. See the patch D50898 for more info on the functionality. In addition to above patch this one also converts the suggestion into a CK_Pattern with whole insertion text as the name of the suggestion and factors out CodeCompletionString generation for declerations so that it can be re-used by others. Reviewers: ioeric, ilya-biryukov Reviewed By: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52225 llvm-svn: 343568
* [CodeComplete] #include completion treats -I as non-system (require ↵Sam McCall2018-10-011-4/+10
| | | | | | header-like extension). llvm-svn: 343457
* [CodeComplete] Generate completion fix-its for C code as wellIvan Donchevskii2018-09-211-0/+19
| | | | | | | | | Current completion fix-its approach does not provide OtherOpBase for C code. But we can easily proceed in this case taking the original Base type. Differential Revision: https://reviews.llvm.org/D52261 llvm-svn: 342721
* [CodeComplete] Add completions for filenames in #include directives.Sam McCall2018-09-181-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: The dir component ("somedir" in #include <somedir/fo...>) is considered fixed. We append "foo" to each directory on the include path, and then list its files. Completions are of the forms: #include <somedir/fo^ foo.h> fox/ The filter is set to the filename part ("fo"), so fuzzy matching can be applied to the filename only. No fancy scoring/priorities are set, and no information is added to CodeCompleteResult to make smart scoring possible. Could be in future. Reviewers: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52076 llvm-svn: 342449
* [CodeCompletion] Enable signature help when initializing class/struct/union ↵Kadir Cetinkaya2018-09-111-0/+24
| | | | | | | | | | | | | | | | | | | | members. Summary: Factors out member decleration gathering and uses it in parsing to call signature help. Doesn't support signature help for base class constructors, the code was too coupled with diagnostic handling, but still can be factored out but just needs more afford. Reviewers: sammccall, ilya-biryukov, ioeric Reviewed By: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51917 llvm-svn: 341949
* [clang] Make sure codecompletion is called for calls even when inside a token.Kadir Cetinkaya2018-09-101-0/+27
| | | | | | | | | | | | | | | | | Summary: Currently CodeCompleteCall only gets called after a comma or parantheses. This patch makes sure it is called even at the cases like: ```foo(1^);``` Reviewers: ilya-biryukov, ioeric, hokein Reviewed By: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D51038 llvm-svn: 341824
* [CodeComplete] Clearly distinguish signature help and code completion.Ilya Biryukov2018-09-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Code completion in clang is actually a mix of two features: - Code completion is a familiar feature. Results are exposed via the CodeCompleteConsumer::ProcessCodeCompleteResults callback. - Signature help figures out if the current expression is an argument of some function call and shows corresponding signatures if so. Results are exposed via CodeCompleteConsumer::ProcessOverloadCandidates. This patch refactors the implementation to untangle those two from each other and makes some naming tweaks to avoid confusion when reading the code. The refactoring is required for signature help fixes, see D51038. The only intended behavior change is the order of callbacks. ProcessOverloadCandidates is now called before ProcessCodeCompleteResults. Reviewers: sammccall, kadircet Reviewed By: sammccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51782 llvm-svn: 341660
* [CodeComplete] Report location of opening parens for signature helpIlya Biryukov2018-08-301-0/+33
| | | | | | | | | | | | | | Summary: Used in clangd. Reviewers: sammccall Reviewed By: sammccall Subscribers: ioeric, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51436 llvm-svn: 341063
* [CodeComplete] Add a few extra tests for r333538. NFCIlya Biryukov2018-06-011-1/+19
| | | | | | | | | From a follow-up discussion in D44480. New tests check that function bodies are not skipped: - In presence of ptr declarators, e.g. `auto**`. - When `decltype(auto)` is used in return type, only `auto` was checked before. llvm-svn: 333735
* [Sema] Don't skip function bodies with 'auto' without trailing return typeIlya Biryukov2018-05-302-0/+70
| | | | | | | | | | | | | | | | | | Summary: Skipping them was clearly not intentional. It's impossible to guarantee correctness if the bodies are skipped. Also adds a test case for r327504, now that it does not produce invalid errors that made the test fail. Reviewers: aaron.ballman, sammccall, rsmith Reviewed By: rsmith Subscribers: rayglover-ibm, rwols, cfe-commits Differential Revision: https://reviews.llvm.org/D44480 llvm-svn: 333538
* Optionally add code completion results for arrow instead of dotIvan Donchevskii2018-05-251-0/+44
| | | | | | | | | | | | | Currently getting such completions requires source correction, reparsing and calling completion again. And if it shows no results and rollback is required then it costs one more reparse. With this change it's possible to get all results which can be later filtered to split changes which require correction. Differential Revision: https://reviews.llvm.org/D41537 llvm-svn: 333272
* [CodeComplete] Provide completion in decls even for incomplete typesIlya Biryukov2018-05-141-0/+13
| | | | | | | | | | | | | | | | | | | | Summary: This change fixes lack of completions in the following case ('^'designates completion points) : void f(^); struct Incomplete; Incomplete g(^); Reviewers: bkramer, aaron.ballman, sammccall Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D46639 llvm-svn: 332244
* [CodeComplete] Fix completion in the middle of ident in ctor lists.Ilya Biryukov2018-04-252-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The example that was broken before (^ designates completion points): class Foo { Foo() : fie^ld^() {} // no completions were provided here. int field; }; To fix it we don't cut off lexing after an identifier followed by code completion token is lexed. Instead we skip the rest of identifier and continue lexing. This is consistent with behavior of completion when completion token is right before the identifier. Reviewers: sammccall, aaron.ballman, bkramer, sepavloff, arphaman, rsmith Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D44932 llvm-svn: 330833
* [CodeComplete] Fix completion at the end of keywordsIlya Biryukov2018-04-249-16/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Make completion behave consistently no matter if it is run at the start, in the middle or at the end of an identifier that happens to be a keyword or a macro name. Since completion is often ran on incomplete identifiers, they may turn into keywords by accident. For example, we should produce same results for all of these completion points: // ^ is completion point. ^class cla^ss class^ Previously clang produced different results for the last case (as if the completion point was after a space: `class ^`). This change also updates some offsets in tests that (unintentionally?) relied on the old behavior. Reviewers: sammccall, bkramer, arphaman, aaron.ballman Reviewed By: sammccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D45887 llvm-svn: 330717
* [SemaOverload] Fixed crash on code completionIlya Biryukov2018-03-091-0/+8
| | | | | | | | | | | | | | | | | | Summary: The relevant failing assertion message is: ../tools/clang/lib/Sema/SemaInit.cpp:8411: PerformCopyInitialization(): Assertion `InitE && "No initialization expression?"' failed. See the added test case for a repro. Reviewers: bkramer, sammccall, ioeric, hokein Reviewed By: sammccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D44300 llvm-svn: 327134
OpenPOWER on IntegriCloud