Patch to store ivars into interface class object.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41961 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/Decl.cpp b/AST/Decl.cpp
index 4b668c2..965ba21 100644
--- a/AST/Decl.cpp
+++ b/AST/Decl.cpp
@@ -186,6 +186,18 @@
delete[] ParamInfo;
}
+/// ObjcAddInstanceVariablesToClass - Inserts instance variables
+/// into ObjcInterfaceDecl's fields.
+///
+void ObjcInterfaceDecl::ObjcAddInstanceVariablesToClass(ObjcIvarDecl **ivars,
+ unsigned numIvars) {
+ NumIvars = numIvars;
+ if (numIvars) {
+ Ivars = new ObjcIvarDecl*[numIvars];
+ memcpy(Ivars, ivars, numIvars*sizeof(ObjcIvarDecl*));
+ }
+}
+
/// addObjcMethods - Insert instance and methods declarations into
/// ObjcInterfaceDecl's InsMethods and ClsMethods fields.
///
diff --git a/Parse/ParseObjc.cpp b/Parse/ParseObjc.cpp
index 22b3985..29f8001 100644
--- a/Parse/ParseObjc.cpp
+++ b/Parse/ParseObjc.cpp
@@ -659,7 +659,7 @@
}
}
if (AllIvarDecls.size()) { // Check for {} - no ivars in braces
- Actions.ObjcAddInstanceVariable(interfaceDecl,
+ Actions.ObjcAddVisibilityToIvars(interfaceDecl,
&AllIvarDecls[0], AllIvarDecls.size(), &AllVisibilities[0]);
Actions.ParseRecordBody(LBraceLoc, interfaceDecl,
&AllIvarDecls[0], AllIvarDecls.size());
diff --git a/Sema/Sema.h b/Sema/Sema.h
index 1e74321..2b50f5e 100644
--- a/Sema/Sema.h
+++ b/Sema/Sema.h
@@ -369,9 +369,9 @@
tok::TokenKind MethodType, TypeTy *ReturnType,
IdentifierInfo *SelectorName, AttributeList *AttrList);
- virtual void ObjcAddInstanceVariable(DeclTy *ClassDec, DeclTy **Ivar,
- unsigned numIvars,
- tok::ObjCKeywordKind *visibility);
+ virtual void ObjcAddVisibilityToIvars(DeclTy *ClassDec, DeclTy **Ivar,
+ unsigned numIvars,
+ tok::ObjCKeywordKind *visibility);
private:
// UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
// functions and arrays to their respective pointers (C99 6.3.2.1).
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index 05ec204..6e2f431 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -877,9 +877,9 @@
return IDecl;
}
-void Sema::ObjcAddInstanceVariable(DeclTy *ClassDecl, DeclTy **Ivar,
- unsigned numIvars,
- tok::ObjCKeywordKind *visibility) {
+void Sema::ObjcAddVisibilityToIvars(DeclTy *ClassDecl, DeclTy **Ivar,
+ unsigned numIvars,
+ tok::ObjCKeywordKind *visibility) {
assert((ClassDecl && numIvars) && "missing class or instance variable");
ObjcInterfaceDecl *OInterface = dyn_cast<ObjcInterfaceDecl>(
static_cast<Decl *>(ClassDecl));
@@ -1217,6 +1217,12 @@
// Okay, we successfully defined 'Record'.
if (Record)
Record->defineBody(&RecFields[0], RecFields.size());
+ else {
+ ObjcIvarDecl **ClsFields =
+ reinterpret_cast<ObjcIvarDecl**>(&RecFields[0]);
+ cast<ObjcInterfaceDecl>(static_cast<Decl*>(RecDecl))->
+ ObjcAddInstanceVariablesToClass(ClsFields, RecFields.size());
+ }
}
void Sema::ObjcAddMethodsToClass(DeclTy *ClassDecl,
diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj
index 06a6d79..a7d7e5f 100644
--- a/clang.xcodeproj/project.pbxproj
+++ b/clang.xcodeproj/project.pbxproj
@@ -675,6 +675,7 @@
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
+ compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
projectDirPath = "";
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index 2431597..46ffb6c 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -23,6 +23,7 @@
class Expr;
class Stmt;
class FunctionDecl;
+class ObjcIvarDecl;
class ObjcMethodDecl;
class AttributeList;
@@ -536,7 +537,7 @@
class ObjcInterfaceDecl : public TypeDecl {
/// Ivars/NumIvars - This is a new[]'d array of pointers to Decls.
- FieldDecl **Ivars; // Null if not defined.
+ ObjcIvarDecl **Ivars; // Null if not defined.
int NumIvars; // -1 if not defined.
/// instance methods
@@ -554,7 +555,8 @@
InsMethods(0), NumInsMethods(-1), ClsMethods(0), NumClsMethods(-1),
isForwardDecl(FD) { }
- void addInstanceVariable(FieldDecl ivar);
+ void ObjcAddInstanceVariablesToClass(ObjcIvarDecl **ivars,
+ unsigned numIvars);
void ObjcAddMethods(ObjcMethodDecl **insMethods, unsigned numInsMembers,
ObjcMethodDecl **clsMethods, unsigned numClsMembers);
diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h
index ffb147f..770187a 100644
--- a/include/clang/Parse/Action.h
+++ b/include/clang/Parse/Action.h
@@ -449,9 +449,9 @@
AttributeList *AttrList) {
return 0;
}
- virtual void ObjcAddInstanceVariable(DeclTy *ClassDec, DeclTy **Ivars,
- unsigned numIvars,
- tok::ObjCKeywordKind *visibility) {
+ virtual void ObjcAddVisibilityToIvars(DeclTy *ClassDec, DeclTy **Ivars,
+ unsigned numIvars,
+ tok::ObjCKeywordKind *visibility) {
return;
}
virtual void ObjcAddMethodsToClass(DeclTy *ClassDecl,