Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions flang/include/flang/Parser/openmp-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
24 changes: 0 additions & 24 deletions flang/lib/Parser/openmp-parsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
19 changes: 19 additions & 0 deletions flang/lib/Parser/openmp-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down