[flang-commits] [flang] b4386f7 - [flang][OpenMP] Push context for all directives in resolve-directives.cpp (#181736)
via flang-commits
flang-commits at lists.llvm.org
Thu Feb 19 04:53:51 PST 2026
Author: Krzysztof Parzyszek
Date: 2026-02-19T06:53:47-06:00
New Revision: b4386f7b556bd40265921ebf32e6763322382bf6
URL: https://github.com/llvm/llvm-project/commit/b4386f7b556bd40265921ebf32e6763322382bf6
DIFF: https://github.com/llvm/llvm-project/commit/b4386f7b556bd40265921ebf32e6763322382bf6.diff
LOG: [flang][OpenMP] Push context for all directives in resolve-directives.cpp (#181736)
The visitors for loop and simple-standalone constructs had switch
statements that explicitly listed all directives in the category, and
pushed the context for them.
The visitor for OmpBlockConstruct listed a selection of block-associated
directives, but they are the only ones for which OmpBlockConstruct is
created directly without a subclass.
Added:
Modified:
flang/lib/Semantics/resolve-directives.cpp
Removed:
################################################################################
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index ba645033df60f..e8d3f9c98d19d 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -1961,34 +1961,8 @@ static std::string ScopeSourcePos(const Fortran::semantics::Scope &scope);
bool OmpAttributeVisitor::Pre(const parser::OmpBlockConstruct &x) {
const parser::OmpDirectiveSpecification &dirSpec{x.BeginDir()};
llvm::omp::Directive dirId{dirSpec.DirId()};
- switch (dirId) {
- case llvm::omp::Directive::OMPD_masked:
- case llvm::omp::Directive::OMPD_parallel_masked:
- case llvm::omp::Directive::OMPD_master:
- case llvm::omp::Directive::OMPD_parallel_master:
- case llvm::omp::Directive::OMPD_ordered:
- case llvm::omp::Directive::OMPD_parallel:
- case llvm::omp::Directive::OMPD_scope:
- case llvm::omp::Directive::OMPD_single:
- case llvm::omp::Directive::OMPD_target:
- case llvm::omp::Directive::OMPD_target_data:
- case llvm::omp::Directive::OMPD_task:
- case llvm::omp::Directive::OMPD_taskgraph:
- case llvm::omp::Directive::OMPD_taskgroup:
- case llvm::omp::Directive::OMPD_teams:
- case llvm::omp::Directive::OMPD_workdistribute:
- case llvm::omp::Directive::OMPD_workshare:
- case llvm::omp::Directive::OMPD_parallel_workshare:
- case llvm::omp::Directive::OMPD_target_teams:
- case llvm::omp::Directive::OMPD_target_teams_workdistribute:
- case llvm::omp::Directive::OMPD_target_parallel:
- case llvm::omp::Directive::OMPD_teams_workdistribute:
- PushContext(dirSpec.source, dirId);
- break;
- default:
- // TODO others
- break;
- }
+ PushContext(dirSpec.source, dirId);
+
if (dirId == llvm::omp::Directive::OMPD_master ||
dirId == llvm::omp::Directive::OMPD_parallel_master)
IssueNonConformanceWarning(dirId, dirSpec.source, 52);
@@ -2001,23 +1975,9 @@ bool OmpAttributeVisitor::Pre(const parser::OmpBlockConstruct &x) {
void OmpAttributeVisitor::Post(const parser::OmpBlockConstruct &x) {
const parser::OmpDirectiveSpecification &dirSpec{x.BeginDir()};
llvm::omp::Directive dirId{dirSpec.DirId()};
- switch (dirId) {
- case llvm::omp::Directive::OMPD_masked:
- case llvm::omp::Directive::OMPD_master:
- case llvm::omp::Directive::OMPD_parallel_masked:
- case llvm::omp::Directive::OMPD_parallel_master:
- case llvm::omp::Directive::OMPD_parallel:
- case llvm::omp::Directive::OMPD_scope:
- case llvm::omp::Directive::OMPD_single:
- case llvm::omp::Directive::OMPD_target:
- case llvm::omp::Directive::OMPD_task:
- case llvm::omp::Directive::OMPD_teams:
- case llvm::omp::Directive::OMPD_workdistribute:
- case llvm::omp::Directive::OMPD_parallel_workshare:
- case llvm::omp::Directive::OMPD_target_teams:
- case llvm::omp::Directive::OMPD_target_parallel:
- case llvm::omp::Directive::OMPD_target_teams_workdistribute:
- case llvm::omp::Directive::OMPD_teams_workdistribute: {
+ unsigned version{context_.langOptions().OpenMPVersion};
+
+ if (llvm::omp::isPrivatizingConstruct(dirId, version)) {
bool hasPrivate;
for (const auto *allocName : allocateNames_) {
hasPrivate = false;
@@ -2036,10 +1996,6 @@ void OmpAttributeVisitor::Post(const parser::OmpBlockConstruct &x) {
allocName->ToString());
}
}
- break;
- }
- default:
- break;
}
PopContext();
}
@@ -2047,20 +2003,7 @@ void OmpAttributeVisitor::Post(const parser::OmpBlockConstruct &x) {
bool OmpAttributeVisitor::Pre(
const parser::OpenMPSimpleStandaloneConstruct &x) {
const auto &standaloneDir{std::get<parser::OmpDirectiveName>(x.v.t)};
- switch (standaloneDir.v) {
- case llvm::omp::Directive::OMPD_barrier:
- case llvm::omp::Directive::OMPD_ordered:
- case llvm::omp::Directive::OMPD_scan:
- case llvm::omp::Directive::OMPD_target_enter_data:
- case llvm::omp::Directive::OMPD_target_exit_data:
- case llvm::omp::Directive::OMPD_target_update:
- case llvm::omp::Directive::OMPD_taskwait:
- case llvm::omp::Directive::OMPD_taskyield:
- PushContext(standaloneDir.source, standaloneDir.v);
- break;
- default:
- break;
- }
+ PushContext(standaloneDir.source, standaloneDir.v);
ClearDataSharingAttributeObjects();
return true;
}
@@ -2068,50 +2011,8 @@ bool OmpAttributeVisitor::Pre(
bool OmpAttributeVisitor::Pre(const parser::OpenMPLoopConstruct &x) {
const parser::OmpDirectiveSpecification &beginSpec{x.BeginDir()};
const parser::OmpDirectiveName &beginName{beginSpec.DirName()};
- switch (beginName.v) {
- case llvm::omp::Directive::OMPD_distribute:
- case llvm::omp::Directive::OMPD_distribute_parallel_do:
- case llvm::omp::Directive::OMPD_distribute_parallel_do_simd:
- case llvm::omp::Directive::OMPD_distribute_simd:
- case llvm::omp::Directive::OMPD_do:
- case llvm::omp::Directive::OMPD_do_simd:
- case llvm::omp::Directive::OMPD_loop:
- case llvm::omp::Directive::OMPD_masked_taskloop_simd:
- case llvm::omp::Directive::OMPD_masked_taskloop:
- case llvm::omp::Directive::OMPD_master_taskloop_simd:
- case llvm::omp::Directive::OMPD_master_taskloop:
- case llvm::omp::Directive::OMPD_parallel_do:
- case llvm::omp::Directive::OMPD_parallel_do_simd:
- case llvm::omp::Directive::OMPD_parallel_masked_taskloop_simd:
- case llvm::omp::Directive::OMPD_parallel_masked_taskloop:
- case llvm::omp::Directive::OMPD_parallel_master_taskloop_simd:
- case llvm::omp::Directive::OMPD_parallel_master_taskloop:
- case llvm::omp::Directive::OMPD_simd:
- case llvm::omp::Directive::OMPD_target_loop:
- case llvm::omp::Directive::OMPD_target_parallel_do:
- case llvm::omp::Directive::OMPD_target_parallel_do_simd:
- case llvm::omp::Directive::OMPD_target_parallel_loop:
- case llvm::omp::Directive::OMPD_target_teams_distribute:
- case llvm::omp::Directive::OMPD_target_teams_distribute_parallel_do:
- case llvm::omp::Directive::OMPD_target_teams_distribute_parallel_do_simd:
- case llvm::omp::Directive::OMPD_target_teams_distribute_simd:
- case llvm::omp::Directive::OMPD_target_teams_loop:
- case llvm::omp::Directive::OMPD_target_simd:
- case llvm::omp::Directive::OMPD_taskloop:
- case llvm::omp::Directive::OMPD_taskloop_simd:
- case llvm::omp::Directive::OMPD_teams_distribute:
- case llvm::omp::Directive::OMPD_teams_distribute_parallel_do:
- case llvm::omp::Directive::OMPD_teams_distribute_parallel_do_simd:
- case llvm::omp::Directive::OMPD_teams_distribute_simd:
- case llvm::omp::Directive::OMPD_teams_loop:
- case llvm::omp::Directive::OMPD_fuse:
- case llvm::omp::Directive::OMPD_tile:
- case llvm::omp::Directive::OMPD_unroll:
- PushContext(beginName.source, beginName.v);
- break;
- default:
- break;
- }
+ PushContext(beginName.source, beginName.v);
+
if (beginName.v == llvm::omp::OMPD_master_taskloop ||
beginName.v == llvm::omp::OMPD_master_taskloop_simd ||
beginName.v == llvm::omp::OMPD_parallel_master_taskloop ||
More information about the flang-commits
mailing list