summaryrefslogtreecommitdiff
path: root/flang/lib/Semantics/rewrite-parse-tree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'flang/lib/Semantics/rewrite-parse-tree.cpp')
-rw-r--r--flang/lib/Semantics/rewrite-parse-tree.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/flang/lib/Semantics/rewrite-parse-tree.cpp b/flang/lib/Semantics/rewrite-parse-tree.cpp
index 5b7dab309eda..b5a07680a337 100644
--- a/flang/lib/Semantics/rewrite-parse-tree.cpp
+++ b/flang/lib/Semantics/rewrite-parse-tree.cpp
@@ -195,18 +195,16 @@ void RewriteMutator::OpenMPSimdOnly(
++it;
continue;
}
- auto &nest =
- std::get<std::optional<parser::NestedConstruct>>(ompLoop->t);
-
if (auto *doConstruct =
- std::get_if<parser::DoConstruct>(&nest.value())) {
+ const_cast<parser::DoConstruct *>(ompLoop->GetNestedLoop())) {
auto &loopBody = std::get<parser::Block>(doConstruct->t);
// We can only remove some constructs from a loop when it's _not_ a
// OpenMP simd loop
- OpenMPSimdOnly(loopBody, /*isNonSimdLoopBody=*/true);
- auto newDoConstruct = std::move(*doConstruct);
+ OpenMPSimdOnly(const_cast<parser::Block &>(loopBody),
+ /*isNonSimdLoopBody=*/true);
+
auto newLoop = parser::ExecutionPartConstruct{
- parser::ExecutableConstruct{std::move(newDoConstruct)}};
+ parser::ExecutableConstruct{std::move(*doConstruct)}};
it = block.erase(it);
block.insert(it, std::move(newLoop));
continue;
@@ -386,11 +384,8 @@ bool RewriteMutator::Pre(parser::OpenMPLoopConstruct &ompLoop) {
// If we're looking at a non-simd OpenMP loop, we need to explicitly
// call OpenMPSimdOnly on the nested loop block while indicating where
// the block comes from.
- auto &nest = std::get<std::optional<parser::NestedConstruct>>(ompLoop.t);
- if (!nest.has_value()) {
- return true;
- }
- if (auto *doConstruct = std::get_if<parser::DoConstruct>(&*nest)) {
+ if (auto *doConstruct =
+ const_cast<parser::DoConstruct *>(ompLoop.GetNestedLoop())) {
auto &innerBlock = std::get<parser::Block>(doConstruct->t);
OpenMPSimdOnly(innerBlock, /*isNonSimdLoopBody=*/true);
}