Skip to content

Commit a8d506b

Browse files
authored
[flang][OpenMP] Rename enum OmpxHold to Ompx_Hold in parser (#113366)
The convention is to use enum names that match the source spelling (up to upper/lower case), including names with underscores. Remove the special case from unparser, update tests.
1 parent c77d8ed commit a8d506b

File tree

5 files changed

+11
-17
lines changed

5 files changed

+11
-17
lines changed

flang/include/flang/Parser/parse-tree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3455,7 +3455,7 @@ WRAPPER_CLASS(OmpObjectList, std::list<OmpObject>);
34553455
// map-type-modifier -> ALWAYS | CLOSE | PRESENT | OMPX_HOLD
34563456
// map-type -> TO | FROM | TOFROM | ALLOC | RELEASE | DELETE
34573457
struct OmpMapClause {
3458-
ENUM_CLASS(TypeModifier, Always, Close, Present, OmpxHold);
3458+
ENUM_CLASS(TypeModifier, Always, Close, Present, Ompx_Hold);
34593459
ENUM_CLASS(Type, To, From, Tofrom, Alloc, Release, Delete)
34603460
TUPLE_CLASS_BOILERPLATE(OmpMapClause);
34613461
std::tuple<std::optional<std::list<TypeModifier>>, std::optional<Type>,

flang/lib/Lower/OpenMP/Clauses.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -843,10 +843,10 @@ Map make(const parser::OmpClause::Map &inp,
843843
CLAUSET_ENUM_CONVERT( //
844844
convert2, parser::OmpMapClause::TypeModifier, Map::MapTypeModifier,
845845
// clang-format off
846-
MS(Always, Always)
847-
MS(Close, Close)
848-
MS(OmpxHold, OmpxHold)
849-
MS(Present, Present)
846+
MS(Always, Always)
847+
MS(Close, Close)
848+
MS(Ompx_Hold, OmpxHold)
849+
MS(Present, Present)
850850
// clang-format on
851851
);
852852

flang/lib/Parser/openmp-parsers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ TYPE_PARSER(construct<OmpProcBindClause>(
110110
TYPE_PARSER(construct<OmpMapClause::TypeModifier>(
111111
"ALWAYS" >> pure(OmpMapClause::TypeModifier::Always) ||
112112
"CLOSE" >> pure(OmpMapClause::TypeModifier::Close) ||
113-
"OMPX_HOLD" >> pure(OmpMapClause::TypeModifier::OmpxHold) ||
113+
"OMPX_HOLD" >> pure(OmpMapClause::TypeModifier::Ompx_Hold) ||
114114
"PRESENT" >> pure(OmpMapClause::TypeModifier::Present)))
115115

116116
TYPE_PARSER(

flang/lib/Parser/unparse.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,13 +2087,6 @@ class UnparseVisitor {
20872087
}
20882088
Walk(std::get<OmpObjectList>(x.t));
20892089
}
2090-
void Unparse(const OmpMapClause::TypeModifier &x) {
2091-
if (x == OmpMapClause::TypeModifier::OmpxHold) {
2092-
Word("OMPX_HOLD");
2093-
} else {
2094-
Word(OmpMapClause::EnumToString(x));
2095-
}
2096-
}
20972090
void Unparse(const OmpScheduleModifier &x) {
20982091
Walk(std::get<OmpScheduleModifier::Modifier1>(x.t));
20992092
Walk(",", std::get<std::optional<OmpScheduleModifier::Modifier2>>(x.t));
@@ -2801,6 +2794,7 @@ class UnparseVisitor {
28012794
WALK_NESTED_ENUM(OmpOrderClause, Type) // OMP order-type
28022795
WALK_NESTED_ENUM(OmpOrderModifier, Kind) // OMP order-modifier
28032796
WALK_NESTED_ENUM(OmpMapClause, Type) // OMP map-type
2797+
WALK_NESTED_ENUM(OmpMapClause, TypeModifier) // OMP map-type-modifier
28042798
#undef WALK_NESTED_ENUM
28052799
void Unparse(const ReductionOperator::Operator x) {
28062800
switch (x) {

flang/test/Parser/OpenMP/map-modifiers.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ subroutine f00(x)
1818
!PARSE-TREE: OmpBeginBlockDirective
1919
!PARSE-TREE: | OmpBlockDirective -> llvm::omp::Directive = target
2020
!PARSE-TREE: | OmpClauseList -> OmpClause -> Map -> OmpMapClause
21-
!PARSE-TREE: | | TypeModifier = OmpxHold
21+
!PARSE-TREE: | | TypeModifier = Ompx_Hold
2222
!PARSE-TREE: | | TypeModifier = Always
2323
!PARSE-TREE: | | TypeModifier = Present
2424
!PARSE-TREE: | | TypeModifier = Close
@@ -42,7 +42,7 @@ subroutine f01(x)
4242
!PARSE-TREE: OmpBeginBlockDirective
4343
!PARSE-TREE: | OmpBlockDirective -> llvm::omp::Directive = target
4444
!PARSE-TREE: | OmpClauseList -> OmpClause -> Map -> OmpMapClause
45-
!PARSE-TREE: | | TypeModifier = OmpxHold
45+
!PARSE-TREE: | | TypeModifier = Ompx_Hold
4646
!PARSE-TREE: | | TypeModifier = Always
4747
!PARSE-TREE: | | TypeModifier = Present
4848
!PARSE-TREE: | | TypeModifier = Close
@@ -104,7 +104,7 @@ subroutine f10(x)
104104
!PARSE-TREE: OmpBeginBlockDirective
105105
!PARSE-TREE: | OmpBlockDirective -> llvm::omp::Directive = target
106106
!PARSE-TREE: | OmpClauseList -> OmpClause -> Map -> OmpMapClause
107-
!PARSE-TREE: | | TypeModifier = OmpxHold
107+
!PARSE-TREE: | | TypeModifier = Ompx_Hold
108108
!PARSE-TREE: | | TypeModifier = Always
109109
!PARSE-TREE: | | TypeModifier = Present
110110
!PARSE-TREE: | | TypeModifier = Close
@@ -128,7 +128,7 @@ subroutine f11(x)
128128
!PARSE-TREE: OmpBeginBlockDirective
129129
!PARSE-TREE: | OmpBlockDirective -> llvm::omp::Directive = target
130130
!PARSE-TREE: | OmpClauseList -> OmpClause -> Map -> OmpMapClause
131-
!PARSE-TREE: | | TypeModifier = OmpxHold
131+
!PARSE-TREE: | | TypeModifier = Ompx_Hold
132132
!PARSE-TREE: | | TypeModifier = Always
133133
!PARSE-TREE: | | TypeModifier = Present
134134
!PARSE-TREE: | | TypeModifier = Close

0 commit comments

Comments
 (0)