[llvm-branch-commits] [flang] [flang][OpenMP] Add version checks for clauses (PR #110015)

Sergio Afonso via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Sep 26 02:40:37 PDT 2024


================
@@ -163,6 +163,43 @@ class AssociatedLoopChecker {
   std::map<std::string, std::int64_t> constructNamesAndLevels_;
 };
 
+bool OmpStructureChecker::CheckAllowedClause(llvmOmpClause clause) {
+  unsigned version{context_.langOptions().OpenMPVersion};
+  DirectiveContext &dirCtx = GetContext();
+  llvm::omp::Directive dir{dirCtx.directive};
+
+  if (!llvm::omp::isAllowedClauseForDirective(dir, clause, version)) {
+    unsigned allowedInVersion{[&] {
+      for (unsigned v : {45, 50, 51, 52, 60}) {
+        if (v <= version) {
+          continue;
+        }
+        if (llvm::omp::isAllowedClauseForDirective(dir, clause, v)) {
+          return v;
+        }
+      }
+      return 0u;
+    }()};
+
+    auto clauseName{parser::ToUpperCaseLetters(getClauseName(clause).str())};
+    auto dirName{parser::ToUpperCaseLetters(getDirectiveName(dir).str())};
----------------
skatrak wrote:

Nit: Perhaps move this into the `if` below to avoid evaluating it when it's not going to be needed.

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


More information about the llvm-branch-commits mailing list