[all-commits] [llvm/llvm-project] 147424: Reland "[analyzer] Canonicalize SymIntExpr so the ...

tomasz-kaminski-sonarsource via All-commits all-commits at lists.llvm.org
Thu May 12 06:40:40 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 14742443a25826547e480189657b16c7a11664e7
      https://github.com/llvm/llvm-project/commit/14742443a25826547e480189657b16c7a11664e7
  Author: Tomasz KamiƄski <tomasz.kaminski at sonarsource.com>
  Date:   2022-05-12 (Thu, 12 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:
  -----------
  Reland "[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