[PATCH] D47617: [Analyzer] Fix Z3ConstraintManager crash (PR37646)

Vlad Tsyrklevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 5 23:14:03 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC334065: [Analyzer] Fix Z3ConstraintManager crash (PR37646) (authored by vlad.tsyrklevich, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47617?vs=149796&id=150074#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47617

Files:
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
  test/Analysis/apsint.c
  test/Analysis/z3/apsint.c


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);
Index: test/Analysis/z3/apsint.c
===================================================================
--- test/Analysis/z3/apsint.c
+++ 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
+++ test/Analysis/apsint.c
@@ -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(); });
-}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47617.150074.patch
Type: text/x-patch
Size: 1662 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180606/96d14b6b/attachment.bin>


More information about the cfe-commits mailing list