[clang] 31cca21 - Revert "OpenMP 5.0 metadirective"

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 18 06:21:24 PDT 2021


Author: Nico Weber
Date: 2021-09-18T09:10:37-04:00
New Revision: 31cca215654ac5eca01796248696b8d710a5cffc

URL: https://github.com/llvm/llvm-project/commit/31cca215654ac5eca01796248696b8d710a5cffc
DIFF: https://github.com/llvm/llvm-project/commit/31cca215654ac5eca01796248696b8d710a5cffc.diff

LOG: Revert "OpenMP 5.0 metadirective"

This reverts commit c7d7b98e5263472f05b2f3cb767b5d16e1349e9a.
Breaks tests on macOS, see comment on https://reviews.llvm.org/D91944

Added: 
    

Modified: 
    clang/include/clang-c/Index.h
    clang/include/clang/AST/RecursiveASTVisitor.h
    clang/include/clang/AST/StmtOpenMP.h
    clang/include/clang/Basic/DiagnosticParseKinds.td
    clang/include/clang/Basic/DiagnosticSemaKinds.td
    clang/include/clang/Basic/StmtNodes.td
    clang/include/clang/Sema/Sema.h
    clang/include/clang/Serialization/ASTBitCodes.h
    clang/lib/AST/OpenMPClause.cpp
    clang/lib/AST/StmtOpenMP.cpp
    clang/lib/AST/StmtPrinter.cpp
    clang/lib/AST/StmtProfile.cpp
    clang/lib/Basic/OpenMPKinds.cpp
    clang/lib/CodeGen/CGOpenMPRuntime.cpp
    clang/lib/CodeGen/CGStmt.cpp
    clang/lib/CodeGen/CGStmtOpenMP.cpp
    clang/lib/CodeGen/CodeGenFunction.h
    clang/lib/Parse/ParseOpenMP.cpp
    clang/lib/Sema/SemaExceptionSpec.cpp
    clang/lib/Sema/SemaOpenMP.cpp
    clang/lib/Sema/TreeTransform.h
    clang/lib/Serialization/ASTReaderStmt.cpp
    clang/lib/Serialization/ASTWriterStmt.cpp
    clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
    clang/tools/libclang/CIndex.cpp
    clang/tools/libclang/CXCursor.cpp
    flang/lib/Semantics/check-omp-structure.cpp
    llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 
    clang/test/OpenMP/metadirective_ast_print.c
    clang/test/OpenMP/metadirective_device_kind_codegen.c
    clang/test/OpenMP/metadirective_device_kind_codegen.cpp
    clang/test/OpenMP/metadirective_empty.cpp
    clang/test/OpenMP/metadirective_implementation_codegen.c
    clang/test/OpenMP/metadirective_implementation_codegen.cpp
    clang/test/OpenMP/metadirective_messages.cpp


