From c8d0ff41f20ef19d517b22113f6f0de3abcb2a25 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Thu, 28 Aug 2025 10:36:57 -0500 Subject: [PATCH] [flang][OpenMP] Simplify getLocation in FlangOmpReportVisitor, NFC Use a utility function to get the construct source. --- .../FlangOmpReport/FlangOmpReportVisitor.cpp | 29 ++----------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/flang/examples/FlangOmpReport/FlangOmpReportVisitor.cpp b/flang/examples/FlangOmpReport/FlangOmpReportVisitor.cpp index cc058bf28329b..ab2e8fd8df58f 100644 --- a/flang/examples/FlangOmpReport/FlangOmpReportVisitor.cpp +++ b/flang/examples/FlangOmpReport/FlangOmpReportVisitor.cpp @@ -65,32 +65,9 @@ SourcePosition OpenMPCounterVisitor::getLocation( c.u); } SourcePosition OpenMPCounterVisitor::getLocation(const OpenMPConstruct &c) { - return std::visit( - Fortran::common::visitors{ - [&](const OpenMPStandaloneConstruct &c) -> SourcePosition { - return parsing->allCooked().GetSourcePositionRange(c.source)->first; - }, - // OpenMPSectionsConstruct, OpenMPLoopConstruct, - // OpenMPBlockConstruct, OpenMPCriticalConstruct Get the source from - // the directive field. - [&](const auto &c) -> SourcePosition { - const CharBlock &source{std::get<0>(c.t).source}; - return parsing->allCooked().GetSourcePositionRange(source)->first; - }, - [&](const OpenMPAtomicConstruct &c) -> SourcePosition { - const CharBlock &source{c.source}; - return parsing->allCooked().GetSourcePositionRange(source)->first; - }, - [&](const OpenMPSectionConstruct &c) -> SourcePosition { - const CharBlock &source{c.source}; - return parsing->allCooked().GetSourcePositionRange(source)->first; - }, - [&](const OpenMPUtilityConstruct &c) -> SourcePosition { - const CharBlock &source{c.source}; - return parsing->allCooked().GetSourcePositionRange(source)->first; - }, - }, - c.u); + return parsing->allCooked() + .GetSourcePositionRange(omp::GetOmpDirectiveName(c).source) + ->first; } std::string OpenMPCounterVisitor::getName(const OmpWrapperType &w) {