[flang-commits] [clang] [flang] [llvm] [openmp] [Clang][OpenMP] Add permutation clause (PR #92030)

Alexey Bataev via flang-commits flang-commits at lists.llvm.org
Fri Oct 4 10:06:37 PDT 2024


================
@@ -16029,6 +16074,44 @@ OMPClause *SemaOpenMP::ActOnOpenMPSizesClause(ArrayRef<Expr *> SizeExprs,
                                 SanitizedSizeExprs);
 }
 
+OMPClause *SemaOpenMP::ActOnOpenMPPermutationClause(ArrayRef<Expr *> PermExprs,
+                                                    SourceLocation StartLoc,
+                                                    SourceLocation LParenLoc,
+                                                    SourceLocation EndLoc) {
+  size_t NumLoops = PermExprs.size();
+  SmallVector<Expr *> SanitizedPermExprs;
+  llvm::append_range(SanitizedPermExprs, PermExprs);
+
+  for (Expr *&PermExpr : SanitizedPermExprs) {
+    // Skip if template-dependent or already sanitized, e.g. during a partial
+    // template instantiation.
+    if (!PermExpr || PermExpr->isInstantiationDependent())
+      continue;
+
+    llvm::APSInt PermVal;
+    ExprResult PermEvalExpr = SemaRef.VerifyIntegerConstantExpression(
+        PermExpr, &PermVal, Sema::AllowFold);
+    bool IsValid = PermEvalExpr.isUsable();
+    if (IsValid)
----------------
alexey-bataev wrote:

```suggestion
    if (!IsValid) {
      PermExpr = nullptr;
      continue;
    }
```
?

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


More information about the flang-commits mailing list