vabridgers created this revision. Herald added subscribers: steakhal, manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun. Herald added a reviewer: NoQ. Herald added a project: All. vabridgers requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
getAPSIntType crashes when analzying a simple case that uses a fixed point type. Just add a check for isFixedPointType() to the assert to address the problem. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D139759 Files: clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h clang/test/Analysis/fixed-point.c Index: clang/test/Analysis/fixed-point.c =================================================================== --- /dev/null +++ clang/test/Analysis/fixed-point.c @@ -0,0 +1,10 @@ +// RUN: %clang_analyze_cc1 -ffixed-point \ +// RUN: -analyzer-checker=core,debug.ExprInspection -Wno-unused -verify %s + +// expected-no-diagnostics + +long a(int c) { + (long _Accum) c >> 4; + return c; +} + Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h =================================================================== --- clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h +++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h @@ -152,7 +152,8 @@ T = AT->getValueType(); } - assert(T->isIntegralOrEnumerationType() || Loc::isLocType(T)); + assert(T->isIntegralOrEnumerationType() || T->isFixedPointType() || + Loc::isLocType(T)); return APSIntType(Ctx.getIntWidth(T), !T->isSignedIntegerOrEnumerationType()); }
Index: clang/test/Analysis/fixed-point.c =================================================================== --- /dev/null +++ clang/test/Analysis/fixed-point.c @@ -0,0 +1,10 @@ +// RUN: %clang_analyze_cc1 -ffixed-point \ +// RUN: -analyzer-checker=core,debug.ExprInspection -Wno-unused -verify %s + +// expected-no-diagnostics + +long a(int c) { + (long _Accum) c >> 4; + return c; +} + Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h =================================================================== --- clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h +++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h @@ -152,7 +152,8 @@ T = AT->getValueType(); } - assert(T->isIntegralOrEnumerationType() || Loc::isLocType(T)); + assert(T->isIntegralOrEnumerationType() || T->isFixedPointType() || + Loc::isLocType(T)); return APSIntType(Ctx.getIntWidth(T), !T->isSignedIntegerOrEnumerationType()); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits