diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-09-25 00:18:15 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-09-25 00:18:15 +0000 |
commit | 80417471b01ab2726cd04773b2ab700ce564073c (patch) | |
tree | 8673dc1bbefb678e811b886638a6f0abb6603761 /include/clang/Analysis/PathSensitive/BasicValueFactory.h | |
parent | 6026504302763f74102592602b392cecd5ced3ae (diff) |
Fix <rdar://problem/7249327> by allowing silent conversions between signed and unsigned integer values for symbolic values. This is an intermediate solution (i.e. hack) until we support extension/truncation of symbolic integers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82737 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Analysis/PathSensitive/BasicValueFactory.h')
-rw-r--r-- | include/clang/Analysis/PathSensitive/BasicValueFactory.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/include/clang/Analysis/PathSensitive/BasicValueFactory.h b/include/clang/Analysis/PathSensitive/BasicValueFactory.h index 69cd9db77c..12f0ce2d50 100644 --- a/include/clang/Analysis/PathSensitive/BasicValueFactory.h +++ b/include/clang/Analysis/PathSensitive/BasicValueFactory.h @@ -92,16 +92,25 @@ public: /// Convert - Create a new persistent APSInt with the same value as 'From' /// but with the bitwidth and signedness of 'To'. - const llvm::APSInt& Convert(const llvm::APSInt& To, + const llvm::APSInt &Convert(const llvm::APSInt& To, const llvm::APSInt& From) { if (To.isUnsigned() == From.isUnsigned() && To.getBitWidth() == From.getBitWidth()) return From; - return getValue(From.getSExtValue(), - To.getBitWidth(), - To.isUnsigned()); + return getValue(From.getSExtValue(), To.getBitWidth(), To.isUnsigned()); + } + + const llvm::APSInt &Convert(QualType T, const llvm::APSInt &From) { + assert(T->isIntegerType() || Loc::IsLocType(T)); + unsigned bitwidth = Ctx.getTypeSize(T); + bool isUnsigned = T->isUnsignedIntegerType() || Loc::IsLocType(T); + + if (isUnsigned == From.isUnsigned() && bitwidth == From.getBitWidth()) + return From; + + return getValue(From.getSExtValue(), bitwidth, isUnsigned); } const llvm::APSInt& getIntValue(uint64_t X, bool isUnsigned) { |