[PATCH] D47617: [Analyzer] Fix Z3ConstraintManager crash (PR37646)
Vlad Tsyrklevich via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 4 10:01:28 PDT 2018
vlad.tsyrklevich updated this revision to Diff 149796.
vlad.tsyrklevich added a comment.
- Merge test with apsint.c and move to z3/apsint.c
Repository:
rC Clang
https://reviews.llvm.org/D47617
Files:
lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
test/Analysis/apsint.c
test/Analysis/z3/apsint.c
Index: test/Analysis/z3/apsint.c
===================================================================
--- /dev/null
+++ test/Analysis/z3/apsint.c
@@ -0,0 +1,16 @@
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux-gnu -analyzer-checker=core -verify %s
+// expected-no-diagnostics
+
+// https://bugs.llvm.org/show_bug.cgi?id=37622
+_Bool a() {
+ return !({ a(); });
+}
+
+// https://bugs.llvm.org/show_bug.cgi?id=37646
+_Bool b;
+void c() {
+ _Bool a = b | 0;
+ for (;;)
+ if (a)
+ ;
+}
Index: test/Analysis/apsint.c
===================================================================
--- test/Analysis/apsint.c
+++ /dev/null
@@ -1,7 +0,0 @@
-// REQUIRES: z3
-// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux-gnu -analyzer-checker=core -verify %s
-// expected-no-diagnostics
-
-_Bool a() {
- return !({ a(); });
-}
Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===================================================================
--- lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -1231,8 +1231,10 @@
if (!LHS || !RHS)
return nullptr;
- llvm::APSInt ConvertedLHS = *LHS, ConvertedRHS = *RHS;
- QualType LTy = getAPSIntType(*LHS), RTy = getAPSIntType(*RHS);
+ llvm::APSInt ConvertedLHS, ConvertedRHS;
+ QualType LTy, RTy;
+ std::tie(ConvertedLHS, LTy) = fixAPSInt(*LHS);
+ std::tie(ConvertedRHS, RTy) = fixAPSInt(*RHS);
doIntTypeConversion<llvm::APSInt, Z3ConstraintManager::castAPSInt>(
ConvertedLHS, LTy, ConvertedRHS, RTy);
return BVF.evalAPSInt(BSE->getOpcode(), ConvertedLHS, ConvertedRHS);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47617.149796.patch
Type: text/x-patch
Size: 1633 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180604/435e836b/attachment.bin>
More information about the cfe-commits
mailing list