[PATCH] D47617: [Analyzer] Fix Z3 crash (PR37646)
Vlad Tsyrklevich via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 31 21:36:13 PDT 2018
vlad.tsyrklevich created this revision.
vlad.tsyrklevich added reviewers: george.karpenkov, NoQ, ddcc.
Herald added subscribers: cfe-commits, a.sidorin, szepet, xazax.hun.
Fix another Z3ConstraintManager crash, use fixAPSInt() to extend a
boolean APSInt.
Repository:
rC Clang
https://reviews.llvm.org/D47617
Files:
lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
test/Analysis/pr37646.c
Index: test/Analysis/pr37646.c
===================================================================
--- /dev/null
+++ test/Analysis/pr37646.c
@@ -0,0 +1,11 @@
+// REQUIRES: z3
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core -analyzer-store=region -analyzer-constraints=z3 -verify %s
+// expected-no-diagnostics
+
+_Bool b;
+void c() {
+ _Bool a = b | 0;
+ for (;;)
+ if (a)
+ ;
+}
Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===================================================================
--- lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -1211,8 +1211,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 BV.evalAPSInt(BSE->getOpcode(), ConvertedLHS, ConvertedRHS);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47617.149396.patch
Type: text/x-patch
Size: 1216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180601/b240c750/attachment.bin>
More information about the cfe-commits
mailing list