################################################################################
diff  --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index b49acf6b58543..8afd4c9ff1d05 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -2592,11 +2592,7 @@ enum CXCursorKind {
    */
   CXCursor_OMPUnrollDirective = 293,
 
-  /** OpenMP metadirective directive.
-   */
-  CXCursor_OMPMetaDirective = 294,
-
-  CXCursor_LastStmt = CXCursor_OMPMetaDirective,
+  CXCursor_LastStmt = CXCursor_OMPUnrollDirective,
 
   /**
    * Cursor that represents the translation unit itself.

diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h
index 9b261e8540dac..9bfa5b9c23260 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2842,9 +2842,6 @@ RecursiveASTVisitor<Derived>::TraverseOMPLoopDirective(OMPLoopDirective *S) {
   return TraverseOMPExecutableDirective(S);
 }
 
-DEF_TRAVERSE_STMT(OMPMetaDirective,
-                  { TRY_TO(TraverseOMPExecutableDirective(S)); })
-
 DEF_TRAVERSE_STMT(OMPParallelDirective,
                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
 

diff  --git a/clang/include/clang/AST/StmtOpenMP.h b/clang/include/clang/AST/StmtOpenMP.h
index f028c3b323986..cd5fa2b94c317 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -5379,44 +5379,6 @@ class OMPMaskedDirective final : public OMPExecutableDirective {
   }
 };
 
-/// This represents '#pragma omp metadirective' directive.
-///
-/// \code
-/// #pragma omp metadirective when(user={condition(N>10)}: parallel for)
-/// \endcode
-/// In this example directive '#pragma omp metadirective' has clauses 'when'
-/// with a dynamic user condition to check if a variable 'N > 10'
-///
-class OMPMetaDirective final : public OMPExecutableDirective {
-  friend class ASTStmtReader;
-  friend class OMPExecutableDirective;
-  Stmt *IfStmt;
-
-  OMPMetaDirective(SourceLocation StartLoc, SourceLocation EndLoc)
-      : OMPExecutableDirective(OMPMetaDirectiveClass,
-                               llvm::omp::OMPD_metadirective, StartLoc,
-                               EndLoc) {}
-  explicit OMPMetaDirective()
-      : OMPExecutableDirective(OMPMetaDirectiveClass,
-                               llvm::omp::OMPD_metadirective, SourceLocation(),
-                               SourceLocation()) {}
-
-  void setIfStmt(Stmt *S) { IfStmt = S; }
-
-public:
-  static OMPMetaDirective *Create(const ASTContext &C, SourceLocation StartLoc,
-                                  SourceLocation EndLoc,
-                                  ArrayRef<OMPClause *> Clauses,
-                                  Stmt *AssociatedStmt, Stmt *IfStmt);
-  static OMPMetaDirective *CreateEmpty(const ASTContext &C, unsigned NumClauses,
-                                       EmptyShell);
-  Stmt *getIfStmt() const { return IfStmt; }
-
-  static bool classof(const Stmt *T) {
-    return T->getStmtClass() == OMPMetaDirectiveClass;
-  }
-};
-
 } // end namespace clang
 
 #endif

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 834f29fa028a7..6c6c397513a6e 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1436,9 +1436,6 @@ def warn_omp51_compat_attributes : Warning<
   "specifying OpenMP directives with [[]] is incompatible with OpenMP "
   "standards before OpenMP 5.1">,
   InGroup<OpenMPPre51Compat>, DefaultIgnore;
-def err_omp_expected_colon : Error<"missing ':' in %0">;
-def err_omp_expected_context_selector
-    : Error<"expected valid context selector in %0">;
 
 // Pragma loop support.
 def err_pragma_loop_missing_argument : Error<

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 3cadd986b8ae4..cef82aba6c2f1 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10794,8 +10794,6 @@ def err_omp_dispatch_statement_call
 def err_omp_unroll_full_variable_trip_count : Error<
   "loop to be fully unrolled must have a constant trip count">;
 def note_omp_directive_here : Note<"'%0' directive found here">;
-def err_omp_instantiation_not_supported
-    : Error<"instantiation of '%0' not supported yet">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {

diff  --git a/clang/include/clang/Basic/StmtNodes.td b/clang/include/clang/Basic/StmtNodes.td
index c5540a16056f8..508f1fddf1b35 100644
--- a/clang/include/clang/Basic/StmtNodes.td
+++ b/clang/include/clang/Basic/StmtNodes.td
@@ -219,7 +219,6 @@ def AsTypeExpr : StmtNode<Expr>;
 // OpenMP Directives.
 def OMPCanonicalLoop : StmtNode<Stmt>;
 def OMPExecutableDirective : StmtNode<Stmt, 1>;
-def OMPMetaDirective : StmtNode<OMPExecutableDirective>;
 def OMPLoopBasedDirective : StmtNode<OMPExecutableDirective, 1>;
 def OMPLoopDirective : StmtNode<OMPLoopBasedDirective, 1>;
 def OMPParallelDirective : StmtNode<OMPExecutableDirective>;

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 93d5558b8267c..ebe2438141b60 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -10456,12 +10456,6 @@ class Sema final {
   /// \param Init First part of the for loop.
   void ActOnOpenMPLoopInitialization(SourceLocation ForLoc, Stmt *Init);
 
-  /// Called on well-formed '\#pragma omp metadirective' after parsing
-  /// of the  associated statement.
-  StmtResult ActOnOpenMPMetaDirective(ArrayRef<OMPClause *> Clauses,
-                                      Stmt *AStmt, SourceLocation StartLoc,
-                                      SourceLocation EndLoc);
-
   // OpenMP directives and clauses.
   /// Called on correct id-expression from the '#pragma omp
   /// threadprivate'.
@@ -11029,10 +11023,6 @@ class Sema final {
                                      SourceLocation StartLoc,
                                      SourceLocation LParenLoc,
                                      SourceLocation EndLoc);
-  /// Called on well-formed 'when' clause.
-  OMPClause *ActOnOpenMPWhenClause(OMPTraitInfo &TI, SourceLocation StartLoc,
-                                   SourceLocation LParenLoc,
-                                   SourceLocation EndLoc);
   /// Called on well-formed 'default' clause.
   OMPClause *ActOnOpenMPDefaultClause(llvm::omp::DefaultKind Kind,
                                       SourceLocation KindLoc,

diff  --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h
index e771aa3d07aa5..a08c4615b738a 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1893,7 +1893,6 @@ enum StmtCode {
   STMT_SEH_TRY,                     // SEHTryStmt
 
   // OpenMP directives
-  STMT_OMP_META_DIRECTIVE,
   STMT_OMP_CANONICAL_LOOP,
   STMT_OMP_PARALLEL_DIRECTIVE,
   STMT_OMP_SIMD_DIRECTIVE,

diff  --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp
index caf938a5b9582..596a55e425feb 100644
--- a/clang/lib/AST/OpenMPClause.cpp
+++ b/clang/lib/AST/OpenMPClause.cpp
@@ -160,7 +160,6 @@ const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) {
   case OMPC_exclusive:
   case OMPC_uses_allocators:
   case OMPC_affinity:
-  case OMPC_when:
     break;
   default:
     break;
@@ -258,7 +257,6 @@ const OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(const OMPClause *C)
   case OMPC_exclusive:
   case OMPC_uses_allocators:
   case OMPC_affinity:
-  case OMPC_when:
     break;
   default:
     break;

diff  --git a/clang/lib/AST/StmtOpenMP.cpp b/clang/lib/AST/StmtOpenMP.cpp
index f461d9b65042c..b0ef2f49ba040 100644
--- a/clang/lib/AST/StmtOpenMP.cpp
+++ b/clang/lib/AST/StmtOpenMP.cpp
@@ -253,25 +253,6 @@ void OMPLoopDirective::setFinalsConditions(ArrayRef<Expr *> A) {
   llvm::copy(A, getFinalsConditions().begin());
 }
 
-OMPMetaDirective *OMPMetaDirective::Create(const ASTContext &C,
-                                           SourceLocation StartLoc,
-                                           SourceLocation EndLoc,
-                                           ArrayRef<OMPClause *> Clauses,
-                                           Stmt *AssociatedStmt, Stmt *IfStmt) {
-  auto *Dir = createDirective<OMPMetaDirective>(
-      C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);
-  Dir->setIfStmt(IfStmt);
-  return Dir;
-}
-
-OMPMetaDirective *OMPMetaDirective::CreateEmpty(const ASTContext &C,
-                                                unsigned NumClauses,
-                                                EmptyShell) {
-  return createEmptyDirective<OMPMetaDirective>(C, NumClauses,
-                                                /*HasAssociatedStmt=*/true,
-                                                /*NumChildren=*/1);
-}
-
 OMPParallelDirective *OMPParallelDirective::Create(
     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,

diff  --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index 0006f950989cf..45cdb416cd601 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -654,11 +654,6 @@ void StmtPrinter::PrintOMPExecutableDirective(OMPExecutableDirective *S,
     PrintStmt(S->getRawStmt());
 }
 
-void StmtPrinter::VisitOMPMetaDirective(OMPMetaDirective *Node) {
-  Indent() << "#pragma omp metadirective";
-  PrintOMPExecutableDirective(Node);
-}
-
 void StmtPrinter::VisitOMPParallelDirective(OMPParallelDirective *Node) {
   Indent() << "#pragma omp parallel";
   PrintOMPExecutableDirective(Node);

diff  --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index 1afa3773c7111..ed000c2467fac 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -903,10 +903,6 @@ void StmtProfiler::VisitOMPLoopDirective(const OMPLoopDirective *S) {
   VisitOMPLoopBasedDirective(S);
 }
 
-void StmtProfiler::VisitOMPMetaDirective(const OMPMetaDirective *S) {
-  VisitOMPExecutableDirective(S);
-}
-
 void StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) {
   VisitOMPExecutableDirective(S);
 }

diff  --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index c86c0958fef45..84579c0f0ae2b 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -185,7 +185,6 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind, StringRef Str,
   case OMPC_exclusive:
   case OMPC_uses_allocators:
   case OMPC_affinity:
-  case OMPC_when:
     break;
   default:
     break;
@@ -429,7 +428,6 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
   case OMPC_exclusive:
   case OMPC_uses_allocators:
   case OMPC_affinity:
-  case OMPC_when:
     break;
   default:
     break;
@@ -593,9 +591,6 @@ void clang::getOpenMPCaptureRegions(
     OpenMPDirectiveKind DKind) {
   assert(unsigned(DKind) < llvm::omp::Directive_enumSize);
   switch (DKind) {
-  case OMPD_metadirective:
-    CaptureRegions.push_back(OMPD_metadirective);
-    break;
   case OMPD_parallel:
   case OMPD_parallel_for:
   case OMPD_parallel_for_simd:

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 63db859003f1e..6390a84219d4e 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6740,7 +6740,6 @@ const Expr *CGOpenMPRuntime::getNumTeamsExprForTargetDirective(
   case OMPD_parallel_master_taskloop:
   case OMPD_parallel_master_taskloop_simd:
   case OMPD_requires:
-  case OMPD_metadirective:
   case OMPD_unknown:
     break;
   default:
@@ -7215,7 +7214,6 @@ llvm::Value *CGOpenMPRuntime::emitNumThreadsForTargetDirective(
   case OMPD_parallel_master_taskloop:
   case OMPD_parallel_master_taskloop_simd:
   case OMPD_requires:
-  case OMPD_metadirective:
   case OMPD_unknown:
     break;
   default:
@@ -9853,7 +9851,6 @@ getNestedDistributeDirective(ASTContext &Ctx, const OMPExecutableDirective &D) {
     case OMPD_parallel_master_taskloop:
     case OMPD_parallel_master_taskloop_simd:
     case OMPD_requires:
-    case OMPD_metadirective:
     case OMPD_unknown:
     default:
       llvm_unreachable("Unexpected directive.");
@@ -10704,7 +10701,6 @@ void CGOpenMPRuntime::scanForTargetRegionsFunctions(const Stmt *S,
     case OMPD_parallel_master_taskloop:
     case OMPD_parallel_master_taskloop_simd:
     case OMPD_requires:
-    case OMPD_metadirective:
     case OMPD_unknown:
     default:
       llvm_unreachable("Unknown target directive for OpenMP device codegen.");
@@ -11386,7 +11382,6 @@ void CGOpenMPRuntime::emitTargetDataStandAloneCall(
     case OMPD_target_parallel_for:
     case OMPD_target_parallel_for_simd:
     case OMPD_requires:
-    case OMPD_metadirective:
     case OMPD_unknown:
     default:
       llvm_unreachable("Unexpected standalone target data directive.");

diff  --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 373179349fb0a..324ed046922c3 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -196,9 +196,6 @@ void CodeGenFunction::EmitStmt(const Stmt *S, ArrayRef<const Attr *> Attrs) {
   case Stmt::SEHTryStmtClass:
     EmitSEHTryStmt(cast<SEHTryStmt>(*S));
     break;
-  case Stmt::OMPMetaDirectiveClass:
-    EmitOMPMetaDirective(cast<OMPMetaDirective>(*S));
-    break;
   case Stmt::OMPCanonicalLoopClass:
     EmitOMPCanonicalLoop(cast<OMPCanonicalLoop>(S));
     break;

diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 68ab1362a454c..55c4822387d0e 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1784,10 +1784,6 @@ void CodeGenFunction::EmitOMPParallelDirective(const OMPParallelDirective &S) {
   checkForLastprivateConditionalUpdate(*this, S);
 }
 
-void CodeGenFunction::EmitOMPMetaDirective(const OMPMetaDirective &S) {
-  EmitStmt(S.getIfStmt());
-}
-
 namespace {
 /// RAII to handle scopes for loop transformation directives.
 class OMPTransformDirectiveScopeRAII {
@@ -5990,7 +5986,6 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, OpenMPClauseKind Kind,
   case OMPC_novariants:
   case OMPC_nocontext:
   case OMPC_filter:
-  case OMPC_when:
     llvm_unreachable("Clause is not allowed in 'omp atomic'.");
   }
 }

diff  --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 6c13445129b0c..023fd4dce32fa 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -3464,7 +3464,6 @@ class CodeGenFunction : public CodeGenTypeCache {
                                        const RegionCodeGenTy &BodyGen,
                                        OMPTargetDataInfo &InputInfo);
 
-  void EmitOMPMetaDirective(const OMPMetaDirective &S);
   void EmitOMPParallelDirective(const OMPParallelDirective &S);
   void EmitOMPSimdDirective(const OMPSimdDirective &S);
   void EmitOMPTileDirective(const OMPTileDirective &S);

diff  --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index ea8964f50ff10..fb4c541f1d741 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -2226,7 +2226,6 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
   case OMPD_target_teams_distribute_simd:
   case OMPD_dispatch:
   case OMPD_masked:
-  case OMPD_metadirective:
     Diag(Tok, diag::err_omp_unexpected_directive)
         << 1 << getOpenMPDirectiveName(DKind);
     break;
@@ -2281,10 +2280,8 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
 ///
 StmtResult
 Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
-  static bool ReadDirectiveWithinMetadirective = false;
-  if (!ReadDirectiveWithinMetadirective)
-    assert(Tok.isOneOf(tok::annot_pragma_openmp, tok::annot_attr_openmp) &&
-           "Not an OpenMP directive!");
+  assert(Tok.isOneOf(tok::annot_pragma_openmp, tok::annot_attr_openmp) &&
+         "Not an OpenMP directive!");
   ParsingOpenMPDirectiveRAII DirScope(*this);
   ParenBraceBracketBalancer BalancerRAIIObj(*this);
   SmallVector<OMPClause *, 5> Clauses;
@@ -2293,15 +2290,8 @@ Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
       FirstClauses(llvm::omp::Clause_enumSize + 1);
   unsigned ScopeFlags = Scope::FnScope | Scope::DeclScope |
                         Scope::CompoundStmtScope | Scope::OpenMPDirectiveScope;
-  SourceLocation Loc = ReadDirectiveWithinMetadirective
-                           ? Tok.getLocation()
-                           : ConsumeAnnotationToken(),
-                 EndLoc;
+  SourceLocation Loc = ConsumeAnnotationToken(), EndLoc;
   OpenMPDirectiveKind DKind = parseOpenMPDirectiveKind(*this);
-  if (ReadDirectiveWithinMetadirective && DKind == OMPD_unknown) {
-    Diag(Tok, diag::err_omp_unknown_directive);
-    return StmtError();
-  }
   OpenMPDirectiveKind CancelRegion = OMPD_unknown;
   // Name of critical directive.
   DeclarationNameInfo DirName;
@@ -2309,141 +2299,6 @@ Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
   bool HasAssociatedStatement = true;
 
   switch (DKind) {
-  case OMPD_metadirective: {
-    ConsumeToken();
-    SmallVector<VariantMatchInfo, 4> VMIs;
-
-    // First iteration of parsing all clauses of metadirective.
-    // This iteration only parses and collects all context selector ignoring the
-    // associated directives.
-    TentativeParsingAction TPA(*this);
-    ASTContext &ASTContext = Actions.getASTContext();
-
-    BalancedDelimiterTracker T(*this, tok::l_paren,
-                               tok::annot_pragma_openmp_end);
-    while (Tok.isNot(tok::annot_pragma_openmp_end)) {
-      OpenMPClauseKind CKind = Tok.isAnnotation()
-                                   ? OMPC_unknown
-                                   : getOpenMPClauseKind(PP.getSpelling(Tok));
-      SourceLocation Loc = ConsumeToken();
-
-      // Parse '('.
-      if (T.expectAndConsume(diag::err_expected_lparen_after,
-                             getOpenMPClauseName(CKind).data()))
-        return Directive;
-
-      OMPTraitInfo &TI = Actions.getASTContext().getNewOMPTraitInfo();
-      if (CKind == OMPC_when) {
-        // parse and get OMPTraitInfo to pass to the When clause
-        parseOMPContextSelectors(Loc, TI);
-        if (TI.Sets.size() == 0) {
-          Diag(Tok, diag::err_omp_expected_context_selector) << "when clause";
-          TPA.Commit();
-          return Directive;
-        }
-
-        // Parse ':'
-        if (Tok.is(tok::colon))
-          ConsumeAnyToken();
-        else {
-          Diag(Tok, diag::err_omp_expected_colon) << "when clause";
-          TPA.Commit();
-          return Directive;
-        }
-      }
-      // Skip Directive for now. We will parse directive in the second iteration
-      int paren = 0;
-      while (Tok.isNot(tok::r_paren) || paren != 0) {
-        if (Tok.is(tok::l_paren))
-          paren++;
-        if (Tok.is(tok::r_paren))
-          paren--;
-        if (Tok.is(tok::annot_pragma_openmp_end)) {
-          Diag(Tok, diag::err_omp_expected_punc)
-              << getOpenMPClauseName(CKind) << 0;
-          TPA.Commit();
-          return Directive;
-        }
-        ConsumeAnyToken();
-      }
-      // Parse ')'
-      if (Tok.is(tok::r_paren))
-        T.consumeClose();
-
-      VariantMatchInfo VMI;
-      TI.getAsVariantMatchInfo(ASTContext, VMI);
-
-      VMIs.push_back(VMI);
-    }
-
-    TPA.Revert();
-    // End of the first iteration. Parser is reset to the start of metadirective
-
-    TargetOMPContext OMPCtx(ASTContext, /* DiagUnknownTrait */ nullptr,
-                            /* CurrentFunctionDecl */ nullptr,
-                            ArrayRef<llvm::omp::TraitProperty>());
-
-    // A single match is returned for OpenMP 5.0
-    int BestIdx = getBestVariantMatchForContext(VMIs, OMPCtx);
-
-    int Idx = 0;
-    // In OpenMP 5.0 metadirective is either replaced by another directive or
-    // ignored.
-    // TODO: In OpenMP 5.1 generate multiple directives based upon the matches
-    // found by getBestWhenMatchForContext.
-    while (Tok.isNot(tok::annot_pragma_openmp_end)) {
-      // OpenMP 5.0 implementation - Skip to the best index found.
-      if (Idx++ != BestIdx) {
-        ConsumeToken();  // Consume clause name
-        T.consumeOpen(); // Consume '('
-        int paren = 0;
-        // Skip everything inside the clause
-        while (Tok.isNot(tok::r_paren) || paren != 0) {
-          if (Tok.is(tok::l_paren))
-            paren++;
-          if (Tok.is(tok::r_paren))
-            paren--;
-          ConsumeAnyToken();
-        }
-        // Parse ')'
-        if (Tok.is(tok::r_paren))
-          T.consumeClose();
-        continue;
-      }
-
-      OpenMPClauseKind CKind = Tok.isAnnotation()
-                                   ? OMPC_unknown
-                                   : getOpenMPClauseKind(PP.getSpelling(Tok));
-      SourceLocation Loc = ConsumeToken();
-
-      // Parse '('.
-      T.consumeOpen();
-
-      // Skip ContextSelectors for when clause
-      if (CKind == OMPC_when) {
-        OMPTraitInfo &TI = Actions.getASTContext().getNewOMPTraitInfo();
-        // parse and skip the ContextSelectors
-        parseOMPContextSelectors(Loc, TI);
-
-        // Parse ':'
-        ConsumeAnyToken();
-      }
-
-      // If no directive is passed, skip in OpenMP 5.0.
-      // TODO: Generate nothing directive from OpenMP 5.1.
-      if (Tok.is(tok::r_paren)) {
-        SkipUntil(tok::annot_pragma_openmp_end);
-        break;
-      }
-
-      // Parse Directive
-      ReadDirectiveWithinMetadirective = true;
-      Directive = ParseOpenMPDeclarativeOrExecutableDirective(StmtCtx);
-      ReadDirectiveWithinMetadirective = false;
-      break;
-    }
-    break;
-  }
   case OMPD_threadprivate: {
     // FIXME: Should this be permitted in C++?
     if ((StmtCtx & ParsedStmtContext::AllowDeclarationsInC) ==
@@ -2635,13 +2490,6 @@ Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
     Actions.StartOpenMPDSABlock(DKind, DirName, Actions.getCurScope(), Loc);
 
     while (Tok.isNot(tok::annot_pragma_openmp_end)) {
-      // If we are parsing for a directive within a metadirective, the directive
-      // ends with a ')'.
-      if (ReadDirectiveWithinMetadirective && Tok.is(tok::r_paren)) {
-        while (Tok.isNot(tok::annot_pragma_openmp_end))
-          ConsumeAnyToken();
-        break;
-      }
       bool HasImplicitClause = false;
       if (ImplicitClauseAllowed && Tok.is(tok::l_paren)) {
         HasImplicitClause = true;

diff  --git a/clang/lib/Sema/SemaExceptionSpec.cpp b/clang/lib/Sema/SemaExceptionSpec.cpp
index f32bb0d298ba7..0d40b47b24da4 100644
--- a/clang/lib/Sema/SemaExceptionSpec.cpp
+++ b/clang/lib/Sema/SemaExceptionSpec.cpp
@@ -1496,7 +1496,6 @@ CanThrowResult Sema::canThrow(const Stmt *S) {
   case Stmt::OMPInteropDirectiveClass:
   case Stmt::OMPDispatchDirectiveClass:
   case Stmt::OMPMaskedDirectiveClass:
-  case Stmt::OMPMetaDirectiveClass:
   case Stmt::ReturnStmtClass:
   case Stmt::SEHExceptStmtClass:
   case Stmt::SEHFinallyStmtClass:

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 1c81104520f93..a22462bd68fc1 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -4314,7 +4314,6 @@ void Sema::ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope) {
   case OMPD_declare_variant:
   case OMPD_begin_declare_variant:
   case OMPD_end_declare_variant:
-  case OMPD_metadirective:
     llvm_unreachable("OpenMP Directive is not allowed");
   case OMPD_unknown:
   default:
@@ -6364,7 +6363,6 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
       case OMPC_atomic_default_mem_order:
       case OMPC_device_type:
       case OMPC_match:
-      case OMPC_when:
       default:
         llvm_unreachable("Unexpected clause");
       }
@@ -13302,7 +13300,6 @@ OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
   case OMPC_exclusive:
   case OMPC_uses_allocators:
   case OMPC_affinity:
-  case OMPC_when:
   default:
     llvm_unreachable("Clause is not allowed.");
   }
@@ -13459,7 +13456,6 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause(
     case OMPD_atomic:
     case OMPD_teams_distribute:
     case OMPD_requires:
-    case OMPD_metadirective:
       llvm_unreachable("Unexpected OpenMP directive with if-clause");
     case OMPD_unknown:
     default:
@@ -13542,7 +13538,6 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause(
     case OMPD_teams_distribute:
     case OMPD_teams_distribute_simd:
     case OMPD_requires:
-    case OMPD_metadirective:
       llvm_unreachable("Unexpected OpenMP directive with num_threads-clause");
     case OMPD_unknown:
     default:
@@ -13623,7 +13618,6 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause(
     case OMPD_atomic:
     case OMPD_distribute_simd:
     case OMPD_requires:
-    case OMPD_metadirective:
       llvm_unreachable("Unexpected OpenMP directive with num_teams-clause");
     case OMPD_unknown:
     default:
@@ -13704,7 +13698,6 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause(
     case OMPD_atomic:
     case OMPD_distribute_simd:
     case OMPD_requires:
-    case OMPD_metadirective:
       llvm_unreachable("Unexpected OpenMP directive with thread_limit-clause");
     case OMPD_unknown:
     default:
@@ -13785,7 +13778,6 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause(
     case OMPD_distribute_simd:
     case OMPD_target_teams:
     case OMPD_requires:
-    case OMPD_metadirective:
       llvm_unreachable("Unexpected OpenMP directive with schedule clause");
     case OMPD_unknown:
     default:
@@ -13866,7 +13858,6 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause(
     case OMPD_atomic:
     case OMPD_target_teams:
     case OMPD_requires:
-    case OMPD_metadirective:
       llvm_unreachable("Unexpected OpenMP directive with dist_schedule clause");
     case OMPD_unknown:
     default:
@@ -13949,7 +13940,6 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause(
     case OMPD_atomic:
     case OMPD_distribute_simd:
     case OMPD_requires:
-    case OMPD_metadirective:
       llvm_unreachable("Unexpected OpenMP directive with device-clause");
     case OMPD_unknown:
     default:
@@ -14032,7 +14022,6 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause(
     case OMPD_atomic:
     case OMPD_distribute_simd:
     case OMPD_requires:
-    case OMPD_metadirective:
       llvm_unreachable("Unexpected OpenMP directive with grainsize-clause");
     case OMPD_unknown:
     default:
@@ -14052,15 +14041,6 @@ static OpenMPDirectiveKind getOpenMPCaptureRegionForClause(
   case OMPC_filter:
     // Do not capture filter-clause expressions.
     break;
-  case OMPC_when:
-    if (DKind == OMPD_metadirective) {
-      CaptureRegion = OMPD_metadirective;
-    } else if (DKind == OMPD_unknown) {
-      llvm_unreachable("Unknown OpenMP directive");
-    } else {
-      llvm_unreachable("Unexpected OpenMP directive with when clause");
-    }
-    break;
   case OMPC_firstprivate:
   case OMPC_lastprivate:
   case OMPC_reduction:
@@ -14588,7 +14568,6 @@ OMPClause *Sema::ActOnOpenMPSimpleClause(
   case OMPC_exclusive:
   case OMPC_uses_allocators:
   case OMPC_affinity:
-  case OMPC_when:
   default:
     llvm_unreachable("Clause is not allowed.");
   }
@@ -14881,7 +14860,6 @@ OMPClause *Sema::ActOnOpenMPSingleExprWithArgClause(
   case OMPC_exclusive:
   case OMPC_uses_allocators:
   case OMPC_affinity:
-  case OMPC_when:
   default:
     llvm_unreachable("Clause is not allowed.");
   }
@@ -15131,7 +15109,6 @@ OMPClause *Sema::ActOnOpenMPClause(OpenMPClauseKind Kind,
   case OMPC_exclusive:
   case OMPC_uses_allocators:
   case OMPC_affinity:
-  case OMPC_when:
   default:
     llvm_unreachable("Clause is not allowed.");
   }
@@ -15674,7 +15651,6 @@ OMPClause *Sema::ActOnOpenMPVarListClause(
   case OMPC_nocontext:
   case OMPC_detach:
   case OMPC_uses_allocators:
-  case OMPC_when:
   default:
     llvm_unreachable("Clause is not allowed.");
   }

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index b4089def5d9c0..2a7ceaf6425ee 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -8504,15 +8504,6 @@ StmtResult TreeTransform<Derived>::TransformOMPExecutableDirective(
       AssociatedStmt.get(), D->getBeginLoc(), D->getEndLoc());
 }
 
-template <typename Derived>
-StmtResult
-TreeTransform<Derived>::TransformOMPMetaDirective(OMPMetaDirective *D) {
-  // TODO: Fix This
-  SemaRef.Diag(D->getBeginLoc(), diag::err_omp_instantiation_not_supported)
-      << getOpenMPDirectiveName(D->getDirectiveKind());
-  return StmtError();
-}
-
 template <typename Derived>
 StmtResult
 TreeTransform<Derived>::TransformOMPParallelDirective(OMPParallelDirective *D) {

diff  --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp
index ecdae0d177664..b100f946f5588 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -2307,13 +2307,6 @@ void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
   VisitOMPLoopBasedDirective(D);
 }
 
-void ASTStmtReader::VisitOMPMetaDirective(OMPMetaDirective *D) {
-  VisitStmt(D);
-  // The NumClauses field was read in ReadStmtFromStream.
-  Record.skipInts(1);
-  VisitOMPExecutableDirective(D);
-}
-
 void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
   VisitStmt(D);
   VisitOMPExecutableDirective(D);
@@ -3190,11 +3183,6 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
       S = OMPCanonicalLoop::createEmpty(Context);
       break;
 
-    case STMT_OMP_META_DIRECTIVE:
-      S = OMPMetaDirective::CreateEmpty(
-          Context, Record[ASTStmtReader::NumStmtFields], Empty);
-      break;
-
     case STMT_OMP_PARALLEL_DIRECTIVE:
       S =
         OMPParallelDirective::CreateEmpty(Context,

diff  --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp
index 9ee4d0cafe451..2bb5e4f3563df 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -2205,13 +2205,6 @@ void ASTStmtWriter::VisitOMPLoopDirective(OMPLoopDirective *D) {
   VisitOMPLoopBasedDirective(D);
 }
 
-void ASTStmtWriter::VisitOMPMetaDirective(OMPMetaDirective *D) {
-  VisitStmt(D);
-  Record.push_back(D->getNumClauses());
-  VisitOMPExecutableDirective(D);
-  Code = serialization::STMT_OMP_META_DIRECTIVE;
-}
-
 void ASTStmtWriter::VisitOMPParallelDirective(OMPParallelDirective *D) {
   VisitStmt(D);
   VisitOMPExecutableDirective(D);

diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 2379c8b7ae613..66332d3b848cd 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1298,8 +1298,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
     case Stmt::OMPDispatchDirectiveClass:
     case Stmt::OMPMaskedDirectiveClass:
     case Stmt::CapturedStmtClass:
-    case Stmt::OMPUnrollDirectiveClass:
-    case Stmt::OMPMetaDirectiveClass: {
+    case Stmt::OMPUnrollDirectiveClass: {
       const ExplodedNode *node = Bldr.generateSink(S, Pred, Pred->getState());
       Engine.addAbortedBlock(node, currBldrCtx->getBlock());
       break;

diff  --git a/clang/test/OpenMP/metadirective_ast_print.c b/clang/test/OpenMP/metadirective_ast_print.c
deleted file mode 100644
index c09da50ab3ec3..0000000000000
--- a/clang/test/OpenMP/metadirective_ast_print.c
+++ /dev/null
@@ -1,73 +0,0 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c -std=c99 -ast-print %s -o - | FileCheck %s
-
-// RUN: %clang_cc1 -verify -fopenmp-simd -x c -std=c99 -ast-print %s -o - | FileCheck %s
-// expected-no-diagnostics
-
-#ifndef HEADER
-#define HEADER
-
-void bar(void);
-
-#define N 10
-void foo(void) {
-#pragma omp metadirective when(device = {kind(cpu)} \
-                               : parallel) default()
-  bar();
-#pragma omp metadirective when(implementation = {vendor(score(0)  \
-                                                        : llvm)}, \
-                               device = {kind(cpu)}               \
-                               : parallel) default(target teams)
-  bar();
-#pragma omp metadirective when(device = {kind(gpu)}                                 \
-                               : target teams) when(implementation = {vendor(llvm)} \
-                                                    : parallel) default()
-  bar();
-#pragma omp metadirective default(target) when(implementation = {vendor(score(5)  \
-                                                                        : llvm)}, \
-                                               device = {kind(cpu, host)}         \
-                                               : parallel)
-  bar();
-#pragma omp metadirective when(user = {condition(N > 10)}                 \
-                               : target) when(user = {condition(N == 10)} \
-                                              : parallel)
-  bar();
-#pragma omp metadirective when(device = {kind(host)} \
-                               : parallel for)
-  for (int i = 0; i < 100; i++)
-    ;
-#pragma omp metadirective when(implementation = {extension(match_all)} \
-                               : parallel) default(parallel for)
-  for (int i = 0; i < 100; i++)
-    ;
-#pragma omp metadirective when(implementation = {extension(match_any)} \
-                               : parallel) default(parallel for)
-  for (int i = 0; i < 100; i++)
-    ;
-#pragma omp metadirective when(implementation = {extension(match_none)} \
-                               : parallel) default(parallel for)
-  for (int i = 0; i < 100; i++)
-    ;
-}
-
-// CHECK: void bar();
-// CHECK: void foo()
-// CHECK-NEXT: #pragma omp parallel
-// CHECK-NEXT: bar()
-// CHECK-NEXT: #pragma omp parallel
-// CHECK-NEXT: bar()
-// CHECK-NEXT: #pragma omp parallel
-// CHECK-NEXT: bar()
-// CHECK-NEXT: #pragma omp parallel
-// CHECK-NEXT: bar()
-// CHECK-NEXT: #pragma omp parallel
-// CHECK-NEXT: bar()
-// CHECK-NEXT: #pragma omp parallel for
-// CHECK-NEXT: for (int i = 0; i < 100; i++)
-// CHECK: #pragma omp parallel
-// CHECK-NEXT: for (int i = 0; i < 100; i++)
-// CHECK: #pragma omp parallel for
-// CHECK-NEXT: for (int i = 0; i < 100; i++)
-// CHECK: #pragma omp parallel
-// CHECK-NEXT: for (int i = 0; i < 100; i++)
-
-#endif

diff  --git a/clang/test/OpenMP/metadirective_device_kind_codegen.c b/clang/test/OpenMP/metadirective_device_kind_codegen.c
deleted file mode 100644
index 3b0c52dddea58..0000000000000
--- a/clang/test/OpenMP/metadirective_device_kind_codegen.c
+++ /dev/null
@@ -1,81 +0,0 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c -std=c99 -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -verify -fopenmp -x c -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -verify -fopenmp -x c -triple aarch64-unknown-linux -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -verify -fopenmp -x c -triple ppc64le-unknown-linux -emit-llvm %s -o - | FileCheck %s
-// expected-no-diagnostics
-#ifndef HEADER
-#define HEADER
-
-void bar();
-
-void foo() {
-#pragma omp metadirective when(device = {kind(any)} \
-                               : parallel)
-  bar();
-#pragma omp metadirective when(device = {kind(host, cpu)} \
-                               : parallel for num_threads(4))
-  for (int i = 0; i < 100; i++)
-    ;
-#pragma omp metadirective when(device = {kind(host)} \
-                               : parallel for)
-  for (int i = 0; i < 100; i++)
-    ;
-#pragma omp metadirective when(device = {kind(nohost, gpu)} \
-                               :) when(device = {kind(cpu)} \
-                                       : parallel)
-  bar();
-#pragma omp metadirective when(device = {kind(any, cpu)} \
-                               : parallel)
-  bar();
-#pragma omp metadirective when(device = {kind(any, host)} \
-                               : parallel)
-  bar();
-#pragma omp metadirective when(device = {kind(gpu)} \
-                               : target parallel for) default(parallel for)
-  for (int i = 0; i < 100; i++)
-    ;
-}
-
-// CHECK-LABEL: define {{.+}} void @foo()
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_1:@.+]] to void
-// CHECK-NEXT: @__kmpc_push_num_threads
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_2:@.+]] to void
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_3:@.+]] to void
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_4:@.+]] to void
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_5:@.+]] to void
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_6:@.+]] to void
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_7:@.+]] to void
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_1]](
-// CHECK: call void {{.+}} @bar
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_2]](
-// CHECK: call void @__kmpc_for_static_init
-// CHECK: call void @__kmpc_for_static_fini
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_3]](
-// CHECK: call void @__kmpc_for_static_init
-// CHECK: call void @__kmpc_for_static_fini
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_4]](
-// CHECK: call void {{.+}} @bar
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_5]](
-// CHECK: call void {{.+}} @bar
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_6]](
-// CHECK: call void {{.+}} @bar
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_7]](
-// CHECK: call void @__kmpc_for_static_init
-// CHECK: call void @__kmpc_for_static_fini
-// CHECK: ret void
-
-#endif

diff  --git a/clang/test/OpenMP/metadirective_device_kind_codegen.cpp b/clang/test/OpenMP/metadirective_device_kind_codegen.cpp
deleted file mode 100644
index f5b29465c40db..0000000000000
--- a/clang/test/OpenMP/metadirective_device_kind_codegen.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope | FileCheck %s
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple aarch64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope | FileCheck %s
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple ppc64le-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope | FileCheck %s
-
-// expected-no-diagnostics
-#ifndef HEADER
-#define HEADER
-
-void bar();
-
-void foo() {
-#pragma omp metadirective when(device = {kind(any)} \
-                               : parallel)
-  bar();
-#pragma omp metadirective when(device = {kind(host, cpu)} \
-                               : parallel for num_threads(4))
-  for (int i = 0; i < 100; i++)
-    ;
-#pragma omp metadirective when(device = {kind(host)} \
-                               : parallel for)
-  for (int i = 0; i < 100; i++)
-    ;
-#pragma omp metadirective when(device = {kind(nohost, gpu)} \
-                               :) when(device = {kind(cpu)} \
-                                       : parallel)
-  bar();
-#pragma omp metadirective when(device = {kind(any, cpu)} \
-                               : parallel)
-  bar();
-#pragma omp metadirective when(device = {kind(any, host)} \
-                               : parallel)
-  bar();
-#pragma omp metadirective when(device = {kind(gpu)} \
-                               : target parallel for) default(parallel for)
-  for (int i = 0; i < 100; i++)
-    ;
-}
-
-// CHECK-LABEL: define {{.+}} void @_Z3foov()
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_1:@.+]] to void
-// CHECK-NEXT: @__kmpc_push_num_threads
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_2:@.+]] to void
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_3:@.+]] to void
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_4:@.+]] to void
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_5:@.+]] to void
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_6:@.+]] to void
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_7:@.+]] to void
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_1]](
-// CHECK: void @_Z3barv()
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_2]](
-// CHECK: call void @__kmpc_for_static_init
-// CHECK: call void @__kmpc_for_static_fini
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_3]](
-// CHECK: call void @__kmpc_for_static_init
-// CHECK: call void @__kmpc_for_static_fini
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_4]](
-// CHECK: void @_Z3barv()
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_5]](
-// CHECK: void @_Z3barv()
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_6]](
-// CHECK: void @_Z3barv()
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_7]](
-// CHECK: call void @__kmpc_for_static_init
-// CHECK: call void @__kmpc_for_static_fini
-// CHECK: ret void
-
-#endif

diff  --git a/clang/test/OpenMP/metadirective_empty.cpp b/clang/test/OpenMP/metadirective_empty.cpp
deleted file mode 100644
index 5c9838ea5a69c..0000000000000
--- a/clang/test/OpenMP/metadirective_empty.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple aarch64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple ppc64le-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
-// expected-no-diagnostics
-
-#ifndef HEADER
-#define HEADER
-
-#define N 1000
-void func() {
-  // Test where a valid when clause contains empty directive.
-  // The directive will be ignored and code for a serial for loop will be generated.
-#pragma omp metadirective when(implementation = {vendor(llvm)} \
-                               :) default(parallel for)
-  for (int i = 0; i < N; i++)
-    ;
-}
-
-// CHECK-LABEL: void @_Z4funcv()
-// CHECK: entry:
-// CHECK:   [[I:%.+]] = alloca i32,
-// CHECK:   store i32 0, i32* [[I]],
-// CHECK:   br label %[[FOR_COND:.+]]
-// CHECK: [[FOR_COND]]:
-// CHECK:   [[ZERO:%.+]] = load i32, i32* [[I]],
-// CHECK:   [[CMP:%.+]] = icmp slt i32 [[ZERO]], 1000
-// CHECK:   br i1 [[CMP]], label %[[FOR_BODY:.+]], label %[[FOR_END:.+]]
-// CHECK: [[FOR_BODY]]:
-// CHECK:   br label %[[FOR_INC:.+]]
-// CHECK: [[FOR_INC]]:
-// CHECK:   [[ONE:%.+]] = load i32, i32* [[I]],
-// CHECK:   [[INC:%.+]] = add nsw i32 [[ONE]], 1
-// CHECK:   store i32 [[INC]], i32* [[I]],
-// CHECK:   br label %[[FOR_COND]],
-// CHECK: [[FOR_END]]:
-// CHECK:   ret void
-// CHECK: }
-
-#endif

