Move FunctionType conversion into CGCall.cpp:
- Added CodeGenTypes::GetFunctionType, taking a CGFunctionInfo.
- Updated Obj-C runtimes to use this instead of rolling the
llvm::FunctionType by hand.
- Killed CodeGenTypes::{ConvertReturnType, DecodeArgumentTypes}.
Add ABIArgInfo class to encapsulate ABI decision of how to lower types
to LLVM.
- Will move to target sometime soon.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56047 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp
index 2641d9d..2c030e9 100644
--- a/lib/CodeGen/CGObjCGNU.cpp
+++ b/lib/CodeGen/CGObjCGNU.cpp
@@ -921,40 +921,15 @@
}
llvm::Function *CGObjCGNU::GenerateMethod(const ObjCMethodDecl *OMD) {
- const llvm::Type *ReturnTy =
- CGM.getTypes().ConvertReturnType(OMD->getResultType());
const ObjCCategoryImplDecl *OCD =
dyn_cast<ObjCCategoryImplDecl>(OMD->getMethodContext());
const std::string &CategoryName = OCD ? OCD->getName() : "";
- const llvm::Type *SelfTy = llvm::PointerType::getUnqual(llvm::Type::Int32Ty);
const std::string &ClassName = OMD->getClassInterface()->getName();
const std::string &MethodName = OMD->getSelector().getName();
- unsigned ArgC = OMD->param_size();
bool isClassMethod = !OMD->isInstance();
- bool isVarArg = OMD->isVariadic();
- llvm::SmallVector<const llvm::Type *, 16> ArgTy;
- for (unsigned i=0 ; i<OMD->param_size() ; i++) {
- const llvm::Type *Ty =
- CGM.getTypes().ConvertType(OMD->getParamDecl(i)->getType());
- if (Ty->isFirstClassType())
- ArgTy.push_back(Ty);
- else
- ArgTy.push_back(llvm::PointerType::getUnqual(Ty));
- }
-
- std::vector<const llvm::Type*> Args;
- if (!ReturnTy->isSingleValueType() && ReturnTy != llvm::Type::VoidTy) {
- Args.push_back(llvm::PointerType::getUnqual(ReturnTy));
- ReturnTy = llvm::Type::VoidTy;
- }
- Args.push_back(SelfTy);
- Args.push_back(SelectorTy);
- Args.insert(Args.end(), ArgTy.begin(), ArgTy.begin()+ArgC);
-
- llvm::FunctionType *MethodTy = llvm::FunctionType::get(ReturnTy,
- Args,
- isVarArg);
+ const llvm::FunctionType *MethodTy =
+ CGM.getTypes().GetFunctionType(CGFunctionInfo(OMD, CGM.getContext()));
std::string FunctionName = SymbolNameForMethod(ClassName, CategoryName,
MethodName, isClassMethod);