diff options
author | Jennifer Yu <jennifer.yu@intel.com> | 2022-11-17 22:03:00 -0800 |
---|---|---|
committer | Jennifer Yu <jennifer.yu@intel.com> | 2022-11-18 17:59:23 -0800 |
commit | 9d90cf2fca4446f5c227f6e3217e96c00665cb72 (patch) | |
tree | 70fd4ddadc5aa52c58d0d1e4c2fd3bc3e34f2ed8 /clang/lib/Sema/SemaOpenMP.cpp | |
parent | 96c037ef9c01e5e26c84e571feb3e5c16519727d (diff) | |
download | llvm-9d90cf2fca4446f5c227f6e3217e96c00665cb72.zip llvm-9d90cf2fca4446f5c227f6e3217e96c00665cb72.tar.gz llvm-9d90cf2fca4446f5c227f6e3217e96c00665cb72.tar.bz2 |
[OPENMP5.1] Initial support for message clause.
Diffstat (limited to 'clang/lib/Sema/SemaOpenMP.cpp')
-rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index e150b0d..89f7a6b 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -6721,6 +6721,7 @@ StmtResult Sema::ActOnOpenMPExecutableDirective( case OMPC_when: case OMPC_at: case OMPC_severity: + case OMPC_message: default: llvm_unreachable("Unexpected clause"); } @@ -11032,25 +11033,27 @@ StmtResult Sema::ActOnOpenMPErrorDirective(ArrayRef<OMPClause *> Clauses, SourceLocation StartLoc, SourceLocation EndLoc, bool InExContext) { - auto AtClauses = - OMPExecutableDirective::getClausesOfKind<OMPAtClause>(Clauses); - const OMPAtClause *AtC = AtClauses.empty() ? nullptr : (*AtClauses.begin()); + const OMPAtClause *AtC = + OMPExecutableDirective::getSingleClause<OMPAtClause>(Clauses); if (AtC && !InExContext && AtC->getAtKind() == OMPC_AT_execution) { Diag(AtC->getAtKindKwLoc(), diag::err_omp_unexpected_execution_modifier); return StmtError(); } - auto SeverityClauses = - OMPExecutableDirective::getClausesOfKind<OMPSeverityClause>(Clauses); + const OMPSeverityClause *SeverityC = - SeverityClauses.empty() ? nullptr : (*SeverityClauses.begin()); + OMPExecutableDirective::getSingleClause<OMPSeverityClause>(Clauses); + const OMPMessageClause *MessageC = + OMPExecutableDirective::getSingleClause<OMPMessageClause>(Clauses); + Expr *ME = MessageC ? MessageC->getMessageString() : nullptr; if (!AtC || AtC->getAtKind() == OMPC_AT_compilation) { if (SeverityC && SeverityC->getSeverityKind() == OMPC_SEVERITY_warning) Diag(SeverityC->getSeverityKindKwLoc(), diag::warn_diagnose_if_succeeded) - << "WARNING"; + << (ME ? cast<StringLiteral>(ME)->getString() : "WARNING"); else - Diag(StartLoc, diag::err_diagnose_if_succeeded) << "ERROR"; + Diag(StartLoc, diag::err_diagnose_if_succeeded) + << (ME ? cast<StringLiteral>(ME)->getString() : "ERROR"); if (!SeverityC || SeverityC->getSeverityKind() != OMPC_SEVERITY_warning) return StmtError(); } @@ -15131,6 +15134,9 @@ OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr, case OMPC_partial: Res = ActOnOpenMPPartialClause(Expr, StartLoc, LParenLoc, EndLoc); break; + case OMPC_message: + Res = ActOnOpenMPMessageClause(Expr, StartLoc, LParenLoc, EndLoc); + break; case OMPC_align: Res = ActOnOpenMPAlignClause(Expr, StartLoc, LParenLoc, EndLoc); break; @@ -16121,6 +16127,7 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause( case OMPC_order: case OMPC_at: case OMPC_severity: + case OMPC_message: case OMPC_destroy: case OMPC_detach: case OMPC_inclusive: @@ -16607,6 +16614,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause( case OMPC_uses_allocators: case OMPC_affinity: case OMPC_when: + case OMPC_message: default: llvm_unreachable("Clause is not allowed."); } @@ -16742,6 +16750,18 @@ OMPClause *Sema::ActOnOpenMPSeverityClause(OpenMPSeverityClauseKind Kind, OMPSeverityClause(Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc); } +OMPClause *Sema::ActOnOpenMPMessageClause(Expr *ME, SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc) { + assert(ME && "NULL expr in Message clause"); + if (!isa<StringLiteral>(ME)) { + Diag(ME->getBeginLoc(), diag::warn_clause_expected_string) + << getOpenMPClauseName(OMPC_message); + return nullptr; + } + return new (Context) OMPMessageClause(ME, StartLoc, LParenLoc, EndLoc); +} + OMPClause *Sema::ActOnOpenMPOrderClause(OpenMPOrderClauseKind Kind, SourceLocation KindKwLoc, SourceLocation StartLoc, @@ -16955,6 +16975,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprWithArgClause( case OMPC_order: case OMPC_at: case OMPC_severity: + case OMPC_message: case OMPC_destroy: case OMPC_novariants: case OMPC_nocontext: @@ -17213,6 +17234,7 @@ OMPClause *Sema::ActOnOpenMPClause(OpenMPClauseKind Kind, case OMPC_order: case OMPC_at: case OMPC_severity: + case OMPC_message: case OMPC_novariants: case OMPC_nocontext: case OMPC_detach: @@ -17769,6 +17791,7 @@ OMPClause *Sema::ActOnOpenMPVarListClause(OpenMPClauseKind Kind, case OMPC_order: case OMPC_at: case OMPC_severity: + case OMPC_message: case OMPC_destroy: case OMPC_novariants: case OMPC_nocontext: |