summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/coroutines.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [coroutines] Fix diagnostics depending on the first coroutine statement.Eric Fiselier2017-03-111-0/+75
| | | | | | | | | | | | | | | | | | Summary: Some coroutine diagnostics need to point to the location of the first coroutine keyword in the function, like when diagnosing a `return` inside a coroutine. Previously we did this by storing each *valid* coroutine statement in a list and select the first one to use in diagnostics. However if every coroutine statement is invalid we would have no location to point to. This patch fixes the storage of the first coroutine statement location, ensuring that it gets stored even when the resulting AST node would be invalid. This patch also removes the `CoroutineStmts` list in `FunctionScopeInfo` because it was unused. Reviewers: rsmith, GorNishanov, aaron.ballman Reviewed By: GorNishanov Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D30776 llvm-svn: 297547
* [coroutines] Fix assertion in DependentCoawaitExpr when the argument is ↵Eric Fiselier2017-03-091-0/+6
| | | | | | | | | | | | | | | | | | | non-dependent. Summary: A `co_await arg` expression has a dependent type whenever the promise type is still dependent, even if the argument to co_await is not. This is because we cannot attempt the `await_transform(<arg>)` until after we know the promise type. This patch fixes an assertion in the constructor of `DependentCoawaitExpr` that asserted that `arg` must also be dependent. Reviewers: rsmith, GorNishanov, aaron.ballman Reviewed By: GorNishanov Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D30772 llvm-svn: 297358
* [coroutines] Build and pass coroutine_handle to await_suspendGor Nishanov2017-03-091-27/+53
| | | | | | | | | | | | | | | | Summary: This patch adds passing a coroutine_handle object to await_suspend calls. It builds the coroutine_handle using coroutine_handle<PromiseType>::from_address(__builtin_coro_frame()). (a revision of https://reviews.llvm.org/D26316 that for some reason refuses to apply via arc patch) Reviewers: GorNishanov Subscribers: mehdi_amini, cfe-commits, EricWF Differential Revision: https://reviews.llvm.org/D30769 llvm-svn: 297356
* [coroutines] Add DependentCoawaitExpr and fix re-building CoroutineBodyStmt.Eric Fiselier2017-03-061-5/+154
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: The changes contained in this patch are: 1. Defines a new AST node `CoawaitDependentExpr` for representing co_await expressions while the promise type is still dependent. 2. Correctly detect and transform the 'co_await' operand to `p.await_transform(<expr>)` when possible. 3. Change the initial/final suspend points to build during the initial parse, so they have the correct operator co_await lookup results. 4. Fix transformation of the CoroutineBodyStmt so that it doesn't re-build the final/initial suspends. @rsmith: This change is a little big, but it's not trivial for me to split it up. Please let me know if you would prefer this submitted as multiple patches. Reviewers: rsmith, GorNishanov Reviewed By: rsmith Subscribers: ABataev, rsmith, mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D26057 llvm-svn: 297093
* [coroutines] Improve diagnostics when building implicit constructs.Eric Fiselier2017-03-061-9/+6
| | | | | | | | | | Previously when a coroutine was building the implicit setup/destroy constructs it would emit diagostics about failures on the first co_await/co_return/co_yield it encountered. This was confusing because that construct may not itself be ill-formed. This patch moves the diagnostics to the function start instead. llvm-svn: 297089
* [coroutines] NFC: Refactor Sema::CoroutineBodyStmt construction.Gor Nishanov2017-02-131-1/+1
| | | | | | | | | | | | | | | | | | | Summary: Sema::CheckCompletedCoroutineBody was growing unwieldy with building all of the substatements. Also, constructors for CoroutineBodyStmt had way too many parameters. Instead, CoroutineBodyStmt now defines CtorArgs structure with all of the required construction parameters. CheckCompleteCoroutineBody delegates construction of individual substatements to short functions one per each substatement. Also, added a drive-by fix of initializing CoroutinePromise to nullptr in ScopeInfo.h. And addressed the FIXME that wanted to tail allocate extra room at the end of the CoroutineBodyStmt to hold parameter move expressions. (The comment was longer that the code that implemented tail allocation). Reviewers: rsmith, EricWF Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D28835 llvm-svn: 294933
* [coroutines] Sema: Allow co_return all by itself.Gor Nishanov2017-01-101-2/+1
| | | | | | | | | | Reviewers: rsmith, EricWF Subscribers: mehdi_amini, llvm-commits, EricWF Differential Revision: https://reviews.llvm.org/D26038 llvm-svn: 291513
* [coroutines] Add diagnostics for copy/move assignment operators and ↵Eric Fiselier2016-10-271-4/+21
| | | | | | | | | | | | | | functions with deduced return types. Summary: The title says it all. Additionally this patch refactors the diagnostic code into a separate function. Reviewers: GorNishanov, rsmith Subscribers: majnemer, mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D25292 llvm-svn: 285331
* [coroutines] Build fallthrough and set_exception statements.Eric Fiselier2016-10-271-3/+41
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch adds semantic checking and building of the fall-through `co_return;` statement as well as the `p.set_exception(std::current_exception())` call for handling uncaught exceptions. The fall-through statement is built and checked according to: > [dcl.fct.def.coroutine]/4 > The unqualified-ids return_void and return_value are looked up in the scope of class P. If > both are found, the program is ill-formed. If the unqualified-id return_void is found, flowing > off the end of a coroutine is equivalent to a co_return with no operand. Otherwise, flowing off > the end of a coroutine results in undefined behavior. Similarly the `set_exception` call is only built when that unqualified-id is found in the scope of class P. Additionally this patch adds fall-through warnings for non-void returning coroutines. Since it's surprising undefined behavior I thought it would be important to add the warning right away. Reviewers: majnemer, GorNishanov, rsmith Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D25349 llvm-svn: 285271
* [coroutines] Fix co_return statement for initializer list argumentsEric Fiselier2016-10-061-5/+19
| | | | | | | | | | | | | | | Summary: Previously the statement `co_return {42}` would be transformed into `P.return_void()`, since the type of `{42}` is represented as `void` by Clang. This patch fixes the bug by checking for `InitListExpr` arguments and transforming them accordingly. Reviewers: majnemer, GorNishanov, rsmith Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D25296 llvm-svn: 283495
* [coroutines] Switch to using std::experimental namespace per P0057R5Gor Nishanov2016-10-041-19/+34
| | | | | | | | | | | | | | Summary: Look for coroutine_traits and friends in std::experimental namespace. Patch (mostly) by EricWF. Reviewers: cfe-commits, EricWF, rsmith Subscribers: majnemer, mehdi_amini Differential Revision: https://reviews.llvm.org/D25068 llvm-svn: 283170
* [coroutines] Rename driver flag -fcoroutines to -fcoroutines-tsGor Nishanov2016-10-021-1/+1
| | | | | | | | | | | | | | | Summary: Also makes -fcoroutines_ts to be both a Driver and CC1 flag. Patch mostly by EricWF. Reviewers: rnk, cfe-commits, rsmith, EricWF Subscribers: mehdi_amini Differential Revision: https://reviews.llvm.org/D25130 llvm-svn: 283064
* [coroutines] Diagnose when 'main' is declared as a coroutine.Eric Fiselier2016-09-301-0/+8
| | | | | | | | | | | | Summary: The title says it all. Reviewers: rsmith, GorNishanov Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D25078 llvm-svn: 282973
* [Coroutines] Fix assertion about uncorrected typos in ↵Eric Fiselier2016-09-291-0/+17
| | | | | | co_await/co_yield/co_return expressions llvm-svn: 282792
* [coroutines] Build a CoroutineBodyStmt when finishing parsing a coroutine, ↵Richard Smith2015-11-241-1/+74
| | | | | | and form the initial_suspend, final_suspend, and get_return_object calls. llvm-svn: 253946
* [coroutines] Check for overload sets in co_yield / co_return operands being ↵Richard Smith2015-11-221-8/+28
| | | | | | resolved by a call to yield_value / return_value before rejecting them. llvm-svn: 253817
* [coroutines] Build implicit return_value / return_void calls for co_return.Richard Smith2015-11-221-0/+13
| | | | llvm-svn: 253816
* [coroutines] Factor out co_await representation into common base class for ↵Richard Smith2015-11-221-0/+5
| | | | | | co_await and co_yield, and use it to hold await_* calls. llvm-svn: 253811
* [coroutines] Better handling of placeholder types.Richard Smith2015-11-201-0/+15
| | | | llvm-svn: 253731
* [coroutines] Support braced-init-list as operand of co_yield expression.Richard Smith2015-11-201-2/+5
| | | | llvm-svn: 253726
* [coroutines] Synthesize yield_value call for co_yield.Richard Smith2015-11-201-1/+19
| | | | llvm-svn: 253725
* [coroutines] Per latest wording paper, co_* are no longer permitted in anyRichard Smith2015-11-201-2/+11
| | | | | | unevaluated operands. llvm-svn: 253641
* [coroutines] Tweak diagnostics to always use fully-qualified name for ↵Richard Smith2015-11-191-1/+6
| | | | | | std::coroutine_traits. llvm-svn: 253535
* [coroutines] Creation of promise object, lookup of operator co_await, buildingRichard Smith2015-10-271-16/+72
| | | | | | of await_* calls, and AST representation for same. llvm-svn: 251387
* [coroutines] Initial stub Sema functionality for handling coroutine await / ↵Richard Smith2015-10-221-0/+51
yield / return. llvm-svn: 250993
OpenPOWER on IntegriCloud