Lines Matching refs:property

1 //===--- SemaObjCProperty.cpp - Semantic Analysis for ObjC @property ------===//
10 // This file implements semantic analysis for Objective C @property and
33 /// getImpliedARCOwnership - Given a set of property attributes and a
55 // property type.
64 /// Check the internal consistency of a property declaration.
65 static void checkARCPropertyDecl(Sema &S, ObjCPropertyDecl *property) {
66 if (property->isInvalidDecl()) return;
69 = property->getPropertyAttributes();
71 = property->getType().getObjCLifetime();
77 = getImpliedARCOwnership(propertyKind, property->getType());
79 // We have a lifetime qualifier but no dominating property
81 // setting the property attribute according to the lifetime
92 property->setPropertyAttributes(attr);
98 property->setInvalidDecl();
99 S.Diag(property->getLocation(),
101 << property->getDeclName()
115 /// \brief Check this Objective-C property against a property declared in the
125 // Look for a property with the same name.
134 // Check this property against any protocols we inherit.
159 // property is defaulted to 'assign' if it is readwrite and is
195 // Validate the attributes on the @property.
205 // For a class, compare the property against a property in our superclass.
219 // Also compare the property against a property in our protocols.
338 // Diagnose if this property is already in continuation class.
344 // Check for duplicate declaration of this property in current and
381 // We need to look in the @interface to see if the @property was
389 // Find the property in continuation class's primary class only.
394 // No matching property found in the primary class. Just fall thru
395 // and add property to continuation class's primary class.
401 // A case of continuation class adding a new property in the class. This
415 // Relax the strict type matching for property type in continuation class.
416 // Allow property object type of continuation class to be different as long
417 // as it narrows the object type in its primary class property. Note that
419 // property in primary class and 'narrowed' type for a 'readwrite' property
433 // The property 'PIDecl's readonly attribute will be over-ridden
434 // with continuation class's readwrite property attribute!
479 // property is declared both in the @interface and the continuation.
519 // Issue a warning if property is 'assign' as default and its object, which is
617 ObjCPropertyDecl *property,
619 if (property->isInvalidDecl() || ivar->isInvalidDecl()) return;
624 // The lifetime implied by the property's attributes.
626 getImpliedARCOwnership(property->getPropertyAttributes(),
627 property->getType());
640 // property implementation before parsing any method bodies.
657 << property->getDeclName()
664 << property->getDeclName()
670 << property->getDeclName()
672 << ((property->getPropertyAttributesAsWritten()
680 // Any other property should be ignored.
684 S.Diag(property->getLocation(), diag::note_property_declare);
691 /// property with no known lifetime of its own, using backing
692 /// 'ivar's attribute, if any. If no backing 'ivar', property's
695 ObjCPropertyDecl *property, ObjCIvarDecl *ivar) {
697 getImpliedARCOwnership(property->getPropertyAttributes(),
698 property->getType());
703 // if no backing ivar, make property 'strong'.
704 property->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_strong);
707 // property assumes owenership of backing ivar.
711 property->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_strong);
713 property->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_weak);
717 /// DiagnoseClassAndClassExtPropertyMismatch - diagnose inconsistant property
722 ObjCPropertyDecl *property) {
723 unsigned Attributes = property->getPropertyAttributesAsWritten();
730 DeclContext::lookup_result R = Ext->lookup(property->getDeclName());
743 // placed on class's property declaration now make sense in the overridden
744 // property.
777 S.Diag(property->getLocation(),
787 /// builds the AST node for a property implementation declaration; declared
799 // Make sure we have a context for the property implementation declaration.
809 ObjCPropertyDecl *property = 0;
811 // Find the class or category class where this property must have
822 // Look for this property declaration in the @implementation's @interface
823 property = IDecl->FindPropertyDeclaration(PropertyId);
824 if (!property) {
828 unsigned PIkind = property->getPropertyAttributesAsWritten();
835 Diag(property->getLocation(), diag::note_property_declare);
839 dyn_cast<ObjCCategoryDecl>(property->getDeclContext())) {
842 Diag(property->getLocation(), diag::note_property_declare);
848 property->hasAttr<IBOutletAttr>() &&
851 // Search into the class extensions and see if 'readonly property is
856 DeclContext::lookup_result R = Ext->lookup(property->getDeclName());
868 Diag(property->getLocation(), diag::warn_auto_readonly_iboutlet_property)
869 << property->getName();
872 property->getLParenLoc(), readonlyLoc)) {
876 Diag(property->getLocation(),
883 DiagnoseClassAndClassExtPropertyMismatch(*this, IDecl, property);
902 // Look for this property declaration in @implementation's category
903 property = Category->FindPropertyDeclaration(PropertyId);
904 if (!property) {
924 QualType PropType = property->getType();
929 property->getDeclName())) {
930 Diag(property->getLocation(), diag::note_property_declare);
935 (property->getPropertyAttributesAsWritten() &
938 setImpliedPropertyAttributeForReadOnlyProperty(property, Ivar);
942 = property->getPropertyAttributes();
944 // Add GC __weak to the ivar type if the property is weak.
950 Diag(property->getLocation(), diag::note_property_declare);
957 // Check when default synthesizing a property that there is
958 // an ivar matching property name and issue warning; since this
960 // property in non-default synthesis case.
963 IDecl->lookupInstanceVariable(property->getIdentifier(),
970 Diag(property->getLocation(), diag::note_property_declare);
977 // property attributes.
983 // explicitly write an ownership attribute on the property.
984 if (!property->hasWrittenStorageAttribute() &&
988 Diag(property->getLocation(), diag::note_property_declare);
992 assert(lifetime && "no lifetime for property?");
999 Diag(property->getLocation(),
1008 Diag(property->getLocation(), diag::note_property_declare);
1022 Diag(property->getLocation(), diag::note_property_declare);
1039 // a property implementation and to avoid future warnings.
1043 << property->getDeclName() << Ivar->getDeclName()
1049 property->setPropertyIvarDecl(Ivar);
1053 // Check that type of property and its ivar are type compatible.
1068 << property->getDeclName() << PropType
1072 // a property implementation and to avoid future warnings.
1077 // specifically for property redeclarations as well as for ivars.
1083 << property->getDeclName() << PropType
1093 << property->getDeclName() << Ivar->getDeclName();
1098 if ((property->getType()->isObjCObjectPointerType() ||
1102 << property->getDeclName() << Ivar->getDeclName();
1107 checkARCPropertyImpl(*this, PropertyLoc, property, Ivar);
1112 assert (property && "ActOnPropertyImplDecl - property declaration missing");
1115 property,
1124 if (ObjCMethodDecl *getterMethod = property->getGetterMethodDecl()) {
1155 if (property->hasAttr<NSReturnsNotRetainedAttr>() &&
1159 Diag(property->getLocation(), diag::note_property_declare);
1162 if (ObjCMethodDecl *setterMethod = property->getSetterMethodDecl()) {
1185 if (property->getPropertyAttributes() &
1192 if (property->getType()->isReferenceType()) {
1195 << property->getType();
1225 // use and if 1) property is @dynamic or 2) property is synthesized
1326 // FIXME. For future support of covariant property types, revisit this.
1339 bool Sema::DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *property,
1345 QualType PropertyIvarType = property->getType().getNonReferenceType();
1357 << property->getDeclName() << PropertyIvarType
1372 << property->getDeclName()
1383 /// the same property declared in the class or category.
1391 // FIXME: We should perform this check when the property in the category
1414 // FIXME: We should perform this check when the property in the class
1434 /// isPropertyReadonly - Return true if property is readonly, by searching
1435 /// for the property in the class and in its categories and implementations
1442 // Even if property is ready only, if interface has a user defined setter,
1447 // Main class has the property as 'readonly'. Must search
1448 // through the category list to see if the property's
1519 // Exclude property for protocols which conform to class's super-class,
1520 // as super-class has to implement the property.
1550 /// an ivar synthesized for 'Method' and 'Method' is a property accessor
1562 // look up a property declaration whose one of its accessors is implemented
1566 ObjCPropertyDecl *property = *P;
1567 if ((property->getGetterName() == IMD->getSelector() ||
1568 property->getSetterName() == IMD->getSelector()) &&
1569 (property->getPropertyIvarDecl() == IV))
1591 // If property to be implemented in the super class, ignore.
1605 // Is there a matching property synthesize/dynamic?
1643 /* property = */ Prop->getIdentifier(),
1673 // its primary class (and its super classes) if property is
1695 // Collect property accessors implemented in current implementation.
1723 // When reporting on missing property getter implementation in
1743 // When reporting on missing property setter implementation in
1801 // We only care about readwrite atomic property.
1824 // @property () ... case.
1828 FixItHint::CreateReplacement(PropSourceRange, "@property (nonatomic");
1831 //@property id etc.
1837 FixItHint::CreateReplacement(PropSourceRange, "@property (nonatomic) ");
1841 // @property () ... case.
1845 FixItHint::CreateReplacement(PropSourceRange, "@property (nonatomic, ");
1884 /// AddPropertyAttrs - Propagates attributes from a property to the
1885 /// implicitly-declared getter or setter for that property.
1900 /// have the property type and issue diagnostics if they don't.
1904 void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
1911 GetterMethod = CD->getInstanceMethod(property->getGetterName());
1912 SetterMethod = CD->getInstanceMethod(property->getSetterName());
1913 DiagnosePropertyAccessorMismatch(property, GetterMethod,
1914 property->getLocation());
1918 property->getPropertyAttributes();
1926 property->getType().getNonReferenceType())) {
1927 Diag(property->getLocation(),
1929 << property->getDeclName()
1937 // FIXME: The synthesized property we set here is misleading. We almost always
1942 // No instance method of same name as property getter name was found.
1947 property->getLocation();
1950 property->getGetterName(),
1951 property->getType(), 0, CD, /*isInstance=*/true,
1954 (property->getPropertyImplementation() ==
1960 AddPropertyAttrs(*this, GetterMethod, property);
1966 if (property->hasAttr<NSReturnsNotRetainedAttr>())
1974 // the property with the same name is seen in the @implementation
1976 property->setGetterMethodDecl(GetterMethod);
1978 // Skip setter if property is read-only.
1979 if (!property->isReadOnly()) {
1982 // No instance method of same name as property setter name was found.
1987 property->getLocation();
1991 property->getSetterName(), Context.VoidTy, 0,
1996 (property->getPropertyImplementation() ==
2005 property->getIdentifier(),
2006 property->getType().getUnqualifiedType(),
2012 AddPropertyAttrs(*this, SetterMethod, property);
2026 // the property with the same name is seen in the @implementation
2028 property->setSetterMethodDecl(SetterMethod);
2034 // @property double bar;
2074 // 'readonly' property with no obvious lifetime.
2087 // we postpone most property diagnosis until class's implementation
2213 // Warn if user supplied no assignment attribute, property is
2221 // With arc, @property definitions should default to (strong) when
2222 // not specified; including when property is 'readonly'.
2233 // Don't issue warning on property with no life time in class
2234 // extension as it is inherited from property in primary class.