================
@@ -15705,6 +15726,29 @@ static Expr *makeFloorIVRef(Sema &SemaRef,
ArrayRef<VarDecl *> FloorIndVars,
OrigCntVar->getExprLoc());
}
+/// Build loop variable finalization statement from HelperExprs.Finals.
+/// Returns a CompoundStmt containing all finalization statements, or nullptr
+/// if there are no finalization statements.
+/// Note: Loops with non-arithmetic loop variables (e.g., iterators) are
skipped
+/// because finalization only applies to integer/floating-point counters.
+static Stmt *buildLoopFinalization(
+ ASTContext &Context,
+ ArrayRef<OMPLoopBasedDirective::HelperExprs> LoopHelpers) {
+ SmallVector<Stmt *, 8> FinalizationStmts;
+
+ for (size_t I : llvm::seq<size_t>(LoopHelpers.size())) {
+ for (auto *Final : LoopHelpers[I].Finals)
+ if (Final)
+ FinalizationStmts.push_back(Final);
----------------
alexey-bataev wrote:
```suggestion
FinalizationStmts.push_back(IfStmt::Create(
Context, SourceLocation(), IfStatementKind::Ordinary, nullptr,
nullptr, LoopHelpers[I].PreCond, SourceLocation(),
SourceLocation(), Final, SourceLocation(), nullptr));
```
https://github.com/llvm/llvm-project/pull/214717
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits