[cfe-commits] r69843 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/Frontend/PCHReader.cpp lib/Frontend/PCHWriter.cpp test/PCH/objc_property.h test/PCH/objc_property.m
Douglas Gregor
dgregor at apple.com
Wed Apr 22 16:20:34 PDT 2009
Author: dgregor
Date: Wed Apr 22 18:20:34 2009
New Revision: 69843
URL: http://llvm.org/viewvc/llvm-project?rev=69843&view=rev
Log:
PCH support for Objective-C property declarations (UNTESTED!)
Added:
cfe/trunk/test/PCH/objc_property.h
cfe/trunk/test/PCH/objc_property.m
Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/Frontend/PCHReader.cpp
cfe/trunk/lib/Frontend/PCHWriter.cpp
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=69843&r1=69842&r2=69843&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Wed Apr 22 18:20:34 2009
@@ -1071,7 +1071,8 @@
IdentifierInfo *Id, QualType T,
PropertyControl propControl = None);
QualType getType() const { return DeclType; }
-
+ void setType(QualType T) { DeclType = T; }
+
PropertyAttributeKind getPropertyAttributes() const {
return PropertyAttributeKind(PropertyAttributes);
}
Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=69843&r1=69842&r2=69843&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Wed Apr 22 18:20:34 2009
@@ -303,7 +303,21 @@
void PCHDeclReader::VisitObjCPropertyDecl(ObjCPropertyDecl *D) {
VisitNamedDecl(D);
- // FIXME: Implement.
+ D->setType(Reader.GetType(Record[Idx++]));
+ // FIXME: stable encoding
+ D->setPropertyAttributes(
+ (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]);
+ // FIXME: stable encoding
+ D->setPropertyImplementation(
+ (ObjCPropertyDecl::PropertyControl)Record[Idx++]);
+ D->setGetterName(Reader.ReadDeclarationName(Record, Idx).getObjCSelector());
+ D->setSetterName(Reader.ReadDeclarationName(Record, Idx).getObjCSelector());
+ D->setGetterMethodDecl(
+ cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])));
+ D->setSetterMethodDecl(
+ cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])));
+ D->setPropertyIvarDecl(
+ cast_or_null<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++])));
}
void PCHDeclReader::VisitObjCImplDecl(ObjCImplDecl *D) {
@@ -2264,7 +2278,7 @@
}
case pch::DECL_OBJC_PROPERTY: {
- // FIXME: Implement.
+ D = ObjCPropertyDecl::Create(Context, 0, SourceLocation(), 0, QualType());
break;
}
Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=69843&r1=69842&r2=69843&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Wed Apr 22 18:20:34 2009
@@ -478,7 +478,16 @@
void PCHDeclWriter::VisitObjCPropertyDecl(ObjCPropertyDecl *D) {
VisitNamedDecl(D);
- // FIXME: Implement.
+ Writer.AddTypeRef(D->getType(), Record);
+ // FIXME: stable encoding
+ Record.push_back((unsigned)D->getPropertyAttributes());
+ // FIXME: stable encoding
+ Record.push_back((unsigned)D->getPropertyImplementation());
+ Writer.AddDeclarationName(D->getGetterName(), Record);
+ Writer.AddDeclarationName(D->getSetterName(), Record);
+ Writer.AddDeclRef(D->getGetterMethodDecl(), Record);
+ Writer.AddDeclRef(D->getSetterMethodDecl(), Record);
+ Writer.AddDeclRef(D->getPropertyIvarDecl(), Record);
Code = pch::DECL_OBJC_PROPERTY;
}
@@ -1715,7 +1724,13 @@
W.Code = (pch::DeclCode)0;
W.Visit(D);
if (DC) W.VisitDeclContext(DC, LexicalOffset, VisibleOffset);
- assert(W.Code && "Unhandled declaration kind while generating PCH");
+
+ if (!W.Code) {
+ fprintf(stderr, "Cannot serialize declaration of kind %s\n",
+ D->getDeclKindName());
+ assert(false && "Unhandled declaration kind while generating PCH");
+ exit(-1);
+ }
Stream.EmitRecord(W.Code, Record);
// If the declaration had any attributes, write them now.
Added: cfe/trunk/test/PCH/objc_property.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/objc_property.h?rev=69843&view=auto
==============================================================================
--- cfe/trunk/test/PCH/objc_property.h (added)
+++ cfe/trunk/test/PCH/objc_property.h Wed Apr 22 18:20:34 2009
@@ -0,0 +1,12 @@
+/* For use with the objc_property.m PCH test */
+ at interface TestProperties
+{
+ int value;
+ float percentage;
+}
+
++ alloc;
+
+ at property int value;
+ at property float percentage;
+ at end
Added: cfe/trunk/test/PCH/objc_property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/objc_property.m?rev=69843&view=auto
==============================================================================
--- cfe/trunk/test/PCH/objc_property.m (added)
+++ cfe/trunk/test/PCH/objc_property.m Wed Apr 22 18:20:34 2009
@@ -0,0 +1,11 @@
+// Test this without pch.
+// FIXME: clang-cc -include %S/objc_property.h -fsyntax-only -verify %s &&
+
+// Test with pch.
+// FIXME: clang-cc -x=objective-c -emit-pch -o %t %S/objc_property.h &&
+// FIXME: clang-cc -include-pch %t -fsyntax-only -verify %s
+
+void func() {
+ TestProperties *xx = [TestProperties alloc];
+ xx.value = 5;
+}
More information about the cfe-commits
mailing list