[all-commits] [llvm/llvm-project] f0d6cb: [analyzer] Canonicalize SymIntExpr so the RHS is p...

tomasz-kaminski-sonarsource via All-commits all-commits at lists.llvm.org
Thu May 5 08:49:11 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f0d6cb4a5cf5723d7ddab2c7dab74f2f62116a6d
  Author: Tomasz KamiƄski <tomasz.kaminski at sonarsource.com>
  Date:   2022-05-05 (Thu, 05 May 2022)

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

  Log Message:
  [analyzer] Canonicalize SymIntExpr so the RHS is positive when possible

This PR changes the `SymIntExpr` so the expression that uses a
negative value as `RHS`, for example: `x +/- (-N)`, is modeled as
`x -/+ N` instead.

This avoids producing a very large `RHS` when the symbol is cased to
an unsigned number, and as consequence makes the value more robust in
presence of casts.

Note that this change is not applied if `N` is the lowest negative
value for which negation would not be representable.

Reviewed By: steakhal

Patch By: tomasz-kaminski-sonarsource!

Differential Revision: https://reviews.llvm.org/D124658

More information about the All-commits mailing list