Lines Matching defs:property

1 //===--- SemaObjCProperty.cpp - Semantic Analysis for ObjC @property ------===//
9 // This file implements semantic analysis for Objective C @property and
31 /// getImpliedARCOwnership - Given a set of property attributes and a
52 // property type.
61 /// Check the internal consistency of a property declaration with
64 ObjCPropertyDecl *property) {
65 if (property->isInvalidDecl()) return;
67 ObjCPropertyAttribute::Kind propertyKind = property->getPropertyAttributes();
69 = property->getType().getObjCLifetime();
74 = getImpliedARCOwnership(propertyKind, property->getType());
76 // We have a lifetime qualifier but no dominating property
78 // setting the property attribute according to the lifetime
89 property->setPropertyAttributes(attr);
95 property->setInvalidDecl();
96 S.Diag(property->getLocation(),
98 << property->getDeclName()
103 /// Check this Objective-C property against a property declared in the
113 // Look for a property with the same name.
121 // Check this property against any protocols we inherit.
217 // Validate the attributes on the @property.
228 // For a class, compare the property against a property in our superclass.
242 // Also compare the property against a property in our protocols.
255 // when property in class extension is constructed.
345 // Determine whether the given property is readonly and implicitly
365 // If we're allowed to propagate atomicity, and the new property did
382 // One of the properties is atomic; if it's a readonly property, and
409 // Diagnose if this property is already in continuation class.
414 // We need to look in the @interface to see if the @property was
425 // Find the property in the extended class's primary class or
430 // If we found a property in an extension, complain.
439 // A readonly property declared in the primary class can be refined
440 // by adding a readwrite property within an extension.
444 // property is declared both in the @interface and the continuation.
484 // Take the ownership from the original property.
488 // If the redeclaration is 'weak' but the original property is not,
508 // If there was no declaration of a property with the same name in
518 // Relax the strict type matching for property type in continuation class.
519 // Allow property object type of continuation class to be different as long
520 // as it narrows the object type in its primary class property. Note that
522 // property in primary class and 'narrowed' type for a 'readwrite' property
539 // Check that atomicity of property in class extension matches the previous
572 // Issue a warning if property is 'assign' as default and its
606 // Class property and instance property can have the same name.
705 ObjCPropertyDecl *property,
707 if (property->isInvalidDecl() || ivar->isInvalidDecl()) return;
712 // The lifetime implied by the property's attributes.
714 getImpliedARCOwnership(property->getPropertyAttributes(),
715 property->getType());
730 // property implementation before parsing any method bodies.
747 << property->getDeclName()
754 << property->getDeclName()
760 << property->getDeclName() << ivar->getDeclName()
761 << ((property->getPropertyAttributesAsWritten() &
769 // Any other property should be ignored.
773 S.Diag(property->getLocation(), diag::note_property_declare);
780 /// property with no known lifetime of its own, using backing
781 /// 'ivar's attribute, if any. If no backing 'ivar', property's
784 ObjCPropertyDecl *property, ObjCIvarDecl *ivar) {
786 getImpliedARCOwnership(property->getPropertyAttributes(),
787 property->getType());
792 // if no backing ivar, make property 'strong'.
793 property->setPropertyAttributes(ObjCPropertyAttribute::kind_strong);
796 // property assumes owenership of backing ivar.
800 property->setPropertyAttributes(ObjCPropertyAttribute::kind_strong);
802 property->setPropertyAttributes(ObjCPropertyAttribute::kind_weak);
816 /// property declaration that should be synthesised in all of the inherited
825 "Expected a property from a protocol");
850 // Select the 'readwrite' property if such property exists.
857 // Check that the old property is compatible with the new one.
870 // Represents a property from another protocol that conflicts with the
879 // Verify the property attributes.
887 // The ownership might be incompatible unless the property has no explicit
996 /// Determine whether any storage attributes were written on the property.
1001 // If this is a readwrite property in a class extension that refines
1002 // a readonly property in the original class definition, check it as
1005 // If it's a readonly property, we're not interested.
1012 // Find the corresponding property in the primary class definition.
1029 /// Create a synthesized property accessor stub inside the \@implementation.
1057 /// builds the AST node for a property implementation declaration; declared
1067 // Make sure we have a context for the property implementation declaration.
1077 ObjCPropertyDecl *property = nullptr;
1079 // Find the class or category class where this property must have
1090 // Look for this property declaration in the @implementation's @interface
1091 property = IDecl->FindPropertyDeclaration(PropertyId, QueryKind);
1092 if (!property) {
1096 if (property->isClassProperty() && Synthesize) {
1100 unsigned PIkind = property->getPropertyAttributesAsWritten();
1107 Diag(property->getLocation(), diag::note_property_declare);
1111 dyn_cast<ObjCCategoryDecl>(property->getDeclContext())) {
1114 Diag(property->getLocation(), diag::note_property_declare);
1119 property->hasAttr<IBOutletAttr>() && !AtLoc.isValid()) {
1121 // Search into the class extensions and see if 'readonly property is
1124 DeclContext::lookup_result R = Ext->lookup(property->getDeclName());
1135 Diag(property->getLocation(), diag::warn_auto_readonly_iboutlet_property)
1136 << property;
1139 property->getLParenLoc(), readonlyLoc)) {
1143 Diag(property->getLocation(),
1149 if (Synthesize && isa<ObjCProtocolDecl>(property->getDeclContext()))
1150 property = SelectPropertyForSynthesisFromProtocols(SemaRef, AtLoc, IDecl,
1151 property);
1170 // Look for this property declaration in @implementation's category
1171 property = Category->FindPropertyDeclaration(PropertyId, QueryKind);
1172 if (!property) {
1192 QualType PropType = property->getType();
1197 property->getDeclName())) {
1198 Diag(property->getLocation(), diag::note_property_declare);
1203 (property->getPropertyAttributesAsWritten() &
1206 setImpliedPropertyAttributeForReadOnlyProperty(property, Ivar);
1209 ObjCPropertyAttribute::Kind kind = property->getPropertyAttributes();
1213 // Add GC __weak to the ivar type if the property is weak.
1218 Diag(property->getLocation(), diag::note_property_declare);
1225 // the property type.
1234 Diag(property->getLocation(), diag::note_property_declare);
1243 Diag(property->getLocation(),
1255 // Check when default synthesizing a property that there is
1256 // an ivar matching property name and issue warning; since this
1258 // property in non-default synthesis case.
1261 IDecl->lookupInstanceVariable(property->getIdentifier(),
1268 Diag(property->getLocation(), diag::note_property_declare);
1275 // property attributes.
1281 // explicitly write an ownership attribute on the property.
1282 if (!hasWrittenStorageAttribute(property, QueryKind) &&
1286 Diag(property->getLocation(), diag::note_property_declare);
1290 assert(lifetime && "no lifetime for property?");
1306 Diag(property->getLocation(), diag::note_property_declare);
1327 // a property implementation and to avoid future warnings.
1331 << property->getDeclName() << Ivar->getDeclName()
1337 property->setPropertyIvarDecl(Ivar);
1341 // Check that type of property and its ivar are type compatible.
1355 << property->getDeclName() << PropType
1359 // a property implementation and to avoid future warnings.
1364 // specifically for property redeclarations as well as for ivars.
1370 << property->getDeclName() << PropType
1380 << property->getDeclName() << Ivar->getDeclName();
1385 if ((property->getType()->isObjCObjectPointerType() ||
1389 << property->getDeclName() << Ivar->getDeclName();
1395 checkARCPropertyImpl(SemaRef, PropertyLoc, property, Ivar);
1400 assert (property && "ActOnPropertyImplDecl - property declaration missing");
1402 Context, SemaRef.CurContext, AtLoc, PropertyLoc, property,
1410 if (ObjCMethodDecl *getterMethod = property->getGetterMethodDecl()) {
1455 if (property->hasAttr<NSReturnsNotRetainedAttr>() &&
1459 Diag(property->getLocation(), diag::note_property_declare);
1475 if (ObjCMethodDecl *setterMethod = property->getSetterMethodDecl()) {
1514 if (property->getPropertyAttributes() &
1521 if (property->getType()->isReferenceType()) {
1524 << property->getType();
1554 // use and if 1) property is @dynamic or 2) property is synthesized
1620 // to be overridden by a property with any explicit ownership in the subclass.
1648 // atomic property is 'readonly'.
1672 // FIXME. For future support of covariant property types, revisit this.
1685 bool SemaObjC::DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *property,
1693 property->getType().getNonReferenceType().getAtomicUnqualifiedType();
1705 << property->getDeclName() << PropertyRValueType
1720 << property->getDeclName()
1778 // Exclude property for protocols which conform to class's super-class,
1779 // as super-class has to implement the property.
1810 /// an ivar synthesized for 'Method' and 'Method' is a property accessor
1822 // look up a property declaration whose one of its accessors is implemented
1830 // Also look up property declaration in class extension whose one of its
1877 // Is there a matching property synthesize/dynamic?
1908 // Suppress the warning if class's superclass implements property's
1909 // getter and implements property's setter (if readwrite property).
1910 // Or, if property is going to be implemented in its super class.
1923 // If property to be implemented in the super class, ignore.
1949 /* property = */ Prop->getIdentifier(),
1983 // When reporting on missing property setter/getter implementation in
2023 // its primary class (and its super classes) if property is
2079 // Collect property accessors implemented in current implementation.
2099 // Is there a matching property synthesize/dynamic?
2119 const auto *property = propertyImpl->getPropertyDecl();
2124 (property->getPropertyAttributes() &
2126 property->getGetterMethodDecl() && property->getSetterMethodDecl()) {
2136 << setterImpl->getSelector() << property->getDeclName();
2189 // We only care about readwrite atomic property.
2213 // @property () ... case.
2222 //@property id etc.
2259 // Look for a getter explicitly declared alongside the property.
2337 /// AddPropertyAttrs - Propagates attributes from a property to the
2338 /// implicitly-declared getter or setter for that property.
2351 /// have the property type and issue diagnostics if they don't.
2354 void SemaObjC::ProcessPropertyDecl(ObjCPropertyDecl *property) {
2357 ObjCContainerDecl *CD = cast<ObjCContainerDecl>(property->getDeclContext());
2361 bool IsClassProperty = property->isClassProperty();
2363 CD->getClassMethod(property->getGetterName()) :
2364 CD->getInstanceMethod(property->getGetterName());
2372 getClassMethod(property->getGetterName()) :
2374 getInstanceMethod(property->getGetterName());
2377 CD->getClassMethod(property->getSetterName()) :
2378 CD->getInstanceMethod(property->getSetterName());
2383 getClassMethod(property->getSetterName()) :
2385 getInstanceMethod(property->getSetterName());
2386 DiagnosePropertyAccessorMismatch(property, GetterMethod,
2387 property->getLocation());
2394 property->getGetterName(), !IsClassProperty, true, false, CatDecl);
2396 if (ExistingGetter->isDirectMethod() || property->isDirectProperty()) {
2397 Diag(property->getLocation(), diag::err_objc_direct_duplicate_decl)
2398 << property->isDirectProperty() << 1 /* property */
2407 if (!property->isReadOnly() && !SetterMethod) {
2410 property->getSetterName(), !IsClassProperty, true, false, CatDecl);
2412 if (ExistingSetter->isDirectMethod() || property->isDirectProperty()) {
2413 Diag(property->getLocation(), diag::err_objc_direct_duplicate_decl)
2414 << property->isDirectProperty() << 1 /* property */
2423 if (!property->isReadOnly() && SetterMethod) {
2430 property->getType().getNonReferenceType())) {
2431 Diag(property->getLocation(),
2433 << property->getDeclName()
2441 // FIXME: The synthesized property we set here is misleading. We almost always
2446 // No instance/class method of same name as property getter name was found.
2449 SourceLocation Loc = property->getLocation();
2451 // The getter returns the declared property type with all qualifiers
2453 QualType resultTy = property->getType().getAtomicUnqualifiedType();
2455 // If the property is null_resettable, the getter returns nonnull.
2456 if (property->getPropertyAttributes() &
2467 Context, Loc, Loc, property->getGetterName(), resultTy, nullptr, CD,
2471 (property->getPropertyImplementation() == ObjCPropertyDecl::Optional)
2476 AddPropertyAttrs(SemaRef, GetterMethod, property);
2478 if (property->isDirectProperty())
2481 if (property->hasAttr<NSReturnsNotRetainedAttr>())
2485 if (property->hasAttr<ObjCReturnsInnerPointerAttr>())
2489 if (const SectionAttr *SA = property->getAttr<SectionAttr>())
2499 // the property with the same name is seen in the @implementation
2504 property->setGetterMethodDecl(GetterMethod);
2506 // Skip setter if property is read-only.
2507 if (!property->isReadOnly()) {
2510 // No instance/class method of same name as property setter name was
2514 SourceLocation Loc = property->getLocation();
2517 Context, Loc, Loc, property->getSetterName(), Context.VoidTy, nullptr,
2524 (property->getPropertyImplementation() == ObjCPropertyDecl::Optional)
2530 property->getType().getUnqualifiedType().getAtomicUnqualifiedType();
2532 // If the property is null_resettable, the setter accepts a
2534 if (property->getPropertyAttributes() &
2548 property->getIdentifier(),
2555 AddPropertyAttrs(SemaRef, SetterMethod, property);
2557 if (property->isDirectProperty())
2561 if (const SectionAttr *SA = property->getAttr<SectionAttr>())
2573 // the property with the same name is seen in the @implementation
2578 property->setSetterMethodDecl(SetterMethod);
2584 // @property double bar;
2751 // Warn if user supplied no assignment attribute, property is
2757 // With arc, @property definitions should default to strong when
2768 // Don't issue warning on property with no life time in class
2769 // extension as it is inherited from property in primary class.