//===-- 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/indirection.h" #include "flang/Common/template.h" #include "flang/Common/visit.h" #include "flang/Parser/tools.h" #include #include #include namespace Fortran::parser::omp { const OpenMPDeclarativeConstruct *GetOmp(const DeclarationConstruct &x) { if (auto *y = std::get_if(&x.u)) { if (auto *z{std::get_if>( &y->u)}) { return &z->value(); } } return nullptr; } const OpenMPConstruct *GetOmp(const ExecutionPartConstruct &x) { if (auto *y{std::get_if(&x.u)}) { if (auto *z{std::get_if>(&y->u)}) { return &z->value(); } } return nullptr; } const OpenMPLoopConstruct *GetOmpLoop(const ExecutionPartConstruct &x) { if (auto *construct{GetOmp(x)}) { if (auto *omp{std::get_if(&construct->u)}) { return omp; } } return nullptr; } const DoConstruct *GetDoConstruct(const ExecutionPartConstruct &x) { if (auto *y{std::get_if(&x.u)}) { if (auto *z{std::get_if>(&y->u)}) { return &z->value(); } } return nullptr; } // Get the Label from a Statement<...> contained in an ExecutionPartConstruct, // or std::nullopt, if there is no Statement<...> contained in there. template static std::optional