summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCodeComplete.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Concepts] Type ConstraintsSaar Raz2020-01-151-1/+5
| | | | | | | Add support for type-constraints in template type parameters. Also add support for template type parameters as pack expansions (where the type constraint can now contain an unexpanded parameter pack). Differential Revision: https://reviews.llvm.org/D44352
* Fix "pointer is null" static analyzer warnings. NFCI.Simon Pilgrim2020-01-111-6/+6
| | | | Use castAs<> instead of getAs<> since the pointers are dereferenced immediately and castAs will perform the null assertion for us.
* [CodeComplete] Suggest 'return nullptr' in functions returning pointersIlya Biryukov2020-01-101-0/+7
| | | | | | | | | | Reviewers: kadircet Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72497
* [Sema] Fixes -Wrange-loop-analysis warningsMark de Wever2019-12-171-1/+1
| | | | | | This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall. Differential Revision: https://reviews.llvm.org/D71529
* [clangd] Show lambda signature for lambda autocompletionsKirill Bobyrev2019-11-221-3/+27
| | | | | | | | | | | | | | | | | | | | | | | | 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
* [CGDebugInfo] Emit subprograms for decls when AT_tail_call is understood ↵Vedant Kumar2019-11-191-14/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (reland with fixes) Currently, clang emits subprograms for declared functions when the target debugger or DWARF standard is known to support entry values (DW_OP_entry_value & the GNU equivalent). Treat DW_AT_tail_call the same way to allow debuggers to follow cross-TU tail calls. Pre-patch debug session with a cross-TU tail call: ``` * frame #0: 0x0000000100000fa4 main`target at b.c:4:3 [opt] frame #1: 0x0000000100000f99 main`main at a.c:8:10 [opt] ``` Post-patch (note that the tail-calling frame, "helper", is visible): ``` * frame #0: 0x0000000100000fa4 main`target at b.c:4:3 [opt] frame #1: 0x0000000100000f80 main`helper [opt] [artificial] frame #2: 0x0000000100000f99 main`main at a.c:8:10 [opt] ``` This was reverted in 5b9a072c because it attached declaration subprograms to inlinable builtin calls, which interacted badly with the MergeICmps pass. The fix is to not attach declarations to builtins. rdar://46577651 Differential Revision: https://reviews.llvm.org/D69743
* [CodeComplete] Constructor overload candidates report as vector(int) instead ↵Sam McCall2019-11-151-0/+4
| | | | | | | | | | | | | | | | | | | 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
* [clangd] Do not insert parentheses when completing a using declarationIlya Biryukov2019-10-281-17/+16
| | | | | | | | | | | | | | | | | | 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
* [CodeComplete] Ensure object is the same in compareOverloads()Ilya Biryukov2019-10-041-0/+3
| | | | | | | | | | | | | | | | | | 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
* [CodeComplete] Fix ASTUnit cached completion of macros from preamble, broken ↵Sam McCall2019-07-181-4/+2
| | | | | | | | | | | | | | | | | | in r342528 Summary: The problem is the default LoadExternal with no completer, which happens when loading global results. Reviewers: ilya-biryukov, nik Subscribers: arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64864 llvm-svn: 366409
* Fix parameter name comments using clang-tidy. NFC.Rui Ueyama2019-07-161-5/+5
| | | | | | | | | | | | | | | | | | | | | This patch applies clang-tidy's bugprone-argument-comment tool to LLVM, clang and lld source trees. Here is how I created this patch: $ git clone https://github.com/llvm/llvm-project.git $ cd llvm-project $ mkdir build $ cd build $ cmake -GNinja -DCMAKE_BUILD_TYPE=Debug \ -DLLVM_ENABLE_PROJECTS='clang;lld;clang-tools-extra' \ -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLLVM_ENABLE_LLD=On \ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ../llvm $ ninja $ parallel clang-tidy -checks='-*,bugprone-argument-comment' \ -config='{CheckOptions: [{key: StrictMode, value: 1}]}' -fix \ ::: ../llvm/lib/**/*.{cpp,h} ../clang/lib/**/*.{cpp,h} ../lld/**/*.{cpp,h} llvm-svn: 366177
* Use getOperatorSpelling to get the spelling of an overloaded operatorRichard Smith2019-06-141-2/+3
| | | | | | rather than duplicating operator name tables in multiple places. llvm-svn: 363446
* Re-land "[CodeComplete] Improve overload handling for C++ qualified and ↵Sam McCall2019-06-101-20/+121
| | | | | | | | 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-112/+20
| | | | | | | | 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-20/+112
| | | | | | | | 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-111/+14
| | | | | | | | | | 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-14/+111
| | | | | | | | | | | | | | | | | | | | | 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-041-12/+4
| | | | | | | | | | | | | | | | | | | | | | | | 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-031-0/+17
| | | | | | | | | | | | | | | | | | | | 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-291-0/+2
| | | | | | | | | 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] Set preferred type for qualified-idIlya Biryukov2019-05-281-5/+11
| | | | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62514 llvm-svn: 361838
* [CodeComplete] Consistently break after '{' in multi-line patternsIlya Biryukov2019-05-281-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-11/+26
| | | | | | | | | | | | | | 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-0/+3
| | | | | | | 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-18/+29
| | | | | | | | | | | | | | | | | | | | | | | | 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/+2
| | | | | | 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/+71
| | | | | | | | | | | | | | | | 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-21/+44
| | | | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62010 llvm-svn: 360912
* [c++20] Add support for explicit(bool), as described in P0892R2.Richard Smith2019-05-091-1/+2
| | | | | | | | Patch by Tyker! Differential Revision: https://reviews.llvm.org/D60934 llvm-svn: 360311
* [CodeComplete] Add a trailing semicolons to some pattern completionsIlya Biryukov2019-05-061-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert r359949 "[clang] adding explicit(bool) from c++2a"Hans Wennborg2019-05-061-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This caused Clang to start erroring on the following: struct S {   template <typename = int> explicit S(); }; struct T : S {}; struct U : T {   U(); }; U::U() {} $ clang -c /tmp/x.cc /tmp/x.cc:10:4: error: call to implicitly-deleted default constructor of 'T' U::U() {}    ^ /tmp/x.cc:5:12: note: default constructor of 'T' is implicitly deleted because base class 'S' has no default constructor struct T : S {};            ^ 1 error generated. See discussion on the cfe-commits email thread. This also reverts the follow-ups r359966 and r359968. > this patch adds support for the explicit bool specifier. > > Changes: > - The parsing for the explicit(bool) specifier was added in ParseDecl.cpp. > - The storage of the explicit specifier was changed. the explicit specifier was stored as a boolean value in the FunctionDeclBitfields and in the DeclSpec class. now it is stored as a PointerIntPair<Expr*, 2> with a flag and a potential expression in CXXConstructorDecl, CXXDeductionGuideDecl, CXXConversionDecl and in the DeclSpec class. > - Following the AST change, Serialization, ASTMatchers, ASTComparator and ASTPrinter were adapted. > - Template instantiation was adapted to instantiate the potential expressions of the explicit(bool) specifier When instantiating their associated declaration. > - The Add*Candidate functions were adapted, they now take a Boolean indicating if the context allowing explicit constructor or conversion function and this boolean is used to remove invalid overloads that required template instantiation to be detected. > - Test for Semantic and Serialization were added. > > This patch is not yet complete. I still need to check that interaction with CTAD and deduction guides is correct. and add more tests for AST operations. But I wanted first feedback. > Perhaps this patch should be spited in smaller patches, but making each patch testable as a standalone may be tricky. > > Patch by Tyker > > Differential Revision: https://reviews.llvm.org/D60934 llvm-svn: 360024
* [clang] adding explicit(bool) from c++2aNicolas Lesser2019-05-041-2/+4
| | | | | | | | | | | | | | | | | | | | | this patch adds support for the explicit bool specifier. Changes: - The parsing for the explicit(bool) specifier was added in ParseDecl.cpp. - The storage of the explicit specifier was changed. the explicit specifier was stored as a boolean value in the FunctionDeclBitfields and in the DeclSpec class. now it is stored as a PointerIntPair<Expr*, 2> with a flag and a potential expression in CXXConstructorDecl, CXXDeductionGuideDecl, CXXConversionDecl and in the DeclSpec class. - Following the AST change, Serialization, ASTMatchers, ASTComparator and ASTPrinter were adapted. - Template instantiation was adapted to instantiate the potential expressions of the explicit(bool) specifier When instantiating their associated declaration. - The Add*Candidate functions were adapted, they now take a Boolean indicating if the context allowing explicit constructor or conversion function and this boolean is used to remove invalid overloads that required template instantiation to be detected. - Test for Semantic and Serialization were added. This patch is not yet complete. I still need to check that interaction with CTAD and deduction guides is correct. and add more tests for AST operations. But I wanted first feedback. Perhaps this patch should be spited in smaller patches, but making each patch testable as a standalone may be tricky. Patch by Tyker Differential Revision: https://reviews.llvm.org/D60934 llvm-svn: 359949
* Use llvm::stable_sortFangrui Song2019-04-241-16/+13
| | | | llvm-svn: 359098
* [CodeComplete] Fix crash when completing ObjC block parameter with a broken typeSam McCall2019-04-041-0/+5
| | | | | | | | | | | | | | | | | | | Summary: The fix isn't great, but it's hard to fix properly because the completion code sensibly uses ParmVarDecl to represent parameters, but the AST-building code sensibly doesn't synthesize them if the type is broken. Also this case is apparently really rare, so it's probably not worth bending over backwards for. Reviewers: ilya-biryukov Subscribers: javed.absar, kristof.beyls, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60258 llvm-svn: 357686
* Basic: Return a reference from FileManager::getVirtualFileSystem, NFCDuncan P. N. Exon Smith2019-03-261-2/+3
| | | | | | | | | | FileManager constructs a VFS in its constructor if it isn't passed one, and there's no way to reset it. Make that contract clear by returning a reference from its accessor. https://reviews.llvm.org/D59388 llvm-svn: 357038
* [Sema][NFCI] Don't allocate storage for the various ↵Bruno Ricci2019-03-251-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CorrectionCandidateCallback unless we are going to do some typo correction The various CorrectionCandidateCallbacks are currently heap-allocated unconditionally. This was needed because of delayed typo correction. However these allocations represent currently 15.4% of all allocations (number of allocations) when parsing all of Boost (!), mostly because of ParseCastExpression, ParseStatementOrDeclarationAfterAttrtibutes and isCXXDeclarationSpecifier. Note that all of these callback objects are small. Let's not do this. Instead initially allocate the callback on the stack, and only do a heap allocation if we are going to do some typo correction. Do this by: 1. Adding a clone function to each callback, which will do a polymorphic clone of the callback. This clone function is required to be implemented by every callback (of which there is a fair amount). Make sure this is the case by making it pure virtual. 2. Use this clone function when we are going to try to correct a typo. This additionally cut the time of -fsyntax-only on all of Boost by 0.5% (not that much, but still something). No functional changes intended. Differential Revision: https://reviews.llvm.org/D58827 Reviewed By: rnk llvm-svn: 356925
* Support framework import/include auto-completionDavid Goldman2019-02-271-6/+28
| | | | | | | | | | | | | | 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
* [CodeComplete] Propagate preferred type for function arguments in more casesIlya Biryukov2019-02-261-2/+22
| | | | | | | | | | | | | | | | | | | | | Summary: See the added test for some new cases. This change also removes special code completion calls inside the ParseExpressionList function now that we properly propagate expected type to the function responsible for parsing elements of the expression list (ParseAssignmentExpression). Reviewers: kadircet Reviewed By: kadircet Subscribers: xbolva00, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58541 llvm-svn: 354864
* [CodeComplete] Collect visited contexts when scope specifier is invalid.Eric Liu2019-02-211-1/+14
| | | | | | | | | | | | | | | | | Summary: This will allow completion consumers to guess the specified scope by putting together scopes in the context with the specified scope (e.g. when the specified namespace is not imported yet). Reviewers: ilya-biryukov Subscribers: jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58446 llvm-svn: 354570
* Make some helper functions static. NFC.Benjamin Kramer2019-02-111-2/+2
| | | | llvm-svn: 353705
* [CodeComplete] Propagate preferred types through parser in more casesIlya Biryukov2019-01-311-112/+199
| | | | | | | | | | | | | | Preferred types are used by code completion for ranking. This commit considerably increases the number of points in code where those types are propagated. In order to avoid complicating signatures of Parser's methods, a preferred type is kept as a member variable in the parser and updated during parsing. Differential revision: https://reviews.llvm.org/D56723 llvm-svn: 352788
* Rename getTypeQualifiers to getMethodQualifiers.Anastasia Stulova2019-01-281-5/+5
| | | | | | | | Use more descriptive name for the method qualifiers getter. Differential Revision: https://reviews.llvm.org/D56792 llvm-svn: 352349
* [CodeComplete] [clangd] Fix crash on ValueDecl with a null typeIlya Biryukov2019-01-241-1/+2
| | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D57093 llvm-svn: 352040
* 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
* [Sema][NFC] Fix Wimplicit-fallthrough warning in getCursorKindForDeclBruno Ricci2018-12-211-0/+1
| | | | | | All cases are covered so add an llvm_unreachable. NFC. llvm-svn: 349933
* [CodeComplete] Properly determine qualifiers of 'this' in a lambdaIlya Biryukov2018-12-191-5/+3
| | | | | | | | | | | | | | | | | 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] Temporarily disable failing assertionIlya Biryukov2018-12-131-1/+2
| | | | | | | | | Found the case in the clang codebase where the assertion fires. To avoid crashing assertion-enabled builds before I re-add the missing operation. Will restore the assertion alongside the upcoming fix. llvm-svn: 349061
* [CodeComplete] Fill preferred type on binary expressionsIlya Biryukov2018-12-131-3/+80
| | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D55648 llvm-svn: 349053
* [CodeComplete] Set preferred type to bool on conditionsIlya Biryukov2018-12-131-2/+4
| | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55431 llvm-svn: 349050
* [OpenCL] Add generic AS to 'this' pointerMikael Nilsson2018-12-131-7/+5
| | | | | | | | | | | | | Address spaces are cast into generic before invoking the constructor. Added support for a trailing Qualifiers object in FunctionProtoType. Note: This recommits the previously reverted patch, but now it is commited together with a fix for lldb. Differential Revision: https://reviews.llvm.org/D54862 llvm-svn: 349019
OpenPOWER on IntegriCloud