[clang] [openmp] [Clang][OpenMP] Fix tile/unroll on iterator- and foreach-loops. (PR #91459)
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Tue May 21 10:47:55 PDT 2024
================
@@ -9924,11 +9954,24 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr,
Stmt *DependentPreInits = Transform->getPreInits();
if (!DependentPreInits)
return;
- for (Decl *C : cast<DeclStmt>(DependentPreInits)->getDeclGroup()) {
- auto *D = cast<VarDecl>(C);
- DeclRefExpr *Ref = buildDeclRefExpr(SemaRef, D, D->getType(),
- Transform->getBeginLoc());
- Captures[Ref] = Ref;
+
+ // Search for pre-init declared variables that need to be captured
+ // to be referenceable inside the directive.
+ SmallVector<Stmt *> Constituents;
+ if (auto *CS = dyn_cast<CompoundStmt>(DependentPreInits))
+ llvm::append_range(Constituents, CS->body());
+ else
+ Constituents.push_back(DependentPreInits);
----------------
alexey-bataev wrote:
```suggestion
appendFlattendedStmtList(Constituents, DependentPreInits);
```
https://github.com/llvm/llvm-project/pull/91459
More information about the cfe-commits
mailing list