aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/ELFObjectFile.cpp
diff options
context:
space:
mode:
authorM. Zeeshan Siddiqui <mzs@microsoft.com>2025-07-30 18:21:59 -0700
committerGitHub <noreply@github.com>2025-07-31 09:21:59 +0800
commit70471f08ee109cd0472fdd6659c2a1ad236c6835 (patch)
tree80c27ed10109cc7351fde2d4c6a4e71102cd81fe /llvm/lib/Object/ELFObjectFile.cpp
parent5906ff67ae80e47ad8f48f8a063f283c74d62282 (diff)
downloadllvm-70471f08ee109cd0472fdd6659c2a1ad236c6835.zip
llvm-70471f08ee109cd0472fdd6659c2a1ad236c6835.tar.gz
llvm-70471f08ee109cd0472fdd6659c2a1ad236c6835.tar.bz2
[Sema] Fix -Wunreachable-code false negative when operands differ only by implicit casts (#149972)
## Motivation `-Wunreachable-code` missed—or in rare cases crashed on—tautological comparisons such as ```cpp x != 0 || x != 1.0 // always true x == 0 && x == 1.0 // always false ``` when the *same* variable appears on both sides but one operand goes through a floating‑rank promotion that is target‑dependent. On back‑ends with **native half‑precision** (`_Float16` / `__fp16`) such as AArch64 `+fullfp16`, no promotion occurs, so the cast stacks between the two operands differ and the existing heuristic bails out. ## Technical description * **Extends `Expr::isSameComparisonOperand()`** – the helper now ignores parentheses **and value‑preserving implicit casts** (`CK_LValueToRValue`, floating‑rank `CK_FloatingCast`) before comparing the underlying operands. This prevents floating‑rank promotions and lvalue‑to‑rvalue conversions from blocking the unreachable‑code diagnostic on targets with native FP16. *No change needed in `CheckIncorrectLogicOperator`; it simply benefits from the improved helper.* * **Regression test** – `warn-unreachable_crash.cpp` updated to cover both the promoted case (x86‑64) and the native‑half case (AArch64 `+fullfp16`). * **Docs** – release‑note bullet added under *Bug Fixes in This Version*. @ziqingluo-90 @yronglin Could you please review promptly? (feel free to also merge it on my behalf) Thanks! Fixes #149967 Co-authored-by: Zeeshan Siddiqui <mzs@ntdev.microsoft.com>
Diffstat (limited to 'llvm/lib/Object/ELFObjectFile.cpp')
0 files changed, 0 insertions, 0 deletions