]> granicus.if.org Git - clang/commitdiff
Add ASTContext::MakeIntValue
authorDaniel Dunbar <daniel@zuster.org>
Wed, 18 Feb 2009 00:29:14 +0000 (00:29 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 18 Feb 2009 00:29:14 +0000 (00:29 +0000)
 - Makes an APSInt given a uint64_t and a type, with the appropriate
   width and signedness to match the type. Yay for functional over
   imperative.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64863 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ASTContext.h

index 0cb2b35f5a17931ab9d6eaa5b0a05ba921024b30..349b6e3f83ece9f10e1ce25cfd64c145143593ac 100644 (file)
@@ -615,6 +615,18 @@ public:
   void Emit(llvm::Serializer& S) const;
   static ASTContext* Create(llvm::Deserializer& D);  
   
+  //===--------------------------------------------------------------------===//
+  //                    Integer Values
+  //===--------------------------------------------------------------------===//
+
+  /// MakeIntValue - Make an APSInt of the appropriate width and
+  /// signedness for the given \arg Value and integer \arg Type.
+  llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) {
+    llvm::APSInt Res(getIntWidth(Type), !Type->isSignedIntegerType());
+    Res = Value;
+    return Res;
+  }
+
 private:
   ASTContext(const ASTContext&); // DO NOT IMPLEMENT
   void operator=(const ASTContext&); // DO NOT IMPLEMENT