[llvm-branch-commits] [flang] [flang][OpenMP] Refactor CountGeneratedNests, NFC (PR #185293)

Tom Eccles via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Mar 9 05:09:16 PDT 2026


================
@@ -363,15 +336,15 @@ void OmpStructureChecker::CheckNestedConstruct(
 
   // Check if a loop-nest-associated construct has only one top-level loop
   // in it.
-  if (std::optional<size_t> numLoops{CountGeneratedNests(body)}) {
+  if (std::optional<int64_t> numLoops{GetNumGeneratedNests(body)}) {
     if (*numLoops == 0) {
       context_.Say(beginSpec.DirName().source,
           "This construct should contain a DO-loop or a loop-nest-generating OpenMP construct"_err_en_US);
     } else {
       auto assoc{llvm::omp::getDirectiveAssociation(beginSpec.DirName().v)};
       if (*numLoops > 1 && assoc == llvm::omp::Association::LoopNest) {
         context_.Say(beginSpec.DirName().source,
-            "This construct applies to a loop nest, but has a loop sequence of length %zu"_err_en_US,
+            "This construct applies to a loop nest, but has a loop sequence of length %ld"_err_en_US,
----------------
tblah wrote:

I think on some platforms `int64_t` could be `long long`. I would probably do something like

```suggestion
            "This construct applies to a loop nest, but has a loop sequence of length %lld"_err_en_US, static_cast<long long>(*numLoops)
```

Or I see in expression.cpp there are cases where the source value is cast to `std::intmax_t` and `%jd` is used.

https://github.com/llvm/llvm-project/pull/185293


More information about the llvm-branch-commits mailing list