[all-commits] [llvm/llvm-project] 23b88e: [analyzer] Remove inaccurate legacy handling of ba...

DonatNagyE via All-commits all-commits at lists.llvm.org
Fri Sep 29 11:02:51 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 23b88e812366cd00a3724e182f43edab080b634b
      https://github.com/llvm/llvm-project/commit/23b88e812366cd00a3724e182f43edab080b634b
  Author: DonatNagyE <donat.nagy at ericsson.com>
  Date:   2023-09-29 (Fri, 29 Sep 2023)

  Changed paths:
    M clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
    M clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
    M clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
    R clang/test/Analysis/bitwise-ops-nocrash.c
    R clang/test/Analysis/bitwise-ops.c
    M clang/test/Analysis/bitwise-shift-sanity-checks.c
    R clang/test/Analysis/left-shift-cxx2a.cpp
    M clang/test/Analysis/svalbuilder-simplify-no-crash.c

  Log Message:
  -----------
  [analyzer] Remove inaccurate legacy handling of bad bitwise shifts (#66647)

Previously, bitwise shifts with constant operands were validated by the
checker `core.UndefinedBinaryOperatorResult`. However, this logic was
unreliable, and commit 25b9696b61e53a958e217bb3d0eab66350dc187f added
the dedicated checker `core.BitwiseShift` which validated the
preconditions of all bitwise shifts with a more accurate logic (that
uses the real types from the AST instead of the unreliable type
information encoded in `APSInt` objects).

This commit disables the inaccurate logic that could mark bitwise shifts
as 'undefined' and removes the redundant shift-related warning messages
from core.UndefinedBinaryOperatorResult. The tests that were validating
this logic are also deleted by this commit; but I verified that those
testcases trigger the expected bug reports from `core.BitwiseShift`. (I
didn't convert them to tests of `core.BitwiseShift`, because that
checker already has its own extensive test suite with many analogous
testcases.)

I hope that there will be a time when the constant folding will be
reliable, but until then we need hacky solutions like this improve the
quality of results.




More information about the All-commits mailing list