[all-commits] [llvm/llvm-project] 8e965d: [analyzer] Fix zext assertion failure in loop unro...

JOSTAR via All-commits all-commits at lists.llvm.org
Sat Dec 28 02:09:50 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8e965d89c9624c184c48806dc39d50209265f0f8
      https://github.com/llvm/llvm-project/commit/8e965d89c9624c184c48806dc39d50209265f0f8
  Author: JOSTAR <52376093+shenjunjiekoda at users.noreply.github.com>
  Date:   2024-12-28 (Sat, 28 Dec 2024)

  Changed paths:
    M clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
    A clang/test/Analysis/PR121201.cpp

  Log Message:
  -----------
  [analyzer] Fix zext assertion failure in loop unrolling (#121203)

The current implementation of APInt extension in the code can trigger an
assertion failure when the `zext` function is called with a target width
smaller than the current bit width. For example:
```cpp
if (InitNum.getBitWidth() != BoundNum.getBitWidth()) {
    InitNum = InitNum.zext(BoundNum.getBitWidth());
    BoundNum = BoundNum.zext(InitNum.getBitWidth());
}
```

This logic does not guarantee that the `zext` target width is always
greater than or equal to the current bit width, leading to potential
crashes.

Expected Behavior:
- Ensure InitNum and BoundNum are extended to the maximum of their respective widths.
- Prevent assertion failures by enforcing correct `zext` usage.

Fixes #121201



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list