10
10
#include " flang/Parser/parse-tree-visitor.h"
11
11
#include " flang/Parser/parse-tree.h"
12
12
#include " flang/Semantics/semantics.h"
13
-
14
- #include < stack>
15
13
// After Loop Canonicalization, rewrite OpenMP parse tree to make OpenMP
16
14
// Constructs more structured which provide explicit scopes for later
17
15
// structural checks and semantic analysis.
@@ -150,8 +148,8 @@ class CanonicalizationOfOmp {
150
148
if (GetConstructIf<parser::CompilerDirective>(*nextIt))
151
149
continue ;
152
150
// Keep track of the loops to handle the end loop directives
153
- std::stack <parser::OpenMPLoopConstruct *> loops;
154
- loops.push (&x);
151
+ llvm::SmallVector <parser::OpenMPLoopConstruct *> loops;
152
+ loops.push_back (&x);
155
153
if (auto *innerConstruct{
156
154
GetConstructIf<parser::OpenMPConstruct>(*nextIt)}) {
157
155
if (auto *innerOmpLoop{
@@ -162,12 +160,12 @@ class CanonicalizationOfOmp {
162
160
if (innerDir.v == llvm::omp::Directive::OMPD_tile) {
163
161
std::get<std::optional<
164
162
common::Indirection<parser::OpenMPLoopConstruct>>>(
165
- loops.top ()->t ) = std::move (*innerOmpLoop);
163
+ loops.back ()->t ) = std::move (*innerOmpLoop);
166
164
// Retrieveing the address so that DoConstruct or inner loop can be
167
165
// set later.
168
- loops.push (&(std::get<std::optional<
166
+ loops.push_back (&(std::get<std::optional<
169
167
common::Indirection<parser::OpenMPLoopConstruct>>>(
170
- loops.top ()->t )
168
+ loops.back ()->t )
171
169
.value ()
172
170
.value ()));
173
171
nextIt = block.erase (nextIt);
@@ -180,16 +178,16 @@ class CanonicalizationOfOmp {
180
178
// move DoConstruct
181
179
std::get<std::optional<std::variant<parser::DoConstruct,
182
180
common::Indirection<parser::OpenMPLoopConstruct>>>>(
183
- loops.top ()->t ) = std::move (*doCons);
181
+ loops.back ()->t ) = std::move (*doCons);
184
182
nextIt = block.erase (nextIt);
185
183
// try to match OmpEndLoopDirective
186
184
while (nextIt != block.end () && !loops.empty ()) {
187
185
if (auto *endDir{
188
186
GetConstructIf<parser::OmpEndLoopDirective>(*nextIt)}) {
189
187
std::get<std::optional<parser::OmpEndLoopDirective>>(
190
- loops.top ()->t ) = std::move (*endDir);
188
+ loops.back ()->t ) = std::move (*endDir);
191
189
nextIt = block.erase (nextIt);
192
- loops.pop ();
190
+ loops.pop_back ();
193
191
} else {
194
192
// If there is a mismatch bail out.
195
193
break ;
0 commit comments