summaryrefslogtreecommitdiff
path: root/flang/lib/Parser/openmp-utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'flang/lib/Parser/openmp-utils.cpp')
-rw-r--r--flang/lib/Parser/openmp-utils.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/flang/lib/Parser/openmp-utils.cpp b/flang/lib/Parser/openmp-utils.cpp
index dfe8dbdd5ac9..3201e5149e27 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,