diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-03-11 04:03:24 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-03-11 04:03:24 +0000 |
commit | 154c96331774d8d7f063b88b2cd73a69ded70800 (patch) | |
tree | 374c005586e1f8527eafd2bbd0bbd40a7d055dfc | |
parent | 32c41ec66e101a2e5ecb9f260bda59ec063e7a92 (diff) | |
download | bcm5719-llvm-154c96331774d8d7f063b88b2cd73a69ded70800.tar.gz bcm5719-llvm-154c96331774d8d7f063b88b2cd73a69ded70800.zip |
Add utility method to BasicValueFactory to convert an APSInt to one of a different sign.
llvm-svn: 66637
-rw-r--r-- | clang/include/clang/Analysis/PathSensitive/BasicValueFactory.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/include/clang/Analysis/PathSensitive/BasicValueFactory.h b/clang/include/clang/Analysis/PathSensitive/BasicValueFactory.h index 64db2cd87bb..18ae1d88e4e 100644 --- a/clang/include/clang/Analysis/PathSensitive/BasicValueFactory.h +++ b/clang/include/clang/Analysis/PathSensitive/BasicValueFactory.h @@ -75,6 +75,18 @@ public: const llvm::APSInt& getValue(const llvm::APInt& X, bool isUnsigned); const llvm::APSInt& getValue(uint64_t X, unsigned BitWidth, bool isUnsigned); const llvm::APSInt& getValue(uint64_t X, QualType T); + + const llvm::APSInt& ConvertSignedness(const llvm::APSInt& To, + const llvm::APSInt& From) { + assert(To.getBitWidth() == From.getBitWidth()); + + // Same sign? Just return. + if (To.isUnsigned() == From.isUnsigned()) + return From; + + // Convert! + return getValue(llvm::APSInt((llvm::APInt&) From, To.isUnsigned())); + } const llvm::APSInt& getIntValue(uint64_t X, bool isUnsigned) { QualType T = isUnsigned ? Ctx.UnsignedIntTy : Ctx.IntTy; |