From: Bill Wendling Date: Wed, 22 Feb 2012 09:30:11 +0000 (+0000) Subject: Use an ArrayRef when we can instead of passing in a SmallVectorImpl reference. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=795b10062c2eaffae9e04241fb1a73cdbcb24a37;p=clang Use an ArrayRef when we can instead of passing in a SmallVectorImpl reference. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151150 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index ff25609b67..79f3b4420a 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -2019,7 +2019,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, } llvm::Value *CodeGenFunction:: -BuildVector(const SmallVectorImpl &Ops) { +BuildVector(ArrayRef Ops) { assert((Ops.size() & (Ops.size() - 1)) == 0 && "Not a power-of-two sized vector!"); bool AllConstants = true; diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index 3e8b528c77..299f44c3ef 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -337,10 +337,9 @@ private: /// containing a size and an array of structures containing instance variable /// metadata. This is used purely for introspection in the fragile ABI. In /// the non-fragile ABI, it's used for instance variable fixup. - llvm::Constant *GenerateIvarList( - const SmallVectorImpl &IvarNames, - const SmallVectorImpl &IvarTypes, - const SmallVectorImpl &IvarOffsets); + llvm::Constant *GenerateIvarList(ArrayRef IvarNames, + ArrayRef IvarTypes, + ArrayRef IvarOffsets); /// Generates a method list structure. This is a structure containing a size /// and an array of structures containing method metadata. /// @@ -348,8 +347,8 @@ private: /// pointer allowing them to be chained together in a linked list. llvm::Constant *GenerateMethodList(const StringRef &ClassName, const StringRef &CategoryName, - const SmallVectorImpl &MethodSels, - const SmallVectorImpl &MethodTypes, + ArrayRef MethodSels, + ArrayRef MethodTypes, bool isClassMethodList); /// Emits an empty protocol. This is used for @protocol() where no protocol /// is found. The runtime will (hopefully) fix up the pointer to refer to the @@ -362,8 +361,7 @@ private: SmallVectorImpl &InstanceMethodTypes); /// Generates a list of referenced protocols. Classes, categories, and /// protocols all use this structure. - llvm::Constant *GenerateProtocolList( - const SmallVectorImpl &Protocols); + llvm::Constant *GenerateProtocolList(ArrayRef Protocols); /// To ensure that all protocols are seen by the runtime, we add a category on /// a class defined in the runtime, declaring no methods, but adopting the /// protocols. This is a horribly ugly hack, but it allows us to collect all @@ -388,8 +386,8 @@ private: /// Generates a method list. This is used by protocols to define the required /// and optional methods. llvm::Constant *GenerateProtocolMethodList( - const SmallVectorImpl &MethodNames, - const SmallVectorImpl &MethodTypes); + ArrayRef MethodNames, + ArrayRef MethodTypes); /// Returns a selector with the specified type encoding. An empty string is /// used to return an untyped selector (with the types field set to NULL). llvm::Value *GetSelector(CGBuilderTy &Builder, Selector Sel, @@ -428,7 +426,7 @@ protected: /// significant bit being assumed to come first in the bitfield. Therefore, /// a bitfield with the 64th bit set will be (int64_t)&{ 2, [0, 1<<31] }, /// while a bitfield / with the 63rd bit set will be 1<<64. - llvm::Constant *MakeBitField(llvm::SmallVectorImpl &bits); + llvm::Constant *MakeBitField(ArrayRef bits); public: CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion, unsigned protocolClassVersion); @@ -1257,11 +1255,12 @@ CGObjCGNU::GenerateMessageSend(CodeGenFunction &CGF, /// Generates a MethodList. Used in construction of a objc_class and /// objc_category structures. -llvm::Constant *CGObjCGNU::GenerateMethodList(const StringRef &ClassName, - const StringRef &CategoryName, - const SmallVectorImpl &MethodSels, - const SmallVectorImpl &MethodTypes, - bool isClassMethodList) { +llvm::Constant *CGObjCGNU:: +GenerateMethodList(const StringRef &ClassName, + const StringRef &CategoryName, + ArrayRef MethodSels, + ArrayRef MethodTypes, + bool isClassMethodList) { if (MethodSels.empty()) return NULLPtr; // Get the method structure type. @@ -1314,10 +1313,10 @@ llvm::Constant *CGObjCGNU::GenerateMethodList(const StringRef &ClassName, } /// Generates an IvarList. Used in construction of a objc_class. -llvm::Constant *CGObjCGNU::GenerateIvarList( - const SmallVectorImpl &IvarNames, - const SmallVectorImpl &IvarTypes, - const SmallVectorImpl &IvarOffsets) { +llvm::Constant *CGObjCGNU:: +GenerateIvarList(ArrayRef IvarNames, + ArrayRef IvarTypes, + ArrayRef IvarOffsets) { if (IvarNames.size() == 0) return NULLPtr; // Get the method structure type. @@ -1444,9 +1443,9 @@ llvm::Constant *CGObjCGNU::GenerateClassStructure( return Class; } -llvm::Constant *CGObjCGNU::GenerateProtocolMethodList( - const SmallVectorImpl &MethodNames, - const SmallVectorImpl &MethodTypes) { +llvm::Constant *CGObjCGNU:: +GenerateProtocolMethodList(ArrayRef MethodNames, + ArrayRef MethodTypes) { // Get the method structure type. llvm::StructType *ObjCMethodDescTy = llvm::StructType::get( PtrToInt8Ty, // Really a selector, but the runtime does the casting for us. @@ -1473,8 +1472,7 @@ llvm::Constant *CGObjCGNU::GenerateProtocolMethodList( } // Create the protocol list structure used in classes, categories and so on -llvm::Constant *CGObjCGNU::GenerateProtocolList( - const SmallVectorImpl &Protocols) { +llvm::Constant *CGObjCGNU::GenerateProtocolList(ArrayRefProtocols){ llvm::ArrayType *ProtocolArrayTy = llvm::ArrayType::get(PtrToInt8Ty, Protocols.size()); llvm::StructType *ProtocolListTy = llvm::StructType::get( @@ -1771,7 +1769,7 @@ void CGObjCGNU::GenerateProtocolHolderCategory(void) { /// significant bit being assumed to come first in the bitfield. Therefore, a /// bitfield with the 64th bit set will be (int64_t)&{ 2, [0, 1<<31] }, while a /// bitfield / with the 63rd bit set will be 1<<64. -llvm::Constant *CGObjCGNU::MakeBitField(llvm::SmallVectorImpl &bits) { +llvm::Constant *CGObjCGNU::MakeBitField(ArrayRef bits) { int bitCount = bits.size(); int ptrBits = (TheModule.getPointerSize() == llvm::Module::Pointer32) ? 32 : 64; diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 9e3f7d7b22..db910d9f3a 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -831,7 +831,7 @@ protected: void BuildAggrIvarLayout(const ObjCImplementationDecl *OI, const llvm::StructLayout *Layout, const RecordDecl *RD, - const SmallVectorImpl &RecFields, + ArrayRef RecFields, unsigned int BytePos, bool ForStrongLayout, bool &HasUnion); @@ -2561,14 +2561,14 @@ CGObjCMac::EmitClassExtension(const ObjCImplementationDecl *ID) { /* struct objc_ivar { - char *ivar_name; - char *ivar_type; - int ivar_offset; + char *ivar_name; + char *ivar_type; + int ivar_offset; }; struct objc_ivar_list { - int ivar_count; - struct objc_ivar list[count]; + int ivar_count; + struct objc_ivar list[count]; }; */ llvm::Constant *CGObjCMac::EmitIvarList(const ObjCImplementationDecl *ID, @@ -3768,7 +3768,7 @@ void CGObjCCommonMac::BuildAggrIvarRecordLayout(const RecordType *RT, void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCImplementationDecl *OI, const llvm::StructLayout *Layout, const RecordDecl *RD, - const SmallVectorImpl &RecFields, + ArrayRef RecFields, unsigned int BytePos, bool ForStrongLayout, bool &HasUnion) { bool IsUnion = (RD && RD->isUnion()); diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 6327fa2225..65338bf8ee 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -2226,7 +2226,7 @@ public: llvm::Value *EmitNeonShiftVector(llvm::Value *V, llvm::Type *Ty, bool negateForRightShift); - llvm::Value *BuildVector(const SmallVectorImpl &Ops); + llvm::Value *BuildVector(ArrayRef Ops); llvm::Value *EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E); llvm::Value *EmitHexagonBuiltinExpr(unsigned BuiltinID, const CallExpr *E); llvm::Value *EmitPPCBuiltinExpr(unsigned BuiltinID, const CallExpr *E);