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 | 672e408f14b528fe5e41c5dc99e95e671149a1e9 (patch) | |
tree | 48ea20bb77cd82856af4beca1dce8673c10563aa /include/clang/Analysis/PathSensitive/BasicValueFactory.h | |
parent | 21028dd8850c64a414f7a82dfddcc291351203d6 (diff) |
Add utility method to BasicValueFactory to convert an APSInt to one of a different sign.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66637 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Analysis/PathSensitive/BasicValueFactory.h')
-rw-r--r-- | include/clang/Analysis/PathSensitive/BasicValueFactory.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/clang/Analysis/PathSensitive/BasicValueFactory.h b/include/clang/Analysis/PathSensitive/BasicValueFactory.h index 64db2cd87b..18ae1d88e4 100644 --- a/include/clang/Analysis/PathSensitive/BasicValueFactory.h +++ b/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; |