This is an archive of the discontinued LLVM Phabricator instance.

[coroutines] Fix building of new/delete expressions when get_return_object_on_allocation_failure() is present.
ClosedPublic

Authored by EricWF on Mar 31 2017, 7:07 PM.

Details

Summary

This patch implements [dcl.fct.def.coroutine]p8:

The unqualified-id get_return_object_on_allocation_failure is looked up in the scope of
class P by class member access lookup (3.4.5). If a declaration is found, ..., and if a
global allocation function is selected, the ::operator new(size_t, nothrow_t) form shall be used.
[...]
The allocation function used in this case must have a non-throwing noexcept-specification.

Diff Detail

Event Timeline

EricWF created this revision.Mar 31 2017, 7:07 PM
EricWF added a subscriber: cfe-commits.
EricWF updated this revision to Diff 93737.Mar 31 2017, 7:21 PM
  • general cleanup.
EricWF updated this revision to Diff 93739.Mar 31 2017, 7:25 PM
  • Remove incorrectly added changes.

Note that this patch is built on top of D31487 and not trunk.

EricWF updated this revision to Diff 93742.Apr 1 2017, 12:17 AM
  • Actually remove incorrectly added changes.
This revision is now accepted and ready to land.Apr 1 2017, 7:32 PM
EricWF updated this revision to Diff 93939.Apr 3 2017, 2:00 PM
  • Merge with master
  • Fix coro-alloc.cpp test so that it declares new.
  • Add FIXME comment regarding assertion about an MaybeODRUsedExpr that hasn't been correctly handled. (the VarDecl for std::nothrow is broken).
EricWF planned changes to this revision.Apr 3 2017, 2:08 PM

This patch currently triggers an assertion in SemaDecl.cpp:12290 assert(MaybeODRUseExprs.empty() && "Leftover expressions for odr-use checking");

I'll have to come up with a fix for that before this is committed. Unfortunately the easy fix of calling MakeVarDeclReferenced or similar doesn't work. I suspect this is due to the current active scope when ActOnFinishFunctionBody is called.

EricWF updated this revision to Diff 95074.Apr 12 2017, 6:40 PM
  • Add call to MarkDeclRefReferenced even though it doesn't prevent the assertion.
This revision is now accepted and ready to land.Apr 12 2017, 6:40 PM
EricWF added inline comments.Apr 12 2017, 6:41 PM
lib/Sema/SemaCoroutine.cpp
680

@rsmith is this the correct way to build a DeclRefExpr to an existing global?

GorNishanov added inline comments.Apr 13 2017, 6:13 AM
lib/Sema/CoroutineBuilder.h
1 ↗(On Diff #95074)

This file is called:

CoroutineStmtBuilder.h

in trunk

14 ↗(On Diff #95074)
#ifndef LLVM_CLANG_LIB_SEMA_COROUTINESTMTBUILDER_H
#define LLVM_CLANG_LIB_SEMA_COROUTINESTMTBUILDER_H
EricWF marked an inline comment as done.Apr 15 2017, 2:44 PM
EricWF added inline comments.
lib/Sema/CoroutineBuilder.h
1 ↗(On Diff #95074)

Woops, this file should have been deleted.

EricWF updated this revision to Diff 95382.Apr 15 2017, 2:45 PM
EricWF marked an inline comment as done.
  • Fix MaybeODRUseExprs assertion.
  • Remove mistakenly present CoroutineBuilder.h file.

I'll land this later today if there are no objections.

EricWF closed this revision.Apr 16 2017, 2:32 AM
EricWF reopened this revision.Apr 17 2017, 5:06 PM

Re-opening since the last commit had to be reverted.

This revision is now accepted and ready to land.Apr 17 2017, 5:08 PM
EricWF updated this revision to Diff 95511.Apr 17 2017, 5:09 PM
  • Update so it merges against master.
EricWF closed this revision.Apr 17 2017, 8:25 PM