================ @@ -5965,6 +5967,263 @@ static bool teamsLoopCanBeParallelFor(Stmt *AStmt, Sema &SemaRef) { return Checker.teamsLoopCanBeParallelFor(); } +static Expr *getInitialExprFromCapturedExpr(Expr *Cond) { + + Expr *SubExpr = Cond->IgnoreParenImpCasts(); + + if (auto *DeclRef = dyn_cast<DeclRefExpr>(SubExpr)) { + if (auto *CapturedExprDecl = + dyn_cast<OMPCapturedExprDecl>(DeclRef->getDecl())) { + + // Retrieve the initial expression from the captured expression + return CapturedExprDecl->getInit(); + } + } + return nullptr; +} + +// Next two functions, cloneAssociatedStmt() & +// replaceWithNewTraitsOrDirectCall(), are for transforming the call traits. +// e.g. +// #pragma omp declare variant(foo_variant_dispatch) match(construct={dispatch}) +// #pragma omp declare variant(foo_variant_allCond) match(user={condition(1)}) +// .. +// #pragma omp dispatch nocontext(cond_true) +// foo(i, j); +// is changed to: +// if (cond_true) { +// foo(i,j) // with traits: CodeGen call to foo_variant_allCond(i,j) +// } else { +// #pragma omp dispatch +// foo(i,j) // with traits: CodeGen call to foo_variant_dispatch(i,j) +// } +// +// The next 2 functions, are for: +// if (cond_true) { +// foo(i,j) // with traits: runtime call to foo_variant_allCond(i,j) +// } +// +static Expr *replaceWithNewTraitsOrDirectCall(const ASTContext &Context, Expr *, + SemaOpenMP *, bool); + +static StmtResult cloneAssociatedStmt(const ASTContext &Context, Stmt *StmtP, + SemaOpenMP *SemaPtr, bool NoContext) { + if (CapturedStmt *AssocStmt = dyn_cast<CapturedStmt>(StmtP)) { ---------------- alexey-bataev wrote:
`if (auto *AssocStmt = dyn_cast<CapturedStmt>(StmtP)) {` https://github.com/llvm/llvm-project/pull/117904 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits