FLANG
openmp-utils.h
1//===-- lib/Semantics/openmp-utils.h --------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Common utilities used in OpenMP semantic checks.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef FORTRAN_SEMANTICS_OPENMP_UTILS_H
14#define FORTRAN_SEMANTICS_OPENMP_UTILS_H
15
16#include "flang/Evaluate/type.h"
17#include "flang/Parser/char-block.h"
18#include "flang/Parser/parse-tree.h"
19#include "flang/Semantics/tools.h"
20
21#include "llvm/ADT/ArrayRef.h"
22
23#include <optional>
24#include <string>
25#include <type_traits>
26#include <utility>
27
28namespace Fortran::semantics {
30class Symbol;
31
32// Add this namespace to avoid potential conflicts
33namespace omp {
34template <typename T, typename U = std::remove_const_t<T>> U AsRvalue(T &t) {
35 return U(t);
36}
37
38template <typename T> T &&AsRvalue(T &&t) { return std::move(t); }
39
40const Scope &GetScopingUnit(const Scope &scope);
41
42// There is no consistent way to get the source of an ActionStmt, but there
43// is "source" in Statement<T>. This structure keeps the ActionStmt with the
44// extracted source for further use.
46 const parser::ActionStmt *stmt{nullptr};
47 parser::CharBlock source;
48
49 operator bool() const { return stmt != nullptr; }
50};
51
53SourcedActionStmt GetActionStmt(const parser::Block &block);
54
55std::string ThisVersion(unsigned version);
56std::string TryVersion(unsigned version);
57
58const parser::Designator *GetDesignatorFromObj(const parser::OmpObject &object);
59const parser::DataRef *GetDataRefFromObj(const parser::OmpObject &object);
60const parser::ArrayElement *GetArrayElementFromObj(
61 const parser::OmpObject &object);
62const Symbol *GetObjectSymbol(const parser::OmpObject &object);
63std::optional<parser::CharBlock> GetObjectSource(
64 const parser::OmpObject &object);
65const Symbol *GetArgumentSymbol(const parser::OmpArgument &argument);
66const parser::OmpObject *GetArgumentObject(const parser::OmpArgument &argument);
67
68bool IsCommonBlock(const Symbol &sym);
69bool IsExtendedListItem(const Symbol &sym);
70bool IsVariableListItem(const Symbol &sym);
71bool IsVarOrFunctionRef(const MaybeExpr &expr);
72
73bool IsMapEnteringType(parser::OmpMapType::Value type);
74bool IsMapExitingType(parser::OmpMapType::Value type);
75
76std::optional<SomeExpr> GetEvaluateExpr(const parser::Expr &parserExpr);
77std::optional<evaluate::DynamicType> GetDynamicType(
78 const parser::Expr &parserExpr);
79
80std::optional<bool> GetLogicalValue(const SomeExpr &expr);
81
82std::optional<bool> IsContiguous(
83 SemanticsContext &semaCtx, const parser::OmpObject &object);
84
85std::vector<SomeExpr> GetAllDesignators(const SomeExpr &expr);
86const SomeExpr *HasStorageOverlap(
87 const SomeExpr &base, llvm::ArrayRef<SomeExpr> exprs);
88bool IsAssignment(const parser::ActionStmt *x);
89bool IsPointerAssignment(const evaluate::Assignment &x);
90const parser::Block &GetInnermostExecPart(const parser::Block &block);
91bool IsStrictlyStructuredBlock(const parser::Block &block);
92} // namespace omp
93} // namespace Fortran::semantics
94
95#endif // FORTRAN_SEMANTICS_OPENMP_UTILS_H
Definition expression.h:878
Definition char-block.h:28
Definition semantics.h:67
Definition symbol.h:781
Definition FIRType.h:89
Definition parse-tree.h:490
Definition parse-tree.h:1912
Definition parse-tree.h:1819
Definition parse-tree.h:1858
Definition parse-tree.h:547
Definition parse-tree.h:1701
Definition parse-tree.h:3508
Definition parse-tree.h:3596
Definition openmp-utils.h:45