summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGObjC.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2008-08-16 03:19:19 +0000
committerDaniel Dunbar <daniel@zuster.org>2008-08-16 03:19:19 +0000
commitb7ec246872b412f0e7bb9e93eacfd78cfa6adfb3 (patch)
tree03d87c2a2a8966f8fa3652531269a98558147584 /lib/CodeGen/CGObjC.cpp
parent54d19091a809d30a5e6e352fda53377d69ebda66 (diff)
downloadclang-b7ec246872b412f0e7bb9e93eacfd78cfa6adfb3.tar.gz
clang-b7ec246872b412f0e7bb9e93eacfd78cfa6adfb3.tar.bz2
clang-b7ec246872b412f0e7bb9e93eacfd78cfa6adfb3.tar.xz
Add NeXT runtime support for generating methods.
Change CodeGenFunction::EmitParmDecl to take either a ParmVarDecl or an ImplicitParamDecl. Drop hasAggregateLLVMType from CodeGenModule.cpp (use version in CodeGenFunction). Change the Objective-C method generation to use EmitParmDecl for implicit parameters. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54838 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGObjC.cpp')
-rw-r--r--lib/CodeGen/CGObjC.cpp38
1 files changed, 12 insertions, 26 deletions
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index 54b4e19c57..2b4eb5b528 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -124,45 +124,31 @@ void CodeGenFunction::GenerateObjCMethod(const ObjCMethodDecl *OMD) {
// Emit allocs for param decls. Give the LLVM Argument nodes names.
llvm::Function::arg_iterator AI = CurFn->arg_begin();
+ // Name the struct return argument.
if (hasAggregateLLVMType(OMD->getResultType())) {
+ AI->setName("agg.result");
++AI;
}
+
// Add implicit parameters to the decl map.
- // TODO: Add something to AST to let the runtime specify the names and types
- // of these.
-
- llvm::Value *&SelfEntry = LocalDeclMap[OMD->getSelfDecl()];
- const llvm::Type *IPTy = AI->getType();
- llvm::Value *DeclPtr = new llvm::AllocaInst(IPTy, 0, AI->getName() +
- ".addr", AllocaInsertPt);
- // Store the initial value into the alloca.
- Builder.CreateStore(AI, DeclPtr);
- SelfEntry = DeclPtr;
+ EmitParmDecl(*OMD->getSelfDecl(), AI);
+ ++AI;
+
+ EmitParmDecl(*OMD->getCmdDecl(), AI);
++AI;
- llvm::Value *&CmdEntry = LocalDeclMap[OMD->getCmdDecl()];
- IPTy = AI->getType();
- DeclPtr = new llvm::AllocaInst(IPTy, 0, AI->getName() +
- ".addr", AllocaInsertPt);
- // Store the initial value into the alloca.
- Builder.CreateStore(AI, DeclPtr);
- CmdEntry = DeclPtr;
for (unsigned i = 0, e = OMD->getNumParams(); i != e; ++i, ++AI) {
assert(AI != CurFn->arg_end() && "Argument mismatch!");
EmitParmDecl(*OMD->getParamDecl(i), AI);
}
-
+ assert(AI == CurFn->arg_end() && "Argument mismatch");
+
GenerateFunction(OMD->getBody());
}
-llvm::Value *CodeGenFunction::LoadObjCSelf(void)
-{
- if (const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(CurFuncDecl)) {
- ValueDecl *Decl = OMD->getSelfDecl();
- llvm::Value *SelfPtr = LocalDeclMap[&(*(Decl))];
- return Builder.CreateLoad(SelfPtr, "self");
- }
- return NULL;
+llvm::Value *CodeGenFunction::LoadObjCSelf(void) {
+ const ObjCMethodDecl *OMD = cast<ObjCMethodDecl>(CurFuncDecl);
+ return Builder.CreateLoad(LocalDeclMap[OMD->getSelfDecl()], "self");
}
CGObjCRuntime::~CGObjCRuntime() {}