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);
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);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits