Skip to content

Commit 2db790a

Browse files
committed
Iterate backwards
1 parent 1585cde commit 2db790a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

flang/lib/Semantics/check-omp-structure.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,10 @@ void OmpStructureChecker::CheckDirectiveSpelling(
270270
// with spaces removed).
271271
auto removeSpaces = [](llvm::StringRef s) {
272272
std::string n{s.str()};
273-
for (auto it{n.begin()}; it != n.end();) {
274-
it = isspace(*it) ? n.erase(it) : std::next(it);
273+
for (size_t idx{n.size()}; idx > 0; --idx) {
274+
if (isspace(n[idx - 1])) {
275+
n.erase(idx - 1, 1);
276+
}
275277
}
276278
return n;
277279
};

0 commit comments

Comments
 (0)