From 2f92230035e1dc53a560247aee2bec167a90ba7e Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Mon, 9 Aug 2010 10:54:37 +0000 Subject: [PATCH] Complete PCH support for ObjCPropertyImplDecl. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110570 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Frontend/PCHReaderDecl.cpp | 3 ++- lib/Frontend/PCHWriterDecl.cpp | 9 ++++++--- test/PCH/objcxx-ivar-class.h | 6 +++++- test/PCH/objcxx-ivar-class.mm | 6 ++++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp index 6c0bdf6068..7aab7b7557 100644 --- a/lib/Frontend/PCHReaderDecl.cpp +++ b/lib/Frontend/PCHReaderDecl.cpp @@ -526,7 +526,8 @@ void PCHDeclReader::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { cast_or_null(Reader.GetDecl(Record[Idx++]))); D->setPropertyIvarDecl( cast_or_null(Reader.GetDecl(Record[Idx++]))); - // FIXME. read GetterCXXConstructor and SetterCXXAssignment + D->setGetterCXXConstructor(Reader.ReadExpr(Cursor)); + D->setSetterCXXAssignment(Reader.ReadExpr(Cursor)); } void PCHDeclReader::VisitFieldDecl(FieldDecl *FD) { diff --git a/lib/Frontend/PCHWriterDecl.cpp b/lib/Frontend/PCHWriterDecl.cpp index 6a78140b3a..a509ed1dce 100644 --- a/lib/Frontend/PCHWriterDecl.cpp +++ b/lib/Frontend/PCHWriterDecl.cpp @@ -305,8 +305,10 @@ void PCHDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) { VisitNamedDecl(D); // FIXME: convert to LazyStmtPtr? // Unlike C/C++, method bodies will never be in header files. - Record.push_back(D->getBody() != 0); - if (D->getBody() != 0) { + bool HasBodyStuff = D->getBody() != 0 || + D->getSelfDecl() != 0 || D->getCmdDecl() != 0; + Record.push_back(HasBodyStuff); + if (HasBodyStuff) { Writer.AddStmt(D->getBody()); Writer.AddDeclRef(D->getSelfDecl(), Record); Writer.AddDeclRef(D->getCmdDecl(), Record); @@ -478,7 +480,8 @@ void PCHDeclWriter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { Writer.AddSourceLocation(D->getLocStart(), Record); Writer.AddDeclRef(D->getPropertyDecl(), Record); Writer.AddDeclRef(D->getPropertyIvarDecl(), Record); - // FIXME. write GetterCXXConstructor and SetterCXXAssignment. + Writer.AddStmt(D->getGetterCXXConstructor()); + Writer.AddStmt(D->getSetterCXXAssignment()); Code = pch::DECL_OBJC_PROPERTY_IMPL; } diff --git a/test/PCH/objcxx-ivar-class.h b/test/PCH/objcxx-ivar-class.h index aa114e5577..50ebda709d 100644 --- a/test/PCH/objcxx-ivar-class.h +++ b/test/PCH/objcxx-ivar-class.h @@ -1,11 +1,15 @@ struct S { S(); + S(const S&); + S& operator= (const S&); }; @interface C { - S s; + S position; } +@property(assign, nonatomic) S position; @end @implementation C + @synthesize position; @end diff --git a/test/PCH/objcxx-ivar-class.mm b/test/PCH/objcxx-ivar-class.mm index 48d359c11b..89d3e087f9 100644 --- a/test/PCH/objcxx-ivar-class.mm +++ b/test/PCH/objcxx-ivar-class.mm @@ -5,5 +5,11 @@ // RUN: %clang_cc1 -x objective-c++-header -emit-pch -o %t %S/objcxx-ivar-class.h // RUN: %clang_cc1 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s +// CHECK: [C position] +// CHECK: call void @_ZN1SC1ERKS_ + +// CHECK: [C setPosition:] +// CHECK: call %struct.S* @_ZN1SaSERKS_ + // CHECK: [C .cxx_destruct] // CHECK: [C .cxx_construct] -- 2.40.0