[llvm-branch-commits] [cfe-tag] r100500 - in /cfe/tags/Apple/clang/clang/tools/clang: lib/Sema/Sema.h lib/Sema/SemaObjCProperty.cpp test/SemaObjC/nsobject-attribute.m
Ted Kremenek
kremenek at apple.com
Mon Apr 5 16:56:57 PDT 2010
Author: kremenek
Date: Mon Apr 5 18:56:56 2010
New Revision: 100500
URL: http://llvm.org/viewvc/llvm-project?rev=100500&view=rev
Log:
Merge in r99951, r100496, r100496. (<rdar://problem/7809468>)
Modified:
cfe/tags/Apple/clang/clang/tools/clang/lib/Sema/Sema.h
cfe/tags/Apple/clang/clang/tools/clang/lib/Sema/SemaObjCProperty.cpp
cfe/tags/Apple/clang/clang/tools/clang/test/SemaObjC/nsobject-attribute.m
Modified: cfe/tags/Apple/clang/clang/tools/clang/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/tags/Apple/clang/clang/tools/clang/lib/Sema/Sema.h?rev=100500&r1=100499&r2=100500&view=diff
==============================================================================
--- cfe/tags/Apple/clang/clang/tools/clang/lib/Sema/Sema.h (original)
+++ cfe/tags/Apple/clang/clang/tools/clang/lib/Sema/Sema.h Mon Apr 5 18:56:56 2010
@@ -3729,7 +3729,7 @@
/// Ensure attributes are consistent with type.
/// \param [in, out] Attributes The attributes to check; they will
/// be modified to be consistent with \arg PropertyTy.
- void CheckObjCPropertyAttributes(QualType PropertyTy,
+ void CheckObjCPropertyAttributes(DeclPtrTy PropertyPtrTy,
SourceLocation Loc,
unsigned &Attributes);
void ProcessPropertyDecl(ObjCPropertyDecl *property, ObjCContainerDecl *DC);
Modified: cfe/tags/Apple/clang/clang/tools/clang/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/tags/Apple/clang/clang/tools/clang/lib/Sema/SemaObjCProperty.cpp?rev=100500&r1=100499&r2=100500&view=diff
==============================================================================
--- cfe/tags/Apple/clang/clang/tools/clang/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/tags/Apple/clang/clang/tools/clang/lib/Sema/SemaObjCProperty.cpp Mon Apr 5 18:56:56 2010
@@ -44,9 +44,6 @@
Diag(AtLoc, diag::error_reference_property);
return DeclPtrTy();
}
- // Validate the attributes on the @property.
- CheckObjCPropertyAttributes(T, AtLoc, Attributes);
-
// Proceed with constructing the ObjCPropertDecls.
ObjCContainerDecl *ClassDecl =
cast<ObjCContainerDecl>(ClassCategory.getAs<Decl>());
@@ -60,10 +57,13 @@
isOverridingProperty, T,
MethodImplKind);
- return DeclPtrTy::make(CreatePropertyDecl(S, ClassDecl, AtLoc, FD,
+ DeclPtrTy Res = DeclPtrTy::make(CreatePropertyDecl(S, ClassDecl, AtLoc, FD,
GetterSel, SetterSel,
isAssign, isReadWrite,
Attributes, T, MethodImplKind));
+ // Validate the attributes on the @property.
+ CheckObjCPropertyAttributes(Res, AtLoc, Attributes);
+ return Res;
}
Sema::DeclPtrTy
@@ -160,7 +160,7 @@
PIDecl->getSetterName(),
DeclPtrTy::make(CCPrimary), isOverridingProperty,
MethodImplKind);
- PIDecl = ProtocolPtrTy.getAs<ObjCPropertyDecl>();
+ PIDecl = cast<ObjCPropertyDecl>(ProtocolPtrTy.getAs<Decl>());
}
PIDecl->makeitReadWriteAttribute();
if (Attributes & ObjCDeclSpec::DQ_PR_retain)
@@ -281,7 +281,8 @@
DeclPtrTy ClassCatImpDecl,
IdentifierInfo *PropertyId,
IdentifierInfo *PropertyIvar) {
- Decl *ClassImpDecl = ClassCatImpDecl.getAs<Decl>();
+ ObjCContainerDecl *ClassImpDecl =
+ cast_or_null<ObjCContainerDecl>(ClassCatImpDecl.getAs<Decl>());
// Make sure we have a context for the property implementation declaration.
if (!ClassImpDecl) {
Diag(AtLoc, diag::error_missing_property_context);
@@ -982,10 +983,16 @@
AddInstanceMethodToGlobalPool(SetterMethod);
}
-void Sema::CheckObjCPropertyAttributes(QualType PropertyTy,
+void Sema::CheckObjCPropertyAttributes(DeclPtrTy PropertyPtrTy,
SourceLocation Loc,
unsigned &Attributes) {
// FIXME: Improve the reported location.
+ Decl *PDecl = PropertyPtrTy.getAs<Decl>();
+ if (!PDecl)
+ return;
+
+ ObjCPropertyDecl *PropertyDecl = cast<ObjCPropertyDecl>(PDecl);
+ QualType PropertyTy = PropertyDecl->getType();
// readonly and readwrite/assign/retain/copy conflict.
if ((Attributes & ObjCDeclSpec::DQ_PR_readonly) &&
@@ -1010,7 +1017,8 @@
if ((Attributes & (ObjCDeclSpec::DQ_PR_copy | ObjCDeclSpec::DQ_PR_retain)) &&
!PropertyTy->isObjCObjectPointerType() &&
!PropertyTy->isBlockPointerType() &&
- !Context.isObjCNSObjectType(PropertyTy)) {
+ !Context.isObjCNSObjectType(PropertyTy) &&
+ !PropertyDecl->getAttr<ObjCNSObjectAttr>()) {
Diag(Loc, diag::err_objc_property_requires_object)
<< (Attributes & ObjCDeclSpec::DQ_PR_copy ? "copy" : "retain");
Attributes &= ~(ObjCDeclSpec::DQ_PR_copy | ObjCDeclSpec::DQ_PR_retain);
Modified: cfe/tags/Apple/clang/clang/tools/clang/test/SemaObjC/nsobject-attribute.m
URL: http://llvm.org/viewvc/llvm-project/cfe/tags/Apple/clang/clang/tools/clang/test/SemaObjC/nsobject-attribute.m?rev=100500&r1=100499&r2=100500&view=diff
==============================================================================
--- cfe/tags/Apple/clang/clang/tools/clang/test/SemaObjC/nsobject-attribute.m (original)
+++ cfe/tags/Apple/clang/clang/tools/clang/test/SemaObjC/nsobject-attribute.m Mon Apr 5 18:56:56 2010
@@ -7,11 +7,16 @@
typedef struct S1 __attribute__ ((NSObject)) CGColorRef1; // expected-error {{__attribute ((NSObject)) is for pointer types only}}
typedef void * __attribute__ ((NSObject)) CGColorRef2; // expected-error {{__attribute ((NSObject)) is for pointer types only}}
+
@interface HandTested {
@public
CGColorRef x;
}
+
@property(copy) CGColorRef x;
+// rdar: // 7809460
+typedef struct CGColor *CGColorRefNoNSObject;
+ at property (nonatomic, retain) __attribute__((NSObject)) CGColorRefNoNSObject color;
@end
void setProperty(id self, id value) {
@@ -24,6 +29,7 @@
@implementation HandTested
@synthesize x=x;
+ at dynamic color;
@end
int main(int argc, char *argv[]) {
More information about the llvm-branch-commits
mailing list