[llvm-branch-commits] [llvm-branch] r134401 - in /llvm/branches/type-system-rewrite: include/llvm/DerivedTypes.h lib/VMCore/Type.cpp

Chris Lattner sabre at nondot.org
Mon Jul 4 16:28:21 PDT 2011


Author: lattner
Date: Mon Jul  4 18:28:21 2011
New Revision: 134401

URL: http://llvm.org/viewvc/llvm-project?rev=134401&view=rev
Log:
add a helper function

Modified:
    llvm/branches/type-system-rewrite/include/llvm/DerivedTypes.h
    llvm/branches/type-system-rewrite/lib/VMCore/Type.cpp

Modified: llvm/branches/type-system-rewrite/include/llvm/DerivedTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/type-system-rewrite/include/llvm/DerivedTypes.h?rev=134401&r1=134400&r2=134401&view=diff
==============================================================================
--- llvm/branches/type-system-rewrite/include/llvm/DerivedTypes.h (original)
+++ llvm/branches/type-system-rewrite/include/llvm/DerivedTypes.h Mon Jul  4 18:28:21 2011
@@ -109,8 +109,7 @@
 class FunctionType : public DerivedType {
   FunctionType(const FunctionType &);                   // Do not implement
   const FunctionType &operator=(const FunctionType &);  // Do not implement
-  FunctionType(const Type *Result, ArrayRef<const Type*> Params,
-               bool IsVarArgs);
+  FunctionType(const Type *Result, ArrayRef<Type*> Params, bool IsVarArgs);
 
 public:
   /// FunctionType::get - This static method is the primary way of constructing
@@ -118,6 +117,8 @@
   ///
   static FunctionType *get(const Type *Result,
                            ArrayRef<const Type*> Params, bool isVarArg);
+  static FunctionType *get(const Type *Result,
+                           ArrayRef<Type*> Params, bool isVarArg);
 
   /// FunctionType::get - Create a FunctionType taking no parameters.
   ///

Modified: llvm/branches/type-system-rewrite/lib/VMCore/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/type-system-rewrite/lib/VMCore/Type.cpp?rev=134401&r1=134400&r2=134401&view=diff
==============================================================================
--- llvm/branches/type-system-rewrite/lib/VMCore/Type.cpp (original)
+++ llvm/branches/type-system-rewrite/lib/VMCore/Type.cpp Mon Jul  4 18:28:21 2011
@@ -302,7 +302,7 @@
 //                       FunctionType Implementation
 //===----------------------------------------------------------------------===//
 
-FunctionType::FunctionType(const Type *Result, ArrayRef<const Type*> Params,
+FunctionType::FunctionType(const Type *Result, ArrayRef<Type*> Params,
                            bool IsVarArgs)
   : DerivedType(Result->getContext(), FunctionTyID) {
   Type **SubTys = reinterpret_cast<Type**>(this+1);
@@ -314,17 +314,23 @@
   for (unsigned i = 0, e = Params.size(); i != e; ++i) {
     assert(isValidArgumentType(Params[i]) &&
            "Not a valid type for function argument!");
-    SubTys[i+1] = const_cast<Type*>(Params[i]);
+    SubTys[i+1] = Params[i];
   }
 
   ContainedTys = SubTys;
   NumContainedTys = Params.size() + 1; // + 1 for result type
 }
 
+// FIXME: Remove this version.
+FunctionType *FunctionType::get(const Type *ReturnType,
+                                ArrayRef<const Type*> Params, bool isVarArg) {
+  return get(ReturnType, ArrayRef<Type*>(const_cast<Type**>(Params.data()),
+                                         Params.size()), isVarArg);
+}
 
 // FunctionType::get - The factory function for the FunctionType class.
 FunctionType *FunctionType::get(const Type *ReturnType,
-                                ArrayRef<const Type*> Params, bool isVarArg) {
+                                ArrayRef<Type*> Params, bool isVarArg) {
   // TODO: This is brutally slow.
   std::vector<Type*> Key;
   Key.reserve(Params.size()+2);





More information about the llvm-branch-commits mailing list