This is an archive of the discontinued LLVM Phabricator instance.

[clang] dependent co_return fix
Needs ReviewPublic

Authored by urnathan on May 13 2022, 6:04 AM.

Details

Summary

This addresses an issue with dependent co_return handling, and
preparation for PR55406's fix.

If the co_return type is not void, we'll look for return_value, but
if it's void, we'll look for return_void. Usually the promise type is
dependent, and no lookup is actually done. But, if it is
non-dependent, we'll do the lookup for return_value even when the type
is T. And then possibly emit an incorrect diagnostic.

We should only do the lookup when the types are non-dependent. This
is the only coroutine place where the name we look for depends on an
expression type.

Diff Detail

Event Timeline

urnathan created this revision.May 13 2022, 6:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2022, 6:04 AM
Herald added a subscriber: StephenFan. · View Herald Transcript
urnathan requested review of this revision.May 13 2022, 6:04 AM
MaskRay added inline comments.May 16 2022, 8:06 PM
clang/test/SemaCXX/coroutine-dep.cpp
45

Add a comment what this co_return checks.

46

Add a comment about what this NullStmt does.

MaskRay added inline comments.May 16 2022, 8:18 PM
clang/lib/Sema/SemaCoroutine.cpp
983

The condition Promise->getType()->isDependentType() is not covered by a test. Is it needed?

clang/test/SemaCXX/coroutine-dep.cpp
1

Other tests use *dependent* to indicate dependent types. It's unneeded to abbreviate it into dep.

55

Delete unneeded public:

ChuanqiXu added inline comments.May 16 2022, 8:50 PM
clang/lib/Sema/SemaCoroutine.cpp
980
clang/test/SemaCXX/coroutine-dep.cpp
1
3

nit: it could save some typings by #include "Inputs/std-coroutine.h"

urnathan updated this revision to Diff 430119.May 17 2022, 10:33 AM
urnathan marked 8 inline comments as done.

update

clang/lib/Sema/SemaCoroutine.cpp
983

existing tests cover that.

What's the reason you removed me as a reviewer? I don't think I did any thing bad.

clang/lib/Sema/SemaCoroutine.cpp
983

No. It doesn't. I've tried to remove the check and all the tests still pass.

urnathan marked an inline comment as done.May 18 2022, 4:12 AM
urnathan added inline comments.
clang/lib/Sema/SemaCoroutine.cpp
983

correct.