[all-commits] [llvm/llvm-project] 881b6a: [analyzer][NFC] Re-enable skipped SValTests by rel...

Balazs Benics via All-commits all-commits at lists.llvm.org
Wed Jan 19 06:16:44 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 881b6a009fb6e2dd5fb924524cd6eacd14148a08
      https://github.com/llvm/llvm-project/commit/881b6a009fb6e2dd5fb924524cd6eacd14148a08
  Author: Balazs Benics <balazs.benics at sigmatechnology.se>
  Date:   2022-01-19 (Wed, 19 Jan 2022)

  Changed paths:
    M clang/unittests/StaticAnalyzer/SValTest.cpp

  Log Message:
  -----------
  [analyzer][NFC] Re-enable skipped SValTests by relaxing expectations

Some tests were skipped in D114454 to resolve test failures on some
platforms, where the pointers have different bitwidth than expected.
This patch re-enables these tests, by relaxing the requirements on the
types of the SVal.

The issue:
There is no way to reconstruct the type of the `SVal` perfectly
accurately, since there could be multiple types having the required
bitwidth and signedness.
Consider platforms where `int` and `long` have the same bitwidth.
Additionally, we need to be careful about casting a pointer to an
integral representation, because we don't know what smallest integral
type can represent that.

To workaround these issues, I propose enforcing a type that has the
same signedness and bitwidth as the expected type, instead of perfect
equality.

In the `GetLocAsIntType` test, in case of pointer-to-integral casts
I'm using the widest standard integral type (long long) to make sure
that the pointer can be represented by the type without losing
precision. This won't affect the test in any meaningful way, since the
type of the `lvalue` remained the same.

In one case, I had to replace `getUIntPtrType()` with `UnsignedLongTy`
because on some platforms `getUIntPtrType()` is different then `long
int`.

In this patch, I also enforce that the tests must compile without
errors, to prevent narrowing conversions in the future.

Reviewed By: stevewan

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




More information about the All-commits mailing list