[PATCH] D124658: CSA Normalize SymIntExpr so the RHS is positive when possible

Tomasz KamiƄski via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 29 00:48:37 PDT 2022


tomasz-kaminski-sonarsource created this revision.
tomasz-kaminski-sonarsource added reviewers: vsavchenko, NoQ, steakhal.
Herald added a subscriber: martong.
Herald added a project: All.
tomasz-kaminski-sonarsource requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This PR changes the SymIntExpr so the expression that uses
negative value as RHS, for example: x +/- (-N), are modeled as
as x -/+ N. This avoid producing very large RHS in case when the
symbol is cased to unsigned number, and as consequence makes the
value more robust in presence of cast.
This change is not apllied if N is lowest negative value for
which negation would not be representable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124658

Files:
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/test/Analysis/additive-op-on-sym-int-expr.c
  clang/test/Analysis/expr-inspection.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124658.425983.patch
Type: text/x-patch
Size: 5745 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220429/58af07b5/attachment.bin>


More information about the cfe-commits mailing list