//===-- flang/Parser/openmp-utils.cpp -------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // Common OpenMP utilities. // //===----------------------------------------------------------------------===// #include "flang/Parser/openmp-utils.h" #include "flang/Common/template.h" #include "flang/Common/visit.h" #include #include #include namespace Fortran::parser::omp { const OmpObjectList *GetOmpObjectList(const OmpClause &clause) { // Clauses with OmpObjectList as its data member using MemberObjectListClauses = std::tuple; // Clauses with OmpObjectList in the tuple using TupleObjectListClauses = std::tuple; // TODO:: Generate the tuples using TableGen. return common::visit( common::visitors{ [&](const OmpClause::Depend &x) -> const OmpObjectList * { if (auto *taskDep{std::get_if(&x.v.u)}) { return &std::get(taskDep->t); } else { return nullptr; } }, [&](const auto &x) -> const OmpObjectList * { using Ty = std::decay_t; if constexpr (common::HasMember) { return &x.v; } else if constexpr (common::HasMember) { return &std::get(x.v.t); } else { return nullptr; } }, }, clause.u); } } // namespace Fortran::parser::omp