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
26namespace Fortran::semantics {
27class SemanticsContext;
28class Symbol;
29
30// Add this namespace to avoid potential conflicts
31namespace omp {
32// There is no consistent way to get the source of an ActionStmt, but there
33// is "source" in Statement<T>. This structure keeps the ActionStmt with the
34// extracted source for further use.
35struct SourcedActionStmt {
36 const parser::ActionStmt *stmt{nullptr};
37 parser::CharBlock source;
38
39 operator bool() const { return stmt != nullptr; }
40};
41
42SourcedActionStmt GetActionStmt(const parser::ExecutionPartConstruct *x);
43SourcedActionStmt GetActionStmt(const parser::Block &block);
44
45std::string ThisVersion(unsigned version);
46std::string TryVersion(unsigned version);
47
48const parser::Designator *GetDesignatorFromObj(const parser::OmpObject &object);
49const parser::DataRef *GetDataRefFromObj(const parser::OmpObject &object);
50const parser::ArrayElement *GetArrayElementFromObj(
51 const parser::OmpObject &object);
52const Symbol *GetObjectSymbol(const parser::OmpObject &object);
53const Symbol *GetArgumentSymbol(const parser::OmpArgument &argument);
54std::optional<parser::CharBlock> GetObjectSource(
55 const parser::OmpObject &object);
56
57bool IsCommonBlock(const Symbol &sym);
58bool IsExtendedListItem(const Symbol &sym);
59bool IsVariableListItem(const Symbol &sym);
60bool IsVarOrFunctionRef(const MaybeExpr &expr);
61
62std::optional<SomeExpr> GetEvaluateExpr(const parser::Expr &parserExpr);
63std::optional<evaluate::DynamicType> GetDynamicType(
64 const parser::Expr &parserExpr);
65
66std::optional<bool> IsContiguous(
67 SemanticsContext &semaCtx, const parser::OmpObject &object);
68
69std::vector<SomeExpr> GetAllDesignators(const SomeExpr &expr);
70const SomeExpr *HasStorageOverlap(
71 const SomeExpr &base, llvm::ArrayRef<SomeExpr> exprs);
72bool IsSubexpressionOf(const SomeExpr &sub, const SomeExpr &super);
73bool IsAssignment(const parser::ActionStmt *x);
74bool IsPointerAssignment(const evaluate::Assignment &x);
75const parser::Block &GetInnermostExecPart(const parser::Block &block);
76} // namespace omp
77} // namespace Fortran::semantics
78
79#endif // FORTRAN_SEMANTICS_OPENMP_UTILS_H
80

source code of flang/lib/Semantics/openmp-utils.h