summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail R. Gadelha <mikhail.ramalho@gmail.com>2018-07-16 13:32:22 +0000
committerMikhail R. Gadelha <mikhail.ramalho@gmail.com>2018-07-16 13:32:22 +0000
commit07f6e8e3a5191ae8150ed7530d364326d78f000a (patch)
tree89b04d78db56330a6349b612133b00715bf56a44
parent021e4c82eb600bdc9a55263aa6c0e8d93b7d7822 (diff)
downloadbcm5719-llvm-07f6e8e3a5191ae8150ed7530d364326d78f000a.tar.gz
bcm5719-llvm-07f6e8e3a5191ae8150ed7530d364326d78f000a.zip
[analyzer] Fix the Z3 backend always generating unsigned APSInt
Summary: In `toAPSInt`, the Z3 backend was not checking the variable `Int`'s type and was always generating unsigned `APSInt`s. This was found by accident when I removed: ``` llvm::APSInt ConvertedLHS, ConvertedRHS; QualType LTy, RTy; std::tie(ConvertedLHS, LTy) = fixAPSInt(*LHS); std::tie(ConvertedRHS, RTy) = fixAPSInt(*RHS); - doIntTypePromotion<llvm::APSInt, Z3ConstraintManager::castAPSInt>( - ConvertedLHS, LTy, ConvertedRHS, RTy); return BVF.evalAPSInt(BSE->getOpcode(), ConvertedLHS, ConvertedRHS); ``` And the `BasicValueFactory` started to complain about different `signedness`. Reviewers: george.karpenkov, NoQ, ddcc Reviewed By: ddcc Subscribers: xazax.hun, szepet, a.sidorin Differential Revision: https://reviews.llvm.org/D49305 llvm-svn: 337169
-rw-r--r--clang/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp b/clang/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
index 9e975676ccd..721e17759fb 100644
--- a/clang/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -681,12 +681,14 @@ public:
Z3_get_numeral_uint64(Z3Context::ZC, AST,
reinterpret_cast<__uint64 *>(&Value[0]));
if (Sort.getBitvectorSortSize() <= 64) {
- Int = llvm::APSInt(llvm::APInt(Int.getBitWidth(), Value[0]), true);
+ Int = llvm::APSInt(llvm::APInt(Int.getBitWidth(), Value[0]),
+ Int.isUnsigned());
} else if (Sort.getBitvectorSortSize() == 128) {
Z3Expr ASTHigh = Z3Expr(Z3_mk_extract(Z3Context::ZC, 127, 64, AST));
Z3_get_numeral_uint64(Z3Context::ZC, AST,
reinterpret_cast<__uint64 *>(&Value[1]));
- Int = llvm::APSInt(llvm::APInt(Int.getBitWidth(), Value), true);
+ Int = llvm::APSInt(llvm::APInt(Int.getBitWidth(), Value),
+ Int.isUnsigned());
} else {
assert(false && "Bitwidth not supported!");
return false;
@@ -702,7 +704,7 @@ public:
llvm::APInt(Int.getBitWidth(),
Z3_get_bool_value(Z3Context::ZC, AST) == Z3_L_TRUE ? 1
: 0),
- true);
+ Int.isUnsigned());
return true;
}
}
OpenPOWER on IntegriCloud