aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/DeclObjC.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/AST/DeclObjC.cpp')
-rw-r--r--lib/AST/DeclObjC.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index b9226318e3..e3e4548f64 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -338,6 +338,17 @@ ObjCIvarDecl *
return 0;
}
+void ObjCInterfaceDecl::CollectObjCIvars(std::vector<FieldDecl*> &Fields) {
+ ObjCInterfaceDecl *SuperClass = getSuperClass();
+ if (SuperClass)
+ SuperClass->CollectObjCIvars(Fields);
+ for (ObjCInterfaceDecl::ivar_iterator I = ivar_begin(),
+ E = ivar_end(); I != E; ++I) {
+ ObjCIvarDecl *IVDecl = (*I);
+ Fields.push_back(cast<FieldDecl>(IVDecl));
+ }
+}
+
/// ObjCAddInstanceVariablesToClass - Inserts instance variables
/// into ObjCInterfaceDecl's fields.
///
@@ -352,6 +363,28 @@ void ObjCInterfaceDecl::addInstanceVariablesToClass(ObjCIvarDecl **ivars,
setLocEnd(RBrac);
}
+/// addInstanceVariablesToClass - produces layout info. for the class for its
+/// ivars and all those inherited.
+///
+void ObjCInterfaceDecl::addLayoutToClass(ASTContext &Context)
+{
+ std::vector<FieldDecl*> RecFields;
+ CollectObjCIvars(RecFields);
+ RecordDecl *RD = RecordDecl::Create(Context, TagDecl::TK_struct, 0,
+ getLocation(),
+ getIdentifier());
+ /// FIXME! Can do collection of ivars and adding to the record while
+ /// doing it.
+ for (unsigned int i = 0; i != RecFields.size(); i++) {
+ FieldDecl *Field = FieldDecl::Create(Context, RD, SourceLocation(),
+ RecFields[i]->getIdentifier(),
+ RecFields[i]->getType(), 0, false, 0);
+ RD->addDecl(Context, Field);
+ }
+ RD->completeDefinition(Context);
+ setRecordForDecl(RD);
+}
+
/// ObjCAddInstanceVariablesToClassImpl - Checks for correctness of Instance
/// Variables (Ivars) relative to what declared in @implementation;s class.
/// Ivars into ObjCImplementationDecl's fields.