Skip to content

Commit 8db7571

Browse files
authored
[flang][OpenMP] Simplify getLocation in FlangOmpReportVisitor, NFC (llvm#155871)
Use a utility function to get the construct source.
1 parent 73cf62b commit 8db7571

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

flang/examples/FlangOmpReport/FlangOmpReportVisitor.cpp

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -65,32 +65,9 @@ SourcePosition OpenMPCounterVisitor::getLocation(
6565
c.u);
6666
}
6767
SourcePosition OpenMPCounterVisitor::getLocation(const OpenMPConstruct &c) {
68-
return std::visit(
69-
Fortran::common::visitors{
70-
[&](const OpenMPStandaloneConstruct &c) -> SourcePosition {
71-
return parsing->allCooked().GetSourcePositionRange(c.source)->first;
72-
},
73-
// OpenMPSectionsConstruct, OpenMPLoopConstruct,
74-
// OpenMPBlockConstruct, OpenMPCriticalConstruct Get the source from
75-
// the directive field.
76-
[&](const auto &c) -> SourcePosition {
77-
const CharBlock &source{std::get<0>(c.t).source};
78-
return parsing->allCooked().GetSourcePositionRange(source)->first;
79-
},
80-
[&](const OpenMPAtomicConstruct &c) -> SourcePosition {
81-
const CharBlock &source{c.source};
82-
return parsing->allCooked().GetSourcePositionRange(source)->first;
83-
},
84-
[&](const OpenMPSectionConstruct &c) -> SourcePosition {
85-
const CharBlock &source{c.source};
86-
return parsing->allCooked().GetSourcePositionRange(source)->first;
87-
},
88-
[&](const OpenMPUtilityConstruct &c) -> SourcePosition {
89-
const CharBlock &source{c.source};
90-
return parsing->allCooked().GetSourcePositionRange(source)->first;
91-
},
92-
},
93-
c.u);
68+
return parsing->allCooked()
69+
.GetSourcePositionRange(omp::GetOmpDirectiveName(c).source)
70+
->first;
9471
}
9572

9673
std::string OpenMPCounterVisitor::getName(const OmpWrapperType &w) {

0 commit comments

Comments
 (0)