[clang] [Clang] Propagate elide safe context through [[clang::coro_must_await]] (PR #108474)
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 13 19:21:44 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();
----------------
ChuanqiXu9 wrote:
```suggestion
```
https://github.com/llvm/llvm-project/pull/108474
More information about the cfe-commits
mailing list