mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 19:06:38 +00:00

getAPSIntType crashes when analzying a simple case that uses a fixed point type. getAPSIntType needs to handle fixed point types differently to get sign information. LIT and Unittests were added since there were none previously added. clang: <root>/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h:155: clang::ento::APSIntType clang::ento::BasicValueFactory::getAPSIntType(clang::QualType) const: Assertion `T->isIntegralOrEnumerationType() || Loc::isLocType(T)' failed. Program received signal SIGABRT, Aborted. 0x00007ffff66e2387 in raise () from /lib64/libc.so.6 (gdb) bt at <root>/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h:155 at <root>/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h:172 LHS=0x108965a0, op=clang::BO_Shr, RHS=..., resultTy=...) at <root>/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:213 (this=0x1088e460, state=..., op=clang::BO_Shr, lhs=..., rhs=..., resultTy=...) at <root>/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:681 Reviewed By: steakhal Differential Revision: https://reviews.llvm.org/D139759
66 lines
1.1 KiB
C
66 lines
1.1 KiB
C
// RUN: %clang_analyze_cc1 -ffixed-point \
|
|
// RUN: -analyzer-checker=core,debug.ExprInspection -verify %s
|
|
|
|
// expected-no-diagnostics
|
|
|
|
// Check that getAPSIntType does not crash
|
|
// when using fixed point types.
|
|
|
|
enum Kind { en_0 = 1 };
|
|
|
|
void _enum(int c) {
|
|
(void)((enum Kind) c >> 4);
|
|
}
|
|
|
|
void _inttype(int c) {
|
|
(void)(c >> 4);
|
|
}
|
|
|
|
void _accum(int c) {
|
|
(void)((_Accum) c >> 4);
|
|
}
|
|
|
|
void _fract(int c) {
|
|
(void)((_Fract) c >> 4);
|
|
}
|
|
|
|
void _long_fract(int c) {
|
|
(void)((long _Fract) c >> 4);
|
|
}
|
|
|
|
void _unsigned_accum(int c) {
|
|
(void)((unsigned _Accum) c >> 4);
|
|
}
|
|
|
|
void _short_unsigned_accum(int c) {
|
|
(void)((short unsigned _Accum) c >> 4);
|
|
}
|
|
|
|
void _unsigned_fract(int c) {
|
|
(void)((unsigned _Fract) c >> 4);
|
|
}
|
|
|
|
void sat_accum(int c) {
|
|
(void)((_Sat _Accum) c >> 4);
|
|
}
|
|
|
|
void sat_fract(int c) {
|
|
(void)((_Sat _Fract) c >> 4);
|
|
}
|
|
|
|
void sat_long_fract(int c) {
|
|
(void)((_Sat long _Fract) c >> 4);
|
|
}
|
|
|
|
void sat_unsigned_accum(int c) {
|
|
(void)((_Sat unsigned _Accum) c >> 4);
|
|
}
|
|
|
|
void sat_short_unsigned_accum(int c) {
|
|
(void)((_Sat short unsigned _Accum) c >> 4);
|
|
}
|
|
|
|
void sat_unsigned_fract(int c) {
|
|
(void)((_Sat unsigned _Fract) c >> 4);
|
|
}
|