llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-openmp

Author: Krzysztof Parzyszek (kparzysz)

<details>
<summary>Changes</summary>

&lt;sub&gt;Stack created with &lt;a 
href="https://github.com/github/gh-stack"&gt;GitHub Stacks CLI&lt;/a&gt; • 
&lt;a href="https://gh.io/stacks-feedback"&gt;Give Feedback 
💬&lt;/a&gt;&lt;/sub&gt;

---
Full diff: https://github.com/llvm/llvm-project/pull/210406.diff


4 Files Affected:

- (modified) flang/lib/Parser/openmp-parsers.cpp (+2-5) 
- (modified) llvm/include/llvm/Frontend/OpenMP/OMP.h (+9) 
- (modified) llvm/lib/Frontend/OpenMP/OMP.cpp (+2-4) 
- (modified) llvm/unittests/Frontend/OpenMPDirectiveNameParserTest.cpp (+2-4) 


``````````diff
diff --git a/flang/lib/Parser/openmp-parsers.cpp 
b/flang/lib/Parser/openmp-parsers.cpp
index 105a72de5cb29..9051d5863df07 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -2622,19 +2622,16 @@ TYPE_CONTEXT_PARSER("OpenMP construct"_en_US,
                     Parser<OmpDelimitedMetadirectiveDirective>{}))))
 
 static constexpr DirectiveSet GetLoopDirectives() {
-  using Directive = llvm::omp::Directive;
   using SourceLanguage = llvm::omp::SourceLanguage;
   DirectiveSet loopDirectives;
 
-  for (auto dirVal{llvm::to_underlying(Directive::First_)};
-      dirVal != llvm::to_underlying(Directive::Last_) + 1; ++dirVal) {
-    auto dirId{static_cast<Directive>(dirVal)};
+  for (auto dirId : llvm::omp::directives()) {
     auto assoc{getDirectiveAssociation(dirId)};
     if (assoc == llvm::omp::Association::LoopNest ||
         assoc == llvm::omp::Association::LoopSeq) {
       auto langs{getDirectiveLanguages(dirId)};
       if (llvm::to_underlying(langs & SourceLanguage::Fortran) != 0) {
-        loopDirectives.set(dirVal);
+        loopDirectives.set(llvm::to_underlying(dirId));
       }
     }
   }
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.h 
b/llvm/include/llvm/Frontend/OpenMP/OMP.h
index 530f3f1410212..f54352adaa8b8 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMP.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMP.h
@@ -17,6 +17,7 @@
 #include "llvm/Support/Compiler.h"
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Sequence.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 
@@ -33,6 +34,14 @@ LLVM_ABI bool isLeafConstruct(Directive D);
 LLVM_ABI bool isCompositeConstruct(Directive D);
 LLVM_ABI bool isCombinedConstruct(Directive D);
 
+static constexpr inline auto clauses() {
+  return llvm::enum_seq_inclusive(Clause::First_, Clause::Last_);
+}
+
+static constexpr inline auto directives() {
+  return llvm::enum_seq_inclusive(Directive::First_, Directive::Last_);
+}
+
 /// Can clause C have an iterator-modifier.
 static constexpr inline bool canHaveIterator(Clause C) {
   // [5.2:67:5]
diff --git a/llvm/lib/Frontend/OpenMP/OMP.cpp b/llvm/lib/Frontend/OpenMP/OMP.cpp
index 86e144624211c..4e18f49395e4c 100644
--- a/llvm/lib/Frontend/OpenMP/OMP.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMP.cpp
@@ -81,14 +81,12 @@ static void
 collectPrivatizingConstructs(llvm::SmallSet<Directive, 16> &Constructs,
                              unsigned Version) {
   llvm::SmallSet<Clause, 16> Privatizing;
-  for (auto C :
-       llvm::enum_seq_inclusive<Clause>(Clause::First_, Clause::Last_)) {
+  for (auto C : clauses()) {
     if (isPrivatizingClause(C, Version))
       Privatizing.insert(C);
   }
 
-  for (auto D : llvm::enum_seq_inclusive<Directive>(Directive::First_,
-                                                    Directive::Last_)) {
+  for (auto D : directives()) {
     bool AllowsPrivatizing = llvm::any_of(Privatizing, [&](Clause C) {
       return isAllowedClauseForDirective(D, C, Version);
     });
diff --git a/llvm/unittests/Frontend/OpenMPDirectiveNameParserTest.cpp 
b/llvm/unittests/Frontend/OpenMPDirectiveNameParserTest.cpp
index 10329820bef76..3d6ccc744b362 100644
--- a/llvm/unittests/Frontend/OpenMPDirectiveNameParserTest.cpp
+++ b/llvm/unittests/Frontend/OpenMPDirectiveNameParserTest.cpp
@@ -82,8 +82,7 @@ getParamName1(const 
testing::TestParamInfo<Tokenize::ParamType> &Info) {
 }
 
 INSTANTIATE_TEST_SUITE_P(DirectiveNameParserTest, Tokenize,
-                         testing::ValuesIn(llvm::enum_seq_inclusive(
-                             omp::Directive::First_, omp::Directive::Last_)),
+                         testing::ValuesIn(llvm::omp::directives()),
                          getParamName1);
 
 // Test parsing of valid names.
@@ -123,8 +122,7 @@ getParamName2(const 
testing::TestParamInfo<ParseValid::ParamType> &Info) {
 
 INSTANTIATE_TEST_SUITE_P(
     DirectiveNameParserTest, ParseValid,
-    testing::Combine(testing::ValuesIn(llvm::enum_seq_inclusive(
-                         omp::Directive::First_, omp::Directive::Last_)),
+    testing::Combine(testing::ValuesIn(llvm::omp::directives()),
                      testing::ValuesIn(omp::getOpenMPVersions())),
     getParamName2);
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/210406
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to