[flang-commits] [flang] ebb0c9c - [flang][OpenMP] Move some utilities from openmp-parsers to openmp-uti… (#169188)

via flang-commits flang-commits at lists.llvm.org
Sat Nov 22 13:26:21 PST 2025


Author: Krzysztof Parzyszek
Date: 2025-11-22T15:26:17-06:00
New Revision: ebb0c9c559b5809be491aa71cbe8235611081194

URL: https://github.com/llvm/llvm-project/commit/ebb0c9c559b5809be491aa71cbe8235611081194
DIFF: https://github.com/llvm/llvm-project/commit/ebb0c9c559b5809be491aa71cbe8235611081194.diff

LOG: [flang][OpenMP] Move some utilities from openmp-parsers to openmp-uti… (#169188)

…ls, NFC

Added: 
    

Modified: 
    flang/include/flang/Parser/openmp-utils.h
    flang/lib/Parser/openmp-parsers.cpp
    flang/lib/Parser/openmp-utils.cpp

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Parser/openmp-utils.h b/flang/include/flang/Parser/openmp-utils.h
index 7396e57144b90..d4b739f4c9529 100644
--- a/flang/include/flang/Parser/openmp-utils.h
+++ b/flang/include/flang/Parser/openmp-utils.h
@@ -126,6 +126,16 @@ const OpenMPConstruct *GetOmp(const ExecutionPartConstruct &x);
 const OpenMPLoopConstruct *GetOmpLoop(const ExecutionPartConstruct &x);
 const DoConstruct *GetDoConstruct(const ExecutionPartConstruct &x);
 
+// Is the template argument "Statement<T>" for some T?
+template <typename T> struct IsStatement {
+  static constexpr bool value{false};
+};
+template <typename T> struct IsStatement<Statement<T>> {
+  static constexpr bool value{true};
+};
+
+std::optional<Label> GetStatementLabel(const ExecutionPartConstruct &x);
+
 const OmpObjectList *GetOmpObjectList(const OmpClause &clause);
 
 template <typename T>

diff  --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp
index 0652dac209dbb..b7f23348328b4 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -1731,30 +1731,6 @@ struct NonBlockDoConstructParser {
     }
     return std::nullopt;
   }
-
-private:
-  // Is the template argument "Statement<T>" for some T?
-  template <typename T> struct IsStatement {
-    static constexpr bool value{false};
-  };
-  template <typename T> struct IsStatement<Statement<T>> {
-    static constexpr bool value{true};
-  };
-
-  // Get the Label from a Statement<...> contained in an ExecutionPartConstruct,
-  // or std::nullopt, if there is no Statement<...> contained in there.
-  template <typename T>
-  static std::optional<Label> GetStatementLabel(const T &stmt) {
-    if constexpr (IsStatement<T>::value) {
-      return stmt.label;
-    } else if constexpr (WrapperTrait<T>) {
-      return GetStatementLabel(stmt.v);
-    } else if constexpr (UnionTrait<T>) {
-      return common::visit(
-          [&](auto &&s) { return GetStatementLabel(s); }, stmt.u);
-    }
-    return std::nullopt;
-  }
 };
 
 struct LoopNestParser {

diff  --git a/flang/lib/Parser/openmp-utils.cpp b/flang/lib/Parser/openmp-utils.cpp
index dfe8dbdd5ac9e..3201e5149e27c 100644
--- a/flang/lib/Parser/openmp-utils.cpp
+++ b/flang/lib/Parser/openmp-utils.cpp
@@ -58,6 +58,25 @@ const DoConstruct *GetDoConstruct(const ExecutionPartConstruct &x) {
   return nullptr;
 }
 
+// Get the Label from a Statement<...> contained in an ExecutionPartConstruct,
+// or std::nullopt, if there is no Statement<...> contained in there.
+template <typename T>
+static std::optional<Label> GetStatementLabelHelper(const T &stmt) {
+  if constexpr (IsStatement<T>::value) {
+    return stmt.label;
+  } else if constexpr (WrapperTrait<T>) {
+    return GetStatementLabelHelper(stmt.v);
+  } else if constexpr (UnionTrait<T>) {
+    return common::visit(
+        [&](auto &&s) { return GetStatementLabelHelper(s); }, stmt.u);
+  }
+  return std::nullopt;
+}
+
+std::optional<Label> GetStatementLabel(const ExecutionPartConstruct &x) {
+  return GetStatementLabelHelper(x);
+}
+
 const OmpObjectList *GetOmpObjectList(const OmpClause &clause) {
   // Clauses with OmpObjectList as its data member
   using MemberObjectListClauses = std::tuple<OmpClause::Copyin,


        


More information about the flang-commits mailing list