This is an archive of the discontinued LLVM Phabricator instance.

[coroutines] Fix rebuilding of implicit and dependent coroutine statements.
ClosedPublic

Authored by EricWF on Mar 29 2017, 6:25 PM.

Details

Summary

Certain implicitly generated coroutine statements, such as the calls to 'return_value()' or return_void() or get_return_object_on_allocation_failure(), cannot be built until the promise type is no longer dependent. This means they are not built until after the coroutine body statement has been transformed.

This patch fixes an issue where these statements would never be built for coroutine templates.

It also fixes a small issue where diagnostics about get_return_object_on_allocation_failure() were incorrectly suppressed.

Diff Detail

Event Timeline

EricWF created this revision.Mar 29 2017, 6:25 PM
EricWF updated this revision to Diff 93441.Mar 29 2017, 7:35 PM
  • Remove unneeded asserts.
GorNishanov added inline comments.Mar 30 2017, 7:25 AM
lib/Sema/CoroutineBuilder.h
53 ↗(On Diff #93441)

makeReturnObject is built as $promise.get_return_object() should it be put into buildDependentStatements?

EricWF updated this revision to Diff 93508.Mar 30 2017, 11:17 AM
  • Fix insane definition of hasDependentPromiseType()
EricWF updated this revision to Diff 93510.Mar 30 2017, 12:24 PM
  • Remove incorrect comments.
EricWF added inline comments.Mar 30 2017, 12:43 PM
lib/Sema/CoroutineBuilder.h
53 ↗(On Diff #93441)

I don't think so because the statement is required, so we can build it right away and transform it later. The "dependent" statements are ones built different depending on the results of name lookup.

GorNishanov added inline comments.Apr 1 2017, 7:17 PM
lib/Sema/CoroutineBuilder.h
1 ↗(On Diff #93510)

I would name the file to match the class it declares, i.e CoroutineStmtBuilder.h, since it is the only class defined in this header.

9 ↗(On Diff #93510)

I do not think that this description matches the content of the file.

37 ↗(On Diff #93510)

I would move the constructor and two build methods implementations into SemaCoroutine.cpp.

lib/Sema/TreeTransform.h
6908 ↗(On Diff #93510)
if(Expr *OnFallthrough = ...) {
   ...getDerived().TransformStmt(OnFallthrough);
6915 ↗(On Diff #93510)
if(Expr *OnException = ...) {
   ...getDerived().TransformStmt(OnException);
6922 ↗(On Diff #93510)
if(Expr *OnAllocFailure = ...) {
   ...getDerived().TransformStmt(OnAllocFailure);
GorNishanov accepted this revision.Apr 3 2017, 12:10 PM

LGTM with nits addressed

This revision is now accepted and ready to land.Apr 3 2017, 12:10 PM
EricWF updated this revision to Diff 93917.Apr 3 2017, 12:31 PM
EricWF marked 6 inline comments as done.
  • Address inline comments.
EricWF closed this revision.Apr 3 2017, 12:33 PM
EricWF reopened this revision.Apr 17 2017, 1:43 PM

I have to revert this commit due to test failures. I think I uploaded an incorrect patch or bad merge because the tests passed on my machine.

This revision is now accepted and ready to land.Apr 17 2017, 1:43 PM
EricWF updated this revision to Diff 95501.Apr 17 2017, 3:18 PM
  • Upload new, hopefully correct, diff.
EricWF closed this revision.Apr 17 2017, 3:18 PM
EricWF reopened this revision.Apr 17 2017, 4:44 PM

re-opening because I had to revert the changes again. The tests are passing on my local machine but they're failing on the bots. I'm not exactly sure what's going on. Perhaps its UB caused by an uninitialized value? More investigation needed.

This revision is now accepted and ready to land.Apr 17 2017, 4:44 PM
EricWF updated this revision to Diff 95506.Apr 17 2017, 4:47 PM
  • Update against trunk.
EricWF closed this revision.Apr 17 2017, 5:06 PM

Woops, I've been updating the wrong patch. These updates should have been for D31562.