Home | History | Annotate | Download | only in Sema

Lines Matching refs:property

1 //===--- SemaObjCProperty.cpp - Semantic Analysis for ObjC @property ------===//
10 // This file implements semantic analysis for Objective C @property and
27 /// Check the internal consistency of a property declaration.
28 static void checkARCPropertyDecl(Sema &S, ObjCPropertyDecl *property) {
29 if (property->isInvalidDecl()) return;
32 = property->getPropertyAttributes();
34 = property->getType().getObjCLifetime();
53 property->getType()->isObjCRetainableType()) {
57 // We have a lifetime qualifier but no dominating property
64 property->setInvalidDecl();
65 S.Diag(property->getLocation(),
67 << property->getDeclName()
93 // property is defaulted to 'assign' if it is readwrite and is
130 // Validate the attributes on the @property.
150 // Diagnose if this property is already in continuation class.
156 // Check for duplicate declaration of this property in current and
185 // We need to look in the @interface to see if the @property was
193 // Find the property in continuation class's primary class only.
198 // No matching property found in the primary class. Just fall thru
199 // and add property to continuation class's primary class.
205 // A case of continuation class adding a new property in the class. This
213 // The property 'PIDecl's readonly attribute will be over-ridden
214 // with continuation class's readwrite property attribute!
258 // property is declared both in the @interface and the continuation.
291 // Issue a warning if property is 'assign' as default and its object, which is
415 ObjCPropertyDecl *property,
417 if (property->isInvalidDecl() || ivar->isInvalidDecl()) return;
419 QualType propertyType = property->getType();
422 = property->getPropertyAttributes();
445 << property->getDeclName()
467 << property->getDeclName()
488 << property->getDeclName()
493 // Any other property should be ignored.
498 S.Diag(property->getLocation(), diag::note_property_declare);
503 /// builds the AST node for a property implementation declaration; declared
516 // Make sure we have a context for the property implementation declaration.
521 ObjCPropertyDecl *property = 0;
523 // Find the class or category class where this property must have
534 // Look for this property declaration in the @implementation's @interface
535 property = IDecl->FindPropertyDeclaration(PropertyId);
536 if (!property) {
540 unsigned PIkind = property->getPropertyAttributesAsWritten();
547 Diag(property->getLocation(), diag::note_property_declare);
551 dyn_cast<ObjCCategoryDecl>(property->getDeclContext())) {
554 Diag(property->getLocation(), diag::note_property_declare);
575 // Look for this property declaration in @implementation's category
576 property = Category->FindPropertyDeclaration(PropertyId);
577 if (!property) {
590 !property->hasWrittenStorageAttribute() &&
591 property->getType()->isObjCRetainableType()) {
593 Diag(property->getLocation(), diag::note_property_declare);
600 = property->getPropertyAttributes();
601 QualType PropType = Context.getCanonicalType(property->getType());
610 // property attributes.
625 Diag(property->getLocation(), diag::note_property_declare);
633 // assume that an 'assign' property synthesizes __unsafe_unretained
645 Diag(property->getLocation(), diag::note_property_declare);
655 property->setPropertyIvarDecl(Ivar);
660 // a property implementation and to avoid future warnings.
664 << property->getDeclName() << Ivar->getDeclName()
672 // Check that type of property and its ivar are type compatible.
690 << property->getDeclName() << PropType
694 // a property implementation and to avoid future warnings.
699 // specifically for property redeclarations as well as for ivars.
705 << property->getDeclName() << PropType
714 << property->getDeclName() << Ivar->getDeclName();
718 if ((property->getType()->isObjCObjectPointerType() ||
722 << property->getDeclName() << Ivar->getDeclName();
727 checkARCPropertyImpl(*this, PropertyLoc, property, Ivar);
732 assert (property && "ActOnPropertyImplDecl - property declaration missing");
735 property,
740 if (ObjCMethodDecl *getterMethod = property->getGetterMethodDecl()) {
768 if (property->hasAttr<NSReturnsNotRetainedAttr>() &&
772 Diag(property->getLocation(), diag::note_property_declare);
775 if (ObjCMethodDecl *setterMethod = property
820 // use and if 1) property is @dynamic or 2) property is synthesized
868 Sema::DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
872 Property->getPropertyAttributes();
877 Diag(Property->getLocation(), diag::warn_readonly_property)
878 << Property->getDeclName() << inheritedName;
881 Diag(Property->getLocation(), diag::warn_property_attribute)
882 << Property->getDeclName() << "copy" << inheritedName;
893 Diag(Property->getLocation(), diag::warn_property_attribute)
894 << Property->getDeclName() << "retain (or strong)" << inheritedName;
899 Diag(Property->getLocation(), diag::warn_property_attribute)
900 << Property->getDeclName() << "atomic" << inheritedName;
901 if (Property->getSetterName() != SuperProperty->getSetterName())
902 Diag(Property->getLocation(), diag::warn_property_attribute)
903 << Property->getDeclName() << "setter" << inheritedName;
904 if (Property->getGetterName() != SuperProperty->getGetterName())
905 Diag(Property->getLocation(), diag::warn_property_attribute)
906 << Property->getDeclName() << "getter" << inheritedName;
911 Context.getCanonicalType(Property->getType());
915 // FIXME. For future support of covariant property types, revisit this.
921 Diag(Property->getLocation(), diag::warn_property_types_are_incompatible)
922 << Property->getType() << SuperProperty->getType() << inheritedName;
926 bool Sema::DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *property,
930 GetterMethod->getResultType() != property->getType()) {
932 if (property->getType()->isObjCObjectPointerType())
934 property->getType());
937 << property->getDeclName()
946 /// ComparePropertiesInBaseAndSuper - This routine compares property
958 // Does property in super class has declaration in current class?
971 /// the same property declared in the class or category.
985 // Is this property already in category's list of properties?
990 // Property protocol already exist in class. Diagnose any mismatch.
999 // Is this property already in class's list of properties?
1004 // Property protocol already exist in class. Diagnose any mismatch.
1062 /// isPropertyReadonly - Return true if property is readonly, by searching
1063 /// for the property in the class and in its categories and implementations
1070 // Even if property is ready only, if interface has a user defined setter,
1075 // Main class has the property as 'readonly'. Must search
1076 // through the category list to see if the property's
1080 // Even if property is ready only, if a category has a user defined setter,
1147 // Exclude property for protocols which conform to class's super-class,
1148 property.
1204 /// LookupPropertyDecl - Looks up a property in the current class and all
1259 // If property to be implemented in the super class, ignore.
1267 // Property may have been synthesized by user.
1346 ObjCPropertyDecl *Property = (*I);
1351 unsigned Attributes = Property->getPropertyAttributes();
1352 unsigned AttributesAsWrittern = Property->getPropertyAttributesAsWritten();
1356 GetterMethod = IMPDecl->getInstanceMethod(Property->getGetterName());
1357 SetterMethod = IMPDecl->getInstanceMethod(Property->getSetterName());
1362 << Property->getIdentifier() << 0;
1363 Diag(Property->getLocation(), diag::note_property_declare);
1368 << Property->getIdentifier() << 1;
1369 Diag(Property->getLocation(), diag::note_property_declare);
1373 // We only care about readwrite atomic property.
1378 = IMPDecl->FindPropertyImplDecl(Property->getIdentifier())) {
1382 GetterMethod = IMPDecl->getInstanceMethod(Property->getGetterName());
1383 SetterMethod = IMPDecl->getInstanceMethod(Property->getSetterName());
1391 << Property->getIdentifier();
1392 Diag(Property->getLocation(), diag::note_property_declare);
1427 /// AddPropertyAttrs - Propagates attributes from a property to the
1428 /// implicitly-declared getter or setter for that property.
1430 ObjCPropertyDecl *Property) {
1432 for (Decl::attr_iterator A = Property->attr_begin(),
1433 AEnd = Property->attr_end();
1443 /// have the property type and issue diagnostics if they don't.
1447 void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
1454 GetterMethod = CD->getInstanceMethod(property->getGetterName());
1455 SetterMethod = CD->getInstanceMethod(property->getSetterName());
1456 DiagnosePropertyAccessorMismatch(property, GetterMethod,
1457 property->getLocation());
1461 property->getPropertyAttributes();
1467 ((*SetterMethod->param_begin())->getType() != property->getType())) {
1468 Diag(property->getLocation(),
1470 << property->getDeclName()
1478 // FIXME: The synthesized property we set here is misleading. We almost always
1483 // No instance method of same name as property getter name was found.
1488 property->getLocation();
1491 property->getGetterName(),
1492 property->getType(), 0, CD, true, false, true,
1494 (property->getPropertyImplementation() ==
1500 AddPropertyAttrs(*this, GetterMethod, property);
1506 if (property->hasAttr<NSReturnsNotRetainedAttr>())
1511 // the property with the same name is seen in the @implementation
1513 property->setGetterMethodDecl(GetterMethod);
1515 // Skip setter if property is read-only.
1516 if (!property->isReadOnly()) {
1519 // No instance method of same name as property setter name was found.
1524 property->getLocation();
1528 property->getSetterName(), Context.VoidTy, 0,
1530 (property->getPropertyImplementation() ==
1539 property->getIdentifier(),
1540 property->getType().getUnqualifiedType(),
1547 AddPropertyAttrs(*this, SetterMethod, property);
1556 // the property with the same name is seen in the @implementation
1558 property->setSetterMethodDecl(SetterMethod);
1564 // @property double bar;
1698 // Warn if user supplied no assignment attribute, property is