r250991 - [coroutines] Add overloaded unary 'operator co_await'.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 21 22:12:22 PDT 2015
Author: rsmith
Date: Thu Oct 22 00:12:22 2015
New Revision: 250991
URL: http://llvm.org/viewvc/llvm-project?rev=250991&view=rev
Log:
[coroutines] Add overloaded unary 'operator co_await'.
Modified:
cfe/trunk/include/clang/Basic/OperatorKinds.def
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/Parser/cxx1z-coroutines.cpp
Modified: cfe/trunk/include/clang/Basic/OperatorKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OperatorKinds.def?rev=250991&r1=250990&r2=250991&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/OperatorKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OperatorKinds.def Thu Oct 22 00:12:22 2015
@@ -101,6 +101,7 @@ OVERLOADED_OPERATOR_MULTI(Subscript
// ?: can *not* be overloaded, but we need the overload
// resolution machinery for it.
OVERLOADED_OPERATOR_MULTI(Conditional , "?" , false, true , false)
+OVERLOADED_OPERATOR(Coawait , "co_await", kw_co_await , true , false, false)
#undef OVERLOADED_OPERATOR_MULTI
#undef OVERLOADED_OPERATOR
Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=250991&r1=250990&r2=250991&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Thu Oct 22 00:12:22 2015
@@ -1753,6 +1753,9 @@ CXXNameMangler::mangleOperatorName(Overl
// The conditional operator can't be overloaded, but we still handle it when
// mangling expressions.
case OO_Conditional: Out << "qu"; break;
+ // Proposal on cxx-abi-dev, 2015-10-21.
+ // ::= aw # co_await
+ case OO_Coawait: Out << "aw"; break;
case OO_None:
case NUM_OVERLOADED_OPERATORS:
Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=250991&r1=250990&r2=250991&view=diff
==============================================================================
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Thu Oct 22 00:12:22 2015
@@ -1046,6 +1046,14 @@ void MicrosoftCXXNameMangler::mangleOper
break;
}
+ case OO_Coawait: {
+ DiagnosticsEngine &Diags = Context.getDiags();
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+ "cannot mangle this operator co_await yet");
+ Diags.Report(Loc, DiagID);
+ break;
+ }
+
case OO_None:
case NUM_OVERLOADED_OPERATORS:
llvm_unreachable("Not an overloaded operator");
Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=250991&r1=250990&r2=250991&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Thu Oct 22 00:12:22 2015
@@ -854,6 +854,7 @@ static Stmt::StmtClass DecodeOperatorCal
case OO_Arrow:
case OO_Call:
case OO_Conditional:
+ case OO_Coawait:
case NUM_OVERLOADED_OPERATORS:
llvm_unreachable("Invalid operator call kind");
Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=250991&r1=250990&r2=250991&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Oct 22 00:12:22 2015
@@ -6385,6 +6385,7 @@ OMPClause *Sema::ActOnOpenMPReductionCla
case OO_Call:
case OO_Subscript:
case OO_Conditional:
+ case OO_Coawait:
case NUM_OVERLOADED_OPERATORS:
llvm_unreachable("Unexpected reduction identifier");
case OO_None:
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=250991&r1=250990&r2=250991&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Oct 22 00:12:22 2015
@@ -8228,6 +8228,7 @@ void Sema::AddBuiltinOperatorCandidates(
case OO_Array_New:
case OO_Array_Delete:
case OO_Call:
+ case OO_Coawait:
llvm_unreachable(
"Special operators don't use AddBuiltinOperatorCandidates");
Modified: cfe/trunk/test/Parser/cxx1z-coroutines.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx1z-coroutines.cpp?rev=250991&r1=250990&r2=250991&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx1z-coroutines.cpp (original)
+++ cfe/trunk/test/Parser/cxx1z-coroutines.cpp Thu Oct 22 00:12:22 2015
@@ -19,3 +19,17 @@ U f(T t) {
else
co_return {t};
}
+
+struct Y {};
+struct X { Y operator co_await(); };
+struct Z {};
+Y operator co_await(Z);
+
+void f(X x, Z z) {
+ x.operator co_await();
+ operator co_await(z);
+}
+
+void operator co_await(); // expected-error {{must have at least one parameter}}
+void operator co_await(X, Y, Z); // expected-error {{must be a unary operator}}
+void operator co_await(int); // expected-error {{parameter of class or enumeration type}}
More information about the cfe-commits
mailing list