[PATCH] D139759: [analyzer] Fix assertion in getAPSIntType

Vince Bridgers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 9 17:52:07 PST 2022


vabridgers updated this revision to Diff 481809.
vabridgers added a comment.

update commit header


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139759/new/

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());
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139759.481809.patch
Type: text/x-patch
Size: 1115 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221210/d8e65a69/attachment.bin>


More information about the cfe-commits mailing list