[cfe-commits] r69857 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp lib/Frontend/PCHReader.cpp lib/Frontend/PCHWriter.cpp lib/Sema/SemaDecl.cpp tools/clang-cc/RewriteObjC.cpp
Douglas Gregor
dgregor at apple.com
Wed Apr 22 20:23:10 PDT 2009
Author: dgregor
Date: Wed Apr 22 22:23:08 2009
New Revision: 69857
URL: http://llvm.org/viewvc/llvm-project?rev=69857&view=rev
Log:
The ivars in an ObjCImplementationDecl are now stored in the
DeclContext rather than in a separate list. This makes PCH
(de-)serialization trivial, so that ivars can be loaded lazily.
Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/lib/Frontend/PCHReader.cpp
cfe/trunk/lib/Frontend/PCHWriter.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/tools/clang-cc/RewriteObjC.cpp
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=69857&r1=69856&r2=69857&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Wed Apr 22 22:23:08 2009
@@ -946,9 +946,6 @@
/// Implementation Class's super class.
ObjCInterfaceDecl *SuperClass;
- /// Instance variables declared in the @implementation.
- ObjCList<ObjCIvarDecl> IVars;
-
ObjCImplementationDecl(DeclContext *DC, SourceLocation L,
ObjCInterfaceDecl *classInterface,
ObjCInterfaceDecl *superDecl)
@@ -960,13 +957,6 @@
ObjCInterfaceDecl *classInterface,
ObjCInterfaceDecl *superDecl);
- /// Destroy - Call destructors and release memory.
- virtual void Destroy(ASTContext& C);
-
- void setIVarList(ObjCIvarDecl *const *InArray, unsigned Num, ASTContext &C) {
- IVars.set(InArray, Num, C);
- }
-
/// getIdentifier - Get the identifier that names the class
/// interface associated with this implementation.
IdentifierInfo *getIdentifier() const {
@@ -991,11 +981,19 @@
void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; }
- typedef ObjCList<ObjCIvarDecl>::iterator ivar_iterator;
- ivar_iterator ivar_begin() const { return IVars.begin(); }
- ivar_iterator ivar_end() const { return IVars.end(); }
- unsigned ivar_size() const { return IVars.size(); }
- bool ivar_empty() const { return IVars.empty(); }
+ typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator;
+ ivar_iterator ivar_begin(ASTContext &Context) const {
+ return ivar_iterator(decls_begin(Context));
+ }
+ ivar_iterator ivar_end(ASTContext &Context) const {
+ return ivar_iterator(decls_end(Context));
+ }
+ unsigned ivar_size(ASTContext &Context) const {
+ return std::distance(ivar_begin(Context), ivar_end(Context));
+ }
+ bool ivar_empty(ASTContext &Context) const {
+ return ivar_begin(Context) == ivar_end(Context);
+ }
static bool classof(const Decl *D) {
return D->getKind() == ObjCImplementation;
Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=69857&r1=69856&r2=69857&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Wed Apr 22 22:23:08 2009
@@ -637,12 +637,6 @@
return new (C) ObjCImplementationDecl(DC, L, ClassInterface, SuperDecl);
}
-/// Destroy - Call destructors and release memory.
-void ObjCImplementationDecl::Destroy(ASTContext &C) {
- IVars.Destroy(C);
- Decl::Destroy(C);
-}
-
//===----------------------------------------------------------------------===//
// ObjCCompatibleAliasDecl
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=69857&r1=69856&r2=69857&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Wed Apr 22 22:23:08 2009
@@ -334,7 +334,8 @@
void PCHDeclReader::VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
VisitObjCImplDecl(D);
- // FIXME: Implement.
+ D->setSuperClass(
+ cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])));
}
@@ -2270,7 +2271,7 @@
}
case pch::DECL_OBJC_IMPLEMENTATION: {
- // FIXME: Implement.
+ D = ObjCImplementationDecl::Create(Context, 0, SourceLocation(), 0, 0);
break;
}
Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=69857&r1=69856&r2=69857&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Wed Apr 22 22:23:08 2009
@@ -506,7 +506,7 @@
void PCHDeclWriter::VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
VisitObjCImplDecl(D);
- // FIXME: Implement.
+ Writer.AddDeclRef(D->getSuperClass(), Record);
Code = pch::DECL_OBJC_IMPLEMENTATION;
}
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=69857&r1=69856&r2=69857&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Apr 22 22:23:08 2009
@@ -3952,7 +3952,12 @@
} else if (ObjCImplementationDecl *IMPDecl =
dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
assert(IMPDecl && "ActOnFields - missing ObjCImplementationDecl");
- IMPDecl->setIVarList(ClsFields, RecFields.size(), Context);
+ for (unsigned I = 0, N = RecFields.size(); I != N; ++I) {
+ // FIXME: Set the DeclContext correctly when we build the
+ // declarations.
+ ClsFields[I]->setLexicalDeclContext(IMPDecl);
+ IMPDecl->addDecl(Context, ClsFields[I]);
+ }
CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac);
}
}
Modified: cfe/trunk/tools/clang-cc/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/RewriteObjC.cpp?rev=69857&r1=69856&r2=69857&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/RewriteObjC.cpp (original)
+++ cfe/trunk/tools/clang-cc/RewriteObjC.cpp Wed Apr 22 22:23:08 2009
@@ -3185,8 +3185,8 @@
}
// Build _objc_ivar_list metadata for classes ivars if needed
- unsigned NumIvars = !IDecl->ivar_empty()
- ? IDecl->ivar_size()
+ unsigned NumIvars = !IDecl->ivar_empty(*Context)
+ ? IDecl->ivar_size(*Context)
: (CDecl ? CDecl->ivar_size() : 0);
if (NumIvars > 0) {
static bool objc_ivar = false;
@@ -3223,9 +3223,15 @@
Result += "\n";
ObjCInterfaceDecl::ivar_iterator IVI, IVE;
- if (!IDecl->ivar_empty()) {
- IVI = IDecl->ivar_begin();
- IVE = IDecl->ivar_end();
+ llvm::SmallVector<ObjCIvarDecl *, 8> IVars;
+ if (!IDecl->ivar_empty(*Context)) {
+ for (ObjCImplementationDecl::ivar_iterator
+ IV = IDecl->ivar_begin(*Context),
+ IVEnd = IDecl->ivar_end(*Context);
+ IV != IVEnd; ++IV)
+ IVars.push_back(*IV);
+ IVI = IVars.begin();
+ IVE = IVars.end();
} else {
IVI = CDecl->ivar_begin();
IVE = CDecl->ivar_end();
More information about the cfe-commits
mailing list