]> granicus.if.org Git - clang/commitdiff
[OPENMP]Use standard parsing for 'match' clause, NFC.
authorAlexey Bataev <a.bataev@hotmail.com>
Mon, 23 Sep 2019 18:13:31 +0000 (18:13 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Mon, 23 Sep 2019 18:13:31 +0000 (18:13 +0000)
Reused standard clauses parsing scheme for parsing/matching 'match'
clause in 'declare variant' directive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@372635 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/RecursiveASTVisitor.h
include/clang/Basic/OpenMPKinds.def
include/clang/Basic/OpenMPKinds.h
lib/AST/ASTTypeTraits.cpp
lib/AST/OpenMPClause.cpp
lib/Basic/OpenMPKinds.cpp
lib/CodeGen/CGStmtOpenMP.cpp
lib/Parse/ParseOpenMP.cpp
lib/Sema/SemaOpenMP.cpp

index c0cb6aadc7d65830338a264fd03afc28ead12cdf..afc701b95b4141e810bd99c687806521bfd13c4f 100644 (file)
@@ -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;
   }
index 05ecc3496fd43c6839a17a15c71924afc717f4a1..2cd5b296729331d144c646a3c30565f5f4bd3de4 100644 (file)
 #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
index 003737b0ab783de540cff2645c08559be43db8db..fe0ba51becadebdc1206e0106534fc0a9dde54ff 100644 (file)
@@ -36,6 +36,7 @@ enum OpenMPClauseKind {
   OMPC_threadprivate,
   OMPC_uniform,
   OMPC_device_type,
+  OMPC_match,
   OMPC_unknown
 };
 
index 8615dee4e79582434c470e5e6671b94ae9023397..875170c30c253eaf3954a2c49d11fbf65df0df4e 100644 (file)
@@ -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");
   }
index 0312fe6b7696776f5dec7f6221e3e4bc6daa1e15..bfe272b1d935d30563ccafe49166bb3850c7edbc 100644 (file)
@@ -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;
   }
 
index 48590277b98e0495a1d751b984ce70561ea4a307..f69efe1aaaba69322f07d87245ee01eda61229a8 100644 (file)
@@ -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;
index b41ad55322660778133fec85d90eda07c54f7fa4..bb6323e118cc2ac45cc837163d3fe16c1ce3327d 100644 (file)
@@ -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'.");
   }
 }
index 8d852b5dcb5b8498610bdab368c318f9e247c8ad..570f246d19b1d7cf253237bdb74cb5792d68cedd 100644 (file)
@@ -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);
index 6f788fbb86dff1e5066931bb88e79708672ea189..34ce66c4e3f3e7cc58eacf66932f2af58b8f2690 100644 (file)
@@ -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;