24 #include "llvm/ADT/DenseSet.h" 25 #include "llvm/ADT/SmallString.h" 27 using namespace clang;
71 =
property->getPropertyAttributes();
73 =
property->getType().getObjCLifetime();
79 if (!expectedLifetime) {
93 property->setPropertyAttributes(attr);
97 if (propertyLifetime == expectedLifetime)
return;
99 property->setInvalidDecl();
101 diag::err_arc_inconsistent_property_ownership)
112 llvm::SmallPtrSetImpl<ObjCProtocolDecl *> &Known) {
114 if (!Known.insert(Proto).second)
119 for (
unsigned I = 0, N = R.
size(); I != N; ++I) {
150 llvm_unreachable(
"bad qualifier");
201 if (CDecl->IsClassExtension()) {
206 isReadWrite, Attributes,
208 T, TSI, MethodImplKind);
226 (isa<ObjCInterfaceDecl>(ClassDecl) ||
227 isa<ObjCProtocolDecl>(ClassDecl)));
230 if (Res->getType().getObjCLifetime())
233 llvm::SmallPtrSet<ObjCProtocolDecl *, 16> KnownProtos;
236 bool FoundInSuper =
false;
240 for (
unsigned I = 0, N = R.
size(); I != N; ++I) {
250 CurrentInterfaceDecl = Super;
255 for (
auto *
P : CurrentInterfaceDecl->
protocols()) {
260 for (
auto *
P : IFace->all_referenced_protocols()) {
268 if (!Cat->IsClassExtension())
269 for (
auto *
P : Cat->protocols())
283 unsigned attributesAsWritten = 0;
322 bool invalidTemp =
false;
323 StringRef file = SM.
getBufferData(locInfo.first, &invalidTemp);
326 const char *tokenBegin = file.data() + locInfo.second;
331 file.begin(), tokenBegin, file.end());
334 lexer.LexFromRawLexer(Tok);
335 if (Tok.is(tok::raw_identifier) && Tok.getRawIdentifier() == attrName) {
336 Loc = Tok.getLocation();
339 }
while (Tok.isNot(tok::r_paren));
347 bool PropagateAtomicity) {
355 if (OldIsAtomic == NewIsAtomic)
return;
361 auto Attrs =
Property->getPropertyAttributes();
368 if (
Property->getPropertyAttributesAsWritten() &
377 const unsigned AtomicityMask =
379 if (PropagateAtomicity &&
382 Attrs = Attrs & ~AtomicityMask;
394 if ((OldIsAtomic && isImplicitlyReadonlyAtomic(OldProperty)) ||
395 (NewIsAtomic && isImplicitlyReadonlyAtomic(NewProperty)))
401 if (
auto Category = dyn_cast<ObjCCategoryDecl>(OldDC))
402 OldContextName =
Category->getClassInterface()->getIdentifier();
404 OldContextName = cast<ObjCContainerDecl>(OldDC)->
getIdentifier();
421 const bool isReadWrite,
422 unsigned &Attributes,
423 const unsigned AttributesAsWritten,
450 Diag(AtLoc, diag::err_duplicate_property);
469 ? diag::err_use_continuation_class_redeclaration_readwrite
470 : diag::err_use_continuation_class;
481 Diag(AtLoc, diag::warn_property_redecl_getter_mismatch)
492 unsigned ExistingOwnership
495 if (ExistingOwnership && NewOwnership != ExistingOwnership) {
498 Diag(AtLoc, diag::warn_property_attr_mismatch);
503 Attributes = (Attributes & ~
OwnershipMask) | ExistingOwnership;
512 Diag(AtLoc, diag::warn_property_implicitly_mismatched);
520 FD, GetterSel, GetterNameLoc,
521 SetterSel, SetterNameLoc,
523 Attributes, AttributesAsWritten,
524 T, TSI, MethodImplKind, DC);
534 bool IncompatibleObjC =
false;
544 if (!isa<ObjCObjectPointerType>(PrimaryClassPropertyT) ||
545 !isa<ObjCObjectPointerType>(ClassExtPropertyT) ||
547 ConvertedType, IncompatibleObjC))
548 || IncompatibleObjC) {
550 diag::err_type_mismatch_continuation_class) << PDecl->getType();
574 const bool isReadWrite,
575 const unsigned Attributes,
576 const unsigned AttributesAsWritten,
607 Diag(AtLoc, diag::warn_implements_nscopying) << PropertyId;
625 LParenLoc, T, TInfo);
633 Diag(prevDecl->getLocation(), diag::note_property_declare);
642 if (T->isArrayType() || T->isFunctionType()) {
643 Diag(AtLoc, diag::err_property_type) << T;
693 if (Attributes & ObjCDeclSpec::DQ_PR_unsafe_unretained)
698 if (MethodImplKind == tok::objc_required)
700 else if (MethodImplKind == tok::objc_optional)
709 if (Attributes & ObjCDeclSpec::DQ_PR_class)
726 property->getType());
729 if (propertyLifetime == ivarLifetime)
return;
755 switch (propertyLifetime) {
773 << ((
property->getPropertyAttributesAsWritten()
778 llvm_unreachable(
"properties cannot be autoreleasing");
787 S.
Diag(propertyImplLoc, diag::note_property_synthesize);
799 property->getType());
820 return (Attr1 & Kind) != (Attr2 &
Kind);
825 return ((Attr1 & Kinds) != 0) != ((Attr2 & Kinds) != 0);
838 "Expected a property from a protocol");
843 PDecl->collectInheritedProtocolProperties(Property, ProtocolSet,
848 for (
const auto *PI : SDecl->all_referenced_protocols()) {
850 PDecl->collectInheritedProtocolProperties(Property, ProtocolSet,
853 SDecl = SDecl->getSuperClass();
857 if (Properties.empty())
861 size_t SelectedIndex = 0;
862 for (
const auto &Prop : llvm::enumerate(Properties)) {
864 if (Property->
isReadOnly() && !Prop.value()->isReadOnly()) {
865 Property = Prop.value();
866 SelectedIndex = Prop.index();
869 if (Property != OriginalProperty) {
871 Properties[SelectedIndex] = OriginalProperty;
877 IncompatibleType = 0,
878 HasNoExpectedAttribute,
879 HasUnexpectedAttribute,
885 struct MismatchingProperty {
888 StringRef AttributeName;
893 unsigned Attr = Prop->getPropertyAttributesAsWritten();
894 if (Attr != OriginalAttributes) {
895 auto Diag = [&](
bool OriginalHasAttribute, StringRef AttributeName) {
896 MismatchKind
Kind = OriginalHasAttribute ? HasNoExpectedAttribute
897 : HasUnexpectedAttribute;
898 Mismatches.push_back({Prop,
Kind, AttributeName});
915 OriginalAttributes, Attr,
920 "retain (or strong)");
930 Mismatches.push_back({Prop, DifferentGetter,
""});
933 if (!Property->
isReadOnly() && !Prop->isReadOnly() &&
935 Mismatches.push_back({Prop, DifferentSetter,
""});
940 bool IncompatibleObjC =
false;
943 || IncompatibleObjC) {
944 Mismatches.push_back({Prop, IncompatibleType,
""});
950 if (Mismatches.empty())
955 bool HasIncompatibleAttributes =
false;
956 for (
const auto &
Note : Mismatches)
957 HasIncompatibleAttributes =
958 Note.Kind != IncompatibleType ?
true : HasIncompatibleAttributes;
962 Property != OriginalProperty || HasIncompatibleAttributes
963 ? diag::err_protocol_property_mismatch
964 : diag::warn_protocol_property_mismatch);
965 Diag << Mismatches[0].Kind;
966 switch (Mismatches[0].
Kind) {
967 case IncompatibleType:
970 case HasNoExpectedAttribute:
971 case HasUnexpectedAttribute:
972 Diag << Mismatches[0].AttributeName;
974 case DifferentGetter:
977 case DifferentSetter:
982 for (
const auto &
Note : Mismatches) {
984 S.
Diag(
Note.Prop->getLocation(), diag::note_protocol_property_declare)
987 case IncompatibleType:
990 case HasNoExpectedAttribute:
991 case HasUnexpectedAttribute:
994 case DifferentGetter:
997 case DifferentSetter:
1003 S.
Diag(AtLoc, diag::note_property_synthesize);
1025 auto OrigClass =
Category->getClassInterface();
1026 for (
auto Found : OrigClass->lookup(Prop->
getDeclName())) {
1028 return OrigProp->getPropertyAttributesAsWritten() &
OwnershipMask;
1032 for (
const auto *Proto : OrigClass->all_referenced_protocols()) {
1035 return OrigProp->getPropertyAttributesAsWritten() &
OwnershipMask;
1056 if (!ClassImpDecl) {
1057 Diag(AtLoc, diag::err_missing_property_context);
1061 PropertyIvarLoc = PropertyLoc;
1071 if ((IC = dyn_cast<ObjCImplementationDecl>(ClassImpDecl))) {
1076 "ActOnPropertyImplDecl - @implementation without @interface");
1081 Diag(PropertyLoc, diag::err_bad_property_decl) << IDecl->
getDeclName();
1084 if (property->isClassProperty() && Synthesize) {
1085 Diag(PropertyLoc, diag::err_synthesize_on_class_property) << PropertyId;
1088 unsigned PIkind =
property->getPropertyAttributesAsWritten();
1092 Diag(AtLoc, diag::warn_implicit_atomic_property);
1095 Diag(property->getLocation(), diag::note_property_declare);
1099 dyn_cast<ObjCCategoryDecl>(property->getDeclContext())) {
1100 if (!CD->IsClassExtension()) {
1101 Diag(PropertyLoc, diag::err_category_property) << CD->getDeclName();
1102 Diag(property->getLocation(), diag::note_property_declare);
1108 property->hasAttr<IBOutletAttr>() &&
1110 bool ReadWriteProperty =
false;
1117 PIkind = ExtProp->getPropertyAttributesAsWritten();
1119 ReadWriteProperty =
true;
1125 if (!ReadWriteProperty) {
1126 Diag(property->getLocation(), diag::warn_auto_readonly_iboutlet_property)
1130 property->getLParenLoc(), readonlyLoc)) {
1133 SourceRange ReadonlySourceRange(readonlyLoc, endLoc);
1134 Diag(property->getLocation(),
1135 diag::note_auto_readonly_iboutlet_fixup_suggest) <<
1140 if (Synthesize && isa<ObjCProtocolDecl>(property->getDeclContext()))
1144 }
else if ((CatImplClass = dyn_cast<ObjCCategoryImplDecl>(ClassImpDecl))) {
1146 Diag(AtLoc, diag::err_synthesize_category_decl);
1151 Diag(AtLoc, diag::err_missing_property_interface);
1164 Diag(PropertyLoc, diag::err_bad_category_property_decl)
1169 Diag(AtLoc, diag::err_bad_property_context);
1173 bool CompleteTypeErr =
false;
1179 PropertyIvar = PropertyId;
1183 QualType PropType =
property->getType();
1187 diag::err_incomplete_synthesized_property,
1188 property->getDeclName())) {
1189 Diag(property->getLocation(), diag::note_property_declare);
1190 CompleteTypeErr =
true;
1194 (
property->getPropertyAttributesAsWritten() &
1201 =
property->getPropertyAttributes();
1203 bool isARCWeak =
false;
1209 Diag(PropertyDiagLoc, diag::err_gc_weak_property_strong_type);
1210 Diag(property->getLocation(), diag::note_property_declare);
1222 Diag(PropertyDiagLoc,
1224 ? diag::err_synthesizing_arc_weak_property_disabled
1225 : diag::err_synthesizing_arc_weak_property_no_runtime);
1226 Diag(property->getLocation(), diag::note_property_declare);
1228 CompleteTypeErr =
true;
1235 Diag(property->getLocation(),
1236 diag::err_arc_weak_unavailable_property)
1237 << PropertyIvarType;
1256 Diag(PropertyDiagLoc,
1257 diag::warn_autosynthesis_property_ivar_match)
1258 << PropertyId << (Ivar ==
nullptr) << PropertyIvar
1260 Diag(property->getLocation(), diag::note_property_declare);
1268 if ((
getLangOpts().ObjCAutoRefCount || isARCWeak) &&
1276 Diag(PropertyDiagLoc,
1277 diag::err_arc_objc_property_default_assign_on_object);
1278 Diag(property->getLocation(), diag::note_property_declare);
1282 assert(lifetime &&
"no lifetime for property?");
1291 PropertyIvarLoc,PropertyIvarLoc, PropertyIvar,
1292 PropertyIvarType,
nullptr,
1294 (
Expr *)
nullptr,
true);
1297 diag::err_abstract_type_in_decl,
1299 Diag(property->getLocation(), diag::note_property_declare);
1301 CompleteTypeErr =
true;
1303 if (!CompleteTypeErr) {
1306 Diag(PropertyIvarLoc, diag::err_synthesize_variable_sized_ivar)
1307 << PropertyIvarType;
1308 CompleteTypeErr =
true;
1311 if (CompleteTypeErr)
1317 Diag(PropertyDiagLoc, diag::err_missing_property_ivar_decl)
1323 Diag(PropertyDiagLoc, diag::err_ivar_in_superclass_use)
1330 property->setPropertyIvarDecl(Ivar);
1336 if (isa<ObjCObjectPointerType>(PropertyIvarType)
1337 && isa<ObjCObjectPointerType>(IvarType))
1348 Diag(PropertyDiagLoc, diag::err_property_ivar_type)
1349 <<
property->getDeclName() << PropType
1361 if (lhsType != rhsType &&
1363 Diag(PropertyDiagLoc, diag::err_property_ivar_type)
1364 <<
property->getDeclName() << PropType
1373 Diag(PropertyDiagLoc, diag::err_weak_property)
1374 <<
property->getDeclName() << Ivar->
getDeclName();
1379 if ((property->getType()->isObjCObjectPointerType() ||
1382 Diag(PropertyDiagLoc, diag::err_strong_property)
1383 <<
property->getDeclName() << Ivar->
getDeclName();
1387 if (
getLangOpts().ObjCAutoRefCount || isARCWeak ||
1390 }
else if (PropertyIvar)
1392 Diag(PropertyDiagLoc, diag::err_dynamic_property_ivar_decl);
1394 assert (property &&
"ActOnPropertyImplDecl - property declaration missing");
1401 Ivar, PropertyIvarLoc);
1403 if (CompleteTypeErr || !compat)
1406 if (
ObjCMethodDecl *getterMethod = property->getGetterMethodDecl()) {
1407 getterMethod->createImplicitParams(
Context, IDecl);
1419 Expr *LoadSelfExpr =
1421 CK_LValueToRValue, SelfExpr,
nullptr,
1428 LoadSelfExpr,
true,
true);
1431 getterMethod->getReturnType(),
1433 PropertyDiagLoc, IvarRefExpr);
1441 if (property->hasAttr<NSReturnsNotRetainedAttr>() &&
1442 !getterMethod->hasAttr<NSReturnsNotRetainedAttr>()) {
1443 Diag(getterMethod->getLocation(),
1444 diag::warn_property_getter_owning_mismatch);
1445 Diag(property->getLocation(), diag::note_property_declare);
1448 switch (getterMethod->getMethodFamily()) {
1453 Diag(getterMethod->getLocation(), diag::err_arc_illegal_method_def)
1454 << 1 << getterMethod->getSelector();
1460 if (
ObjCMethodDecl *setterMethod = property->getSetterMethodDecl()) {
1461 setterMethod->createImplicitParams(
Context, IDecl);
1471 Expr *LoadSelfExpr =
1473 CK_LValueToRValue, SelfExpr,
nullptr,
1480 LoadSelfExpr,
true,
true);
1488 BO_Assign, lhs, rhs);
1489 if (property->getPropertyAttributes() &
1493 dyn_cast_or_null<CXXOperatorCallExpr>(callExpr))
1494 if (
const FunctionDecl *FuncDecl = CXXCE->getDirectCallee())
1495 if (!FuncDecl->isTrivial())
1496 if (property->getType()->isReferenceType()) {
1497 Diag(PropertyDiagLoc,
1498 diag::err_atomic_property_nontrivial_assign_op)
1499 <<
property->getType();
1500 Diag(FuncDecl->getLocStart(),
1501 diag::note_callee_decl) << FuncDecl;
1512 Diag(PropertyLoc, diag::err_duplicate_ivar_use)
1513 << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()
1515 Diag(PPIDecl->getLocation(), diag::note_previous_use);
1520 Diag(PropertyLoc, diag::err_property_implemented) << PropertyId;
1521 Diag(PPIDecl->getLocation(), diag::note_previous_declaration);
1536 if (PropertyIvar && PropertyIvar != PropertyId)
1551 Diag(PropertyDiagLoc, diag::err_duplicate_ivar_use)
1552 << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()
1554 Diag(PPIDecl->getLocation(), diag::note_previous_use);
1559 Diag(PropertyDiagLoc, diag::err_property_implemented) << PropertyId;
1560 Diag(PPIDecl->getLocation(), diag::note_previous_declaration);
1580 bool OverridingProtocolProperty) {
1589 if (!OverridingProtocolProperty &&
1598 != (SAttr & ObjCPropertyDecl::OBJC_PR_copy))
1600 << Property->
getDeclName() <<
"copy" << inheritedName;
1601 else if (!(SAttr & ObjCPropertyDecl::OBJC_PR_readonly)){
1602 unsigned CAttrRetain =
1605 unsigned SAttrRetain =
1608 bool CStrong = (CAttrRetain != 0);
1609 bool SStrong = (SAttrRetain != 0);
1610 if (CStrong != SStrong)
1612 << Property->
getDeclName() <<
"retain (or strong)" << inheritedName;
1626 << Property->
getDeclName() <<
"setter" << inheritedName;
1631 << Property->
getDeclName() <<
"getter" << inheritedName;
1643 bool IncompatibleObjC =
false;
1646 ConvertedType, IncompatibleObjC) ||
1648 Diag(Property->
getLocation(), diag::warn_property_types_are_incompatible)
1649 << Property->
getType() << SuperProperty->
getType() << inheritedName;
1662 property->getType().getNonReferenceType().getAtomicUnqualifiedType();
1667 if ((propertyObjCPtr =
1673 Diag(Loc, diag::err_property_accessor_type)
1674 <<
property->getDeclName() << PropertyRValueType
1688 Diag(Loc, diag::warn_accessor_property_type_mismatch)
1689 <<
property->getDeclName()
1704 bool CollectClassPropsOnly =
false,
1705 bool IncludeProtocols =
true) {
1707 for (
auto *Prop : IDecl->properties()) {
1708 if (CollectClassPropsOnly && !Prop->isClassProperty())
1710 PropMap[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] =
1715 for (
auto *Ext : IDecl->visible_extensions())
1717 CollectClassPropsOnly, IncludeProtocols);
1719 if (IncludeProtocols) {
1721 for (
auto *PI : IDecl->all_referenced_protocols())
1723 CollectClassPropsOnly);
1727 for (
auto *Prop : CATDecl->properties()) {
1728 if (CollectClassPropsOnly && !Prop->isClassProperty())
1730 PropMap[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] =
1733 if (IncludeProtocols) {
1735 for (
auto *PI : CATDecl->protocols())
1737 CollectClassPropsOnly);
1741 for (
auto *Prop : PDecl->properties()) {
1742 if (CollectClassPropsOnly && !Prop->isClassProperty())
1745 SuperPropMap[std::make_pair(Prop->getIdentifier(),
1746 Prop->isClassProperty())];
1749 if (!PropertyFromSuper ||
1750 PropertyFromSuper->
getIdentifier() != Prop->getIdentifier()) {
1752 PropMap[std::make_pair(Prop->getIdentifier(),
1753 Prop->isClassProperty())];
1759 for (
auto *PI : PDecl->protocols())
1761 CollectClassPropsOnly);
1773 SDecl->collectPropertiesToImplement(PropMap, PO);
1774 SDecl = SDecl->getSuperClass();
1797 (
Property->getPropertyIvarDecl() == IV))
1803 for (
const auto *
Property : Ext->instance_properties())
1806 (
Property->getPropertyIvarDecl() == IV))
1813 bool SuperClassImplementsGetter =
false;
1814 bool SuperClassImplementsSetter =
false;
1816 SuperClassImplementsSetter =
true;
1821 SuperClassImplementsGetter =
true;
1824 SuperClassImplementsSetter =
true;
1825 if (SuperClassImplementsGetter && SuperClassImplementsSetter)
1840 if (PropMap.empty())
1845 for (
unsigned i = 0, e = PropertyOrder.size(); i != e; i++) {
1864 Diag(Prop->
getLocation(), diag::warn_no_autosynthesis_shared_ivar_property)
1866 if (PID->getLocation().isValid())
1867 Diag(PID->getLocation(), diag::note_property_synthesize);
1881 diag::warn_auto_synthesizing_protocol_property)
1885 (Twine(
"@synthesize ") + Prop->
getName() +
";\n\n").str();
1886 Diag(AtEnd, diag::note_add_synthesize_directive)
1892 if (PropInSuperClass) {
1903 Diag(Prop->
getLocation(), diag::warn_autosynthesis_property_in_superclass)
1935 if (!IDecl->isObjCRequiresPropertyDefs())
1943 llvm::SmallPtrSet<const ObjCMethodDecl *, 8> &
SMap) {
1946 auto I = std::find_if(SMap.begin(), SMap.end(),
1948 return x->getSelector() == Method &&
1955 if (I == SMap.end() &&
1956 (PrimaryClass ==
nullptr ||
1960 isa<ObjCCategoryDecl>(CDecl)
1962 ? diag::warn_impl_required_in_category_for_class_property
1963 : diag::warn_setter_getter_impl_required_in_category)
1965 ? diag::warn_impl_required_for_class_property
1966 : diag::warn_setter_getter_impl_required);
1969 if (S.
LangOpts.ObjCDefaultSynthProperties &&
1973 S.
Diag(RID->getLocation(), diag::note_suppressed_class_declare);
1979 bool SynthesizeProperties) {
1993 if ((IDecl =
C->getClassInterface())) {
2003 SynthesizeProperties);
2009 std::unique_ptr<ObjCContainerDecl::PropertyMap> LazyMap;
2012 if (!PDecl->hasAttr<ObjCExplicitProtocolImplAttr>())
2030 for (
auto *PropDecl : PDecl->properties()) {
2031 if ((*LazyMap)[std::make_pair(PropDecl->getIdentifier(),
2032 PropDecl->isClassProperty())])
2034 PropMap[std::make_pair(PropDecl->getIdentifier(),
2035 PropDecl->isClassProperty())] = PropDecl;
2040 if (PropMap.empty())
2045 PropImplMap.insert(I->getPropertyDecl());
2047 llvm::SmallPtrSet<const ObjCMethodDecl *, 8> InsMap;
2049 for (
const auto *I : IMPDecl->
methods())
2057 if (
ObjCImplDecl *IMP = PrimaryClass->getImplementation()) {
2061 for (
const auto *I : IMP->methods())
2065 for (ObjCContainerDecl::PropertyMap::iterator
2066 P = PropMap.begin(), E = PropMap.end();
P != E; ++
P) {
2071 PropImplMap.count(Prop) ||
2077 PrimaryClass, Prop->
getGetterName(), IMPDecl, CDecl,
C, Prop, InsMap);
2078 if (!Prop->isReadOnly())
2080 PrimaryClass, Prop->getSetterName(),
2081 IMPDecl, CDecl,
C, Prop, InsMap);
2087 const auto *
property = propertyImpl->getPropertyDecl();
2091 if (propertyImpl->getPropertyImplementation()
2093 (
property->getPropertyAttributes() &
2095 property->getGetterMethodDecl() &&
2096 property->getSetterMethodDecl()) {
2097 auto *getterMethod =
property->getGetterMethodDecl();
2098 auto *setterMethod =
property->getSetterMethodDecl();
2105 Diag(loc, diag::warn_null_resettable_setter)
2106 << setterMethod->getSelector() <<
property->getDeclName();
2120 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
2122 for (
auto *Prop : Ext->properties())
2123 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
2125 for (ObjCContainerDecl::PropertyMap::iterator I = PM.begin(), E = PM.end();
2130 bool LookedUpGetterSetter =
false;
2143 LookedUpGetterSetter =
true;
2146 diag::warn_default_atomic_custom_getter_setter)
2152 diag::warn_default_atomic_custom_getter_setter)
2159 if ((Attributes & ObjCPropertyDecl::OBJC_PR_nonatomic) ||
2166 if (!LookedUpGetterSetter) {
2174 if ((GetterMethod && !SetterMethod) || (!GetterMethod && SetterMethod)) {
2178 Diag(MethodLoc, diag::warn_atomic_property_rule)
2180 << (SetterMethod !=
nullptr);
2187 StringRef NonatomicStr = AttributesAsWritten?
"nonatomic, " 2190 diag::note_atomic_property_fixup_suggest)
2197 diag::note_atomic_property_fixup_suggest)
2201 Diag(MethodLoc, diag::note_atomic_property_fixup_suggest);
2214 if (PD && !PD->
hasAttr<NSReturnsNotRetainedAttr>() &&
2232 for (
auto *getterRedecl : method->
redecls()) {
2233 if (getterRedecl->isImplicit())
2237 noteLoc = getterRedecl->getLocation();
2238 fixItLoc = getterRedecl->getLocEnd();
2243 tok::kw___attribute, tok::l_paren, tok::l_paren,
2246 tok::r_paren, tok::r_paren
2248 StringRef spelling =
"__attribute__((objc_method_family(none)))";
2250 if (!macroName.empty())
2251 spelling = macroName;
2253 auto noteDiag =
Diag(noteLoc, diag::note_cocoa_naming_declare_family)
2257 fixItText += spelling;
2275 if (I->getMethodFamily() ==
OMF_init)
2276 InitSelSet.insert(I->getSelector());
2279 SuperD->getDesignatedInitializers(DesignatedInits);
2281 I = DesignatedInits.begin(), E = DesignatedInits.end(); I != E; ++I) {
2284 bool Ignore =
false;
2286 Ignore = IMD->isUnavailable();
2290 diag::warn_objc_implementation_missing_designated_init_override)
2303 for (
const auto *A : Property->
attrs()) {
2304 if (isa<DeprecatedAttr>(A) ||
2305 isa<UnavailableAttr>(A) ||
2306 isa<AvailabilityAttr>(A))
2321 bool IsClassProperty =
property->isClassProperty();
2322 GetterMethod = IsClassProperty ?
2330 if (CatDecl->IsClassExtension())
2333 CatDecl->getClassInterface()->
2336 SetterMethod = IsClassProperty ?
2341 if (CatDecl->IsClassExtension())
2344 CatDecl->getClassInterface()->
2349 if (!property->
isReadOnly() && SetterMethod) {
2352 Diag(SetterMethod->getLocation(), diag::err_setter_type_void);
2353 if (SetterMethod->param_size() != 1 ||
2355 (*SetterMethod->param_begin())->getType().getNonReferenceType(),
2356 property->getType().getNonReferenceType())) {
2358 diag::warn_accessor_property_type_mismatch)
2360 << SetterMethod->getSelector();
2361 Diag(SetterMethod->getLocation(), diag::note_declared_at);
2371 if (!GetterMethod) {
2379 QualType resultTy =
property->getType().getAtomicUnqualifiedType();
2388 modifiedTy, modifiedTy);
2394 resultTy,
nullptr, CD,
2395 !IsClassProperty,
false,
2398 (
property->getPropertyImplementation() ==
2402 CD->addDecl(GetterMethod);
2406 if (property->
hasAttr<NSReturnsNotRetainedAttr>())
2407 GetterMethod->
addAttr(NSReturnsNotRetainedAttr::CreateImplicit(
Context,
2410 if (property->
hasAttr<ObjCReturnsInnerPointerAttr>())
2412 ObjCReturnsInnerPointerAttr::CreateImplicit(
Context, Loc));
2414 if (
const SectionAttr *SA = property->
getAttr<SectionAttr>())
2416 SectionAttr::CreateImplicit(
Context, SectionAttr::GNU_section,
2417 SA->getName(), Loc));
2425 property->setGetterMethodDecl(GetterMethod);
2430 if (!SetterMethod) {
2440 nullptr, CD, !IsClassProperty,
2445 (
property->getPropertyImplementation() ==
2452 property->getType().getUnqualifiedType().getAtomicUnqualifiedType();
2462 modifiedTy, modifiedTy);
2475 SetterMethod->setMethodParams(
Context, Argument,
None);
2480 if (
const SectionAttr *SA = property->
getAttr<SectionAttr>())
2481 SetterMethod->addAttr(
2482 SectionAttr::CreateImplicit(
Context, SectionAttr::GNU_section,
2483 SA->getName(), Loc));
2491 SetterMethod->setPropertyAccessor(
true);
2492 property->setSetterMethodDecl(SetterMethod);
2506 if (!IsClassProperty) {
2519 if (!CurrentClass) {
2521 CurrentClass = Cat->getClassInterface();
2522 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(CD))
2523 CurrentClass = Impl->getClassInterface();
2533 unsigned &Attributes,
2534 bool propertyInPrimaryClass) {
2541 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2542 <<
"readonly" <<
"readwrite";
2550 !PropertyTy->isObjCRetainableType() &&
2551 !PropertyDecl->
hasAttr<ObjCNSObjectAttr>()) {
2552 Diag(Loc, diag::err_objc_property_requires_object)
2563 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2564 <<
"assign" <<
"copy";
2568 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2569 <<
"assign" <<
"retain";
2573 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2574 <<
"assign" <<
"strong";
2579 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2580 <<
"assign" <<
"weak";
2583 if (PropertyDecl->
hasAttr<IBOutletCollectionAttr>())
2584 Diag(Loc, diag::warn_iboutletcollection_property_assign);
2587 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2588 <<
"unsafe_unretained" <<
"copy";
2592 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2593 <<
"unsafe_unretained" <<
"retain";
2597 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2598 <<
"unsafe_unretained" <<
"strong";
2603 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2604 <<
"unsafe_unretained" <<
"weak";
2609 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2610 <<
"copy" <<
"retain";
2614 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2615 <<
"copy" <<
"strong";
2619 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2620 <<
"copy" <<
"weak";
2626 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2627 <<
"retain" <<
"weak";
2631 (Attributes & ObjCDeclSpec::DQ_PR_weak)) {
2632 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2633 <<
"strong" <<
"weak";
2637 if (Attributes & ObjCDeclSpec::DQ_PR_weak) {
2639 if (
auto nullability = PropertyTy->getNullability(
Context)) {
2641 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2642 <<
"nonnull" <<
"weak";
2648 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2649 <<
"atomic" <<
"nonatomic";
2656 if (Attributes & ObjCDeclSpec::DQ_PR_readonly) {
2662 }
else if (PropertyTy->isObjCObjectPointerType()) {
2664 (PropertyTy->isObjCClassType() ||
2665 PropertyTy->isObjCQualifiedClassType());
2670 else if (propertyInPrimaryClass) {
2675 Diag(Loc, diag::warn_objc_property_no_assignment_attribute);
2679 Diag(Loc, diag::warn_objc_property_default_assign_on_object);
2689 if (!(Attributes & ObjCDeclSpec::DQ_PR_copy)
2692 && PropertyTy->isBlockPointerType())
2693 Diag(Loc, diag::warn_objc_property_copy_missing_on_block);
2694 else if ((Attributes & ObjCDeclSpec::DQ_PR_retain) &&
2696 !(Attributes & ObjCDeclSpec::DQ_PR_strong) &&
2697 PropertyTy->isBlockPointerType())
2698 Diag(Loc, diag::warn_objc_property_retain_of_block);
2700 if ((Attributes & ObjCDeclSpec::DQ_PR_readonly) &&
2702 Diag(Loc, diag::warn_objc_readonly_property_has_setter);
A call to an overloaded operator written using operator syntax.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
ObjCPropertyQueryKind getQueryKind() const
const internal::VariadicDynCastAllOfMatcher< Stmt, CallExpr > callExpr
Matches call expressions.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Represents a function declaration or definition.
Lexer - This provides a simple interface that turns a text buffer into a stream of tokens...
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
protocol_range protocols() const
Smart pointer class that efficiently represents Objective-C method names.
A (possibly-)qualified type.
ObjCInterfaceDecl * getClassInterface()
all_protocol_range all_referenced_protocols() const
ObjCInterfaceDecl * getClassInterface()
bool IvarBacksCurrentMethodAccessor(ObjCInterfaceDecl *IFace, ObjCMethodDecl *Method, ObjCIvarDecl *IV)
IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is an ivar synthesized for 'Meth...
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
bool isObjCPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType, bool &IncompatibleObjC)
isObjCPointerConversion - Determines whether this is an Objective-C pointer conversion.
bool isArithmeticType() const
Decl * ActOnProperty(Scope *S, SourceLocation AtLoc, SourceLocation LParenLoc, FieldDeclarator &FD, ObjCDeclSpec &ODS, Selector GetterSel, Selector SetterSel, tok::ObjCKeywordKind MethodImplKind, DeclContext *lexicalDC=nullptr)
Defines the SourceManager interface.
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
void setObjCLifetime(ObjCLifetime type)
static void CollectSuperClassPropertyImplementations(ObjCInterfaceDecl *CDecl, ObjCInterfaceDecl::PropertyMap &PropMap)
CollectSuperClassPropertyImplementations - This routine collects list of properties to be implemented...
bool isRecordType() const
llvm::SmallVector< ObjCPropertyDecl *, 8 > PropertyDeclOrder
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
void DiagnoseMissingDesignatedInitOverrides(const ObjCImplementationDecl *ImplD, const ObjCInterfaceDecl *IFD)
void CheckObjCPropertyAttributes(Decl *PropertyPtrTy, SourceLocation Loc, unsigned &Attributes, bool propertyInPrimaryClass)
Ensure attributes are consistent with type.
Captures information about "declaration specifiers" specific to Objective-C.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
static ObjCPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, SourceLocation AtLocation, SourceLocation LParenLocation, QualType T, TypeSourceInfo *TSI, PropertyControl propControl=None)
void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
StringRef getLastMacroWithSpelling(SourceLocation Loc, ArrayRef< TokenValue > Tokens) const
Return the name of the macro defined before Loc that has spelling Tokens.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
void setPropertyImplementation(PropertyControl pc)
A container of type source information.
void ProcessPropertyDecl(ObjCPropertyDecl *property)
Process the specified property declaration and create decls for the setters and getters as needed...
void setPropertyAccessor(bool isAccessor)
static bool areIncompatiblePropertyAttributes(unsigned Attr1, unsigned Attr2, unsigned Kinds)
Decl * ActOnPropertyImplDecl(Scope *S, SourceLocation AtLoc, SourceLocation PropertyLoc, bool ImplKind, IdentifierInfo *PropertyId, IdentifierInfo *PropertyIvar, SourceLocation PropertyIvarLoc, ObjCPropertyQueryKind QueryKind)
ActOnPropertyImplDecl - This routine performs semantic checks and builds the AST node for a property ...
StringRef getBufferData(FileID FID, bool *Invalid=nullptr) const
Return a StringRef to the source buffer data for the specified FileID.
RAII object to handle the state changes required to synthesize a function body.
const T * getAs() const
Member-template getAs<specific type>'.
static unsigned getOwnershipRule(unsigned attr)
ObjCMethodDecl - Represents an instance or class method declaration.
ObjCPropertyDecl * HandlePropertyInClassExtension(Scope *S, SourceLocation AtLoc, SourceLocation LParenLoc, FieldDeclarator &FD, Selector GetterSel, SourceLocation GetterNameLoc, Selector SetterSel, SourceLocation SetterNameLoc, const bool isReadWrite, unsigned &Attributes, const unsigned AttributesAsWritten, QualType T, TypeSourceInfo *TSI, tok::ObjCKeywordKind MethodImplKind)
Called by ActOnProperty to handle @property declarations in class extensions.
bool ClassImplementsProtocol(ObjCProtocolDecl *lProto, bool lookupCategory, bool RHSIsQualifiedID=false)
ClassImplementsProtocol - Checks that 'lProto' protocol has been implemented in IDecl class...
bool isInvalidDecl() const
static InitializedEntity InitializeResult(SourceLocation ReturnLoc, QualType Type, bool NRVO)
Create the initialization entity for the result of a function.
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
protocol_range protocols() const
Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
Parse and apply any fixits to the source.
The collection of all-type qualifiers we support.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
static void CollectImmediateProperties(ObjCContainerDecl *CDecl, ObjCContainerDecl::PropertyMap &PropMap, ObjCContainerDecl::PropertyMap &SuperPropMap, bool CollectClassPropsOnly=false, bool IncludeProtocols=true)
CollectImmediateProperties - This routine collects all properties in the class and its conforming pro...
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
instprop_range instance_properties() const
One of these records is kept for each identifier that is lexed.
SourceLocation getSetterNameLoc() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The results of name lookup within a DeclContext.
ObjCMethodDecl * getClassMethod(Selector Sel, bool AllowHidden=false) const
ObjCMethodFamily
A family of Objective-C methods.
instmeth_range instance_methods() const
method_range methods() const
Token - This structure provides full information about a lexed token.
prop_range properties() const
This little struct is used to capture information about structure field declarators, which is basically just a bitfield size.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
bool isClassProperty() const
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
void collectPropertiesToImplement(PropertyMap &PM, PropertyDeclOrder &PO) const override
This routine collects list of properties to be implemented in the class.
void setObjCWeakProperty(bool Val=true)
bool isNonFragile() const
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?
ObjCContainerDecl - Represents a container for method declarations.
static ObjCPropertyImplDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation atLoc, SourceLocation L, ObjCPropertyDecl *property, Kind PK, ObjCIvarDecl *ivarDecl, SourceLocation ivarLoc)
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing, variable initialization, and function return values.
Whether values of this type can be null is (explicitly) unspecified.
PropertyAttributeKind getPropertyAttributes() const
const ObjCInterfaceDecl * isObjCRequiresPropertyDefs() const
isObjCRequiresPropertyDefs - Checks that a class or one of its super classes must not be auto-synthes...
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
static void DiagnoseUnimplementedAccessor(Sema &S, ObjCInterfaceDecl *PrimaryClass, Selector Method, ObjCImplDecl *IMPDecl, ObjCContainerDecl *CDecl, ObjCCategoryDecl *C, ObjCPropertyDecl *Prop, llvm::SmallPtrSet< const ObjCMethodDecl *, 8 > &SMap)
bool isReadOnly() const
isReadOnly - Return true iff the property has a setter.
Values of this type can never be null.
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
Scope - A scope is a transient data structure that is used while parsing the program.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
Represents an Objective-C protocol declaration.
const LangOptions & getLangOpts() const
PropertyControl getPropertyImplementation() const
Represents an ObjC class declaration.
ObjCPropertyDecl * CreatePropertyDecl(Scope *S, ObjCContainerDecl *CDecl, SourceLocation AtLoc, SourceLocation LParenLoc, FieldDeclarator &FD, Selector GetterSel, SourceLocation GetterNameLoc, Selector SetterSel, SourceLocation SetterNameLoc, const bool isReadWrite, const unsigned Attributes, const unsigned AttributesAsWritten, QualType T, TypeSourceInfo *TSI, tok::ObjCKeywordKind MethodImplKind, DeclContext *lexicalDC=nullptr)
Called by ActOnProperty and HandlePropertyInClassExtension to handle creating the ObjcPropertyDecl fo...
QualType getReturnType() const
IdentifierInfo * getIdentifier() const
const LangOptions & LangOpts
This object can be modified without requiring retains or releases.
void AtomicPropertySetterGetterRules(ObjCImplDecl *IMPDecl, ObjCInterfaceDecl *IDecl)
AtomicPropertySetterGetterRules - This routine enforces the rule (via warning) when atomic property h...
void setGetterCXXConstructor(Expr *getterCXXConstructor)
void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddInstanceMethodToGlobalPool - All instance methods in a translation unit are added to a global pool...
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
void CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod, ObjCInterfaceDecl *CurrentClass, ResultTypeCompatibilityKind RTC)
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Sema - This implements semantic analysis and AST building for C.
static void AddPropertyAttrs(Sema &S, ObjCMethodDecl *PropertyMethod, ObjCPropertyDecl *Property)
AddPropertyAttrs - Propagates attributes from a property to the implicitly-declared getter or setter ...
bool isFragile() const
The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ...
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
llvm::SmallPtrSet< Selector, 8 > SelectorSet
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
void addObjCLifetime(ObjCLifetime type)
QualType getUsageType(QualType objectType) const
Retrieve the type of this instance variable when viewed as a member of a specific object type...
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
SourceLocation getBeginLoc() const
Get the begin source location.
bool isObjCGCStrong() const
true when Type is objc's strong.
Expr - This represents one expression.
known_extensions_range known_extensions() const
static ObjCMethodDecl * Create(ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc, Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo, DeclContext *contextDecl, bool isInstance=true, bool isVariadic=false, bool isPropertyAccessor=false, bool isImplicitlyDeclared=false, bool isDefined=false, ImplementationControl impControl=None, bool HasRelatedResultType=false)
Selector getSetterName() const
bool HasUserDeclaredSetterMethod(const ObjCPropertyDecl *P) const
This routine returns 'true' if a user declared setter method was found in the class, its protocols, its super classes or categories.
IdentifierInfo * getDefaultSynthIvarName(ASTContext &Ctx) const
Get the default name of the synthesized ivar.
bool isObjCARCImplicitlyUnretainedType() const
Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...
TypeSourceInfo * getTypeSourceInfo() const
bool isObjCRetainableType() const
static ObjCPropertyDecl::PropertyAttributeKind makePropertyAttributesAsWritten(unsigned Attributes)
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
static bool hasWrittenStorageAttribute(ObjCPropertyDecl *Prop, ObjCPropertyQueryKind QueryKind)
Determine whether any storage attributes were written on the property.
Defines the clang::Preprocessor interface.
DeclContext * getDeclContext()
ObjCInterfaceDecl * getSuperClass() const
Stores token information for comparing actual tokens with predefined values.
ObjCPropertyDecl * FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyVisibleInPrimaryClass - Finds declaration of the property with name 'PropertyId' in the p...
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
ParmVarDecl *const * param_iterator
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
clang::ObjCRuntime ObjCRuntime
propimpl_range property_impls() const
Qualifiers Quals
The local qualifiers.
llvm::SmallDenseSet< const ObjCProtocolDecl *, 8 > ProtocolPropertySet
bool isInstanceMethod() const
Preprocessor & getPreprocessor() const
Selector getSelector() const
SourceLocation getLocEnd() const LLVM_READONLY
static StringRef getIdentifier(const Token &Tok)
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const
Return the uniqued reference to the type for an Objective-C gc-qualified type.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
RecordDecl * getDecl() const
SourceLocation getLocStart() const LLVM_READONLY
There is no lifetime qualification on this type.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
Assigning into this object requires the old value to be released and the new value to be retained...
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Encodes a location in the source.
bool getSynthesize() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
void setPropertyAttributesAsWritten(PropertyAttributeKind PRVal)
static Qualifiers::ObjCLifetime getImpliedARCOwnership(ObjCPropertyDecl::PropertyAttributeKind attrs, QualType type)
getImpliedARCOwnership - Given a set of property attributes and a type, infer an expected lifetime...
ObjCPropertyAttributeKind getPropertyAttributes() const
ObjCCategoryDecl - Represents a category declaration.
void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl *IMPDecl, ObjCContainerDecl *CDecl, bool SynthesizeProperties)
DiagnoseUnimplementedProperties - This routine warns on those properties which must be implemented by...
Represents one property declaration in an Objective-C interface.
ObjCMethodDecl * lookupPropertyAccessor(const Selector Sel, const ObjCCategoryDecl *Cat, bool IsClassProperty) const
Lookup a setter or getter in the class hierarchy, including in all categories except for category pas...
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=NotForRedeclaration)
Find the protocol with the given name, if any.
ObjCPropertyImplDecl * FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const
FindPropertyImplIvarDecl - This method lookup the ivar in the list of properties implemented in this ...
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
Indicates that the nullability of the type was spelled with a property attribute rather than a type q...
Assigning into this object requires a lifetime extension.
bool hasFlexibleArrayMember() const
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void DiagnoseOwningPropertyGetterSynthesis(const ObjCImplementationDecl *D)
void setSetterCXXAssignment(Expr *setterCXXAssignment)
static void checkARCPropertyImpl(Sema &S, SourceLocation propertyImplLoc, ObjCPropertyDecl *property, ObjCIvarDecl *ivar)
bool isObjCGCWeak() const
true when Type is objc's weak.
bool propertyTypesAreCompatible(QualType, QualType)
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
const ObjCInterfaceDecl * getClassInterface() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
static void setImpliedPropertyAttributeForReadOnlyProperty(ObjCPropertyDecl *property, ObjCIvarDecl *ivar)
setImpliedPropertyAttributeForReadOnlyProperty - This routine evaludates life-time attributes for a '...
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
void diagnoseNullResettableSynthesizedSetters(const ObjCImplDecl *impDecl)
Diagnose any null-resettable synthesized setters.
void setGetterName(Selector Sel, SourceLocation Loc=SourceLocation())
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
static bool SuperClassImplementsProperty(ObjCInterfaceDecl *IDecl, ObjCPropertyDecl *Prop)
PropertyAttributeKind getPropertyAttributesAsWritten() const
The basic abstraction for the target Objective-C runtime.
SourceLocation getLocStart() const LLVM_READONLY
bool CheckARCMethodDecl(ObjCMethodDecl *method)
Check a method declaration for compatibility with the Objective-C ARC conventions.
llvm::DenseMap< std::pair< IdentifierInfo *, unsigned >, ObjCPropertyDecl * > PropertyMap
bool hasObjCLifetime() const
bool hasDesignatedInitializers() const
Returns true if this interface decl contains at least one initializer marked with the 'objc_designate...
Represents a pointer to an Objective C object.
static ObjCIvarDecl * Create(ASTContext &C, ObjCContainerDecl *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW=nullptr, bool synthesized=false)
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
void overwritePropertyAttributes(unsigned PRVal)
SourceLocation getGetterNameLoc() const
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
void addDecl(Decl *D)
Add the declaration D into this context.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance, bool shallowCategoryLookup=false, bool followSuper=true, const ObjCCategoryDecl *C=nullptr) const
lookupMethod - This method returns an instance/class method by looking in the class, its categories, and its super classes (using a linear search).
void setSetterName(Selector Sel, SourceLocation Loc=SourceLocation())
static void checkAtomicPropertyMismatch(Sema &S, ObjCPropertyDecl *OldProperty, ObjCPropertyDecl *NewProperty, bool PropagateAtomicity)
Check for a mismatch in the atomicity of the given properties.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
SourceManager & getSourceManager()
bool isObjCObjectType() const
bool IsClassExtension() const
SourceLocation getIdentifierLoc() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
static bool LocPropertyAttribute(ASTContext &Context, const char *attrName, SourceLocation LParenLoc, SourceLocation &Loc)
Reading or writing from this object requires a barrier call.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups, surround it with a ExprWithCleanups node.
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D...
Compatible - the types are compatible according to the standard.
ObjCPropertyImplDecl * FindPropertyImplDecl(IdentifierInfo *propertyId, ObjCPropertyQueryKind queryKind) const
FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl added to the list of thos...
ObjCIvarDecl - Represents an ObjC instance variable.
static unsigned deducePropertyOwnershipFromType(Sema &S, QualType T)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
void setPropertyAttributes(PropertyAttributeKind PRVal)
void DiagnosePropertyMismatch(ObjCPropertyDecl *Property, ObjCPropertyDecl *SuperProperty, const IdentifierInfo *Name, bool OverridingProtocolProperty)
DiagnosePropertyMismatch - Compares two properties for their attributes and types and warns on a vari...
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
bool isArcWeakrefUnavailable() const
isArcWeakrefUnavailable - Checks for a class or one of its super classes to be incompatible with __we...
static ObjCPropertyDecl * SelectPropertyForSynthesisFromProtocols(Sema &S, SourceLocation AtLoc, ObjCInterfaceDecl *ClassDecl, ObjCPropertyDecl *Property)
SelectPropertyForSynthesisFromProtocols - Finds the most appropriate property declaration that should...
bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD, ObjCMethodDecl *Getter, SourceLocation Loc)
void DefaultSynthesizeProperties(Scope *S, ObjCImplDecl *IMPDecl, ObjCInterfaceDecl *IDecl, SourceLocation AtEnd)
DefaultSynthesizeProperties - This routine default synthesizes all properties which must be synthesiz...
static const unsigned OwnershipMask
A reference to a declared variable, function, enum, etc.
void addPropertyImplementation(ObjCPropertyImplDecl *property)
static void CheckPropertyAgainstProtocol(Sema &S, ObjCPropertyDecl *Prop, ObjCProtocolDecl *Proto, llvm::SmallPtrSetImpl< ObjCProtocolDecl *> &Known)
Check this Objective-C property against a property declared in the given protocol.
An l-value expression is a reference to an object with independent storage.
A trivial tuple used to represent a source range.
void setLexicalDeclContext(DeclContext *DC)
ObjCMethodDecl * getGetterMethodDecl() const
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
llvm::DenseMap< const Stmt *, CFGBlock * > SMap
AccessControl getAccessControl() const
bool isPropertyAccessor() const
Selector getGetterName() const
SourceLocation getLParenLoc() const
void setType(QualType newType)
const LangOptions & getLangOpts() const
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
This class handles loading and caching of source files into memory.
static void checkPropertyDeclWithOwnership(Sema &S, ObjCPropertyDecl *property)
Check the internal consistency of a property declaration with an explicit ownership qualifier...
Attr - This represents one attribute.
SourceLocation getLocation() const
TypeSourceInfo * GetTypeForDeclarator(Declarator &D, Scope *S)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
QualType getType() const
Return the type wrapped by this type source info.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
static bool isIncompatiblePropertyAttribute(unsigned Attr1, unsigned Attr2, ObjCPropertyDecl::PropertyAttributeKind Kind)
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
ObjCCategoryDecl * FindCategoryDeclaration(IdentifierInfo *CategoryId) const
FindCategoryDeclaration - Finds category declaration in the list of categories for this class and ret...