[cfe-commits] r66637 - /cfe/trunk/include/clang/Analysis/PathSensitive/BasicValueFactory.h

Ted Kremenek kremenek at apple.com
Tue Mar 10 21:03:25 PDT 2009


Author: kremenek
Date: Tue Mar 10 23:03:24 2009
New Revision: 66637

URL: http://llvm.org/viewvc/llvm-project?rev=66637&view=rev
Log:
Add utility method to BasicValueFactory to convert an APSInt to one of a different sign.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/BasicValueFactory.h

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/BasicValueFactory.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/BasicValueFactory.h?rev=66637&r1=66636&r2=66637&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/BasicValueFactory.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/BasicValueFactory.h Tue Mar 10 23:03:24 2009
@@ -75,6 +75,18 @@
   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;





More information about the cfe-commits mailing list