forked from OSchip/llvm-project
[OPENMP]Use standard parsing for 'match' clause, NFC.
Reused standard clauses parsing scheme for parsing/matching 'match' clause in 'declare variant' directive. llvm-svn: 372635
This commit is contained in:
parent
1962122c4d
commit
dba792c522
|
@ -2844,6 +2844,7 @@ bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
|
|||
case OMPC_threadprivate:
|
||||
case OMPC_uniform:
|
||||
case OMPC_device_type:
|
||||
case OMPC_match:
|
||||
case OMPC_unknown:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -194,6 +194,9 @@
|
|||
#ifndef OPENMP_DEVICE_TYPE_KIND
|
||||
#define OPENMP_DEVICE_TYPE_KIND(Name)
|
||||
#endif
|
||||
#ifndef OPENMP_DECLARE_VARIANT_CLAUSE
|
||||
#define OPENMP_DECLARE_VARIANT_CLAUSE(Name)
|
||||
#endif
|
||||
|
||||
// OpenMP directives.
|
||||
OPENMP_DIRECTIVE(threadprivate)
|
||||
|
@ -959,6 +962,10 @@ OPENMP_DEVICE_TYPE_KIND(host)
|
|||
OPENMP_DEVICE_TYPE_KIND(nohost)
|
||||
OPENMP_DEVICE_TYPE_KIND(any)
|
||||
|
||||
// Clauses allowed for OpenMP directive 'declare variant'.
|
||||
OPENMP_DECLARE_VARIANT_CLAUSE(match)
|
||||
|
||||
#undef OPENMP_DECLARE_VARIANT_CLAUSE
|
||||
#undef OPENMP_DEVICE_TYPE_KIND
|
||||
#undef OPENMP_ALLOCATE_CLAUSE
|
||||
#undef OPENMP_DECLARE_MAPPER_CLAUSE
|
||||
|
|
|
@ -36,6 +36,7 @@ enum OpenMPClauseKind {
|
|||
OMPC_threadprivate,
|
||||
OMPC_uniform,
|
||||
OMPC_device_type,
|
||||
OMPC_match,
|
||||
OMPC_unknown
|
||||
};
|
||||
|
||||
|
|
|
@ -117,6 +117,7 @@ ASTNodeKind ASTNodeKind::getFromNode(const OMPClause &C) {
|
|||
case OMPC_threadprivate:
|
||||
case OMPC_uniform:
|
||||
case OMPC_device_type:
|
||||
case OMPC_match:
|
||||
case OMPC_unknown:
|
||||
llvm_unreachable("unexpected OpenMP clause kind");
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ OMPClause::child_range OMPClause::used_children() {
|
|||
case OMPC_threadprivate:
|
||||
case OMPC_uniform:
|
||||
case OMPC_device_type:
|
||||
case OMPC_match:
|
||||
case OMPC_unknown:
|
||||
break;
|
||||
}
|
||||
|
@ -129,6 +130,7 @@ const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) {
|
|||
case OMPC_dynamic_allocators:
|
||||
case OMPC_atomic_default_mem_order:
|
||||
case OMPC_device_type:
|
||||
case OMPC_match:
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -206,6 +208,7 @@ const OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(const OMPClause *C)
|
|||
case OMPC_dynamic_allocators:
|
||||
case OMPC_atomic_default_mem_order:
|
||||
case OMPC_device_type:
|
||||
case OMPC_match:
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ OpenMPClauseKind clang::getOpenMPClauseKind(StringRef Str) {
|
|||
#include "clang/Basic/OpenMPKinds.def"
|
||||
.Case("uniform", OMPC_uniform)
|
||||
.Case("device_type", OMPC_device_type)
|
||||
.Case("match", OMPC_match)
|
||||
.Default(OMPC_unknown);
|
||||
}
|
||||
|
||||
|
@ -74,6 +75,8 @@ const char *clang::getOpenMPClauseName(OpenMPClauseKind Kind) {
|
|||
return "threadprivate or thread local";
|
||||
case OMPC_device_type:
|
||||
return "device_type";
|
||||
case OMPC_match:
|
||||
return "match";
|
||||
}
|
||||
llvm_unreachable("Invalid OpenMP clause kind");
|
||||
}
|
||||
|
@ -200,6 +203,7 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind,
|
|||
case OMPC_unified_shared_memory:
|
||||
case OMPC_reverse_offload:
|
||||
case OMPC_dynamic_allocators:
|
||||
case OMPC_match:
|
||||
break;
|
||||
}
|
||||
llvm_unreachable("Invalid OpenMP simple clause kind");
|
||||
|
@ -393,6 +397,7 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
|
|||
case OMPC_unified_shared_memory:
|
||||
case OMPC_reverse_offload:
|
||||
case OMPC_dynamic_allocators:
|
||||
case OMPC_match:
|
||||
break;
|
||||
}
|
||||
llvm_unreachable("Invalid OpenMP simple clause kind");
|
||||
|
@ -831,6 +836,16 @@ bool clang::isAllowedClauseForDirective(OpenMPDirectiveKind DKind,
|
|||
#define OPENMP_ALLOCATE_CLAUSE(Name) \
|
||||
case OMPC_##Name: \
|
||||
return true;
|
||||
#include "clang/Basic/OpenMPKinds.def"
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OMPD_declare_variant:
|
||||
switch (CKind) {
|
||||
#define OPENMP_DECLARE_VARIANT_CLAUSE(Name) \
|
||||
case OMPC_##Name: \
|
||||
return true;
|
||||
#include "clang/Basic/OpenMPKinds.def"
|
||||
default:
|
||||
break;
|
||||
|
@ -848,7 +863,6 @@ bool clang::isAllowedClauseForDirective(OpenMPDirectiveKind DKind,
|
|||
case OMPD_cancellation_point:
|
||||
case OMPD_declare_reduction:
|
||||
case OMPD_declare_simd:
|
||||
case OMPD_declare_variant:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -4038,6 +4038,7 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, OpenMPClauseKind Kind,
|
|||
case OMPC_dynamic_allocators:
|
||||
case OMPC_atomic_default_mem_order:
|
||||
case OMPC_device_type:
|
||||
case OMPC_match:
|
||||
llvm_unreachable("Clause is not allowed in 'omp atomic'.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -796,7 +796,7 @@ bool Parser::parseOpenMPContextSelectors(
|
|||
// Parse inner context selector set name.
|
||||
if (!Tok.is(tok::identifier)) {
|
||||
Diag(Tok.getLocation(), diag::err_omp_declare_variant_no_ctx_selector)
|
||||
<< "match";
|
||||
<< getOpenMPClauseName(OMPC_match);
|
||||
return true;
|
||||
}
|
||||
SmallString<16> Buffer;
|
||||
|
@ -863,9 +863,12 @@ void Parser::ParseOMPDeclareVariantClauses(Parser::DeclGroupPtrTy Ptr,
|
|||
Ptr, AssociatedFunction.get(), SourceRange(Loc, Tok.getLocation()));
|
||||
|
||||
// Parse 'match'.
|
||||
if (!Tok.is(tok::identifier) || PP.getSpelling(Tok).compare("match")) {
|
||||
OpenMPClauseKind CKind = Tok.isAnnotation()
|
||||
? OMPC_unknown
|
||||
: getOpenMPClauseKind(PP.getSpelling(Tok));
|
||||
if (CKind != OMPC_match) {
|
||||
Diag(Tok.getLocation(), diag::err_omp_declare_variant_wrong_clause)
|
||||
<< "match";
|
||||
<< getOpenMPClauseName(OMPC_match);
|
||||
while (!SkipUntil(tok::annot_pragma_openmp_end, Parser::StopBeforeMatch))
|
||||
;
|
||||
// Skip the last annot_pragma_openmp_end.
|
||||
|
@ -875,7 +878,8 @@ void Parser::ParseOMPDeclareVariantClauses(Parser::DeclGroupPtrTy Ptr,
|
|||
(void)ConsumeToken();
|
||||
// Parse '('.
|
||||
BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end);
|
||||
if (T.expectAndConsume(diag::err_expected_lparen_after, "match")) {
|
||||
if (T.expectAndConsume(diag::err_expected_lparen_after,
|
||||
getOpenMPClauseName(OMPC_match))) {
|
||||
while (!SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch))
|
||||
;
|
||||
// Skip the last annot_pragma_openmp_end.
|
||||
|
@ -1950,6 +1954,7 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
|
|||
break;
|
||||
case OMPC_threadprivate:
|
||||
case OMPC_uniform:
|
||||
case OMPC_match:
|
||||
if (!WrongDirective)
|
||||
Diag(Tok, diag::err_omp_unexpected_clause)
|
||||
<< getOpenMPClauseName(CKind) << getOpenMPDirectiveName(DKind);
|
||||
|
|
|
@ -4599,6 +4599,7 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
|
|||
case OMPC_dynamic_allocators:
|
||||
case OMPC_atomic_default_mem_order:
|
||||
case OMPC_device_type:
|
||||
case OMPC_match:
|
||||
llvm_unreachable("Unexpected clause");
|
||||
}
|
||||
for (Stmt *CC : C->children()) {
|
||||
|
@ -10065,6 +10066,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
|
|||
case OMPC_dynamic_allocators:
|
||||
case OMPC_atomic_default_mem_order:
|
||||
case OMPC_device_type:
|
||||
case OMPC_match:
|
||||
llvm_unreachable("Clause is not allowed.");
|
||||
}
|
||||
return Res;
|
||||
|
@ -10615,6 +10617,7 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause(
|
|||
case OMPC_dynamic_allocators:
|
||||
case OMPC_atomic_default_mem_order:
|
||||
case OMPC_device_type:
|
||||
case OMPC_match:
|
||||
llvm_unreachable("Unexpected OpenMP clause.");
|
||||
}
|
||||
return CaptureRegion;
|
||||
|
@ -11009,6 +11012,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause(
|
|||
case OMPC_reverse_offload:
|
||||
case OMPC_dynamic_allocators:
|
||||
case OMPC_device_type:
|
||||
case OMPC_match:
|
||||
llvm_unreachable("Clause is not allowed.");
|
||||
}
|
||||
return Res;
|
||||
|
@ -11188,6 +11192,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprWithArgClause(
|
|||
case OMPC_dynamic_allocators:
|
||||
case OMPC_atomic_default_mem_order:
|
||||
case OMPC_device_type:
|
||||
case OMPC_match:
|
||||
llvm_unreachable("Clause is not allowed.");
|
||||
}
|
||||
return Res;
|
||||
|
@ -11398,6 +11403,7 @@ OMPClause *Sema::ActOnOpenMPClause(OpenMPClauseKind Kind,
|
|||
case OMPC_is_device_ptr:
|
||||
case OMPC_atomic_default_mem_order:
|
||||
case OMPC_device_type:
|
||||
case OMPC_match:
|
||||
llvm_unreachable("Clause is not allowed.");
|
||||
}
|
||||
return Res;
|
||||
|
@ -11605,6 +11611,7 @@ OMPClause *Sema::ActOnOpenMPVarListClause(
|
|||
case OMPC_dynamic_allocators:
|
||||
case OMPC_atomic_default_mem_order:
|
||||
case OMPC_device_type:
|
||||
case OMPC_match:
|
||||
llvm_unreachable("Clause is not allowed.");
|
||||
}
|
||||
return Res;
|
||||
|
|
Loading…
Reference in New Issue