24#include "llvm/ADT/DenseSet.h"
25#include "llvm/ADT/SmallString.h"
56 type->isObjCRetainableType()) {
71 =
property->getType().getObjCLifetime();
77 if (!expectedLifetime) {
91 property->setPropertyAttributes(
attr);
95 if (propertyLifetime == expectedLifetime)
return;
97 property->setInvalidDecl();
99 diag::err_arc_inconsistent_property_ownership)
100 <<
property->getDeclName()
110 llvm::SmallPtrSetImpl<ObjCProtocolDecl *> &Known) {
112 if (!Known.insert(Proto).second)
130 if (S.
getLangOpts().getGC() != LangOptions::NonGC) {
131 if (
T.isObjCGCWeak())
136 }
else if (
auto ownership =
T.getObjCLifetime()) {
148 llvm_unreachable(
"bad qualifier");
196 if (CDecl->IsClassExtension()) {
201 isReadWrite, Attributes,
203 T, TSI, MethodImplKind);
221 (isa<ObjCInterfaceDecl>(ClassDecl) ||
222 isa<ObjCProtocolDecl>(ClassDecl)));
231 bool FoundInSuper =
false;
240 CurrentInterfaceDecl = Super;
245 for (
auto *
P : CurrentInterfaceDecl->
protocols()) {
250 for (
auto *
P : IFace->all_referenced_protocols()) {
258 if (!Cat->IsClassExtension())
259 for (
auto *
P : Cat->protocols())
273 unsigned attributesAsWritten = 0;
312 std::pair<FileID, unsigned> locInfo =
SM.getDecomposedLoc(LParenLoc);
314 bool invalidTemp =
false;
315 StringRef file =
SM.getBufferData(locInfo.first, &invalidTemp);
318 const char *tokenBegin = file.data() + locInfo.second;
321 Lexer lexer(
SM.getLocForStartOfFile(locInfo.first),
323 file.begin(), tokenBegin, file.end());
331 }
while (Tok.
isNot(tok::r_paren));
339 bool PropagateAtomicity) {
345 if (OldIsAtomic == NewIsAtomic)
return;
351 auto Attrs =
Property->getPropertyAttributes();
360 if (
Property->getPropertyAttributesAsWritten() &
371 if (PropagateAtomicity &&
374 Attrs = Attrs & ~AtomicityMask;
386 if ((OldIsAtomic && isImplicitlyReadonlyAtomic(OldProperty)) ||
387 (NewIsAtomic && isImplicitlyReadonlyAtomic(NewProperty)))
393 if (
auto Category = dyn_cast<ObjCCategoryDecl>(OldDC))
394 OldContextName =
Category->getClassInterface()->getIdentifier();
396 OldContextName = cast<ObjCContainerDecl>(OldDC)->getIdentifier();
408 unsigned &Attributes,
const unsigned AttributesAsWritten,
QualType T,
423 bool isClassProperty =
434 Diag(AtLoc, diag::err_duplicate_property);
453 ? diag::err_use_continuation_class_redeclaration_readwrite
454 : diag::err_use_continuation_class;
465 Diag(AtLoc, diag::warn_property_redecl_getter_mismatch)
476 unsigned ExistingOwnership
479 if (ExistingOwnership && NewOwnership != ExistingOwnership) {
482 Diag(AtLoc, diag::warn_property_attr_mismatch);
487 Attributes = (Attributes & ~OwnershipMask) | ExistingOwnership;
496 Diag(AtLoc, diag::warn_property_implicitly_mismatched);
504 FD, GetterSel, GetterNameLoc,
505 SetterSel, SetterNameLoc,
507 Attributes, AttributesAsWritten,
508 T, TSI, MethodImplKind, DC);
518 bool IncompatibleObjC =
false;
528 if (!isa<ObjCObjectPointerType>(PrimaryClassPropertyT) ||
529 !isa<ObjCObjectPointerType>(ClassExtPropertyT) ||
531 PrimaryClassPropertyT, ConvertedType,
532 IncompatibleObjC)) ||
535 diag::err_type_mismatch_continuation_class) << PDecl->
getType();
555 const unsigned Attributes,
const unsigned AttributesAsWritten,
QualType T,
585 Diag(AtLoc, diag::warn_implements_nscopying) << PropertyId;
603 LParenLoc,
T, TInfo);
605 bool isClassProperty =
612 Diag(prevDecl->getLocation(), diag::note_property_declare);
622 Diag(AtLoc, diag::err_property_type) <<
T;
677 if (MethodImplKind == tok::objc_required)
679 else if (MethodImplKind == tok::objc_optional)
692 CDecl->
hasAttr<ObjCDirectMembersAttr>()) {
693 if (isa<ObjCProtocolDecl>(CDecl)) {
720 if (propertyLifetime == ivarLifetime)
return;
746 switch (propertyLifetime) {
749 <<
property->getDeclName()
756 <<
property->getDeclName()
763 << ((
property->getPropertyAttributesAsWritten() &
768 llvm_unreachable(
"properties cannot be autoreleasing");
777 S.
Diag(propertyImplLoc, diag::note_property_synthesize);
809 return (Attr1 & Kind) != (Attr2 & Kind);
814 return ((Attr1 & Kinds) != 0) != ((Attr2 & Kinds) != 0);
826 assert(isa<ObjCProtocolDecl>(
Property->getDeclContext()) &&
827 "Expected a property from a protocol");
832 PDecl->collectInheritedProtocolProperties(
Property, ProtocolSet,
837 for (
const auto *PI : SDecl->all_referenced_protocols()) {
839 PDecl->collectInheritedProtocolProperties(
Property, ProtocolSet,
842 SDecl = SDecl->getSuperClass();
846 if (Properties.empty())
850 size_t SelectedIndex = 0;
851 for (
const auto &Prop : llvm::enumerate(Properties)) {
853 if (
Property->isReadOnly() && !Prop.value()->isReadOnly()) {
855 SelectedIndex = Prop.index();
860 Properties[SelectedIndex] = OriginalProperty;
864 unsigned OriginalAttributes =
Property->getPropertyAttributesAsWritten();
866 IncompatibleType = 0,
867 HasNoExpectedAttribute,
868 HasUnexpectedAttribute,
874 struct MismatchingProperty {
877 StringRef AttributeName;
882 unsigned Attr = Prop->getPropertyAttributesAsWritten();
883 if (
Attr != OriginalAttributes) {
884 auto Diag = [&](
bool OriginalHasAttribute, StringRef AttributeName) {
885 MismatchKind Kind = OriginalHasAttribute ? HasNoExpectedAttribute
886 : HasUnexpectedAttribute;
887 Mismatches.push_back({Prop, Kind, AttributeName});
905 OriginalAttributes,
Attr,
910 "retain (or strong)");
919 if (
Property->getGetterName() != Prop->getGetterName()) {
920 Mismatches.push_back({Prop, DifferentGetter,
""});
923 if (!
Property->isReadOnly() && !Prop->isReadOnly() &&
924 Property->getSetterName() != Prop->getSetterName()) {
925 Mismatches.push_back({Prop, DifferentSetter,
""});
930 bool IncompatibleObjC =
false;
933 || IncompatibleObjC) {
934 Mismatches.push_back({Prop, IncompatibleType,
""});
940 if (Mismatches.empty())
945 bool HasIncompatibleAttributes =
false;
946 for (
const auto &
Note : Mismatches)
947 HasIncompatibleAttributes =
948 Note.Kind != IncompatibleType ?
true : HasIncompatibleAttributes;
952 Property != OriginalProperty || HasIncompatibleAttributes
953 ? diag::err_protocol_property_mismatch
954 : diag::warn_protocol_property_mismatch);
955 Diag << Mismatches[0].Kind;
956 switch (Mismatches[0].Kind) {
957 case IncompatibleType:
960 case HasNoExpectedAttribute:
961 case HasUnexpectedAttribute:
962 Diag << Mismatches[0].AttributeName;
964 case DifferentGetter:
967 case DifferentSetter:
972 for (
const auto &
Note : Mismatches) {
974 S.
Diag(
Note.Prop->getLocation(), diag::note_protocol_property_declare)
977 case IncompatibleType:
980 case HasNoExpectedAttribute:
981 case HasUnexpectedAttribute:
984 case DifferentGetter:
987 case DifferentSetter:
993 S.
Diag(AtLoc, diag::note_property_synthesize);
1015 auto OrigClass =
Category->getClassInterface();
1018 return OrigProp->getPropertyAttributesAsWritten() &
OwnershipMask;
1022 for (
const auto *Proto : OrigClass->all_referenced_protocols()) {
1025 return OrigProp->getPropertyAttributesAsWritten() &
OwnershipMask;
1040 Decl->getSelector(),
Decl->getReturnType(),
1041 Decl->getReturnTypeSourceInfo(), Impl,
Decl->isInstanceMethod(),
1042 Decl->isVariadic(),
Decl->isPropertyAccessor(),
1044 Decl->getImplementationControl(),
Decl->hasRelatedResultType());
1051 Decl->getSelectorLocs(SelLocs);
1070 if (!ClassImpDecl) {
1071 Diag(AtLoc, diag::err_missing_property_context);
1075 PropertyIvarLoc = PropertyLoc;
1085 if ((IC = dyn_cast<ObjCImplementationDecl>(ClassImpDecl))) {
1090 "ActOnPropertyImplDecl - @implementation without @interface");
1095 Diag(PropertyLoc, diag::err_bad_property_decl) << IDecl->
getDeclName();
1098 if (property->isClassProperty() && Synthesize) {
1099 Diag(PropertyLoc, diag::err_synthesize_on_class_property) << PropertyId;
1102 unsigned PIkind =
property->getPropertyAttributesAsWritten();
1106 Diag(AtLoc, diag::warn_implicit_atomic_property);
1109 Diag(property->getLocation(), diag::note_property_declare);
1113 dyn_cast<ObjCCategoryDecl>(property->getDeclContext())) {
1114 if (!CD->IsClassExtension()) {
1115 Diag(PropertyLoc, diag::err_category_property) << CD->getDeclName();
1116 Diag(property->getLocation(), diag::note_property_declare);
1121 property->hasAttr<IBOutletAttr>() && !AtLoc.
isValid()) {
1122 bool ReadWriteProperty =
false;
1128 PIkind = ExtProp->getPropertyAttributesAsWritten();
1130 ReadWriteProperty =
true;
1136 if (!ReadWriteProperty) {
1137 Diag(property->getLocation(), diag::warn_auto_readonly_iboutlet_property)
1141 property->getLParenLoc(), readonlyLoc)) {
1144 SourceRange ReadonlySourceRange(readonlyLoc, endLoc);
1145 Diag(property->getLocation(),
1146 diag::note_auto_readonly_iboutlet_fixup_suggest) <<
1151 if (Synthesize && isa<ObjCProtocolDecl>(property->getDeclContext()))
1155 }
else if ((CatImplClass = dyn_cast<ObjCCategoryImplDecl>(ClassImpDecl))) {
1157 Diag(AtLoc, diag::err_synthesize_category_decl);
1162 Diag(AtLoc, diag::err_missing_property_interface);
1173 property =
Category->FindPropertyDeclaration(PropertyId, QueryKind);
1175 Diag(PropertyLoc, diag::err_bad_category_property_decl)
1180 Diag(AtLoc, diag::err_bad_property_context);
1184 bool CompleteTypeErr =
false;
1190 PropertyIvar = PropertyId;
1194 QualType PropType =
property->getType();
1198 diag::err_incomplete_synthesized_property,
1199 property->getDeclName())) {
1200 Diag(property->getLocation(), diag::note_property_declare);
1201 CompleteTypeErr =
true;
1205 (property->getPropertyAttributesAsWritten() &
1213 bool isARCWeak =
false;
1219 Diag(PropertyDiagLoc, diag::err_gc_weak_property_strong_type);
1220 Diag(property->getLocation(), diag::note_property_declare);
1232 Diag(PropertyDiagLoc,
1234 ? diag::err_synthesizing_arc_weak_property_disabled
1235 : diag::err_synthesizing_arc_weak_property_no_runtime);
1236 Diag(property->getLocation(), diag::note_property_declare);
1238 CompleteTypeErr =
true;
1245 Diag(property->getLocation(),
1246 diag::err_arc_weak_unavailable_property)
1247 << PropertyIvarType;
1266 Diag(PropertyDiagLoc,
1267 diag::warn_autosynthesis_property_ivar_match)
1268 << PropertyId << (Ivar ==
nullptr) << PropertyIvar
1270 Diag(property->getLocation(), diag::note_property_declare);
1278 if ((
getLangOpts().ObjCAutoRefCount || isARCWeak) &&
1286 Diag(PropertyDiagLoc,
1287 diag::err_arc_objc_property_default_assign_on_object);
1288 Diag(property->getLocation(), diag::note_property_declare);
1292 assert(lifetime &&
"no lifetime for property?");
1301 PropertyIvarLoc,PropertyIvarLoc, PropertyIvar,
1302 PropertyIvarType,
nullptr,
1304 (
Expr *)
nullptr,
true);
1306 diag::err_abstract_type_in_decl,
1308 Diag(property->getLocation(), diag::note_property_declare);
1310 CompleteTypeErr =
true;
1312 if (!CompleteTypeErr) {
1315 Diag(PropertyIvarLoc, diag::err_synthesize_variable_sized_ivar)
1316 << PropertyIvarType;
1317 CompleteTypeErr =
true;
1320 if (CompleteTypeErr)
1326 Diag(PropertyDiagLoc, diag::err_missing_property_ivar_decl)
1332 Diag(PropertyDiagLoc, diag::err_ivar_in_superclass_use)
1339 property->setPropertyIvarDecl(Ivar);
1344 if (!Context.
hasSameType(PropertyIvarType, IvarType)) {
1345 if (isa<ObjCObjectPointerType>(PropertyIvarType)
1346 && isa<ObjCObjectPointerType>(IvarType))
1352 PropertyIvarLoc, PropertyIvarType, IvarType) ==
1356 Diag(PropertyDiagLoc, diag::err_property_ivar_type)
1357 <<
property->getDeclName() << PropType
1369 if (lhsType != rhsType &&
1371 Diag(PropertyDiagLoc, diag::err_property_ivar_type)
1372 <<
property->getDeclName() << PropType
1381 Diag(PropertyDiagLoc, diag::err_weak_property)
1382 <<
property->getDeclName() << Ivar->
getDeclName();
1387 if ((property->getType()->isObjCObjectPointerType() ||
1390 Diag(PropertyDiagLoc, diag::err_strong_property)
1391 <<
property->getDeclName() << Ivar->
getDeclName();
1395 if (
getLangOpts().ObjCAutoRefCount || isARCWeak ||
1398 }
else if (PropertyIvar)
1400 Diag(PropertyDiagLoc, diag::err_dynamic_property_ivar_decl);
1402 assert (property &&
"ActOnPropertyImplDecl - property declaration missing");
1407 Ivar, PropertyIvarLoc);
1409 if (CompleteTypeErr || !compat)
1412 if (
ObjCMethodDecl *getterMethod = property->getGetterMethodDecl()) {
1413 getterMethod->createImplicitParams(Context, IDecl);
1419 getterMethod->getSelector(), getterMethod->isInstanceMethod());
1438 Context, SelfDecl->
getType(), CK_LValueToRValue, SelfExpr,
nullptr,
1445 LoadSelfExpr,
true,
true);
1448 getterMethod->getReturnType()),
1449 PropertyDiagLoc, IvarRefExpr);
1457 if (property->hasAttr<NSReturnsNotRetainedAttr>() &&
1458 !getterMethod->hasAttr<NSReturnsNotRetainedAttr>()) {
1459 Diag(getterMethod->getLocation(),
1460 diag::warn_property_getter_owning_mismatch);
1461 Diag(property->getLocation(), diag::note_property_declare);
1464 switch (getterMethod->getMethodFamily()) {
1469 Diag(getterMethod->getLocation(), diag::err_arc_illegal_method_def)
1470 << 1 << getterMethod->getSelector();
1477 if (
ObjCMethodDecl *setterMethod = property->getSetterMethodDecl()) {
1478 setterMethod->createImplicitParams(Context, IDecl);
1483 setterMethod->getSelector(), setterMethod->isInstanceMethod());
1486 AtLoc, PropertyLoc);
1500 Context, SelfDecl->
getType(), CK_LValueToRValue, SelfExpr,
nullptr,
1507 LoadSelfExpr,
true,
true);
1516 if (property->getPropertyAttributes() &
1520 dyn_cast_or_null<CXXOperatorCallExpr>(
callExpr))
1521 if (
const FunctionDecl *FuncDecl = CXXCE->getDirectCallee())
1522 if (!FuncDecl->isTrivial())
1523 if (property->getType()->isReferenceType()) {
1524 Diag(PropertyDiagLoc,
1525 diag::err_atomic_property_nontrivial_assign_op)
1526 <<
property->getType();
1527 Diag(FuncDecl->getBeginLoc(), diag::note_callee_decl)
1539 Diag(PropertyLoc, diag::err_duplicate_ivar_use)
1540 << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()
1542 Diag(PPIDecl->getLocation(), diag::note_previous_use);
1547 Diag(PropertyLoc, diag::err_property_implemented) << PropertyId;
1548 Diag(PPIDecl->getLocation(), diag::note_previous_declaration);
1563 if (PropertyIvar && PropertyIvar != PropertyId)
1578 Diag(PropertyDiagLoc, diag::err_duplicate_ivar_use)
1579 << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()
1581 Diag(PPIDecl->getLocation(), diag::note_previous_use);
1586 Diag(PropertyDiagLoc, diag::err_property_implemented) << PropertyId;
1587 Diag(PPIDecl->getLocation(), diag::note_previous_declaration);
1596 Diag(PropertyLoc, diag::err_objc_direct_dynamic_property);
1598 diag::note_previous_declaration);
1615 bool OverridingProtocolProperty) {
1623 if (!OverridingProtocolProperty &&
1629 Diag(
Property->getLocation(), diag::warn_readonly_property)
1630 <<
Property->getDeclName() << inheritedName;
1633 Diag(
Property->getLocation(), diag::warn_property_attribute)
1634 <<
Property->getDeclName() <<
"copy" << inheritedName;
1640 bool CStrong = (CAttrRetain != 0);
1641 bool SStrong = (SAttrRetain != 0);
1642 if (CStrong != SStrong)
1643 Diag(
Property->getLocation(), diag::warn_property_attribute)
1644 <<
Property->getDeclName() <<
"retain (or strong)" << inheritedName;
1657 Diag(
Property->getLocation(), diag::warn_property_attribute)
1658 <<
Property->getDeclName() <<
"setter" << inheritedName;
1662 Diag(
Property->getLocation(), diag::warn_property_attribute)
1663 <<
Property->getDeclName() <<
"getter" << inheritedName;
1675 bool IncompatibleObjC =
false;
1678 IncompatibleObjC) ||
1680 Diag(
Property->getLocation(), diag::warn_property_types_are_incompatible)
1695 property->getType().getNonReferenceType().getAtomicUnqualifiedType();
1696 bool compat = Context.
hasSameType(PropertyRValueType, GetterType);
1700 if ((propertyObjCPtr =
1706 Diag(
Loc, diag::err_property_accessor_type)
1707 <<
property->getDeclName() << PropertyRValueType
1721 Diag(
Loc, diag::warn_accessor_property_type_mismatch)
1722 <<
property->getDeclName()
1737 bool CollectClassPropsOnly =
false,
1738 bool IncludeProtocols =
true) {
1740 for (
auto *Prop : IDecl->properties()) {
1741 if (CollectClassPropsOnly && !Prop->isClassProperty())
1743 PropMap[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] =
1748 for (
auto *Ext : IDecl->visible_extensions())
1750 CollectClassPropsOnly, IncludeProtocols);
1752 if (IncludeProtocols) {
1754 for (
auto *PI : IDecl->all_referenced_protocols())
1756 CollectClassPropsOnly);
1760 for (
auto *Prop : CATDecl->properties()) {
1761 if (CollectClassPropsOnly && !Prop->isClassProperty())
1763 PropMap[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] =
1766 if (IncludeProtocols) {
1768 for (
auto *PI : CATDecl->protocols())
1770 CollectClassPropsOnly);
1774 for (
auto *Prop : PDecl->properties()) {
1775 if (CollectClassPropsOnly && !Prop->isClassProperty())
1778 SuperPropMap[std::make_pair(Prop->getIdentifier(),
1779 Prop->isClassProperty())];
1782 if (!PropertyFromSuper ||
1783 PropertyFromSuper->
getIdentifier() != Prop->getIdentifier()) {
1785 PropMap[std::make_pair(Prop->getIdentifier(),
1786 Prop->isClassProperty())];
1792 for (
auto *PI : PDecl->protocols())
1794 CollectClassPropsOnly);
1805 SDecl->collectPropertiesToImplement(PropMap);
1806 SDecl = SDecl->getSuperClass();
1829 (
Property->getPropertyIvarDecl() == IV))
1835 for (
const auto *
Property : Ext->instance_properties())
1838 (
Property->getPropertyIvarDecl() == IV))
1845 bool SuperClassImplementsGetter =
false;
1846 bool SuperClassImplementsSetter =
false;
1848 SuperClassImplementsSetter =
true;
1853 SuperClassImplementsGetter =
true;
1856 SuperClassImplementsSetter =
true;
1857 if (SuperClassImplementsGetter && SuperClassImplementsSetter)
1872 if (PropMap.empty())
1877 for (
const auto &PropEntry : PropMap) {
1889 if (ImpMethod && !ImpMethod->
getBody()) {
1893 if (ImpMethod && !ImpMethod->
getBody())
1898 Diag(Prop->
getLocation(), diag::warn_no_autosynthesis_shared_ivar_property)
1900 if (PID->getLocation().isValid())
1901 Diag(PID->getLocation(), diag::note_property_synthesize);
1915 diag::warn_auto_synthesizing_protocol_property)
1919 (Twine(
"@synthesize ") + Prop->
getName() +
";\n\n").str();
1920 Diag(AtEnd, diag::note_add_synthesize_directive)
1926 if (PropInSuperClass) {
1937 Diag(Prop->
getLocation(), diag::warn_autosynthesis_property_in_superclass)
1970 if (!IDecl->isObjCRequiresPropertyDefs())
1989 if (I ==
SMap.end() &&
1990 (PrimaryClass ==
nullptr ||
1994 isa<ObjCCategoryDecl>(CDecl)
1996 ? diag::warn_impl_required_in_category_for_class_property
1997 : diag::warn_setter_getter_impl_required_in_category)
1999 ? diag::warn_impl_required_for_class_property
2000 : diag::warn_setter_getter_impl_required);
2003 if (S.
LangOpts.ObjCDefaultSynthProperties &&
2007 S.
Diag(RID->getLocation(), diag::note_suppressed_class_declare);
2013 bool SynthesizeProperties) {
2027 if ((IDecl =
C->getClassInterface())) {
2036 SynthesizeProperties);
2042 std::unique_ptr<ObjCContainerDecl::PropertyMap> LazyMap;
2045 if (!PDecl->hasAttr<ObjCExplicitProtocolImplAttr>())
2063 for (
auto *PropDecl : PDecl->properties()) {
2064 if ((*LazyMap)[std::make_pair(PropDecl->getIdentifier(),
2065 PropDecl->isClassProperty())])
2067 PropMap[std::make_pair(PropDecl->getIdentifier(),
2068 PropDecl->isClassProperty())] = PropDecl;
2073 if (PropMap.empty())
2076 llvm::DenseSet<ObjCPropertyDecl *> PropImplMap;
2078 PropImplMap.insert(I->getPropertyDecl());
2082 for (
const auto *I : IMPDecl->
methods())
2087 if (
C && !
C->IsClassExtension())
2088 if ((PrimaryClass =
C->getClassInterface()))
2094 for (
const auto *I : IMP->methods())
2098 for (ObjCContainerDecl::PropertyMap::iterator
2099 P = PropMap.begin(),
E = PropMap.end();
P !=
E; ++
P) {
2104 PropImplMap.count(Prop) ||
2110 IMPDecl, CDecl,
C, Prop, InsMap);
2121 const auto *
property = propertyImpl->getPropertyDecl();
2124 if (propertyImpl->getPropertyImplementation() ==
2126 (property->getPropertyAttributes() &
2128 property->getGetterMethodDecl() && property->getSetterMethodDecl()) {
2129 auto *getterImpl = propertyImpl->getGetterMethodDecl();
2130 auto *setterImpl = propertyImpl->getSetterMethodDecl();
2131 if ((!getterImpl || getterImpl->isSynthesizedAccessorStub()) &&
2132 (!setterImpl || setterImpl->isSynthesizedAccessorStub())) {
2137 Diag(loc, diag::warn_null_resettable_setter)
2138 << setterImpl->getSelector() <<
property->getDeclName();
2151 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
2153 for (
auto *Prop : Ext->properties())
2154 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
2156 for (ObjCContainerDecl::PropertyMap::iterator I = PM.begin(),
E = PM.end();
2162 unsigned Attributes =
Property->getPropertyAttributes();
2163 unsigned AttributesAsWritten =
Property->getPropertyAttributesAsWritten();
2167 GetterMethod =
Property->isClassProperty() ?
2170 SetterMethod =
Property->isClassProperty() ?
2174 GetterMethod =
nullptr;
2176 SetterMethod =
nullptr;
2179 diag::warn_default_atomic_custom_getter_setter)
2181 Diag(
Property->getLocation(), diag::note_property_declare);
2185 diag::warn_default_atomic_custom_getter_setter)
2187 Diag(
Property->getLocation(), diag::note_property_declare);
2199 GetterMethod = PIDecl->getGetterMethodDecl();
2200 SetterMethod = PIDecl->getSetterMethodDecl();
2202 GetterMethod =
nullptr;
2204 SetterMethod =
nullptr;
2205 if ((
bool)GetterMethod ^ (
bool)SetterMethod) {
2208 : SetterMethod->getLocation());
2209 Diag(MethodLoc, diag::warn_atomic_property_rule)
2210 <<
Property->getIdentifier() << (GetterMethod !=
nullptr)
2211 << (SetterMethod !=
nullptr);
2213 if (
Property->getLParenLoc().isValid() &&
2218 StringRef NonatomicStr = AttributesAsWritten?
"nonatomic, "
2221 diag::note_atomic_property_fixup_suggest)
2223 }
else if (
Property->getLParenLoc().isInvalid()) {
2226 Property->getTypeSourceInfo()->getTypeLoc().getBeginLoc();
2228 diag::note_atomic_property_fixup_suggest)
2231 Diag(MethodLoc, diag::note_atomic_property_fixup_suggest);
2232 Diag(
Property->getLocation(), diag::note_property_declare);
2243 for (
const auto *PID :
D->property_impls()) {
2245 if (PD && !PD->
hasAttr<NSReturnsNotRetainedAttr>() &&
2265 for (
auto *getterRedecl : method->
redecls()) {
2266 if (getterRedecl->isImplicit())
2270 noteLoc = getterRedecl->getLocation();
2271 fixItLoc = getterRedecl->getEndLoc();
2276 tok::kw___attribute, tok::l_paren, tok::l_paren,
2279 tok::r_paren, tok::r_paren
2281 StringRef spelling =
"__attribute__((objc_method_family(none)))";
2283 if (!macroName.empty())
2284 spelling = macroName;
2286 auto noteDiag =
Diag(noteLoc, diag::note_cocoa_naming_declare_family)
2290 fixItText += spelling;
2307 if (I->getMethodFamily() ==
OMF_init)
2308 InitSelSet.insert(I->getSelector());
2313 I = DesignatedInits.begin(),
E = DesignatedInits.end(); I !=
E; ++I) {
2318 bool Ignore =
false;
2324 if (
auto *IMD = Ext->getInstanceMethod(MD->
getSelector())) {
2325 Ignore = IMD->isUnavailable();
2331 diag::warn_objc_implementation_missing_designated_init_override)
2344 for (
const auto *A :
Property->attrs()) {
2345 if (isa<DeprecatedAttr>(A) ||
2346 isa<UnavailableAttr>(A) ||
2347 isa<AvailabilityAttr>(A))
2363 bool IsClassProperty =
property->isClassProperty();
2364 GetterMethod = IsClassProperty ?
2372 if (CatDecl->IsClassExtension())
2375 CatDecl->getClassInterface()->
2378 SetterMethod = IsClassProperty ?
2383 if (CatDecl->IsClassExtension())
2386 CatDecl->getClassInterface()->
2393 if (!GetterMethod) {
2395 auto *ExistingGetter = CatDecl->getClassInterface()->lookupMethod(
2396 property->
getGetterName(), !IsClassProperty,
true,
false, CatDecl);
2397 if (ExistingGetter) {
2400 <<
property->isDirectProperty() << 1
2401 << ExistingGetter->isDirectMethod()
2402 << ExistingGetter->getDeclName();
2403 Diag(ExistingGetter->getLocation(), diag::note_previous_declaration);
2409 if (!property->
isReadOnly() && !SetterMethod) {
2411 auto *ExistingSetter = CatDecl->getClassInterface()->lookupMethod(
2412 property->
getSetterName(), !IsClassProperty,
true,
false, CatDecl);
2413 if (ExistingSetter) {
2416 <<
property->isDirectProperty() << 1
2417 << ExistingSetter->isDirectMethod()
2418 << ExistingSetter->getDeclName();
2419 Diag(ExistingSetter->getLocation(), diag::note_previous_declaration);
2425 if (!property->
isReadOnly() && SetterMethod) {
2431 (*SetterMethod->
param_begin())->getType().getNonReferenceType(),
2434 diag::warn_accessor_property_type_mismatch)
2435 <<
property->getDeclName()
2447 if (!GetterMethod) {
2455 QualType resultTy =
property->getType().getAtomicUnqualifiedType();
2464 modifiedTy, modifiedTy);
2470 !IsClassProperty,
false,
2481 GetterMethod->
addAttr(ObjCDirectAttr::CreateImplicit(Context,
Loc));
2483 if (property->
hasAttr<NSReturnsNotRetainedAttr>())
2484 GetterMethod->
addAttr(NSReturnsNotRetainedAttr::CreateImplicit(Context,
2487 if (property->
hasAttr<ObjCReturnsInnerPointerAttr>())
2489 ObjCReturnsInnerPointerAttr::CreateImplicit(Context,
Loc));
2491 if (
const SectionAttr *SA = property->
getAttr<SectionAttr>())
2492 GetterMethod->
addAttr(SectionAttr::CreateImplicit(
2493 Context, SA->getName(),
Loc, SectionAttr::GNU_section));
2506 property->setGetterMethodDecl(GetterMethod);
2511 if (!SetterMethod) {
2520 CD, !IsClassProperty,
2532 property->getType().getUnqualifiedType().getAtomicUnqualifiedType();
2542 modifiedTy, modifiedTy);
2560 SetterMethod->
addAttr(ObjCDirectAttr::CreateImplicit(Context,
Loc));
2563 if (
const SectionAttr *SA = property->
getAttr<SectionAttr>())
2564 SetterMethod->
addAttr(SectionAttr::CreateImplicit(
2565 Context, SA->getName(),
Loc, SectionAttr::GNU_section));
2580 property->setSetterMethodDecl(SetterMethod);
2594 if (!IsClassProperty) {
2607 if (!CurrentClass) {
2609 CurrentClass = Cat->getClassInterface();
2610 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(CD))
2611 CurrentClass = Impl->getClassInterface();
2620 unsigned &Attributes,
2621 bool propertyInPrimaryClass) {
2628 Diag(
Loc, diag::err_objc_property_attr_mutually_exclusive)
2629 <<
"readonly" <<
"readwrite";
2640 !PropertyDecl->
hasAttr<ObjCNSObjectAttr>()) {
2641 Diag(
Loc, diag::err_objc_property_requires_object)
2646 :
"retain (or strong)");
2659 Diag(
Loc, diag::warn_objc_property_assign_on_object);
2665 Diag(
Loc, diag::err_objc_property_attr_mutually_exclusive)
2666 <<
"assign" <<
"copy";
2667 Attributes &= ~ObjCPropertyAttribute::kind_copy;
2670 Diag(
Loc, diag::err_objc_property_attr_mutually_exclusive)
2671 <<
"assign" <<
"retain";
2672 Attributes &= ~ObjCPropertyAttribute::kind_retain;
2675 Diag(
Loc, diag::err_objc_property_attr_mutually_exclusive)
2676 <<
"assign" <<
"strong";
2677 Attributes &= ~ObjCPropertyAttribute::kind_strong;
2681 Diag(
Loc, diag::err_objc_property_attr_mutually_exclusive)
2682 <<
"assign" <<
"weak";
2683 Attributes &= ~ObjCPropertyAttribute::kind_weak;
2685 if (PropertyDecl->
hasAttr<IBOutletCollectionAttr>())
2686 Diag(
Loc, diag::warn_iboutletcollection_property_assign);
2689 Diag(
Loc, diag::err_objc_property_attr_mutually_exclusive)
2690 <<
"unsafe_unretained" <<
"copy";
2691 Attributes &= ~ObjCPropertyAttribute::kind_copy;
2694 Diag(
Loc, diag::err_objc_property_attr_mutually_exclusive)
2695 <<
"unsafe_unretained" <<
"retain";
2696 Attributes &= ~ObjCPropertyAttribute::kind_retain;
2699 Diag(
Loc, diag::err_objc_property_attr_mutually_exclusive)
2700 <<
"unsafe_unretained" <<
"strong";
2701 Attributes &= ~ObjCPropertyAttribute::kind_strong;
2705 Diag(
Loc, diag::err_objc_property_attr_mutually_exclusive)
2706 <<
"unsafe_unretained" <<
"weak";
2707 Attributes &= ~ObjCPropertyAttribute::kind_weak;
2711 Diag(
Loc, diag::err_objc_property_attr_mutually_exclusive)
2712 <<
"copy" <<
"retain";
2713 Attributes &= ~ObjCPropertyAttribute::kind_retain;
2716 Diag(
Loc, diag::err_objc_property_attr_mutually_exclusive)
2717 <<
"copy" <<
"strong";
2718 Attributes &= ~ObjCPropertyAttribute::kind_strong;
2721 Diag(
Loc, diag::err_objc_property_attr_mutually_exclusive)
2722 <<
"copy" <<
"weak";
2723 Attributes &= ~ObjCPropertyAttribute::kind_weak;
2727 Diag(
Loc, diag::err_objc_property_attr_mutually_exclusive) <<
"retain"
2729 Attributes &= ~ObjCPropertyAttribute::kind_retain;
2732 Diag(
Loc, diag::err_objc_property_attr_mutually_exclusive) <<
"strong"
2734 Attributes &= ~ObjCPropertyAttribute::kind_weak;
2741 Diag(
Loc, diag::err_objc_property_attr_mutually_exclusive)
2742 <<
"nonnull" <<
"weak";
2748 Diag(
Loc, diag::err_objc_property_attr_mutually_exclusive) <<
"atomic"
2750 Attributes &= ~ObjCPropertyAttribute::kind_atomic;
2769 else if (propertyInPrimaryClass) {
2774 Diag(
Loc, diag::warn_objc_property_no_assignment_attribute);
2778 Diag(
Loc, diag::warn_objc_property_default_assign_on_object);
2790 Diag(
Loc, diag::warn_objc_property_copy_missing_on_block);
2795 Diag(
Loc, diag::warn_objc_property_retain_of_block);
2799 Diag(
Loc, diag::warn_objc_readonly_property_has_setter);
llvm::DenseMap< const Stmt *, CFGBlock * > SMap
enum clang::sema::@1655::IndirectLocalPathEntry::EntryKind Kind
Defines the clang::Expr interface and subclasses for C++ expressions.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Defines the clang::Preprocessor interface.
static bool SuperClassImplementsProperty(ObjCInterfaceDecl *IDecl, ObjCPropertyDecl *Prop)
static bool areIncompatiblePropertyAttributes(unsigned Attr1, unsigned Attr2, unsigned Kinds)
static Qualifiers::ObjCLifetime getImpliedARCOwnership(ObjCPropertyAttribute::Kind attrs, QualType type)
getImpliedARCOwnership - Given a set of property attributes and a type, infer an expected lifetime.
static void checkARCPropertyImpl(Sema &S, SourceLocation propertyImplLoc, ObjCPropertyDecl *property, ObjCIvarDecl *ivar)
static bool LocPropertyAttribute(ASTContext &Context, const char *attrName, SourceLocation LParenLoc, SourceLocation &Loc)
static void AddPropertyAttrs(Sema &S, ObjCMethodDecl *PropertyMethod, ObjCPropertyDecl *Property)
AddPropertyAttrs - Propagates attributes from a property to the implicitly-declared getter or setter ...
static void checkPropertyDeclWithOwnership(Sema &S, ObjCPropertyDecl *property)
Check the internal consistency of a property declaration with an explicit ownership qualifier.
static unsigned deducePropertyOwnershipFromType(Sema &S, QualType T)
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...
static void checkAtomicPropertyMismatch(Sema &S, ObjCPropertyDecl *OldProperty, ObjCPropertyDecl *NewProperty, bool PropagateAtomicity)
Check for a mismatch in the atomicity of the given properties.
static void setImpliedPropertyAttributeForReadOnlyProperty(ObjCPropertyDecl *property, ObjCIvarDecl *ivar)
setImpliedPropertyAttributeForReadOnlyProperty - This routine evaludates life-time attributes for a '...
static unsigned getOwnershipRule(unsigned attr)
static ObjCMethodDecl * RedeclarePropertyAccessor(ASTContext &Context, ObjCImplementationDecl *Impl, ObjCMethodDecl *AccessorDecl, SourceLocation AtLoc, SourceLocation PropertyLoc)
Create a synthesized property accessor stub inside the @implementation.
static bool hasWrittenStorageAttribute(ObjCPropertyDecl *Prop, ObjCPropertyQueryKind QueryKind)
Determine whether any storage attributes were written on the property.
static void CollectSuperClassPropertyImplementations(ObjCInterfaceDecl *CDecl, ObjCInterfaceDecl::PropertyMap &PropMap)
CollectSuperClassPropertyImplementations - This routine collects list of properties to be implemented...
static const unsigned OwnershipMask
static void DiagnoseUnimplementedAccessor(Sema &S, ObjCInterfaceDecl *PrimaryClass, Selector Method, ObjCImplDecl *IMPDecl, ObjCContainerDecl *CDecl, ObjCCategoryDecl *C, ObjCPropertyDecl *Prop, llvm::SmallPtrSet< const ObjCMethodDecl *, 8 > &SMap)
static ObjCPropertyDecl * SelectPropertyForSynthesisFromProtocols(Sema &S, SourceLocation AtLoc, ObjCInterfaceDecl *ClassDecl, ObjCPropertyDecl *Property)
SelectPropertyForSynthesisFromProtocols - Finds the most appropriate property declaration that should...
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.
static ObjCPropertyAttribute::Kind makePropertyAttributesAsWritten(unsigned Attributes)
static bool isIncompatiblePropertyAttribute(unsigned Attr1, unsigned Attr2, ObjCPropertyAttribute::Kind Kind)
This file declares semantic analysis for Objective-C.
Defines the SourceManager interface.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType) const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
bool propertyTypesAreCompatible(QualType, QualType)
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
const LangOptions & getLangOpts() const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const
Return the uniqued reference to the type for an Objective-C gc-qualified type.
Attr - This represents one attribute.
static std::optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
A call to an overloaded operator written using operator syntax.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
The results of name lookup within a DeclContext.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
void addDecl(Decl *D)
Add the declaration D into this context.
A reference to a declared variable, function, enum, etc.
Decl - This represents one declaration (or definition), e.g.
SourceLocation getEndLoc() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
void setAttrs(const AttrVec &Attrs)
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isInvalidDecl() const
SourceLocation getLocation() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
DeclContext * getDeclContext()
SourceLocation getBeginLoc() const LLVM_READONLY
void setLexicalDeclContext(DeclContext *DC)
SourceLocation getIdentifierLoc() const
void setObjCWeakProperty(bool Val=true)
const IdentifierInfo * getIdentifier() const
This represents one expression.
Represents difference between two FPOptions values.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
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.
Represents a function declaration or definition.
One of these records is kept for each identifier that is lexed.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
static InitializedEntity InitializeResult(SourceLocation ReturnLoc, QualType Type)
Create the initialization entity for the result of a function.
clang::ObjCRuntime ObjCRuntime
Lexer - This provides a simple interface that turns a text buffer into a stream of tokens.
bool LexFromRawLexer(Token &Result)
LexFromRawLexer - Lex a token from a designated raw lexer (one with no associated preprocessor object...
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
ObjCCategoryDecl - Represents a category declaration.
ObjCInterfaceDecl * getClassInterface()
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
ObjCContainerDecl - Represents a container for method declarations.
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
method_range methods() const
llvm::MapVector< std::pair< IdentifierInfo *, unsigned >, ObjCPropertyDecl * > PropertyMap
instmeth_range instance_methods() const
llvm::SmallDenseSet< const ObjCProtocolDecl *, 8 > ProtocolPropertySet
ObjCPropertyDecl * getProperty(const IdentifierInfo *Id, bool IsInstance) const
instprop_range instance_properties() const
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
ObjCMethodDecl * getClassMethod(Selector Sel, bool AllowHidden=false) const
prop_range properties() const
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
bool HasUserDeclaredSetterMethod(const ObjCPropertyDecl *P) const
This routine returns 'true' if a user declared setter method was found in the class,...
Captures information about "declaration specifiers" specific to Objective-C.
ObjCPropertyAttribute::Kind getPropertyAttributes() const
SourceLocation getGetterNameLoc() const
SourceLocation getSetterNameLoc() const
void addPropertyImplementation(ObjCPropertyImplDecl *property)
propimpl_range property_impls() const
ObjCPropertyImplDecl * FindPropertyImplDecl(IdentifierInfo *propertyId, ObjCPropertyQueryKind queryKind) const
FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl added to the list of thos...
const ObjCInterfaceDecl * getClassInterface() const
ObjCPropertyImplDecl * FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const
FindPropertyImplIvarDecl - This method lookup the ivar in the list of properties implemented in this ...
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Represents an ObjC class declaration.
ObjCPropertyDecl * FindPropertyVisibleInPrimaryClass(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyVisibleInPrimaryClass - Finds declaration of the property with name 'PropertyId' in the p...
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
all_protocol_range all_referenced_protocols() const
visible_extensions_range visible_extensions() const
ObjCCategoryDecl * FindCategoryDeclaration(const IdentifierInfo *CategoryId) const
FindCategoryDeclaration - Finds category declaration in the list of categories for this class and ret...
protocol_range protocols() const
const ObjCInterfaceDecl * isObjCRequiresPropertyDefs() const
isObjCRequiresPropertyDefs - Checks that a class or one of its super classes must not be auto-synthes...
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...
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,...
bool ClassImplementsProtocol(ObjCProtocolDecl *lProto, bool lookupCategory, bool RHSIsQualifiedID=false)
ClassImplementsProtocol - Checks that 'lProto' protocol has been implemented in IDecl class,...
ObjCImplementationDecl * getImplementation() const
bool hasDesignatedInitializers() const
Returns true if this interface decl contains at least one initializer marked with the 'objc_designate...
void getDesignatedInitializers(llvm::SmallVectorImpl< const ObjCMethodDecl * > &Methods) const
Returns the designated initializers for the interface.
void collectPropertiesToImplement(PropertyMap &PM) const override
This routine collects list of properties to be implemented in the class.
bool isArcWeakrefUnavailable() const
isArcWeakrefUnavailable - Checks for a class or one of its super classes to be incompatible with __we...
ObjCInterfaceDecl * getSuperClass() const
known_extensions_range known_extensions() const
ObjCIvarDecl - Represents an ObjC instance variable.
AccessControl getAccessControl() const
bool getSynthesize() const
static ObjCIvarDecl * Create(ASTContext &C, ObjCContainerDecl *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW=nullptr, bool synthesized=false)
QualType getUsageType(QualType objectType) const
Retrieve the type of this instance variable when viewed as a member of a specific object type.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
ObjCMethodDecl - Represents an instance or class method declaration.
void setDefined(bool isDefined)
unsigned param_size() const
void setSelfDecl(ImplicitParamDecl *SD)
bool isPropertyAccessor() 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 isSynthesizedAccessorStub=false, bool isImplicitlyDeclared=false, bool isDefined=false, ObjCImplementationControl impControl=ObjCImplementationControl::None, bool HasRelatedResultType=false)
param_const_iterator param_begin() const
void setCmdDecl(ImplicitParamDecl *CD)
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
bool isSynthesizedAccessorStub() const
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl * > Params, ArrayRef< SourceLocation > SelLocs=std::nullopt)
Sets the method's parameters and selector source locations.
void setPropertyAccessor(bool isAccessor)
Selector getSelector() const
bool isInstanceMethod() const
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID)
createImplicitParams - Used to lazily create the self and cmd implicit parameters.
QualType getReturnType() const
ParmVarDecl *const * param_iterator
bool isClassMethod() const
ObjCInterfaceDecl * getClassInterface()
Represents a pointer to an Objective C object.
Represents one property declaration in an Objective-C interface.
ObjCPropertyQueryKind getQueryKind() const
bool isClassProperty() const
void setPropertyImplementation(PropertyControl pc)
void setSetterName(Selector Sel, SourceLocation Loc=SourceLocation())
ObjCMethodDecl * getGetterMethodDecl() const
bool isInstanceProperty() const
void setPropertyAttributes(ObjCPropertyAttribute::Kind PRVal)
bool isReadOnly() const
isReadOnly - Return true iff the property has a setter.
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
bool isDirectProperty() const
Selector getSetterName() const
void setPropertyAttributesAsWritten(ObjCPropertyAttribute::Kind PRVal)
void overwritePropertyAttributes(unsigned PRVal)
Selector getGetterName() const
ObjCPropertyAttribute::Kind getPropertyAttributesAsWritten() const
IdentifierInfo * getDefaultSynthIvarName(ASTContext &Ctx) const
Get the default name of the synthesized ivar.
ObjCPropertyAttribute::Kind getPropertyAttributes() const
static ObjCPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, const IdentifierInfo *Id, SourceLocation AtLocation, SourceLocation LParenLocation, QualType T, TypeSourceInfo *TSI, PropertyControl propControl=None)
void setGetterName(Selector Sel, SourceLocation Loc=SourceLocation())
PropertyControl getPropertyImplementation() const
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Kind getPropertyImplementation() const
void setSetterMethodDecl(ObjCMethodDecl *MD)
ObjCPropertyDecl * getPropertyDecl() const
void setSetterCXXAssignment(Expr *setterCXXAssignment)
static ObjCPropertyImplDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation atLoc, SourceLocation L, ObjCPropertyDecl *property, Kind PK, ObjCIvarDecl *ivarDecl, SourceLocation ivarLoc)
void setGetterMethodDecl(ObjCMethodDecl *MD)
void setGetterCXXConstructor(Expr *getterCXXConstructor)
Represents an Objective-C protocol declaration.
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
protocol_range protocols() const
The basic abstraction for the target Objective-C runtime.
bool isNonFragile() const
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?
bool allowsDirectDispatch() const
Does this runtime supports direct dispatch.
bool isFragile() const
The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ...
Represents a parameter to a function.
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
StringRef getLastMacroWithSpelling(SourceLocation Loc, ArrayRef< TokenValue > Tokens) const
Return the name of the macro defined before Loc that has spelling Tokens.
A (possibly-)qualified type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
bool isObjCGCStrong() const
true when Type is objc's strong.
bool isObjCGCWeak() const
true when Type is objc's weak.
The collection of all-type qualifiers we support.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
bool hasObjCLifetime() const
void addObjCLifetime(ObjCLifetime type)
void setObjCLifetime(ObjCLifetime type)
bool hasFlexibleArrayMember() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
Scope - A scope is a transient data structure that is used while parsing the program.
Smart pointer class that efficiently represents Objective-C method names.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
ASTContext & getASTContext() const
const LangOptions & getLangOpts() const
void DefaultSynthesizeProperties(Scope *S, ObjCImplDecl *IMPDecl, ObjCInterfaceDecl *IDecl, SourceLocation AtEnd)
DefaultSynthesizeProperties - This routine default synthesizes all properties which must be synthesiz...
bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD, ObjCMethodDecl *Getter, SourceLocation Loc)
void ProcessPropertyDecl(ObjCPropertyDecl *property)
Process the specified property declaration and create decls for the setters and getters as needed.
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.
void diagnoseNullResettableSynthesizedSetters(const ObjCImplDecl *impDecl)
Diagnose any null-resettable synthesized setters.
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...
bool CheckARCMethodDecl(ObjCMethodDecl *method)
Check a method declaration for compatibility with the Objective-C ARC conventions.
bool IvarBacksCurrentMethodAccessor(ObjCInterfaceDecl *IFace, ObjCMethodDecl *Method, ObjCIvarDecl *IV)
IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is an ivar synthesized for 'Meth...
void DiagnoseOwningPropertyGetterSynthesis(const ObjCImplementationDecl *D)
Decl * ActOnProperty(Scope *S, SourceLocation AtLoc, SourceLocation LParenLoc, FieldDeclarator &FD, ObjCDeclSpec &ODS, Selector GetterSel, Selector SetterSel, tok::ObjCKeywordKind MethodImplKind, DeclContext *lexicalDC=nullptr)
void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl *IMPDecl, ObjCContainerDecl *CDecl, bool SynthesizeProperties)
DiagnoseUnimplementedProperties - This routine warns on those properties which must be implemented by...
void AtomicPropertySetterGetterRules(ObjCImplDecl *IMPDecl, ObjCInterfaceDecl *IDecl)
AtomicPropertySetterGetterRules - This routine enforces the rule (via warning) when atomic property h...
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 ...
void DiagnoseMissingDesignatedInitOverrides(const ObjCImplementationDecl *ImplD, const ObjCInterfaceDecl *IFD)
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Find the protocol with the given name, if any.
void CheckObjCPropertyAttributes(Decl *PropertyPtrTy, SourceLocation Loc, unsigned &Attributes, bool propertyInPrimaryClass)
Ensure attributes are consistent with type.
void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
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...
void CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod, ObjCInterfaceDecl *CurrentClass, ResultTypeCompatibilityKind RTC)
void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddInstanceMethodToGlobalPool - All instance methods in a translation unit are added to a global pool...
RAII object to handle the state changes required to synthesize a function body.
Sema - This implements semantic analysis and AST building for C.
Preprocessor & getPreprocessor() const
bool isObjCPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType, bool &IncompatibleObjC)
isObjCPointerConversion - Determines whether this is an Objective-C pointer conversion.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
const LangOptions & getLangOpts() const
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
const LangOptions & LangOpts
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
@ Compatible
Compatible - the types are compatible according to the standard.
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
TypeSourceInfo * GetTypeForDeclarator(Declarator &D)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D.
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
@ AbstractSynthesizedIvarType
void ProcessAPINotes(Decl *D)
Map any API notes provided for this declaration to attributes on the declaration.
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing,...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
Stores token information for comparing actual tokens with predefined values.
Token - This structure provides full information about a lexed token.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....
bool isNot(tok::TokenKind K) const
StringRef getRawIdentifier() const
getRawIdentifier - For a raw identifier token (i.e., an identifier lexed in raw mode),...
SourceLocation getEndLoc() const
Get the end source location.
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
bool isBlockPointerType() const
bool isArithmeticType() const
const T * castAs() const
Member-template castAs<specific type>.
bool isObjCObjectType() const
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool isObjCQualifiedClassType() const
bool isObjCClassType() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isObjCARCImplicitlyUnretainedType() const
Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...
bool isRecordType() const
bool isObjCRetainableType() const
std::optional< NullabilityKind > getNullability() const
Determine the nullability of the given type.
void setType(QualType newType)
@ kind_nullability
Indicates that the nullability of the type was spelled with a property attribute rather than a type q...
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
const internal::VariadicDynCastAllOfMatcher< Stmt, CallExpr > callExpr
Matches call expressions.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
The JSON file list parser is used to communicate input to InstallAPI.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
ObjCMethodFamily
A family of Objective-C methods.
@ Property
The type of a property.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
const FunctionProtoType * T
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
This little struct is used to capture information about structure field declarators,...
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
Qualifiers Quals
The local qualifiers.