summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2008-08-15 22:20:32 +0000
committerDaniel Dunbar <daniel@zuster.org>2008-08-15 22:20:32 +0000
commit92992509399e55569dbcb62f7e94f6b6ad9b5177 (patch)
tree827e6c291d8a69efec7e13550af41a424b292710 /clang/lib/CodeGen/CodeGenModule.cpp
parentaffe0267f82fb03831ea1d7bc2c952c78c22a926 (diff)
downloadbcm5719-llvm-92992509399e55569dbcb62f7e94f6b6ad9b5177.tar.gz
bcm5719-llvm-92992509399e55569dbcb62f7e94f6b6ad9b5177.zip
Change CGObjCRuntime methods to take appropriate clang Decls.
- This is in prep for implementation class support for the NeXT runtime, for which the existing methods don't provide enough information (and additionally make too many assumptions about how things should be emitted). llvm-svn: 54824
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp123
1 files changed, 5 insertions, 118 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 500bf5b5d54..3340cdff56a 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -252,125 +252,12 @@ void CodeGenModule::EmitObjCProtocolImplementation(const ObjCProtocolDecl *PD){
}
void CodeGenModule::EmitObjCCategoryImpl(const ObjCCategoryImplDecl *OCD) {
+ Runtime->GenerateCategory(OCD);
+}
- // Collect information about instance methods
- 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);
- InstanceMethodTypes.push_back(GetAddrOfConstantCString(TypeStr));
- }
-
- // Collect information about class methods
- 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);
- ClassMethodTypes.push_back(GetAddrOfConstantCString(TypeStr));
- }
-
- // Collect the names of referenced protocols
- llvm::SmallVector<std::string, 16> Protocols;
- const ObjCInterfaceDecl *ClassDecl = OCD->getClassInterface();
- const ObjCList<ObjCProtocolDecl> &Protos =ClassDecl->getReferencedProtocols();
- for (ObjCList<ObjCProtocolDecl>::iterator I = Protos.begin(),
- E = Protos.end(); I != E; ++I)
- Protocols.push_back((*I)->getName());
-
- // Generate the category
- Runtime->GenerateCategory(OCD->getClassInterface()->getName(),
- OCD->getName(), InstanceMethodSels, InstanceMethodTypes,
- ClassMethodSels, ClassMethodTypes, Protocols);
-}
-
-void CodeGenModule::EmitObjCClassImplementation(
- const ObjCImplementationDecl *OID) {
- // Get the superclass name.
- const ObjCInterfaceDecl * SCDecl = OID->getClassInterface()->getSuperClass();
- const char * SCName = NULL;
- if (SCDecl) {
- SCName = SCDecl->getName();
- }
-
- // Get the class name
- ObjCInterfaceDecl * ClassDecl = (ObjCInterfaceDecl*)OID->getClassInterface();
- const char * ClassName = ClassDecl->getName();
-
- // Get the size of instances. For runtimes that support late-bound instances
- // this should probably be something different (size just of instance
- // varaibles in this class, not superclasses?).
- int instanceSize = 0;
- const llvm::Type *ObjTy = 0;
- if (!Runtime->LateBoundIVars()) {
- ObjTy = getTypes().ConvertType(Context.getObjCInterfaceType(ClassDecl));
- instanceSize = TheTargetData.getABITypeSize(ObjTy);
- } else {
- // This is required by newer ObjC runtimes.
- assert(0 && "Late-bound instance variables not yet supported");
- }
-
- // Collect information about instance variables.
- llvm::SmallVector<llvm::Constant*, 16> IvarNames;
- llvm::SmallVector<llvm::Constant*, 16> IvarTypes;
- llvm::SmallVector<llvm::Constant*, 16> IvarOffsets;
- const llvm::StructLayout *Layout =
- TheTargetData.getStructLayout(cast<llvm::StructType>(ObjTy));
- ObjTy = llvm::PointerType::getUnqual(ObjTy);
- for (ObjCInterfaceDecl::ivar_iterator iter = ClassDecl->ivar_begin(),
- endIter = ClassDecl->ivar_end() ; iter != endIter ; iter++) {
- // Store the name
- IvarNames.push_back(GetAddrOfConstantCString((*iter)->getName()));
- // Get the type encoding for this ivar
- std::string TypeStr;
- llvm::SmallVector<const RecordType *, 8> EncodingRecordTypes;
- Context.getObjCEncodingForType((*iter)->getType(), TypeStr,
- EncodingRecordTypes);
- IvarTypes.push_back(GetAddrOfConstantCString(TypeStr));
- // Get the offset
- int offset =
- (int)Layout->getElementOffset(getTypes().getLLVMFieldNo(*iter));
- IvarOffsets.push_back(
- llvm::ConstantInt::get(llvm::Type::Int32Ty, offset));
- }
-
- // Collect information about instance methods
- 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);
- InstanceMethodTypes.push_back(GetAddrOfConstantCString(TypeStr));
- }
-
- // Collect information about class methods
- 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);
- ClassMethodTypes.push_back(GetAddrOfConstantCString(TypeStr));
- }
- // Collect the names of referenced protocols
- llvm::SmallVector<std::string, 16> Protocols;
- const ObjCList<ObjCProtocolDecl> &Protos =ClassDecl->getReferencedProtocols();
- for (ObjCList<ObjCProtocolDecl>::iterator I = Protos.begin(),
- E = Protos.end(); I != E; ++I)
- Protocols.push_back((*I)->getName());
-
- // Generate the category
- Runtime->GenerateClass(ClassName, SCName, instanceSize, IvarNames, IvarTypes,
- IvarOffsets, InstanceMethodSels, InstanceMethodTypes,
- ClassMethodSels, ClassMethodTypes, Protocols);
+void
+CodeGenModule::EmitObjCClassImplementation(const ObjCImplementationDecl *OID) {
+ Runtime->GenerateClass(OID);
}
void CodeGenModule::EmitStatics() {
OpenPOWER on IntegriCloud