[cfe-commits] r64863 - /cfe/trunk/include/clang/AST/ASTContext.h

Daniel Dunbar daniel at zuster.org
Tue Feb 17 16:29:14 PST 2009


Author: ddunbar
Date: Tue Feb 17 18:29:14 2009
New Revision: 64863

URL: http://llvm.org/viewvc/llvm-project?rev=64863&view=rev
Log:
Add ASTContext::MakeIntValue
 - 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.

Modified:
    cfe/trunk/include/clang/AST/ASTContext.h

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=64863&r1=64862&r2=64863&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Feb 17 18:29:14 2009
@@ -615,6 +615,18 @@
   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





More information about the cfe-commits mailing list