Skip to content

Commit 8743715

Browse files
committed
[flang][Lower] Convert OMP Map and related functions to evaluate::Expr
The related functions are `gatherDataOperandAddrAndBounds` and `genBoundsOps`. The former is used in OpenACC as well, and it was updated to pass evaluate::Expr instead of parser objects. The difference in the test case comes from unfolded conversions of index expressions, which are explicitly of type integer(kind=8). Delete now unused `findRepeatableClause2` and `findClause2`. Add `AsGenericExpr` that takes std::optional. It already returns optional Expr. Making it accept an optional Expr as input would reduce the number of necessary checks when handling frequent optional values in evaluator.
1 parent 841f10e commit 8743715

File tree

4 files changed

+311
-245
lines changed

4 files changed

+311
-245
lines changed

flang/include/flang/Evaluate/tools.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ inline Expr<SomeType> AsGenericExpr(Expr<SomeType> &&x) { return std::move(x); }
148148
std::optional<Expr<SomeType>> AsGenericExpr(DataRef &&);
149149
std::optional<Expr<SomeType>> AsGenericExpr(const Symbol &);
150150

151+
// Propagate std::optional from input to output.
152+
template <typename A>
153+
std::optional<Expr<SomeType>> AsGenericExpr(std::optional<A> &&x) {
154+
if (!x)
155+
return std::nullopt;
156+
return AsGenericExpr(std::move(*x));
157+
}
158+
151159
template <typename A>
152160
common::IfNoLvalue<Expr<SomeKind<ResultType<A>::category>>, A> AsCategoryExpr(
153161
A &&x) {

0 commit comments

Comments
 (0)