[all-commits] [llvm/llvm-project] 627e01: [coroutines] Don't build promise init with no args
Brian Gesiak via All-commits
all-commits at lists.llvm.org
Thu Apr 2 18:45:01 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 627e01feb718dd1aa8e184545976b7229de312a2
https://github.com/llvm/llvm-project/commit/627e01feb718dd1aa8e184545976b7229de312a2
Author: Brian Gesiak <modocache at gmail.com>
Date: 2020-04-02 (Thu, 02 Apr 2020)
Changed paths:
M clang/lib/Sema/SemaCoroutine.cpp
Log Message:
-----------
[coroutines] Don't build promise init with no args
Summary:
In the case of a coroutine that takes no arguments,
`Sema::buildCoroutinePromise` constructs a list-initialization
(`clang::InitializationKind::InitKind::IK_DirectList`) of the
promise variable, using a list of empty arguments. So, if one were to
dump the promise `VarDecl` immediately after `Sema::ActOnCoroutineBodyStart`
calls `checkCoroutineContext`, for a coroutine function that takes no
arguments, they'd see the following:
```
VarDecl 0xb514490 <test.cpp:26:3> col:3 __promise '<dependent type>' callinit
`-ParenListExpr 0xb514510 <col:3> 'NULL TYPE'
```
But after this patch, the `ParenListExpr` is no longer constructed, and
the promise variable uses default initialization
(`clang::InitializationKind::InitKind::IK_Default`):
```
VarDecl 0x63100012dae0 <test.cpp:26:3> col:3 __promise '<dependent type>'
```
As far as I know, there's no case in which list-initialization with no
arguments differs from default initialization, but if I'm wrong please
let me know (and I'll add a test case that demonstrates the change --
but as-is I can't think of a functional test case for this). I think both
comply with the wording of C++20 `[dcl.fct.def.coroutine]p5`:
> _promise-constructor-arguments_ is determined as follows: overload
resolution is performed on a promise constructor call created by
assembling an argument list with lvalues `p1 ... pn`. If a viable
constructor is found (12.4.2), then _promise-constructor-arguments_
is `(p1, ... , pn)`, otherwise _promise-constructor-arguments_ is
empty.
Still, I think this patch is an improvement regardless, because it
reduces the size of the AST.
Reviewers: GorNishanov, rsmith, lewissbaker
Subscribers: EricWF, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D70555
More information about the All-commits
mailing list