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

via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 27 03:05:52 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 223521b13e7465bc177f43e22de526b777d6ff74 3bcf5c8f05df2f62a9ef13537b813e7df2871d1b --extensions cpp -- clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp b/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
index e3b27e2271..9227a7876c 100644
--- a/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
+++ b/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
@@ -286,9 +286,9 @@ static bool shouldCompletelyUnroll(const Stmt *LoopStmt, ASTContext &ASTCtx,
   unsigned MaxWidth = std::max(InitNum.getBitWidth(), BoundNum.getBitWidth());
 
   if (InitNum.getBitWidth() != MaxWidth)
-      InitNum = InitNum.zext(MaxWidth);
+    InitNum = InitNum.zext(MaxWidth);
   if (BoundNum.getBitWidth() != MaxWidth)
-      BoundNum = BoundNum.zext(MaxWidth);
+    BoundNum = BoundNum.zext(MaxWidth);
 
   if (CondOp->getOpcode() == BO_GE || CondOp->getOpcode() == BO_LE)
     maxStep = (BoundNum - InitNum + 1).abs().getZExtValue();

``````````

</details>


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


More information about the cfe-commits mailing list