[Openmp-commits] [clang] [openmp] [Clang][OpenMP] Convert `flatten` floating-point trip-count to integers (PR #229458)

Amit Tiwari via Openmp-commits openmp-commits at lists.llvm.org
Mon Oct 19 08:51:39 PDT 2026


================
@@ -17463,27 +17488,31 @@ SemaOpenMP::ActOnOpenMPFlattenDirective(ArrayRef<OMPClause *> Clauses,
   if (!TripCount.isUsable())
     return StmtError();
 
-  auto MakeNumIterationsInIVTy = [&](unsigned I) -> Expr * {
-    return AssertSuccess(SemaRef.PerformImplicitConversion(
-        MakeNumIterations(I), IVTy, AssignmentAction::Converting,
-        /*AllowExplicit=*/true));
+  auto MakeNumIterationsInIVTy = [&](unsigned I) -> ExprResult {
+    ExprResult N = MakeNumIterations(I);
+    if (!N.isUsable())
+      return ExprError();
+    return SemaRef.PerformImplicitConversion(
+        N.get(), IVTy, AssignmentAction::Converting, /*AllowExplicit=*/true);
----------------
loopacino wrote:

If `PerformImplicitConversion` fails, the old code would get a null expr and keep going. The new code returns `ExprResult` and returns an error if conversion fails (same as kept with `buildNumIterations`). So keeping `AssertSuccess` here would be less safe than more. This is dropped on-purpose. Happy to add a comment if that helps.

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


More information about the Openmp-commits mailing list