[clang] [analyzer] Preserve LocAsInteger through identity operations (PR #225048)
Peiqi Li via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 25 22:31:02 PDT 2026
================
@@ -491,6 +510,11 @@ SVal SimpleSValBuilder::evalBinOpNN(ProgramStateRef state,
rhs.castAs<nonloc::LocAsInteger>().getLoc(),
resultTy);
case nonloc::ConcreteIntKind: {
+ // Preserve the location for identity operations.
+ if (isIdentityOperation(op,
+ rhs.castAs<nonloc::ConcreteInt>().getValue()))
+ return evalCast(lhs, resultTy, QualType{});
+
----------------
voyager-jhk wrote:
The swapped commutative cases are already handled by `evalBinOpNN`, which canonicalizes the operands before reaching this case. `0 + value` and `0 | value` therefore work as well.
https://github.com/llvm/llvm-project/pull/225048
More information about the cfe-commits
mailing list