[clang] [analyzer] Fix zext assertion failure in loop unrolling (PR #121203)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 28 01:42:35 PST 2024


================
@@ -283,10 +283,12 @@ static bool shouldCompletelyUnroll(const Stmt *LoopStmt, ASTContext &ASTCtx,
   llvm::APInt InitNum =
       Matches[0].getNodeAs<IntegerLiteral>("initNum")->getValue();
   auto CondOp = Matches[0].getNodeAs<BinaryOperator>("conditionOperator");
-  if (InitNum.getBitWidth() != BoundNum.getBitWidth()) {
-    InitNum = InitNum.zext(BoundNum.getBitWidth());
-    BoundNum = BoundNum.zext(InitNum.getBitWidth());
-  }
+  unsigned MaxWidth = std::max(InitNum.getBitWidth(), BoundNum.getBitWidth());
----------------
steakhal wrote:

Your reasoning sounds solid!

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


More information about the cfe-commits mailing list