[PATCH] D93575: [flang][openxx][NFC] Remove duplicated function to check required clauses

Valentin Clement via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 18 19:21:00 PST 2020


clementval created this revision.
clementval added reviewers: kiranktp, SouraVX, kiranchandramohan, sameeranjoshi.
clementval requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, sstefan1.
Herald added a project: LLVM.

Remove duplicated function to check for required clauses on a directive. This was
still there from the merging of OpenACC and OpenMP common semantic checks and it can now be 
removed so we use only one function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93575

Files:
  flang/lib/Semantics/check-directive-structure.h
  flang/lib/Semantics/check-omp-structure.cpp
  flang/test/Semantics/omp-device-constructs.f90


Index: flang/test/Semantics/omp-device-constructs.f90
===================================================================
--- flang/test/Semantics/omp-device-constructs.f90
+++ flang/test/Semantics/omp-device-constructs.f90
@@ -122,7 +122,7 @@
   enddo
   !$omp end target data
 
-  !ERROR: At least one MAP clause must appear on the TARGET DATA directive
+  !ERROR: At least one of MAP clause must appear on the TARGET DATA directive
   !$omp target data device(0)
   do i = 1, N
      a = 3.14
Index: flang/lib/Semantics/check-omp-structure.cpp
===================================================================
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -393,8 +393,7 @@
         llvm::omp::Clause::OMPC_copyprivate, {llvm::omp::Clause::OMPC_nowait});
   }
 
-  GetContext().requiredClauses.IterateOverMembers(
-      [this](llvm::omp::Clause c) { CheckRequired(c); });
+  CheckRequireAtLeastOneOf();
 }
 
 void OmpStructureChecker::Enter(const parser::OmpClause &x) {
Index: flang/lib/Semantics/check-directive-structure.h
===================================================================
--- flang/lib/Semantics/check-directive-structure.h
+++ flang/lib/Semantics/check-directive-structure.h
@@ -232,8 +232,6 @@
   // Check that only clauses in set are after the specific clauses.
   void CheckOnlyAllowedAfter(C clause, common::EnumSet<C, ClauseEnumSize> set);
 
-  void CheckRequired(C clause);
-
   void CheckRequireAtLeastOneOf();
 
   void CheckAllowed(C clause);
@@ -326,6 +324,8 @@
 template <typename D, typename C, typename PC, std::size_t ClauseEnumSize>
 void DirectiveStructureChecker<D, C, PC,
     ClauseEnumSize>::CheckRequireAtLeastOneOf() {
+  if (GetContext().requiredClauses.empty())
+    return;
   for (auto cl : GetContext().actualClauses) {
     if (GetContext().requiredClauses.test(cl))
       return;
@@ -447,17 +447,6 @@
       .Attach(beginSource, "Does not match directive"_en_US);
 }
 
-// Check that at least one of the required clauses is present on the directive.
-template <typename D, typename C, typename PC, std::size_t ClauseEnumSize>
-void DirectiveStructureChecker<D, C, PC, ClauseEnumSize>::CheckRequired(C c) {
-  if (!FindClause(c)) {
-    context_.Say(GetContext().directiveSource,
-        "At least one %s clause must appear on the %s directive"_err_en_US,
-        parser::ToUpperCaseLetters(getClauseName(c).str()),
-        ContextDirectiveAsFortran());
-  }
-}
-
 // Check the value of the clause is a positive parameter.
 template <typename D, typename C, typename PC, std::size_t ClauseEnumSize>
 void DirectiveStructureChecker<D, C, PC,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93575.312912.patch
Type: text/x-patch
Size: 2654 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201219/e9c68dcf/attachment.bin>


More information about the llvm-commits mailing list