refactor more objc codegen interfaces to pass around selectors so
we don't push strings into LLVM IR and then have to read them back out.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52765 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 6082226..20afc5e 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -229,9 +229,11 @@
       unsigned ParamAttrs = 0;
       if (ParamType->isRecordType())
         ParamAttrs |= llvm::ParamAttr::ByVal;
-      if (ParamType->isSignedIntegerType() && ParamType->isPromotableIntegerType())
+      if (ParamType->isSignedIntegerType() &&
+          ParamType->isPromotableIntegerType())
         ParamAttrs |= llvm::ParamAttr::SExt;
-      if (ParamType->isUnsignedIntegerType() && ParamType->isPromotableIntegerType())
+      if (ParamType->isUnsignedIntegerType() &&
+          ParamType->isPromotableIntegerType())
         ParamAttrs |= llvm::ParamAttr::ZExt;
       if (ParamAttrs)
         ParamAttrList.push_back(llvm::ParamAttrsWithIndex::get(i + increment,
@@ -273,7 +275,7 @@
       const std::string& aliaseeName = D->getAttr<AliasAttr>()->getAliasee();
       llvm::Function *aliasee = getModule().getFunction(aliaseeName);
       llvm::GlobalValue *alias = new llvm::GlobalAlias(aliasee->getType(),
-                                                       llvm::Function::ExternalLinkage,
+                                               llvm::Function::ExternalLinkage,
                                                        D->getName(),
                                                        aliasee,
                                                        &getModule());
@@ -390,26 +392,24 @@
 void CodeGenModule::EmitObjCCategoryImpl(const ObjCCategoryImplDecl *OCD) {
 
   // Collect information about instance methods
-  llvm::SmallVector<llvm::Constant*, 16> InstanceMethodNames;
+  llvm::SmallVector<Selector, 16> InstanceMethodSels;
   llvm::SmallVector<llvm::Constant*, 16> InstanceMethodTypes;
   for (ObjCCategoryDecl::instmeth_iterator iter = OCD->instmeth_begin(),
       endIter = OCD->instmeth_end() ; iter != endIter ; iter++) {
+    InstanceMethodSels.push_back((*iter)->getSelector());
     std::string TypeStr;
     Context.getObjCEncodingForMethodDecl(*iter,TypeStr);
-    InstanceMethodNames.push_back(
-        GetAddrOfConstantString((*iter)->getSelector().getName()));
     InstanceMethodTypes.push_back(GetAddrOfConstantString(TypeStr));
   }
 
   // Collect information about class methods
-  llvm::SmallVector<llvm::Constant*, 16> ClassMethodNames;
+  llvm::SmallVector<Selector, 16> ClassMethodSels;
   llvm::SmallVector<llvm::Constant*, 16> ClassMethodTypes;
   for (ObjCCategoryDecl::classmeth_iterator iter = OCD->classmeth_begin(),
       endIter = OCD->classmeth_end() ; iter != endIter ; iter++) {
+    ClassMethodSels.push_back((*iter)->getSelector());
     std::string TypeStr;
     Context.getObjCEncodingForMethodDecl(*iter,TypeStr);
-    ClassMethodNames.push_back(
-        GetAddrOfConstantString((*iter)->getSelector().getName()));
     ClassMethodTypes.push_back(GetAddrOfConstantString(TypeStr));
   }
 
@@ -421,8 +421,8 @@
 
   // Generate the category
   Runtime->GenerateCategory(OCD->getClassInterface()->getName(),
-      OCD->getName(), InstanceMethodNames, InstanceMethodTypes,
-      ClassMethodNames, ClassMethodTypes, Protocols);
+      OCD->getName(), InstanceMethodSels, InstanceMethodTypes,
+      ClassMethodSels, ClassMethodTypes, Protocols);
 }
 
 void CodeGenModule::EmitObjCClassImplementation(
@@ -473,26 +473,24 @@
   }
 
   // Collect information about instance methods
-  llvm::SmallVector<llvm::Constant*, 16> InstanceMethodNames;
+  llvm::SmallVector<Selector, 16> InstanceMethodSels;
   llvm::SmallVector<llvm::Constant*, 16> InstanceMethodTypes;
   for (ObjCImplementationDecl::instmeth_iterator iter = OID->instmeth_begin(),
       endIter = OID->instmeth_end() ; iter != endIter ; iter++) {
+    InstanceMethodSels.push_back((*iter)->getSelector());
     std::string TypeStr;
     Context.getObjCEncodingForMethodDecl((*iter),TypeStr);
-    InstanceMethodNames.push_back(
-        GetAddrOfConstantString((*iter)->getSelector().getName()));
     InstanceMethodTypes.push_back(GetAddrOfConstantString(TypeStr));
   }
 
   // Collect information about class methods
-  llvm::SmallVector<llvm::Constant*, 16> ClassMethodNames;
+  llvm::SmallVector<Selector, 16> ClassMethodSels;
   llvm::SmallVector<llvm::Constant*, 16> ClassMethodTypes;
   for (ObjCImplementationDecl::classmeth_iterator iter = OID->classmeth_begin(),
       endIter = OID->classmeth_end() ; iter != endIter ; iter++) {
+    ClassMethodSels.push_back((*iter)->getSelector());
     std::string TypeStr;
     Context.getObjCEncodingForMethodDecl((*iter),TypeStr);
-    ClassMethodNames.push_back(
-        GetAddrOfConstantString((*iter)->getSelector().getName()));
     ClassMethodTypes.push_back(GetAddrOfConstantString(TypeStr));
   }
   // Collect the names of referenced protocols
@@ -502,8 +500,8 @@
 
   // Generate the category
   Runtime->GenerateClass(ClassName, SCName, instanceSize, IvarNames, IvarTypes,
-      IvarOffsets, InstanceMethodNames, InstanceMethodTypes, ClassMethodNames,
-      ClassMethodTypes, Protocols);
+                         IvarOffsets, InstanceMethodSels, InstanceMethodTypes,
+                         ClassMethodSels, ClassMethodTypes, Protocols);
 }