llvm-project/clang/unittests/StaticAnalyzer
Balazs Benics 881b6a009f [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
2022-01-19 15:16:18 +01:00
..
AnalyzerOptionsTest.cpp
BugReportInterestingnessTest.cpp [analyzer][NFC] Separate CallDescription from CallEvent 2021-11-15 19:10:46 +01:00
CMakeLists.txt [analyzer]Skip unstable CSA tests failing on several platforms 2021-12-02 18:30:14 -05:00
CallDescriptionTest.cpp [analyzer][NFC] Separate CallDescription from CallEvent 2021-11-15 19:10:46 +01:00
CallEventTest.cpp [analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function calls, rather than each ExplodedNode in it 2021-09-13 13:50:01 +02:00
CheckerRegistration.h Fix a unittest file after D108695 when Z3 is enabled 2021-09-14 16:11:11 +02:00
ConflictingEvalCallsTest.cpp [analyzer][NFC] Switch to using CallDescription::matches() instead of isCalled() 2021-11-19 18:32:13 +01:00
FalsePositiveRefutationBRVisitorTest.cpp [analyzer][NFC] Separate CallDescription from CallEvent 2021-11-15 19:10:46 +01:00
NoStateChangeFuncVisitorTest.cpp [analyzer][NFC] Switch to using CallDescription::matches() instead of isCalled() 2021-11-19 18:32:13 +01:00
ParamRegionTest.cpp [Analyzer] Replace `assert` with `ASSERT_TRUE` in a unit test to silence warnings 2020-06-12 17:09:34 +02:00
RangeSetTest.cpp [analyzer] Implemented RangeSet::Factory::unite function to handle intersections and adjacency 2021-12-10 18:48:02 +02:00
RegisterCustomCheckersTest.cpp [analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function calls, rather than each ExplodedNode in it 2021-09-13 13:50:01 +02:00
Reusables.h [clang][Analyzer] Add symbol uninterestingness to bug report. 2021-07-15 10:02:18 +02:00
SValTest.cpp [analyzer][NFC] Re-enable skipped SValTests by relaxing expectations 2022-01-19 15:16:18 +01:00
StoreTest.cpp [analyzer] Allow bindings of the CompoundLiteralRegion 2020-05-28 14:11:57 +03:00
SymbolReaperTest.cpp
TestReturnValueUnderConstruction.cpp [Analyzer] Fix for `ExprEngine::computeObjectUnderConstruction()` for base and delegating consturctor initializers 2020-09-25 13:28:22 +02:00