diff  --git a/clang/test/OpenMP/metadirective_implementation_codegen.c b/clang/test/OpenMP/metadirective_implementation_codegen.c
deleted file mode 100644
index 9b4c31a141cf5..0000000000000
--- a/clang/test/OpenMP/metadirective_implementation_codegen.c
+++ /dev/null
@@ -1,72 +0,0 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c -std=c99 -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -verify -fopenmp -x c -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -verify -fopenmp -x c -triple aarch64-unknown-linux -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -verify -fopenmp -x c -triple ppc64le-unknown-linux -emit-llvm %s -o - | FileCheck %s
-// expected-no-diagnostics
-
-#ifndef HEADER
-#define HEADER
-
-void bar();
-
-void foo() {
-#pragma omp metadirective when(implementation = {vendor(score(0)  \
-                                                        : llvm)}, \
-                               device = {kind(cpu)}               \
-                               : parallel) default(target teams)
-  bar();
-#pragma omp metadirective when(device = {kind(gpu)}                                 \
-                               : target teams) when(implementation = {vendor(llvm)} \
-                                                    : parallel) default()
-  bar();
-#pragma omp metadirective default(target) when(implementation = {vendor(score(5)  \
-                                                                        : llvm)}, \
-                                               device = {kind(cpu, host)}         \
-                                               : parallel)
-  bar();
-#pragma omp metadirective when(implementation = {extension(match_all)} \
-                               : parallel) default(parallel for)
-  for (int i = 0; i < 100; i++)
-    ;
-#pragma omp metadirective when(implementation = {extension(match_any)} \
-                               : parallel) default(parallel for)
-  for (int i = 0; i < 100; i++)
-    ;
-#pragma omp metadirective when(implementation = {extension(match_none)} \
-                               : parallel) default(parallel for)
-  for (int i = 0; i < 100; i++)
-    ;
-}
-
-// CHECK: void @foo()
-// CHECK-COUNT-6: ...) @__kmpc_fork_call(
-// CHECK: ret void
-
-// CHECK: define internal void @.omp_outlined.(
-// CHECK: @bar
-// CHECK: ret void
-
-// CHECK: define internal void @.omp_outlined..1(
-// CHECK: @bar
-// CHECK: ret void
-
-// CHECK: define internal void @.omp_outlined..2(
-// CHECK: @bar
-// CHECK: ret void
-
-// CHECK: define internal void @.omp_outlined..3(
-// NO-CHECK: call void @__kmpc_for_static_init
-// NO-CHECK: call void @__kmpc_for_static_fini
-// CHECK: ret void
-
-// CHECK: define internal void @.omp_outlined..4(
-// CHECK: call void @__kmpc_for_static_init
-// CHECK: call void @__kmpc_for_static_fini
-// CHECK: ret void
-
-// CHECK: define internal void @.omp_outlined..5(
-// NO-CHECK: call void @__kmpc_for_static_init
-// NO-CHECK: call void @__kmpc_for_static_fini
-// CHECK: ret void
-
-#endif

