[clang] [Clang] Propagate elide safe context through [[clang::coro_must_await]] (PR #108474)

Yuxuan Chen via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 13 22:30:00 PDT 2024


================
@@ -849,12 +849,30 @@ static bool isAttributedCoroAwaitElidable(const QualType &QT) {
   return Record && Record->hasAttr<CoroAwaitElidableAttr>();
 }
 
-static bool isCoroAwaitElidableCall(Expr *Operand) {
-  if (!Operand->isPRValue()) {
-    return false;
+static void applySafeElideContext(Expr *Operand) {
+  auto *Call = dyn_cast<CallExpr>(Operand->IgnoreImplicit());
+  if (!Call || !Call->isPRValue())
+    return;
+
+  if (!isAttributedCoroAwaitElidable(Call->getType()))
+    return;
+
+  Call->setCoroElideSafe();
+
+  // Check parameter
+  auto *Fn = llvm::dyn_cast_if_present<FunctionDecl>(Call->getCalleeDecl());
+  if (!Fn) {
+    Call->dump();
----------------
yuxuanchen1997 wrote:

Oops. 

https://github.com/llvm/llvm-project/pull/108474


More information about the cfe-commits mailing list