[clang] 929662b - Revert "[analyzer] Fix crash analyzing _BitInt() in evalIntegralCast (#65887)"
Bjorn Pettersson via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 18 14:37:42 PDT 2023
Author: Bjorn Pettersson
Date: 2023-09-18T23:35:48+02:00
New Revision: 929662b489225ac22dd59553f1c67842abe4dd29
URL: https://github.com/llvm/llvm-project/commit/929662b489225ac22dd59553f1c67842abe4dd29
DIFF: https://github.com/llvm/llvm-project/commit/929662b489225ac22dd59553f1c67842abe4dd29.diff
LOG: Revert "[analyzer] Fix crash analyzing _BitInt() in evalIntegralCast (#65887)"
This reverts commit 4898c33527f90b067f353a115442a9a702319fce.
Lots of buildbots are failing, probably because lots of targets not supporting
large _BitInt types.
Added:
Modified:
clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
Removed:
clang/test/Analysis/bitint-no-crash.c
################################################################################
diff --git a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
index f827f43eaa7da67..4fe828bdf7681fc 100644
--- a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -598,9 +598,11 @@ SVal SValBuilder::evalIntegralCast(ProgramStateRef state, SVal val,
APSIntType ToType(getContext().getTypeSize(castTy),
castTy->isUnsignedIntegerType());
llvm::APSInt ToTypeMax = ToType.getMaxValue();
-
- NonLoc ToTypeMaxVal = makeIntVal(ToTypeMax);
-
+ NonLoc ToTypeMaxVal =
+ makeIntVal(ToTypeMax.isUnsigned() ? ToTypeMax.getZExtValue()
+ : ToTypeMax.getSExtValue(),
+ castTy)
+ .castAs<NonLoc>();
// Check the range of the symbol being casted against the maximum value of the
// target type.
NonLoc FromVal = val.castAs<NonLoc>();
diff --git a/clang/test/Analysis/bitint-no-crash.c b/clang/test/Analysis/bitint-no-crash.c
deleted file mode 100644
index 6fa041974a3c981..000000000000000
--- a/clang/test/Analysis/bitint-no-crash.c
+++ /dev/null
@@ -1,11 +0,0 @@
- // RUN: %clang_analyze_cc1 -analyzer-checker=core \
- // RUN: -analyzer-checker=debug.ExprInspection \
- // RUN: -verify %s
-
-// Don't crash when using _BitInt()
-// expected-no-diagnostics
-_BitInt(256) a;
-_BitInt(129) b;
-void c() {
- b = a;
-}
More information about the cfe-commits
mailing list