diff  --git a/clang/test/OpenMP/metadirective_implementation_codegen.cpp b/clang/test/OpenMP/metadirective_implementation_codegen.cpp
deleted file mode 100644
index 9b798f396406a..0000000000000
--- a/clang/test/OpenMP/metadirective_implementation_codegen.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope | FileCheck %s
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple aarch64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope | FileCheck %s
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple ppc64le-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope | FileCheck %s
-// expected-no-diagnostics
-
-#ifndef HEADER
-#define HEADER
-
-void bar();
-
-void foo() {
-#pragma omp metadirective when(implementation = {vendor(score(0)  \
-                                                        : llvm)}, \
-                               device = {kind(cpu)}               \
-                               : parallel) default(target teams)
-  bar();
-#pragma omp metadirective when(device = {kind(gpu)}                                 \
-                               : target teams) when(implementation = {vendor(llvm)} \
-                                                    : parallel) default()
-  bar();
-#pragma omp metadirective default(target) when(implementation = {vendor(score(5)  \
-                                                                        : llvm)}, \
-                                               device = {kind(cpu, host)}         \
-                                               : parallel)
-  bar();
-#pragma omp metadirective when(implementation = {extension(match_all)} \
-                               : parallel) default(parallel for)
-  for (int i = 0; i < 100; i++)
-    ;
-#pragma omp metadirective when(implementation = {extension(match_any)} \
-                               : parallel) default(parallel for)
-  for (int i = 0; i < 100; i++)
-    ;
-#pragma omp metadirective when(implementation = {extension(match_none)} \
-                               : parallel) default(parallel for)
-  for (int i = 0; i < 100; i++)
-    ;
-}
-
-// CHECK-LABEL: void @_Z3foov()
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_2:@.+]] to void
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_3:@.+]] to void
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_4:@.+]] to void
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_5:@.+]] to void
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_6:@.+]] to void
-// CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_7:@.+]] to void
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_2]](
-// CHECK: @_Z3barv
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_3]](
-// CHECK: @_Z3barv
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_4]](
-// CHECK: @_Z3barv
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_5]](
-// NO-CHECK: call void @__kmpc_for_static_init
-// NO-CHECK: call void @__kmpc_for_static_fini
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_6]](
-// CHECK: call void @__kmpc_for_static_init
-// CHECK: call void @__kmpc_for_static_fini
-// CHECK: ret void
-
-// CHECK: define internal void [[OUTLINED_7]](
-// NO-CHECK: call void @__kmpc_for_static_init
-// NO-CHECK: call void @__kmpc_for_static_fini
-// CHECK: ret void
-
-#endif

diff  --git a/clang/test/OpenMP/metadirective_messages.cpp b/clang/test/OpenMP/metadirective_messages.cpp
deleted file mode 100644
index 77d09ba0f7a7e..0000000000000
--- a/clang/test/OpenMP/metadirective_messages.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++14 -emit-llvm %s
-
-void foo() {
-#pragma omp metadirective // expected-error {{expected expression}}
-  ;
-#pragma omp metadirective when() // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
-  ;
-#pragma omp metadirective when(device{}) // expected-warning {{expected '=' after the context set name "device"; '=' assumed}} expected-warning {{expected identifier or string literal describing a context selector; selector skipped}} expected-note {{context selector options are: 'kind' 'arch' 'isa'}} expected-note {{the ignored selector spans until here}} expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}}
-  ;
-#pragma omp metadirective when(device{arch(nvptx)}) // expected-error {{missing ':' in when clause}} expected-error {{expected expression}} expected-warning {{expected '=' after the context set name "device"; '=' assumed}}
-  ;
-#pragma omp metadirective when(device{arch(nvptx)}: ) default() // expected-warning {{expected '=' after the context set name "device"; '=' assumed}}
-  ;
-#pragma omp metadirective when(device = {arch(nvptx)} : ) default(xyz) // expected-error {{expected an OpenMP directive}} expected-error {{use of undeclared identifier 'xyz'}}
-  ;
-#pragma omp metadirective when(device = {arch(nvptx)} : parallel default() // expected-error {{expected ',' or ')' in 'when' clause}} expected-error {{expected expression}}
-  ;
-}

diff  --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 96a7cb4f3469e..7b93164ccaa21 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -5582,8 +5582,6 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
     return cxstring::createRef("ModuleImport");
   case CXCursor_OMPCanonicalLoop:
     return cxstring::createRef("OMPCanonicalLoop");
-  case CXCursor_OMPMetaDirective:
-    return cxstring::createRef("OMPMetaDirective");
   case CXCursor_OMPParallelDirective:
     return cxstring::createRef("OMPParallelDirective");
   case CXCursor_OMPSimdDirective:

diff  --git a/clang/tools/libclang/CXCursor.cpp b/clang/tools/libclang/CXCursor.cpp
index 8d214480e9b84..6fb47300efb82 100644
--- a/clang/tools/libclang/CXCursor.cpp
+++ b/clang/tools/libclang/CXCursor.cpp
@@ -643,9 +643,6 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
   case Stmt::OMPCanonicalLoopClass:
     K = CXCursor_OMPCanonicalLoop;
     break;
-  case Stmt::OMPMetaDirectiveClass:
-    K = CXCursor_OMPMetaDirective;
-    break;
   case Stmt::OMPParallelDirectiveClass:
     K = CXCursor_OMPParallelDirective;
     break;

diff  --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 2c1b2913c5c23..3b58f97b2dba2 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -1391,7 +1391,6 @@ CHECK_SIMPLE_CLAUSE(Use, OMPC_use)
 CHECK_SIMPLE_CLAUSE(Novariants, OMPC_novariants)
 CHECK_SIMPLE_CLAUSE(Nocontext, OMPC_nocontext)
 CHECK_SIMPLE_CLAUSE(Filter, OMPC_filter)
-CHECK_SIMPLE_CLAUSE(When, OMPC_when)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
 CHECK_REQ_SCALAR_INT_CLAUSE(NumTasks, OMPC_num_tasks)

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td
index f968e49f758bf..010a35b60c52e 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -339,7 +339,6 @@ def OMPC_Filter : Clause<"filter"> {
   let clangClass = "OMPFilterClause";
   let flangClass = "ScalarIntExpr";
 }
-def OMPC_When: Clause<"when"> {}
 
 //===----------------------------------------------------------------------===//
 // Definition of OpenMP directives
@@ -1704,10 +1703,6 @@ def OMP_masked : Directive<"masked"> {
     VersionedClause<OMPC_Filter>
   ];
 }
-def OMP_Metadirective : Directive<"metadirective"> {
-  let allowedClauses = [VersionedClause<OMPC_When>];
-  let allowedOnceClauses = [VersionedClause<OMPC_Default>];
-}
 def OMP_Unknown : Directive<"unknown"> {
   let isDefault = true;
 }


        


More information about the cfe-commits mailing list