================
@@ -15811,6 +15813,32 @@ static void diagnoseImplicitlyRetainedSelf(Sema &S) {
           << FixItHint::CreateInsertion(P.first, "self->");
 }
 
+// Return whether FD is `promise_type::get_return_object`.
+bool isGetReturnObject(FunctionDecl *FD) {
+  if (!FD->getDeclName().isIdentifier() ||
+      !FD->getName().equals("get_return_object") || !FD->param_empty())
+    return false;
+  CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD);
+  if (!MD || !MD->isCXXInstanceMember())
+    return false;
+  RecordDecl *PromiseType = MD->getParent();
+  return PromiseType && PromiseType->getDeclName().isIdentifier() &&
----------------
ilya-biryukov wrote:

Why do we restrict the name of the class itself to be `promise_type`?
It's valid to have code like:
```cpp
struct any_name_i_want {
  // that's the promise type.
  // includes `get_return_object` implementation too.
};

struct coro_task {
  using promise_type = any_name_i_want;
};
```

https://github.com/llvm/llvm-project/pull/71945
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to