23 #include "llvm/ADT/DenseSet.h" 24 #include "llvm/ADT/SmallString.h" 26 using namespace clang;
70 =
property->getPropertyAttributes();
72 =
property->getType().getObjCLifetime();
78 if (!expectedLifetime) {
92 property->setPropertyAttributes(attr);
96 if (propertyLifetime == expectedLifetime)
return;
98 property->setInvalidDecl();
100 diag::err_arc_inconsistent_property_ownership)
111 llvm::SmallPtrSetImpl<ObjCProtocolDecl *> &Known) {
113 if (!Known.insert(Proto).second)
118 for (
unsigned I = 0, N = R.
size(); I != N; ++I) {
149 llvm_unreachable(
"bad qualifier");
200 if (CDecl->IsClassExtension()) {
205 isReadWrite, Attributes,
207 T, TSI, MethodImplKind);
225 (isa<ObjCInterfaceDecl>(ClassDecl) ||
226 isa<ObjCProtocolDecl>(ClassDecl)));
229 if (Res->getType().getObjCLifetime())
232 llvm::SmallPtrSet<ObjCProtocolDecl *, 16> KnownProtos;
235 bool FoundInSuper =
false;
239 for (
unsigned I = 0, N = R.
size(); I != N; ++I) {
249 CurrentInterfaceDecl = Super;
254 for (
auto *
P : CurrentInterfaceDecl->
protocols()) {
259 for (
auto *
P : IFace->all_referenced_protocols()) {
267 if (!Cat->IsClassExtension())
268 for (
auto *
P : Cat->protocols())
282 unsigned attributesAsWritten = 0;
323 bool invalidTemp =
false;
324 StringRef file = SM.
getBufferData(locInfo.first, &invalidTemp);
327 const char *tokenBegin = file.data() + locInfo.second;
332 file.begin(), tokenBegin, file.end());
335 lexer.LexFromRawLexer(Tok);
336 if (Tok.is(tok::raw_identifier) && Tok.getRawIdentifier() == attrName) {
337 Loc = Tok.getLocation();
340 }
while (Tok.isNot(tok::r_paren));
348 bool PropagateAtomicity) {
356 if (OldIsAtomic == NewIsAtomic)
return;
362 auto Attrs =
Property->getPropertyAttributes();
369 if (
Property->getPropertyAttributesAsWritten() &
378 const unsigned AtomicityMask =
380 if (PropagateAtomicity &&
383 Attrs = Attrs & ~AtomicityMask;
395 if ((OldIsAtomic && isImplicitlyReadonlyAtomic(OldProperty)) ||
396 (NewIsAtomic && isImplicitlyReadonlyAtomic(NewProperty)))
402 if (
auto Category = dyn_cast<ObjCCategoryDecl>(OldDC))
403 OldContextName =
Category->getClassInterface()->getIdentifier();
405 OldContextName = cast<ObjCContainerDecl>(OldDC)->
getIdentifier();
422 const bool isReadWrite,
423 unsigned &Attributes,
424 const unsigned AttributesAsWritten,
451 Diag(AtLoc, diag::err_duplicate_property);
470 ? diag::err_use_continuation_class_redeclaration_readwrite
471 : diag::err_use_continuation_class;
482 Diag(AtLoc, diag::warn_property_redecl_getter_mismatch)
493 unsigned ExistingOwnership
496 if (ExistingOwnership && NewOwnership != ExistingOwnership) {
499 Diag(AtLoc, diag::warn_property_attr_mismatch);
504 Attributes = (Attributes & ~
OwnershipMask) | ExistingOwnership;
513 Diag(AtLoc, diag::warn_property_implicitly_mismatched);
521 FD, GetterSel, GetterNameLoc,
522 SetterSel, SetterNameLoc,
524 Attributes, AttributesAsWritten,
525 T, TSI, MethodImplKind, DC);
535 bool IncompatibleObjC =
false;
545 if (!isa<ObjCObjectPointerType>(PrimaryClassPropertyT) ||
546 !isa<ObjCObjectPointerType>(ClassExtPropertyT) ||
548 ConvertedType, IncompatibleObjC))
549 || IncompatibleObjC) {
551 diag::err_type_mismatch_continuation_class) << PDecl->getType();
575 const bool isReadWrite,
576 const unsigned Attributes,
577 const unsigned AttributesAsWritten,
608 Diag(AtLoc, diag::warn_implements_nscopying) << PropertyId;
626 LParenLoc, T, TInfo);
634 Diag(prevDecl->getLocation(), diag::note_property_declare);
643 if (T->isArrayType() || T->isFunctionType()) {
644 Diag(AtLoc, diag::err_property_type) << T;
694 if (Attributes & ObjCDeclSpec::DQ_PR_unsafe_unretained)
699 if (MethodImplKind == tok::objc_required)
701 else if (MethodImplKind == tok::objc_optional)
710 if (Attributes & ObjCDeclSpec::DQ_PR_class)
714 CDecl->
hasAttr<ObjCDirectMembersAttr>()) {
715 if (isa<ObjCProtocolDecl>(CDecl)) {
739 property->getType());
742 if (propertyLifetime == ivarLifetime)
return;
768 switch (propertyLifetime) {
786 << ((
property->getPropertyAttributesAsWritten()
791 llvm_unreachable(
"properties cannot be autoreleasing");
800 S.
Diag(propertyImplLoc, diag::note_property_synthesize);
812 property->getType());
833 return (Attr1 & Kind) != (Attr2 &
Kind);
838 return ((Attr1 & Kinds) != 0) != ((Attr2 & Kinds) != 0);
851 "Expected a property from a protocol");
856 PDecl->collectInheritedProtocolProperties(Property, ProtocolSet,
861 for (
const auto *PI : SDecl->all_referenced_protocols()) {
863 PDecl->collectInheritedProtocolProperties(Property, ProtocolSet,
866 SDecl = SDecl->getSuperClass();
870 if (Properties.empty())
874 size_t SelectedIndex = 0;
875 for (
const auto &Prop : llvm::enumerate(Properties)) {
877 if (Property->
isReadOnly() && !Prop.value()->isReadOnly()) {
878 Property = Prop.value();
879 SelectedIndex = Prop.index();
882 if (Property != OriginalProperty) {
884 Properties[SelectedIndex] = OriginalProperty;
890 IncompatibleType = 0,
891 HasNoExpectedAttribute,
892 HasUnexpectedAttribute,
898 struct MismatchingProperty {
901 StringRef AttributeName;
906 unsigned Attr = Prop->getPropertyAttributesAsWritten();
907 if (Attr != OriginalAttributes) {
908 auto Diag = [&](
bool OriginalHasAttribute, StringRef AttributeName) {
909 MismatchKind
Kind = OriginalHasAttribute ? HasNoExpectedAttribute
910 : HasUnexpectedAttribute;
911 Mismatches.push_back({Prop,
Kind, AttributeName});
928 OriginalAttributes, Attr,
933 "retain (or strong)");
943 Mismatches.push_back({Prop, DifferentGetter,
""});
946 if (!Property->
isReadOnly() && !Prop->isReadOnly() &&
948 Mismatches.push_back({Prop, DifferentSetter,
""});
953 bool IncompatibleObjC =
false;
956 || IncompatibleObjC) {
957 Mismatches.push_back({Prop, IncompatibleType,
""});
963 if (Mismatches.empty())
968 bool HasIncompatibleAttributes =
false;
969 for (
const auto &
Note : Mismatches)
970 HasIncompatibleAttributes =
971 Note.Kind != IncompatibleType ?
true : HasIncompatibleAttributes;
975 Property != OriginalProperty || HasIncompatibleAttributes
976 ? diag::err_protocol_property_mismatch
977 : diag::warn_protocol_property_mismatch);
978 Diag << Mismatches[0].Kind;
979 switch (Mismatches[0].
Kind) {
980 case IncompatibleType:
983 case HasNoExpectedAttribute:
984 case HasUnexpectedAttribute:
985 Diag << Mismatches[0].AttributeName;
987 case DifferentGetter:
990 case DifferentSetter:
995 for (
const auto &
Note : Mismatches) {
997 S.
Diag(
Note.Prop->getLocation(), diag::note_protocol_property_declare)
1000 case IncompatibleType:
1003 case HasNoExpectedAttribute:
1004 case HasUnexpectedAttribute:
1007 case DifferentGetter:
1008 Diag <<
Note.Prop->getGetterName();
1010 case DifferentSetter:
1011 Diag <<
Note.Prop->getSetterName();
1016 S.
Diag(AtLoc, diag::note_property_synthesize);
1038 auto OrigClass =
Category->getClassInterface();
1039 for (
auto Found : OrigClass->lookup(Prop->
getDeclName())) {
1041 return OrigProp->getPropertyAttributesAsWritten() &
OwnershipMask;
1045 for (
const auto *Proto : OrigClass->all_referenced_protocols()) {
1048 return OrigProp->getPropertyAttributesAsWritten() &
OwnershipMask;
1096 if (!ClassImpDecl) {
1097 Diag(AtLoc, diag::err_missing_property_context);
1101 PropertyIvarLoc = PropertyLoc;
1111 if ((IC = dyn_cast<ObjCImplementationDecl>(ClassImpDecl))) {
1116 "ActOnPropertyImplDecl - @implementation without @interface");
1121 Diag(PropertyLoc, diag::err_bad_property_decl) << IDecl->
getDeclName();
1124 if (property->isClassProperty() && Synthesize) {
1125 Diag(PropertyLoc, diag::err_synthesize_on_class_property) << PropertyId;
1128 unsigned PIkind =
property->getPropertyAttributesAsWritten();
1132 Diag(AtLoc, diag::warn_implicit_atomic_property);
1135 Diag(property->getLocation(), diag::note_property_declare);
1139 dyn_cast<ObjCCategoryDecl>(property->getDeclContext())) {
1140 if (!CD->IsClassExtension()) {
1141 Diag(PropertyLoc, diag::err_category_property) << CD->getDeclName();
1142 Diag(property->getLocation(), diag::note_property_declare);
1148 property->hasAttr<IBOutletAttr>() &&
1150 bool ReadWriteProperty =
false;
1157 PIkind = ExtProp->getPropertyAttributesAsWritten();
1159 ReadWriteProperty =
true;
1165 if (!ReadWriteProperty) {
1166 Diag(property->getLocation(), diag::warn_auto_readonly_iboutlet_property)
1170 property->getLParenLoc(), readonlyLoc)) {
1173 SourceRange ReadonlySourceRange(readonlyLoc, endLoc);
1174 Diag(property->getLocation(),
1175 diag::note_auto_readonly_iboutlet_fixup_suggest) <<
1180 if (Synthesize && isa<ObjCProtocolDecl>(property->getDeclContext()))
1184 }
else if ((CatImplClass = dyn_cast<ObjCCategoryImplDecl>(ClassImpDecl))) {
1186 Diag(AtLoc, diag::err_synthesize_category_decl);
1191 Diag(AtLoc, diag::err_missing_property_interface);
1204 Diag(PropertyLoc, diag::err_bad_category_property_decl)
1209 Diag(AtLoc, diag::err_bad_property_context);
1213 bool CompleteTypeErr =
false;
1219 PropertyIvar = PropertyId;
1223 QualType PropType =
property->getType();
1227 diag::err_incomplete_synthesized_property,
1228 property->getDeclName())) {
1229 Diag(property->getLocation(), diag::note_property_declare);
1230 CompleteTypeErr =
true;
1234 (
property->getPropertyAttributesAsWritten() &
1241 =
property->getPropertyAttributes();
1243 bool isARCWeak =
false;
1249 Diag(PropertyDiagLoc, diag::err_gc_weak_property_strong_type);
1250 Diag(property->getLocation(), diag::note_property_declare);
1262 Diag(PropertyDiagLoc,
1264 ? diag::err_synthesizing_arc_weak_property_disabled
1265 : diag::err_synthesizing_arc_weak_property_no_runtime);
1266 Diag(property->getLocation(), diag::note_property_declare);
1268 CompleteTypeErr =
true;
1275 Diag(property->getLocation(),
1276 diag::err_arc_weak_unavailable_property)
1277 << PropertyIvarType;
1296 Diag(PropertyDiagLoc,
1297 diag::warn_autosynthesis_property_ivar_match)
1298 << PropertyId << (Ivar ==
nullptr) << PropertyIvar
1300 Diag(property->getLocation(), diag::note_property_declare);
1308 if ((
getLangOpts().ObjCAutoRefCount || isARCWeak) &&
1316 Diag(PropertyDiagLoc,
1317 diag::err_arc_objc_property_default_assign_on_object);
1318 Diag(property->getLocation(), diag::note_property_declare);
1322 assert(lifetime &&
"no lifetime for property?");
1331 PropertyIvarLoc,PropertyIvarLoc, PropertyIvar,
1332 PropertyIvarType,
nullptr,
1334 (
Expr *)
nullptr,
true);
1337 diag::err_abstract_type_in_decl,
1339 Diag(property->getLocation(), diag::note_property_declare);
1341 CompleteTypeErr =
true;
1343 if (!CompleteTypeErr) {
1346 Diag(PropertyIvarLoc, diag::err_synthesize_variable_sized_ivar)
1347 << PropertyIvarType;
1348 CompleteTypeErr =
true;
1351 if (CompleteTypeErr)
1357 Diag(PropertyDiagLoc, diag::err_missing_property_ivar_decl)
1363 Diag(PropertyDiagLoc, diag::err_ivar_in_superclass_use)
1370 property->setPropertyIvarDecl(Ivar);
1376 if (isa<ObjCObjectPointerType>(PropertyIvarType)
1377 && isa<ObjCObjectPointerType>(IvarType))
1388 Diag(PropertyDiagLoc, diag::err_property_ivar_type)
1389 <<
property->getDeclName() << PropType
1401 if (lhsType != rhsType &&
1403 Diag(PropertyDiagLoc, diag::err_property_ivar_type)
1404 <<
property->getDeclName() << PropType
1413 Diag(PropertyDiagLoc, diag::err_weak_property)
1414 <<
property->getDeclName() << Ivar->
getDeclName();
1419 if ((property->getType()->isObjCObjectPointerType() ||
1422 Diag(PropertyDiagLoc, diag::err_strong_property)
1423 <<
property->getDeclName() << Ivar->
getDeclName();
1427 if (
getLangOpts().ObjCAutoRefCount || isARCWeak ||
1430 }
else if (PropertyIvar)
1432 Diag(PropertyDiagLoc, diag::err_dynamic_property_ivar_decl);
1434 assert (property &&
"ActOnPropertyImplDecl - property declaration missing");
1441 Ivar, PropertyIvarLoc);
1443 if (CompleteTypeErr || !compat)
1446 if (
ObjCMethodDecl *getterMethod = property->getGetterMethodDecl()) {
1447 getterMethod->createImplicitParams(
Context, IDecl);
1453 getterMethod->getSelector(), getterMethod->isInstanceMethod());
1471 Expr *LoadSelfExpr =
1473 CK_LValueToRValue, SelfExpr,
nullptr,
1480 LoadSelfExpr,
true,
true);
1483 getterMethod->getReturnType(),
1485 PropertyDiagLoc, IvarRefExpr);
1493 if (property->hasAttr<NSReturnsNotRetainedAttr>() &&
1494 !getterMethod->hasAttr<NSReturnsNotRetainedAttr>()) {
1495 Diag(getterMethod->getLocation(),
1496 diag::warn_property_getter_owning_mismatch);
1497 Diag(property->getLocation(), diag::note_property_declare);
1500 switch (getterMethod->getMethodFamily()) {
1505 Diag(getterMethod->getLocation(), diag::err_arc_illegal_method_def)
1506 << 1 << getterMethod->getSelector();
1513 if (
ObjCMethodDecl *setterMethod = property->getSetterMethodDecl()) {
1514 setterMethod->createImplicitParams(
Context, IDecl);
1519 setterMethod->getSelector(), setterMethod->isInstanceMethod());
1522 AtLoc, PropertyLoc);
1535 Expr *LoadSelfExpr =
1537 CK_LValueToRValue, SelfExpr,
nullptr,
1544 LoadSelfExpr,
true,
true);
1552 BO_Assign, lhs, rhs);
1553 if (property->getPropertyAttributes() &
1557 dyn_cast_or_null<CXXOperatorCallExpr>(callExpr))
1558 if (
const FunctionDecl *FuncDecl = CXXCE->getDirectCallee())
1559 if (!FuncDecl->isTrivial())
1560 if (property->getType()->isReferenceType()) {
1561 Diag(PropertyDiagLoc,
1562 diag::err_atomic_property_nontrivial_assign_op)
1563 <<
property->getType();
1564 Diag(FuncDecl->getBeginLoc(), diag::note_callee_decl)
1576 Diag(PropertyLoc, diag::err_duplicate_ivar_use)
1577 << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()
1579 Diag(PPIDecl->getLocation(), diag::note_previous_use);
1584 Diag(PropertyLoc, diag::err_property_implemented) << PropertyId;
1585 Diag(PPIDecl->getLocation(), diag::note_previous_declaration);
1600 if (PropertyIvar && PropertyIvar != PropertyId)
1615 Diag(PropertyDiagLoc, diag::err_duplicate_ivar_use)
1616 << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()
1618 Diag(PPIDecl->getLocation(), diag::note_previous_use);
1623 Diag(PropertyDiagLoc, diag::err_property_implemented) << PropertyId;
1624 Diag(PPIDecl->getLocation(), diag::note_previous_declaration);
1644 bool OverridingProtocolProperty) {
1653 if (!OverridingProtocolProperty &&
1662 != (SAttr & ObjCPropertyDecl::OBJC_PR_copy))
1664 << Property->
getDeclName() <<
"copy" << inheritedName;
1665 else if (!(SAttr & ObjCPropertyDecl::OBJC_PR_readonly)){
1666 unsigned CAttrRetain =
1669 unsigned SAttrRetain =
1672 bool CStrong = (CAttrRetain != 0);
1673 bool SStrong = (SAttrRetain != 0);
1674 if (CStrong != SStrong)
1676 << Property->
getDeclName() <<
"retain (or strong)" << inheritedName;
1690 << Property->
getDeclName() <<
"setter" << inheritedName;
1695 << Property->
getDeclName() <<
"getter" << inheritedName;
1707 bool IncompatibleObjC =
false;
1710 ConvertedType, IncompatibleObjC) ||
1712 Diag(Property->
getLocation(), diag::warn_property_types_are_incompatible)
1713 << Property->
getType() << SuperProperty->
getType() << inheritedName;
1726 property->getType().getNonReferenceType().getAtomicUnqualifiedType();
1731 if ((propertyObjCPtr =
1737 Diag(Loc, diag::err_property_accessor_type)
1738 <<
property->getDeclName() << PropertyRValueType
1752 Diag(Loc, diag::warn_accessor_property_type_mismatch)
1753 <<
property->getDeclName()
1768 bool CollectClassPropsOnly =
false,
1769 bool IncludeProtocols =
true) {
1771 for (
auto *Prop : IDecl->properties()) {
1772 if (CollectClassPropsOnly && !Prop->isClassProperty())
1774 PropMap[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] =
1779 for (
auto *Ext : IDecl->visible_extensions())
1781 CollectClassPropsOnly, IncludeProtocols);
1783 if (IncludeProtocols) {
1785 for (
auto *PI : IDecl->all_referenced_protocols())
1787 CollectClassPropsOnly);
1791 for (
auto *Prop : CATDecl->properties()) {
1792 if (CollectClassPropsOnly && !Prop->isClassProperty())
1794 PropMap[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] =
1797 if (IncludeProtocols) {
1799 for (
auto *PI : CATDecl->protocols())
1801 CollectClassPropsOnly);
1805 for (
auto *Prop : PDecl->properties()) {
1806 if (CollectClassPropsOnly && !Prop->isClassProperty())
1809 SuperPropMap[std::make_pair(Prop->getIdentifier(),
1810 Prop->isClassProperty())];
1813 if (!PropertyFromSuper ||
1814 PropertyFromSuper->
getIdentifier() != Prop->getIdentifier()) {
1816 PropMap[std::make_pair(Prop->getIdentifier(),
1817 Prop->isClassProperty())];
1823 for (
auto *PI : PDecl->protocols())
1825 CollectClassPropsOnly);
1837 SDecl->collectPropertiesToImplement(PropMap, PO);
1838 SDecl = SDecl->getSuperClass();
1861 (
Property->getPropertyIvarDecl() == IV))
1867 for (
const auto *
Property : Ext->instance_properties())
1870 (
Property->getPropertyIvarDecl() == IV))
1877 bool SuperClassImplementsGetter =
false;
1878 bool SuperClassImplementsSetter =
false;
1880 SuperClassImplementsSetter =
true;
1885 SuperClassImplementsGetter =
true;
1888 SuperClassImplementsSetter =
true;
1889 if (SuperClassImplementsGetter && SuperClassImplementsSetter)
1904 if (PropMap.empty())
1909 for (
unsigned i = 0, e = PropertyOrder.size(); i != e; i++) {
1921 if (ImpMethod && !ImpMethod->
getBody()) {
1925 if (ImpMethod && !ImpMethod->
getBody())
1930 Diag(Prop->
getLocation(), diag::warn_no_autosynthesis_shared_ivar_property)
1932 if (PID->getLocation().isValid())
1933 Diag(PID->getLocation(), diag::note_property_synthesize);
1947 diag::warn_auto_synthesizing_protocol_property)
1951 (Twine(
"@synthesize ") + Prop->
getName() +
";\n\n").str();
1952 Diag(AtEnd, diag::note_add_synthesize_directive)
1958 if (PropInSuperClass) {
1969 Diag(Prop->
getLocation(), diag::warn_autosynthesis_property_in_superclass)
2001 if (!IDecl->isObjCRequiresPropertyDefs())
2009 llvm::SmallPtrSet<const ObjCMethodDecl *, 8> &
SMap) {
2020 if (I == SMap.end() &&
2021 (PrimaryClass ==
nullptr ||
2025 isa<ObjCCategoryDecl>(CDecl)
2027 ? diag::warn_impl_required_in_category_for_class_property
2028 : diag::warn_setter_getter_impl_required_in_category)
2030 ? diag::warn_impl_required_for_class_property
2031 : diag::warn_setter_getter_impl_required);
2034 if (S.
LangOpts.ObjCDefaultSynthProperties &&
2038 S.
Diag(RID->getLocation(), diag::note_suppressed_class_declare);
2044 bool SynthesizeProperties) {
2058 if ((IDecl =
C->getClassInterface())) {
2068 SynthesizeProperties);
2074 std::unique_ptr<ObjCContainerDecl::PropertyMap> LazyMap;
2077 if (!PDecl->hasAttr<ObjCExplicitProtocolImplAttr>())
2095 for (
auto *PropDecl : PDecl->properties()) {
2096 if ((*LazyMap)[std::make_pair(PropDecl->getIdentifier(),
2097 PropDecl->isClassProperty())])
2099 PropMap[std::make_pair(PropDecl->getIdentifier(),
2100 PropDecl->isClassProperty())] = PropDecl;
2105 if (PropMap.empty())
2110 PropImplMap.insert(I->getPropertyDecl());
2112 llvm::SmallPtrSet<const ObjCMethodDecl *, 8> InsMap;
2114 for (
const auto *I : IMPDecl->
methods())
2122 if (
ObjCImplDecl *IMP = PrimaryClass->getImplementation()) {
2126 for (
const auto *I : IMP->methods())
2130 for (ObjCContainerDecl::PropertyMap::iterator
2131 P = PropMap.begin(), E = PropMap.end();
P != E; ++
P) {
2136 PropImplMap.count(Prop) ||
2142 PrimaryClass, Prop->
getGetterName(), IMPDecl, CDecl,
C, Prop, InsMap);
2143 if (!Prop->isReadOnly())
2145 PrimaryClass, Prop->getSetterName(),
2146 IMPDecl, CDecl,
C, Prop, InsMap);
2152 const auto *
property = propertyImpl->getPropertyDecl();
2155 if (propertyImpl->getPropertyImplementation()
2157 (
property->getPropertyAttributes() &
2159 property->getGetterMethodDecl() &&
2160 property->getSetterMethodDecl()) {
2161 auto *getterImpl = propertyImpl->getGetterMethodDecl();
2162 auto *setterImpl = propertyImpl->getSetterMethodDecl();
2163 if ((!getterImpl || getterImpl->isSynthesizedAccessorStub()) &&
2164 (!setterImpl || setterImpl->isSynthesizedAccessorStub())) {
2169 Diag(loc, diag::warn_null_resettable_setter)
2170 << setterImpl->getSelector() <<
property->getDeclName();
2184 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
2186 for (
auto *Prop : Ext->properties())
2187 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
2189 for (ObjCContainerDecl::PropertyMap::iterator I = PM.begin(), E = PM.end();
2207 GetterMethod =
nullptr;
2209 SetterMethod =
nullptr;
2212 diag::warn_default_atomic_custom_getter_setter)
2218 diag::warn_default_atomic_custom_getter_setter)
2225 if ((Attributes & ObjCPropertyDecl::OBJC_PR_nonatomic) ||
2232 GetterMethod = PIDecl->getGetterMethodDecl();
2233 SetterMethod = PIDecl->getSetterMethodDecl();
2235 GetterMethod =
nullptr;
2237 SetterMethod =
nullptr;
2238 if ((
bool)GetterMethod ^ (
bool)SetterMethod) {
2241 : SetterMethod->getLocation());
2242 Diag(MethodLoc, diag::warn_atomic_property_rule)
2244 << (SetterMethod !=
nullptr);
2251 StringRef NonatomicStr = AttributesAsWritten?
"nonatomic, " 2254 diag::note_atomic_property_fixup_suggest)
2261 diag::note_atomic_property_fixup_suggest)
2265 Diag(MethodLoc, diag::note_atomic_property_fixup_suggest);
2278 if (PD && !PD->
hasAttr<NSReturnsNotRetainedAttr>() &&
2298 for (
auto *getterRedecl : method->
redecls()) {
2299 if (getterRedecl->isImplicit())
2303 noteLoc = getterRedecl->getLocation();
2304 fixItLoc = getterRedecl->getEndLoc();
2309 tok::kw___attribute, tok::l_paren, tok::l_paren,
2312 tok::r_paren, tok::r_paren
2314 StringRef spelling =
"__attribute__((objc_method_family(none)))";
2316 if (!macroName.empty())
2317 spelling = macroName;
2319 auto noteDiag =
Diag(noteLoc, diag::note_cocoa_naming_declare_family)
2323 fixItText += spelling;
2341 if (I->getMethodFamily() ==
OMF_init)
2342 InitSelSet.insert(I->getSelector());
2345 SuperD->getDesignatedInitializers(DesignatedInits);
2347 I = DesignatedInits.begin(), E = DesignatedInits.end(); I != E; ++I) {
2352 bool Ignore =
false;
2358 if (
auto *IMD = Ext->getInstanceMethod(MD->
getSelector())) {
2359 Ignore = IMD->isUnavailable();
2365 diag::warn_objc_implementation_missing_designated_init_override)
2378 for (
const auto *A : Property->
attrs()) {
2379 if (isa<DeprecatedAttr>(A) ||
2380 isa<UnavailableAttr>(A) ||
2381 isa<AvailabilityAttr>(A))
2396 bool IsClassProperty =
property->isClassProperty();
2397 GetterMethod = IsClassProperty ?
2405 if (CatDecl->IsClassExtension())
2408 CatDecl->getClassInterface()->
2411 SetterMethod = IsClassProperty ?
2416 if (CatDecl->IsClassExtension())
2419 CatDecl->getClassInterface()->
2424 if (!property->
isReadOnly() && SetterMethod) {
2427 Diag(SetterMethod->getLocation(), diag::err_setter_type_void);
2428 if (SetterMethod->param_size() != 1 ||
2430 (*SetterMethod->param_begin())->getType().getNonReferenceType(),
2431 property->getType().getNonReferenceType())) {
2433 diag::warn_accessor_property_type_mismatch)
2435 << SetterMethod->getSelector();
2436 Diag(SetterMethod->getLocation(), diag::note_declared_at);
2446 if (!GetterMethod) {
2454 QualType resultTy =
property->getType().getAtomicUnqualifiedType();
2463 modifiedTy, modifiedTy);
2469 !IsClassProperty,
false,
2475 CD->addDecl(GetterMethod);
2480 GetterMethod->
addAttr(ObjCDirectAttr::CreateImplicit(
Context, Loc));
2482 if (property->
hasAttr<NSReturnsNotRetainedAttr>())
2483 GetterMethod->
addAttr(NSReturnsNotRetainedAttr::CreateImplicit(
Context,
2486 if (property->
hasAttr<ObjCReturnsInnerPointerAttr>())
2488 ObjCReturnsInnerPointerAttr::CreateImplicit(
Context, Loc));
2490 if (
const SectionAttr *SA = property->
getAttr<SectionAttr>())
2491 GetterMethod->
addAttr(SectionAttr::CreateImplicit(
2493 SectionAttr::GNU_section));
2504 property->setGetterMethodDecl(GetterMethod);
2509 if (!SetterMethod) {
2519 nullptr, CD, !IsClassProperty,
2525 (
property->getPropertyImplementation() ==
2532 property->getType().getUnqualifiedType().getAtomicUnqualifiedType();
2542 modifiedTy, modifiedTy);
2555 SetterMethod->setMethodParams(
Context, Argument, None);
2560 SetterMethod->addAttr(ObjCDirectAttr::CreateImplicit(
Context, Loc));
2563 if (
const SectionAttr *SA = property->
getAttr<SectionAttr>())
2564 SetterMethod->addAttr(SectionAttr::CreateImplicit(
2566 SectionAttr::GNU_section));
2574 SetterMethod->setPropertyAccessor(
true);
2576 SetterMethod->createImplicitParams(
Context,
2577 SetterMethod->getClassInterface());
2578 property->setSetterMethodDecl(SetterMethod);
2592 if (!IsClassProperty) {
2605 if (!CurrentClass) {
2607 CurrentClass = Cat->getClassInterface();
2608 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(CD))
2609 CurrentClass = Impl->getClassInterface();
2619 unsigned &Attributes,
2620 bool propertyInPrimaryClass) {
2627 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2628 <<
"readonly" <<
"readwrite";
2636 !PropertyTy->isObjCRetainableType() &&
2637 !PropertyDecl->
hasAttr<ObjCNSObjectAttr>()) {
2638 Diag(Loc, diag::err_objc_property_requires_object)
2649 PropertyTy->isObjCRetainableType() &&
2650 !PropertyTy->isObjCARCImplicitlyUnretainedType()) {
2651 Diag(Loc, diag::warn_objc_property_assign_on_object);
2655 if (Attributes & ObjCDeclSpec::DQ_PR_assign) {
2657 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2658 <<
"assign" <<
"copy";
2662 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2663 <<
"assign" <<
"retain";
2667 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2668 <<
"assign" <<
"strong";
2673 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2674 <<
"assign" <<
"weak";
2677 if (PropertyDecl->
hasAttr<IBOutletCollectionAttr>())
2678 Diag(Loc, diag::warn_iboutletcollection_property_assign);
2679 }
else if (Attributes & ObjCDeclSpec::DQ_PR_unsafe_unretained) {
2681 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2682 <<
"unsafe_unretained" <<
"copy";
2686 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2687 <<
"unsafe_unretained" <<
"retain";
2691 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2692 <<
"unsafe_unretained" <<
"strong";
2697 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2698 <<
"unsafe_unretained" <<
"weak";
2703 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2704 <<
"copy" <<
"retain";
2708 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2709 <<
"copy" <<
"strong";
2713 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2714 <<
"copy" <<
"weak";
2720 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2721 <<
"retain" <<
"weak";
2725 (Attributes & ObjCDeclSpec::DQ_PR_weak)) {
2726 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2727 <<
"strong" <<
"weak";
2731 if (Attributes & ObjCDeclSpec::DQ_PR_weak) {
2733 if (
auto nullability = PropertyTy->getNullability(
Context)) {
2735 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2736 <<
"nonnull" <<
"weak";
2742 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2743 <<
"atomic" <<
"nonatomic";
2750 if (Attributes & ObjCDeclSpec::DQ_PR_readonly) {
2756 }
else if (PropertyTy->isObjCObjectPointerType()) {
2758 (PropertyTy->isObjCClassType() ||
2759 PropertyTy->isObjCQualifiedClassType());
2764 else if (propertyInPrimaryClass) {
2769 Diag(Loc, diag::warn_objc_property_no_assignment_attribute);
2773 Diag(Loc, diag::warn_objc_property_default_assign_on_object);
2783 if (!(Attributes & ObjCDeclSpec::DQ_PR_copy)
2786 && PropertyTy->isBlockPointerType())
2787 Diag(Loc, diag::warn_objc_property_copy_missing_on_block);
2788 else if ((Attributes & ObjCDeclSpec::DQ_PR_retain) &&
2790 !(Attributes & ObjCDeclSpec::DQ_PR_strong) &&
2791 PropertyTy->isBlockPointerType())
2792 Diag(Loc, diag::warn_objc_property_retain_of_block);
2794 if ((Attributes & ObjCDeclSpec::DQ_PR_readonly) &&
2796 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 isClassMethod() const
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Represents a function declaration or definition.
void setGetterMethodDecl(ObjCMethodDecl *MD)
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.
void setAttrs(const AttrVec &Attrs)
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.
SourceLocation getBeginLoc() const LLVM_READONLY
Captures information about "declaration specifiers" specific to Objective-C.
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, ImplementationControl impControl=None, bool HasRelatedResultType=false)
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)
SourceLocation getEndLoc() const
Get the end source location.
void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID)
createImplicitParams - Used to lazily create the self and cmd implict parameters. ...
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.
bool allowsDirectDispatch() const
Does this runtime supports direct dispatch.
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.
void setSelfDecl(ImplicitParamDecl *SD)
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?
bool isDirectProperty() const
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
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl *> Params, ArrayRef< SourceLocation > SelLocs=llvm::None)
Sets the method's parameters and selector source locations.
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)
void getSelectorLocs(SmallVectorImpl< SourceLocation > &SelLocs) const
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" ...
visible_extensions_range visible_extensions() const
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)
SourceLocation getEndLoc() const LLVM_READONLY
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.
This represents one expression.
known_extensions_range known_extensions() const
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
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver's type...
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.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Defines the clang::Preprocessor interface.
DeclContext * getDeclContext()
ObjCInterfaceDecl * getSuperClass() const
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
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...
void setDefined(bool isDefined)
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
ImplicitParamDecl * getSelfDecl() const
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.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType)
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
TypeSourceInfo * getReturnTypeSourceInfo() const
RecordDecl * getDecl() const
bool isSynthesizedAccessorStub() const
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)
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
void setSetterMethodDecl(ObjCMethodDecl *MD)
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 ...
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.
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
ImplementationControl getImplementationControl() 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.
static ObjCMethodDecl * RedeclarePropertyAccessor(ASTContext &Context, ObjCImplementationDecl *Impl, ObjCMethodDecl *AccessorDecl, SourceLocation AtLoc, SourceLocation PropertyLoc)
Create a synthesized property accessor stub inside the @implementation.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups, surround it with a ExprWithCleanups node.
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.
ImplicitParamDecl * getCmdDecl() const
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...
SourceLocation getBeginLoc() const LLVM_READONLY
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.
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
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
void setCmdDecl(ImplicitParamDecl *CD)
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.
ArrayRef< ParmVarDecl * > parameters() const
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...