Skip to content

Commit 5c23acb

Browse files
committed
[NFC][Clang][OpenMP] Use switch-case statement to process clauses of atomic directive
This patch makes the process of clauses of atomic directive more clear and preparation for the support for `atomic compare capture`. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D115586
1 parent b1ef247 commit 5c23acb

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10934,9 +10934,11 @@ StmtResult Sema::ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses,
1093410934
OpenMPClauseKind MemOrderKind = OMPC_unknown;
1093510935
SourceLocation MemOrderLoc;
1093610936
for (const OMPClause *C : Clauses) {
10937-
if (C->getClauseKind() == OMPC_read || C->getClauseKind() == OMPC_write ||
10938-
C->getClauseKind() == OMPC_update ||
10939-
C->getClauseKind() == OMPC_capture) {
10937+
switch (C->getClauseKind()) {
10938+
case OMPC_read:
10939+
case OMPC_write:
10940+
case OMPC_update:
10941+
case OMPC_capture: {
1094010942
if (AtomicKind != OMPC_unknown) {
1094110943
Diag(C->getBeginLoc(), diag::err_omp_atomic_several_clauses)
1094210944
<< SourceRange(C->getBeginLoc(), C->getEndLoc());
@@ -10946,12 +10948,13 @@ StmtResult Sema::ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses,
1094610948
AtomicKind = C->getClauseKind();
1094710949
AtomicKindLoc = C->getBeginLoc();
1094810950
}
10951+
break;
1094910952
}
10950-
if (C->getClauseKind() == OMPC_seq_cst ||
10951-
C->getClauseKind() == OMPC_acq_rel ||
10952-
C->getClauseKind() == OMPC_acquire ||
10953-
C->getClauseKind() == OMPC_release ||
10954-
C->getClauseKind() == OMPC_relaxed) {
10953+
case OMPC_seq_cst:
10954+
case OMPC_acq_rel:
10955+
case OMPC_acquire:
10956+
case OMPC_release:
10957+
case OMPC_relaxed: {
1095510958
if (MemOrderKind != OMPC_unknown) {
1095610959
Diag(C->getBeginLoc(), diag::err_omp_several_mem_order_clauses)
1095710960
<< getOpenMPDirectiveName(OMPD_atomic) << 0
@@ -10962,6 +10965,10 @@ StmtResult Sema::ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses,
1096210965
MemOrderKind = C->getClauseKind();
1096310966
MemOrderLoc = C->getBeginLoc();
1096410967
}
10968+
break;
10969+
}
10970+
default:
10971+
llvm_unreachable("unknown clause is encountered");
1096510972
}
1096610973
}
1096710974
// OpenMP 5.0, 2.17.7 atomic Construct, Restrictions

0 commit comments

Comments
 (0)