[clang] [clang][OpenMP] Fix APSInt bit-width mismatch in ordered depend/doacross check (PR #238672)

Pranjal Srivastava via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 18 11:52:41 PST 2026


================
@@ -23730,14 +23730,14 @@ ProcessOpenMPDoacrossClauseCommon(Sema &SemaRef, bool IsSource,
 
   SmallVector<Expr *, 8> Vars;
   DSAStackTy::OperatorOffsetTy OpsOffs;
-  llvm::APSInt DepCounter(/*BitWidth=*/32);
   llvm::APSInt TotalDepCount(/*BitWidth=*/32);
 
   if (const Expr *OrderedCountExpr =
           Stack->getParentOrderedRegionParam().first) {
     TotalDepCount = OrderedCountExpr->EvaluateKnownConstInt(SemaRef.Context);
     TotalDepCount.setIsUnsigned(/*Val=*/true);
   }
+  llvm::APSInt DepCounter(TotalDepCount.getBitWidth());
----------------
ipranjalks wrote:

I feel that we can't remove the `setIsUnsigned()` call because the value of `TotalDepCount` changes inside the `if` condition, post which we need to set it back to `Unsigned`.

```
TotalDepCount = OrderedCountExpr->EvaluateKnownConstInt(SemaRef.Context);
TotalDepCount.setIsUnsigned(/*Val=*/true);
```

I can definitely pass the `isUnsigned = true` in the constructor though.

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


More information about the cfe-commits mailing list