24 #include "llvm/ADT/DenseSet.h"
25 #include "llvm/ADT/SmallString.h"
27 using namespace clang;
68 if (property->isInvalidDecl())
return;
71 =
property->getPropertyAttributes();
73 =
property->getType().getObjCLifetime();
79 if (!expectedLifetime) {
93 property->setPropertyAttributes(attr);
97 if (propertyLifetime == expectedLifetime)
return;
99 property->setInvalidDecl();
100 S.
Diag(property->getLocation(),
101 diag::err_arc_inconsistent_property_ownership)
112 llvm::SmallPtrSetImpl<ObjCProtocolDecl *> &Known) {
114 if (!Known.insert(Proto).second)
119 for (
unsigned I = 0, N = R.
size();
I != N; ++
I) {
150 llvm_unreachable(
"bad qualifier");
201 if (CDecl->IsClassExtension()) {
203 FD, GetterSel, SetterSel,
207 T, TSI, MethodImplKind);
215 GetterSel, SetterSel, isReadWrite,
217 T, TSI, MethodImplKind);
219 Res->setLexicalDeclContext(lexicalDC);
224 (isa<ObjCInterfaceDecl>(ClassDecl) ||
225 isa<ObjCProtocolDecl>(ClassDecl)));
228 if (Res->getType().getObjCLifetime())
231 llvm::SmallPtrSet<ObjCProtocolDecl *, 16> KnownProtos;
234 bool FoundInSuper =
false;
238 for (
unsigned I = 0, N = R.
size();
I != N; ++
I) {
248 CurrentInterfaceDecl = Super;
253 for (
auto *
P : CurrentInterfaceDecl->
protocols()) {
258 for (
auto *
P : IFace->all_referenced_protocols()) {
266 if (!Cat->IsClassExtension())
267 for (
auto *
P : Cat->protocols())
281 unsigned attributesAsWritten = 0;
320 bool invalidTemp =
false;
321 StringRef file = SM.
getBufferData(locInfo.first, &invalidTemp);
324 const char *tokenBegin = file.data() + locInfo.second;
329 file.begin(), tokenBegin, file.end());
332 lexer.LexFromRawLexer(Tok);
333 if (Tok.is(tok::raw_identifier) && Tok.getRawIdentifier() == attrName) {
334 Loc = Tok.getLocation();
337 }
while (Tok.isNot(tok::r_paren));
345 bool PropagateAtomicity) {
353 if (OldIsAtomic == NewIsAtomic)
return;
359 auto Attrs =
Property->getPropertyAttributes();
366 if (
Property->getPropertyAttributesAsWritten() &
375 const unsigned AtomicityMask =
377 if (PropagateAtomicity &&
380 Attrs = Attrs & ~AtomicityMask;
392 if ((OldIsAtomic && isImplicitlyReadonlyAtomic(OldProperty)) ||
393 (NewIsAtomic && isImplicitlyReadonlyAtomic(NewProperty)))
398 auto *OldDC = OldProperty->getDeclContext();
399 if (
auto Category = dyn_cast<ObjCCategoryDecl>(OldDC))
400 OldContextName =
Category->getClassInterface()->getIdentifier();
402 OldContextName = cast<ObjCContainerDecl>(OldDC)->
getIdentifier();
404 S.
Diag(NewProperty->getLocation(), diag::warn_property_attribute)
407 S.
Diag(OldProperty->getLocation(), diag::note_property_declare);
416 const bool isReadWrite,
417 unsigned &Attributes,
418 const unsigned AttributesAsWritten,
431 Diag(CDecl->getLocation(), diag::err_continuation_class);
444 if (PIDecl && isa<ObjCCategoryDecl>(PIDecl->getDeclContext())) {
445 Diag(AtLoc, diag::err_duplicate_property);
446 Diag(PIDecl->getLocation(), diag::note_property_declare);
464 ? diag::err_use_continuation_class_redeclaration_readwrite
465 : diag::err_use_continuation_class;
468 Diag(PIDecl->getLocation(), diag::note_property_declare);
476 Diag(AtLoc, diag::warn_property_redecl_getter_mismatch)
478 Diag(PIDecl->getLocation(), diag::note_property_declare);
487 unsigned ExistingOwnership
490 if (ExistingOwnership && NewOwnership != ExistingOwnership) {
493 Diag(AtLoc, diag::warn_property_attr_mismatch);
494 Diag(PIDecl->getLocation(), diag::note_property_declare);
498 Attributes = (Attributes & ~
OwnershipMask) | ExistingOwnership;
507 Diag(AtLoc, diag::warn_property_implicitly_mismatched);
508 Diag(PIDecl->getLocation(), diag::note_property_declare);
515 FD, GetterSel, SetterSel,
517 Attributes, AttributesAsWritten,
518 T, TSI, MethodImplKind, DC);
528 bool IncompatibleObjC =
false;
538 if (!isa<ObjCObjectPointerType>(PrimaryClassPropertyT) ||
539 !isa<ObjCObjectPointerType>(ClassExtPropertyT) ||
541 ConvertedType, IncompatibleObjC))
542 || IncompatibleObjC) {
544 diag::err_type_mismatch_continuation_class) << PDecl->
getType();
545 Diag(PIDecl->getLocation(), diag::note_property_declare);
566 const bool isReadWrite,
567 const unsigned Attributes,
568 const unsigned AttributesAsWritten,
599 Diag(AtLoc, diag::warn_implements_nscopying) << PropertyId;
617 LParenLoc, T, TInfo);
624 Diag(PDecl->getLocation(), diag::err_duplicate_property);
625 Diag(prevDecl->getLocation(), diag::note_property_declare);
626 PDecl->setInvalidDecl();
631 PDecl->setLexicalDeclContext(lexicalDC);
634 if (T->isArrayType() || T->isFunctionType()) {
635 Diag(AtLoc, diag::err_property_type) << T;
636 PDecl->setInvalidDecl();
643 PDecl->setGetterName(GetterSel);
644 PDecl->setSetterName(SetterSel);
645 PDecl->setPropertyAttributesAsWritten(
685 if (Attributes & ObjCDeclSpec::DQ_PR_unsafe_unretained)
690 if (MethodImplKind == tok::objc_required)
692 else if (MethodImplKind == tok::objc_optional)
701 if (Attributes & ObjCDeclSpec::DQ_PR_class)
710 if (property->isInvalidDecl() || ivar->isInvalidDecl())
return;
718 property->getType());
721 if (propertyLifetime == ivarLifetime)
return;
747 switch (propertyLifetime) {
749 S.
Diag(ivar->getLocation(), diag::err_arc_strong_property_ownership)
756 S.
Diag(ivar->getLocation(), diag::error_weak_property)
762 S.
Diag(ivar->getLocation(), diag::err_arc_assign_property_ownership)
765 << ((
property->getPropertyAttributesAsWritten()
770 llvm_unreachable(
"properties cannot be autoreleasing");
777 S.
Diag(property->getLocation(), diag::note_property_declare);
779 S.
Diag(propertyImplLoc, diag::note_property_synthesize);
791 property->getType());
819 PDecl->collectInheritedProtocolProperties(Property, PropMap);
823 for (
const auto *PI : SDecl->all_referenced_protocols()) {
825 PDecl->collectInheritedProtocolProperties(Property, PropMap);
827 SDecl = SDecl->getSuperClass();
834 bool FirsTime =
true;
836 I = PropMap.begin(),
E = PropMap.end();
I !=
E;
I++) {
840 bool IncompatibleObjC =
false;
843 || IncompatibleObjC) {
845 S.
Diag(Property->getLocation(), diag::warn_protocol_property_mismatch)
849 S.
Diag(Prop->getLocation(), diag::note_protocol_property_declare)
854 if (!FirsTime && AtLoc.
isValid())
855 S.
Diag(AtLoc, diag::note_property_synthesize);
875 auto OrigClass =
Category->getClassInterface();
876 for (
auto Found : OrigClass->lookup(Prop->
getDeclName())) {
878 return OrigProp->getPropertyAttributesAsWritten() &
OwnershipMask;
882 for (
const auto *Proto : OrigClass->all_referenced_protocols()) {
885 return OrigProp->getPropertyAttributesAsWritten() &
OwnershipMask;
907 Diag(AtLoc, diag::error_missing_property_context);
911 PropertyIvarLoc = PropertyLoc;
914 PropertyDiagLoc = ClassImpDecl->getLocStart();
921 if ((IC = dyn_cast<ObjCImplementationDecl>(ClassImpDecl))) {
926 "ActOnPropertyImplDecl - @implementation without @interface");
931 Diag(PropertyLoc, diag::error_bad_property_decl) << IDecl->
getDeclName();
934 if (property->isClassProperty() && Synthesize) {
935 Diag(PropertyLoc, diag::error_synthesize_on_class_property) << PropertyId;
938 unsigned PIkind =
property->getPropertyAttributesAsWritten();
942 Diag(AtLoc, diag::warn_implicit_atomic_property);
944 Diag(IC->getLocation(), diag::warn_auto_implicit_atomic_property);
945 Diag(property->getLocation(), diag::note_property_declare);
949 dyn_cast<ObjCCategoryDecl>(property->getDeclContext())) {
950 if (!CD->IsClassExtension()) {
951 Diag(PropertyLoc, diag::error_category_property) << CD->getDeclName();
952 Diag(property->getLocation(), diag::note_property_declare);
958 property->hasAttr<IBOutletAttr>() &&
960 bool ReadWriteProperty =
false;
967 PIkind = ExtProp->getPropertyAttributesAsWritten();
969 ReadWriteProperty =
true;
975 if (!ReadWriteProperty) {
976 Diag(property->getLocation(), diag::warn_auto_readonly_iboutlet_property)
980 property->getLParenLoc(), readonlyLoc)) {
983 SourceRange ReadonlySourceRange(readonlyLoc, endLoc);
984 Diag(property->getLocation(),
985 diag::note_auto_readonly_iboutlet_fixup_suggest) <<
990 if (Synthesize && isa<ObjCProtocolDecl>(property->getDeclContext()))
993 }
else if ((CatImplClass = dyn_cast<ObjCCategoryImplDecl>(ClassImpDecl))) {
995 Diag(AtLoc, diag::error_synthesize_category_decl);
1000 Diag(AtLoc, diag::error_missing_property_interface);
1013 Diag(PropertyLoc, diag::error_bad_category_property_decl)
1018 Diag(AtLoc, diag::error_bad_property_context);
1022 bool CompleteTypeErr =
false;
1028 PropertyIvar = PropertyId;
1032 QualType PropType =
property->getType();
1036 diag::err_incomplete_synthesized_property,
1037 property->getDeclName())) {
1038 Diag(property->getLocation(), diag::note_property_declare);
1039 CompleteTypeErr =
true;
1043 (
property->getPropertyAttributesAsWritten() &
1050 =
property->getPropertyAttributes();
1052 bool isARCWeak =
false;
1058 Diag(PropertyDiagLoc, diag::err_gc_weak_property_strong_type);
1059 Diag(property->getLocation(), diag::note_property_declare);
1071 Diag(PropertyDiagLoc,
1073 ? diag::err_synthesizing_arc_weak_property_disabled
1074 : diag::err_synthesizing_arc_weak_property_no_runtime);
1075 Diag(property->getLocation(), diag::note_property_declare);
1077 CompleteTypeErr =
true;
1084 Diag(property->getLocation(),
1085 diag::err_arc_weak_unavailable_property)
1086 << PropertyIvarType;
1087 Diag(ClassImpDecl->getLocation(), diag::note_implemented_by_class)
1105 Diag(PropertyDiagLoc,
1106 diag::warn_autosynthesis_property_ivar_match)
1107 << PropertyId << (Ivar ==
nullptr) << PropertyIvar
1109 Diag(property->getLocation(), diag::note_property_declare);
1110 Diag(originalIvar->getLocation(), diag::note_ivar_decl);
1117 if ((
getLangOpts().ObjCAutoRefCount || isARCWeak) &&
1125 Diag(PropertyDiagLoc,
1126 diag::err_arc_objc_property_default_assign_on_object);
1127 Diag(property->getLocation(), diag::note_property_declare);
1131 assert(lifetime &&
"no lifetime for property?");
1140 PropertyIvarLoc,PropertyIvarLoc, PropertyIvar,
1141 PropertyIvarType,
nullptr,
1143 (
Expr *)
nullptr,
true);
1146 diag::err_abstract_type_in_decl,
1148 Diag(property->getLocation(), diag::note_property_declare);
1149 Ivar->setInvalidDecl();
1150 }
else if (CompleteTypeErr)
1151 Ivar->setInvalidDecl();
1156 Diag(PropertyDiagLoc, diag::error_missing_property_ivar_decl)
1162 Diag(PropertyDiagLoc, diag::error_ivar_in_superclass_use)
1165 Diag(Ivar->getLocation(), diag::note_previous_access_declaration)
1169 property->setPropertyIvarDecl(Ivar);
1175 if (isa<ObjCObjectPointerType>(PropertyIvarType)
1176 && isa<ObjCObjectPointerType>(IvarType))
1187 Diag(PropertyDiagLoc, diag::error_property_ivar_type)
1188 <<
property->getDeclName() << PropType
1190 Diag(Ivar->getLocation(), diag::note_ivar_decl);
1200 if (lhsType != rhsType &&
1202 Diag(PropertyDiagLoc, diag::error_property_ivar_type)
1203 <<
property->getDeclName() << PropType
1205 Diag(Ivar->getLocation(), diag::note_ivar_decl);
1212 Diag(PropertyDiagLoc, diag::error_weak_property)
1213 <<
property->getDeclName() << Ivar->
getDeclName();
1214 Diag(Ivar->getLocation(), diag::note_ivar_decl);
1218 if ((property->getType()->isObjCObjectPointerType() ||
1221 Diag(PropertyDiagLoc, diag::error_strong_property)
1222 <<
property->getDeclName() << Ivar->
getDeclName();
1226 if (
getLangOpts().ObjCAutoRefCount || isARCWeak ||
1229 }
else if (PropertyIvar)
1231 Diag(PropertyDiagLoc, diag::error_dynamic_property_ivar_decl);
1233 assert (property &&
"ActOnPropertyImplDecl - property declaration missing");
1240 Ivar, PropertyIvarLoc);
1242 if (CompleteTypeErr || !compat)
1243 PIDecl->setInvalidDecl();
1245 if (
ObjCMethodDecl *getterMethod = property->getGetterMethodDecl()) {
1246 getterMethod->createImplicitParams(
Context, IDecl);
1258 Expr *LoadSelfExpr =
1260 CK_LValueToRValue, SelfExpr,
nullptr,
1266 Ivar->getLocation(),
1267 LoadSelfExpr,
true,
true);
1270 getterMethod->getReturnType(),
1272 PropertyDiagLoc, IvarRefExpr);
1280 if (property->hasAttr<NSReturnsNotRetainedAttr>() &&
1281 !getterMethod->hasAttr<NSReturnsNotRetainedAttr>()) {
1282 Diag(getterMethod->getLocation(),
1283 diag::warn_property_getter_owning_mismatch);
1284 Diag(property->getLocation(), diag::note_property_declare);
1287 switch (getterMethod->getMethodFamily()) {
1292 Diag(getterMethod->getLocation(), diag::err_arc_illegal_method_def)
1293 << 1 << getterMethod->getSelector();
1299 if (
ObjCMethodDecl *setterMethod = property->getSetterMethodDecl()) {
1300 setterMethod->createImplicitParams(
Context, IDecl);
1310 Expr *LoadSelfExpr =
1312 CK_LValueToRValue, SelfExpr,
nullptr,
1318 Ivar->getLocation(),
1319 LoadSelfExpr,
true,
true);
1327 BO_Assign, lhs, rhs);
1328 if (property->getPropertyAttributes() &
1332 dyn_cast_or_null<CXXOperatorCallExpr>(callExpr))
1333 if (
const FunctionDecl *FuncDecl = CXXCE->getDirectCallee())
1334 if (!FuncDecl->isTrivial())
1335 if (property->getType()->isReferenceType()) {
1336 Diag(PropertyDiagLoc,
1337 diag::err_atomic_property_nontrivial_assign_op)
1338 <<
property->getType();
1339 Diag(FuncDecl->getLocStart(),
1340 diag::note_callee_decl) << FuncDecl;
1351 Diag(PropertyLoc, diag::error_duplicate_ivar_use)
1352 << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()
1354 Diag(PPIDecl->getLocation(), diag::note_previous_use);
1359 Diag(PropertyLoc, diag::error_property_implemented) << PropertyId;
1360 Diag(PPIDecl->getLocation(), diag::note_previous_declaration);
1375 if (PropertyIvar && PropertyIvar != PropertyId)
1381 Diag(Ivar->getLocation(), diag::err_undeclared_var_use)
1383 Ivar->setInvalidDecl();
1390 Diag(PropertyDiagLoc, diag::error_duplicate_ivar_use)
1391 << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()
1393 Diag(PPIDecl->getLocation(), diag::note_previous_use);
1398 Diag(PropertyDiagLoc, diag::error_property_implemented) << PropertyId;
1399 Diag(PPIDecl->getLocation(), diag::note_previous_declaration);
1419 bool OverridingProtocolProperty) {
1428 if (!OverridingProtocolProperty &&
1434 Diag(Property->getLocation(), diag::warn_readonly_property)
1437 != (SAttr & ObjCPropertyDecl::OBJC_PR_copy))
1438 Diag(Property->getLocation(), diag::warn_property_attribute)
1439 << Property->
getDeclName() <<
"copy" << inheritedName;
1440 else if (!(SAttr & ObjCPropertyDecl::OBJC_PR_readonly)){
1441 unsigned CAttrRetain =
1444 unsigned SAttrRetain =
1447 bool CStrong = (CAttrRetain != 0);
1448 bool SStrong = (SAttrRetain != 0);
1449 if (CStrong != SStrong)
1450 Diag(Property->getLocation(), diag::warn_property_attribute)
1451 << Property->
getDeclName() <<
"retain (or strong)" << inheritedName;
1460 Diag(Property->getLocation(), diag::warn_property_attribute)
1461 << Property->
getDeclName() <<
"setter" << inheritedName;
1462 Diag(SuperProperty->getLocation(), diag::note_property_declare);
1465 Diag(Property->getLocation(), diag::warn_property_attribute)
1466 << Property->
getDeclName() <<
"getter" << inheritedName;
1467 Diag(SuperProperty->getLocation(), diag::note_property_declare);
1478 bool IncompatibleObjC =
false;
1481 ConvertedType, IncompatibleObjC) ||
1483 Diag(Property->getLocation(), diag::warn_property_types_are_incompatible)
1484 << Property->
getType() << SuperProperty->
getType() << inheritedName;
1485 Diag(SuperProperty->getLocation(), diag::note_property_declare);
1497 property->getType().getNonReferenceType().getAtomicUnqualifiedType();
1502 if ((propertyObjCPtr =
1508 Diag(Loc, diag::error_property_accessor_type)
1509 <<
property->getDeclName() << PropertyRValueType
1511 Diag(GetterMethod->getLocation(), diag::note_declared_at);
1523 Diag(Loc, diag::warn_accessor_property_type_mismatch)
1524 <<
property->getDeclName()
1526 Diag(GetterMethod->getLocation(), diag::note_declared_at);
1539 bool CollectClassPropsOnly =
false,
1540 bool IncludeProtocols =
true) {
1542 for (
auto *Prop : IDecl->properties()) {
1543 if (CollectClassPropsOnly && !Prop->isClassProperty())
1545 PropMap[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] =
1550 for (
auto *Ext : IDecl->visible_extensions())
1552 CollectClassPropsOnly, IncludeProtocols);
1554 if (IncludeProtocols) {
1556 for (
auto *PI : IDecl->all_referenced_protocols())
1558 CollectClassPropsOnly);
1562 for (
auto *Prop : CATDecl->properties()) {
1563 if (CollectClassPropsOnly && !Prop->isClassProperty())
1565 PropMap[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] =
1568 if (IncludeProtocols) {
1570 for (
auto *PI : CATDecl->protocols())
1572 CollectClassPropsOnly);
1576 for (
auto *Prop : PDecl->properties()) {
1577 if (CollectClassPropsOnly && !Prop->isClassProperty())
1580 SuperPropMap[std::make_pair(Prop->getIdentifier(),
1581 Prop->isClassProperty())];
1584 if (!PropertyFromSuper ||
1585 PropertyFromSuper->
getIdentifier() != Prop->getIdentifier()) {
1587 PropMap[std::make_pair(Prop->getIdentifier(),
1588 Prop->isClassProperty())];
1594 for (
auto *PI : PDecl->protocols())
1596 CollectClassPropsOnly);
1608 SDecl->collectPropertiesToImplement(PropMap, PO);
1609 SDecl = SDecl->getSuperClass();
1632 (
Property->getPropertyIvarDecl() == IV))
1638 for (
const auto *
Property : Ext->instance_properties())
1641 (
Property->getPropertyIvarDecl() == IV))
1648 bool SuperClassImplementsGetter =
false;
1649 bool SuperClassImplementsSetter =
false;
1651 SuperClassImplementsSetter =
true;
1656 SuperClassImplementsGetter =
true;
1659 SuperClassImplementsSetter =
true;
1660 if (SuperClassImplementsGetter && SuperClassImplementsSetter)
1674 if (PropMap.empty())
1679 for (
unsigned i = 0, e = PropertyOrder.size(); i != e; i++) {
1682 if (Prop->isInvalidDecl() ||
1698 Diag(Prop->getLocation(), diag::warn_no_autosynthesis_shared_ivar_property)
1700 if (PID->getLocation().isValid())
1701 Diag(PID->getLocation(), diag::note_property_synthesize);
1708 dyn_cast<ObjCProtocolDecl>(Prop->getDeclContext())) {
1714 Diag(IMPDecl->getLocation(),
1715 diag::warn_auto_synthesizing_protocol_property)
1717 Diag(Prop->getLocation(), diag::note_property_declare);
1722 if (PropInSuperClass) {
1728 Diag(Prop->getLocation(), diag::warn_no_autosynthesis_property)
1730 Diag(PropInSuperClass->getLocation(), diag::note_property_declare);
1733 Diag(Prop->getLocation(), diag::warn_autosynthesis_property_in_superclass)
1735 Diag(PropInSuperClass->getLocation(), diag::note_property_declare);
1736 Diag(IMPDecl->getLocation(), diag::note_while_in_implementation);
1751 Diag(Prop->getLocation(), diag::warn_missing_explicit_synthesis);
1752 Diag(IMPDecl->getLocation(), diag::note_while_in_implementation);
1764 if (!IDecl->isObjCRequiresPropertyDefs())
1772 llvm::SmallPtrSet<const ObjCMethodDecl *, 8> &
SMap) {
1775 auto I = std::find_if(SMap.begin(), SMap.end(),
1777 return x->getSelector() == Method &&
1784 if (
I == SMap.end() &&
1785 (PrimaryClass ==
nullptr ||
1789 isa<ObjCCategoryDecl>(CDecl)
1791 ? diag::warn_impl_required_in_category_for_class_property
1792 : diag::warn_setter_getter_impl_required_in_category)
1794 ? diag::warn_impl_required_for_class_property
1795 : diag::warn_setter_getter_impl_required);
1796 S.
Diag(IMPDecl->getLocation(), diag) << Prop->
getDeclName() << Method;
1797 S.
Diag(Prop->getLocation(), diag::note_property_declare);
1798 if (S.
LangOpts.ObjCDefaultSynthProperties &&
1802 S.
Diag(RID->getLocation(), diag::note_suppressed_class_declare);
1808 bool SynthesizeProperties) {
1822 if ((IDecl = C->getClassInterface())) {
1832 SynthesizeProperties);
1838 std::unique_ptr<ObjCContainerDecl::PropertyMap> LazyMap;
1841 if (!PDecl->hasAttr<ObjCExplicitProtocolImplAttr>())
1859 for (
auto *PropDecl : PDecl->properties()) {
1860 if ((*LazyMap)[std::make_pair(PropDecl->getIdentifier(),
1861 PropDecl->isClassProperty())])
1863 PropMap[std::make_pair(PropDecl->getIdentifier(),
1864 PropDecl->isClassProperty())] = PropDecl;
1869 if (PropMap.empty())
1874 PropImplMap.insert(
I->getPropertyDecl());
1876 llvm::SmallPtrSet<const ObjCMethodDecl *, 8> InsMap;
1878 for (
const auto *
I : IMPDecl->
methods())
1886 if (
ObjCImplDecl *IMP = PrimaryClass->getImplementation()) {
1890 for (
const auto *
I : IMP->methods())
1895 P = PropMap.begin(),
E = PropMap.end();
P !=
E; ++
P) {
1898 if (Prop->isInvalidDecl() ||
1900 PropImplMap.count(Prop) ||
1906 PrimaryClass, Prop->
getGetterName(), IMPDecl, CDecl, C, Prop, InsMap);
1907 if (!Prop->isReadOnly())
1909 PrimaryClass, Prop->getSetterName(),
1910 IMPDecl, CDecl, C, Prop, InsMap);
1916 const auto *
property = propertyImpl->getPropertyDecl();
1920 if (propertyImpl->getPropertyImplementation()
1922 (
property->getPropertyAttributes() &
1924 property->getGetterMethodDecl() &&
1925 property->getSetterMethodDecl()) {
1926 auto *getterMethod =
property->getGetterMethodDecl();
1927 auto *setterMethod =
property->getSetterMethodDecl();
1932 loc = impDecl->getLocStart();
1934 Diag(loc, diag::warn_null_resettable_setter)
1935 << setterMethod->getSelector() <<
property->getDeclName();
1949 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
1951 for (
auto *Prop : Ext->properties())
1952 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
1959 bool LookedUpGetterSetter =
false;
1972 LookedUpGetterSetter =
true;
1974 Diag(GetterMethod->getLocation(),
1975 diag::warn_default_atomic_custom_getter_setter)
1977 Diag(Property->getLocation(), diag::note_property_declare);
1980 Diag(SetterMethod->getLocation(),
1981 diag::warn_default_atomic_custom_getter_setter)
1983 Diag(Property->getLocation(), diag::note_property_declare);
1988 if ((Attributes & ObjCPropertyDecl::OBJC_PR_nonatomic) ||
1995 if (!LookedUpGetterSetter) {
2003 if ((GetterMethod && !SetterMethod) || (!GetterMethod && SetterMethod)) {
2005 (GetterMethod ? GetterMethod->getLocation()
2006 : SetterMethod->getLocation());
2007 Diag(MethodLoc, diag::warn_atomic_property_rule)
2009 << (SetterMethod !=
nullptr);
2016 StringRef NonatomicStr = AttributesAsWritten?
"nonatomic, "
2018 Diag(Property->getLocation(),
2019 diag::note_atomic_property_fixup_suggest)
2025 Diag(Property->getLocation(),
2026 diag::note_atomic_property_fixup_suggest)
2030 Diag(MethodLoc, diag::note_atomic_property_fixup_suggest);
2031 Diag(Property->getLocation(), diag::note_property_declare);
2043 if (PD && !PD->hasAttr<NSReturnsNotRetainedAttr>() &&
2053 Diag(PD->getLocation(), diag::err_cocoa_naming_owned_rule);
2055 Diag(PD->getLocation(), diag::warn_cocoa_naming_owned_rule);
2061 for (
auto *getterRedecl : method->redecls()) {
2062 if (getterRedecl->isImplicit())
2064 if (getterRedecl->getDeclContext() != PD->getDeclContext())
2066 noteLoc = getterRedecl->getLocation();
2067 fixItLoc = getterRedecl->getLocEnd();
2072 tok::kw___attribute, tok::l_paren, tok::l_paren,
2075 tok::r_paren, tok::r_paren
2077 StringRef spelling =
"__attribute__((objc_method_family(none)))";
2079 if (!macroName.empty())
2080 spelling = macroName;
2082 auto noteDiag =
Diag(noteLoc, diag::note_cocoa_naming_declare_family)
2086 fixItText += spelling;
2105 InitSelSet.insert(
I->getSelector());
2108 SuperD->getDesignatedInitializers(DesignatedInits);
2110 I = DesignatedInits.begin(),
E = DesignatedInits.end();
I !=
E; ++
I) {
2113 bool Ignore =
false;
2115 Ignore = IMD->isUnavailable();
2118 Diag(ImplD->getLocation(),
2119 diag::warn_objc_implementation_missing_designated_init_override)
2121 Diag(MD->getLocation(), diag::note_objc_designated_init_marked_here);
2132 for (
const auto *A : Property->attrs()) {
2133 if (isa<DeprecatedAttr>(A) ||
2134 isa<UnavailableAttr>(A) ||
2135 isa<AvailabilityAttr>(A))
2136 PropertyMethod->addAttr(A->clone(S.
Context));
2147 if (CD->isInvalidDecl())
2150 bool IsClassProperty =
property->isClassProperty();
2151 GetterMethod = IsClassProperty ?
2159 if (CatDecl->IsClassExtension())
2162 CatDecl->getClassInterface()->
2165 SetterMethod = IsClassProperty ?
2170 if (CatDecl->IsClassExtension())
2173 CatDecl->getClassInterface()->
2176 property->getLocation());
2180 property->getPropertyAttributes();
2184 Diag(SetterMethod->getLocation(), diag::err_setter_type_void);
2185 if (SetterMethod->param_size() != 1 ||
2187 (*SetterMethod->param_begin())->getType().getNonReferenceType(),
2188 property->getType().getNonReferenceType())) {
2189 Diag(property->getLocation(),
2190 diag::warn_accessor_property_type_mismatch)
2192 << SetterMethod->getSelector();
2193 Diag(SetterMethod->getLocation(), diag::note_declared_at);
2203 if (!GetterMethod) {
2211 QualType resultTy =
property->getType().getAtomicUnqualifiedType();
2220 modifiedTy, modifiedTy);
2226 resultTy,
nullptr, CD,
2227 !IsClassProperty,
false,
2230 (
property->getPropertyImplementation() ==
2234 CD->addDecl(GetterMethod);
2238 if (property->hasAttr<NSReturnsNotRetainedAttr>())
2239 GetterMethod->addAttr(NSReturnsNotRetainedAttr::CreateImplicit(
Context,
2242 if (property->hasAttr<ObjCReturnsInnerPointerAttr>())
2243 GetterMethod->addAttr(
2244 ObjCReturnsInnerPointerAttr::CreateImplicit(
Context, Loc));
2246 if (
const SectionAttr *SA = property->getAttr<SectionAttr>())
2247 GetterMethod->addAttr(
2248 SectionAttr::CreateImplicit(
Context, SectionAttr::GNU_section,
2249 SA->getName(), Loc));
2257 property->setGetterMethodDecl(GetterMethod);
2262 if (!SetterMethod) {
2272 nullptr, CD, !IsClassProperty,
2277 (
property->getPropertyImplementation() ==
2284 property->getType().getUnqualifiedType().getAtomicUnqualifiedType();
2294 modifiedTy, modifiedTy);
2307 SetterMethod->setMethodParams(
Context, Argument,
None);
2312 if (
const SectionAttr *SA = property->getAttr<SectionAttr>())
2313 SetterMethod->addAttr(
2314 SectionAttr::CreateImplicit(
Context, SectionAttr::GNU_section,
2315 SA->getName(), Loc));
2323 SetterMethod->setPropertyAccessor(
true);
2324 property->setSetterMethodDecl(SetterMethod);
2338 if (!IsClassProperty) {
2351 if (!CurrentClass) {
2353 CurrentClass = Cat->getClassInterface();
2354 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(CD))
2355 CurrentClass = Impl->getClassInterface();
2365 unsigned &Attributes,
2366 bool propertyInPrimaryClass) {
2368 if (!PDecl || PDecl->isInvalidDecl())
2373 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2374 <<
"readonly" <<
"readwrite";
2382 !PropertyTy->isObjCRetainableType() &&
2383 !PropertyDecl->hasAttr<ObjCNSObjectAttr>()) {
2384 Diag(Loc, diag::err_objc_property_requires_object)
2389 PropertyDecl->setInvalidDecl();
2395 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2396 <<
"assign" <<
"copy";
2400 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2401 <<
"assign" <<
"retain";
2405 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2406 <<
"assign" <<
"strong";
2411 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2412 <<
"assign" <<
"weak";
2415 if (PropertyDecl->hasAttr<IBOutletCollectionAttr>())
2416 Diag(Loc, diag::warn_iboutletcollection_property_assign);
2419 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2420 <<
"unsafe_unretained" <<
"copy";
2424 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2425 <<
"unsafe_unretained" <<
"retain";
2429 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2430 <<
"unsafe_unretained" <<
"strong";
2435 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2436 <<
"unsafe_unretained" <<
"weak";
2441 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2442 <<
"copy" <<
"retain";
2446 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2447 <<
"copy" <<
"strong";
2451 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2452 <<
"copy" <<
"weak";
2458 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2459 <<
"retain" <<
"weak";
2463 (Attributes & ObjCDeclSpec::DQ_PR_weak)) {
2464 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2465 <<
"strong" <<
"weak";
2469 if (Attributes & ObjCDeclSpec::DQ_PR_weak) {
2471 if (
auto nullability = PropertyTy->getNullability(
Context)) {
2473 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2474 <<
"nonnull" <<
"weak";
2480 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2481 <<
"atomic" <<
"nonatomic";
2488 if (Attributes & ObjCDeclSpec::DQ_PR_readonly) {
2494 }
else if (PropertyTy->isObjCObjectPointerType()) {
2496 (PropertyTy->isObjCClassType() ||
2497 PropertyTy->isObjCQualifiedClassType());
2502 else if (propertyInPrimaryClass) {
2507 Diag(Loc, diag::warn_objc_property_no_assignment_attribute);
2511 Diag(Loc, diag::warn_objc_property_default_assign_on_object);
2521 if (!(Attributes & ObjCDeclSpec::DQ_PR_copy)
2524 && PropertyTy->isBlockPointerType())
2525 Diag(Loc, diag::warn_objc_property_copy_missing_on_block);
2526 else if ((Attributes & ObjCDeclSpec::DQ_PR_retain) &&
2528 !(Attributes & ObjCDeclSpec::DQ_PR_strong) &&
2529 PropertyTy->isBlockPointerType())
2530 Diag(Loc, diag::warn_objc_property_retain_of_block);
2532 if ((Attributes & ObjCDeclSpec::DQ_PR_readonly) &&
2534 Diag(Loc, diag::warn_objc_readonly_property_has_setter);
StringRef getLastMacroWithSpelling(SourceLocation Loc, ArrayRef< TokenValue > Tokens) const
Return the name of the macro defined before Loc that has spelling Tokens.
A call to an overloaded operator written using operator syntax.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
protocol_range protocols() const
Lexer - This provides a simple interface that turns a text buffer into a stream of tokens...
Smart pointer class that efficiently represents Objective-C method names.
A (possibly-)qualified type.
ObjCInterfaceDecl * getClassInterface()
const ObjCInterfaceDecl * isObjCRequiresPropertyDefs() const
isObjCRequiresPropertyDefs - Checks that a class or one of its super classes must not be auto-synthes...
ObjCInterfaceDecl * getClassInterface()
bool IvarBacksCurrentMethodAccessor(ObjCInterfaceDecl *IFace, ObjCMethodDecl *Method, ObjCIvarDecl *IV)
IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is an ivar synthesized for 'Meth...
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
bool isObjCPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType, bool &IncompatibleObjC)
isObjCPointerConversion - Determines whether this is an Objective-C pointer conversion.
PropertyControl getPropertyImplementation() const
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const LangOptions & getLangOpts() const
bool isClassProperty() const
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
llvm::DenseMap< std::pair< IdentifierInfo *, unsigned >, ObjCPropertyDecl * > PropertyMap
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.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
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
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
void DiagnoseMissingDesignatedInitOverrides(const ObjCImplementationDecl *ImplD, const ObjCInterfaceDecl *IFD)
void CheckObjCPropertyAttributes(Decl *PropertyPtrTy, SourceLocation Loc, unsigned &Attributes, bool propertyInPrimaryClass)
Ensure attributes are consistent with type.
Captures information about "declaration specifiers" specific to Objective-C.
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.
void MarkDeclRefReferenced(DeclRefExpr *E)
Perform reference-marking and odr-use handling for a DeclRefExpr.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
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...
bool isArcWeakrefUnavailable() const
isArcWeakrefUnavailable - Checks for a class or one of its super classes to be incompatible with __we...
void setPropertyAccessor(bool isAccessor)
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 ...
RAII object to handle the state changes required to synthesize a function body.
QualType getUsageType(QualType objectType) const
Retrieve the type of this instance variable when viewed as a member of a specific object type...
llvm::DenseMap< const ObjCProtocolDecl *, ObjCPropertyDecl * > ProtocolPropertyMap
static unsigned getOwnershipRule(unsigned attr)
ObjCMethodDecl - Represents an instance or class method declaration.
bool ClassImplementsProtocol(ObjCProtocolDecl *lProto, bool lookupCategory, bool RHSIsQualifiedID=false)
ClassImplementsProtocol - Checks that 'lProto' protocol has been implemented in IDecl class...
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.
ParmVarDecl - Represents a parameter to a function.
bool isObjCRetainableType() const
Defines the clang::Expr interface and subclasses for C++ expressions.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names the category interface associated with this implementat...
The collection of all-type qualifiers we support.
TypeSourceInfo * getTypeSourceInfo() const
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...
One of these records is kept for each identifier that is lexed.
StringRef getBufferData(FileID FID, bool *Invalid=nullptr) const
Return a StringRef to the source buffer data for the specified FileID.
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.
bool isObjCARCImplicitlyUnretainedType() const
Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...
ObjCMethodFamily
A family of Objective-C methods.
ObjCPropertyDecl * FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyVisibleInPrimaryClass - Finds declaration of the property with name 'PropertyId' in the p...
all_protocol_range all_referenced_protocols() const
ObjCMethodDecl * getClassMethod(Selector Sel, bool AllowHidden=false) const
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Token - This structure provides full information about a lexed token.
method_range methods() const
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
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.
SourceLocation getBeginLoc() const
Get the begin source location.
bool IsClassExtension() const
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)
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
ObjCContainerDecl - Represents a container for method declarations.
const LangOptions & getLangOpts() const
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
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.
ObjCPropertyImplDecl * FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const
FindPropertyImplIvarDecl - This method lookup the ivar in the list of properties implemented in this ...
bool hasDesignatedInitializers() const
Returns true if this interface decl contains at least one initializer marked with the 'objc_designate...
static void DiagnoseUnimplementedAccessor(Sema &S, ObjCInterfaceDecl *PrimaryClass, Selector Method, ObjCImplDecl *IMPDecl, ObjCContainerDecl *CDecl, ObjCCategoryDecl *C, ObjCPropertyDecl *Prop, llvm::SmallPtrSet< const ObjCMethodDecl *, 8 > &SMap)
Selector getSetterName() const
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.
Represents an ObjC class declaration.
propimpl_range property_impls() const
detail::InMemoryDirectory::const_iterator I
PropertyAttributeKind getPropertyAttributes() const
const LangOptions & LangOpts
This object can be modified without requiring retains or releases.
void AtomicPropertySetterGetterRules(ObjCImplDecl *IMPDecl, ObjCInterfaceDecl *IDecl)
AtomicPropertySetterGetterRules - This routine enforces the rule (via warning) when atomic property h...
void setGetterCXXConstructor(Expr *getterCXXConstructor)
void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddInstanceMethodToGlobalPool - All instance methods in a translation unit are added to a global pool...
void CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod, ObjCInterfaceDecl *CurrentClass, ResultTypeCompatibilityKind RTC)
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.
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 ...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
ObjCPropertyAttributeKind getPropertyAttributes() const
llvm::SmallPtrSet< Selector, 8 > SelectorSet
ObjCPropertyImplDecl * FindPropertyImplDecl(IdentifierInfo *propertyId, ObjCPropertyQueryKind queryKind) const
FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl added to the list of thos...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
void addObjCLifetime(ObjCLifetime type)
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
Expr - This represents one expression.
static ObjCMethodDecl * Create(ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc, Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo, DeclContext *contextDecl, bool isInstance=true, bool isVariadic=false, bool isPropertyAccessor=false, bool isImplicitlyDeclared=false, bool isDefined=false, ImplementationControl impControl=None, bool HasRelatedResultType=false)
static ObjCPropertyDecl::PropertyAttributeKind makePropertyAttributesAsWritten(unsigned Attributes)
bool isObjCGCWeak() const
true when Type is objc's weak.
static bool hasWrittenStorageAttribute(ObjCPropertyDecl *Prop, ObjCPropertyQueryKind QueryKind)
Determine whether any storage attributes were written on the property.
Defines the clang::Preprocessor interface.
ParmVarDecl *const * param_iterator
Stores token information for comparing actual tokens with predefined values.
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
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)
bool isInstanceMethod() const
clang::ObjCRuntime ObjCRuntime
Qualifiers Quals
The local qualifiers.
ObjCPropertyDecl * HandlePropertyInClassExtension(Scope *S, SourceLocation AtLoc, SourceLocation LParenLoc, FieldDeclarator &FD, Selector GetterSel, Selector SetterSel, 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.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
SourceLocation getLocEnd() const LLVM_READONLY
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...
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
void DefaultSynthesizeProperties(Scope *S, ObjCImplDecl *IMPDecl, ObjCInterfaceDecl *IDecl)
DefaultSynthesizeProperties - This routine default synthesizes all properties which must be synthesiz...
bool hasObjCLifetime() const
There is no lifetime qualification on this type.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
bool isNonFragile() const
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?
Assigning into this object requires the old value to be released and the new value to be retained...
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
const TemplateArgument * iterator
bool isValid() const
Return true if this is a valid SourceLocation object.
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.
bool getSynthesize() const
static Qualifiers::ObjCLifetime getImpliedARCOwnership(ObjCPropertyDecl::PropertyAttributeKind attrs, QualType type)
getImpliedARCOwnership - Given a set of property attributes and a type, infer an expected lifetime...
ObjCCategoryDecl - Represents a category declaration.
const ObjCInterfaceDecl * getClassInterface() const
QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const
Return the uniqued reference to the type for an Objective-C gc-qualified type.
ObjCPropertyDecl * CreatePropertyDecl(Scope *S, ObjCContainerDecl *CDecl, SourceLocation AtLoc, SourceLocation LParenLoc, FieldDeclarator &FD, Selector GetterSel, Selector SetterSel, 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 isPropertyAccessor() const
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.
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=NotForRedeclaration)
Find the protocol with the given name, if any.
QualType getReturnType() const
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
const IdentifierInfo * getIdentifier() const
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.
QualType getType() const
Return the type wrapped by this type source info.
SourceLocation getLParenLoc() const
void DiagnoseOwningPropertyGetterSynthesis(const ObjCImplementationDecl *D)
llvm::SmallVector< ObjCPropertyDecl *, 8 > PropertyDeclOrder
void setSetterCXXAssignment(Expr *setterCXXAssignment)
static void checkARCPropertyImpl(Sema &S, SourceLocation propertyImplLoc, ObjCPropertyDecl *property, ObjCIvarDecl *ivar)
bool propertyTypesAreCompatible(QualType, QualType)
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
instmeth_range instance_methods() const
ObjCCategoryDecl * FindCategoryDeclaration(IdentifierInfo *CategoryId) const
FindCategoryDeclaration - Finds category declaration in the list of categories for this class and ret...
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 '...
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.
void diagnoseNullResettableSynthesizedSetters(const ObjCImplDecl *impDecl)
Diagnose any null-resettable synthesized setters.
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)
prop_range properties() const
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
The basic abstraction for the target Objective-C runtime.
SourceLocation getLocStart() const LLVM_READONLY
bool CheckARCMethodDecl(ObjCMethodDecl *method)
Check a method declaration for compatibility with the Objective-C ARC conventions.
Selector getGetterName() const
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
Selector getSelector() const
detail::InMemoryDirectory::const_iterator E
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
static void DiagnosePropertyMismatchDeclInProtocols(Sema &S, SourceLocation AtLoc, ObjCInterfaceDecl *ClassDecl, ObjCPropertyDecl *Property)
DiagnosePropertyMismatchDeclInProtocols - diagnose properties declared in inherited protocols with mi...
known_extensions_range known_extensions() const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
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)
bool isObjCObjectType() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
ObjCMethodDecl * getGetterMethodDecl() const
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).
const T * getAs() const
Member-template getAs<specific type>'.
void overwritePropertyAttributes(unsigned PRVal)
instprop_range instance_properties() const
const internal::VariadicDynCastAllOfMatcher< Stmt, CallExpr > callExpr
Matches call expressions.
protocol_range protocols() const
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...
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()
IdentifierInfo * getIdentifier() const
bool isObjCGCStrong() const
true when Type is objc's strong.
AccessControl getAccessControl() const
static bool LocPropertyAttribute(ASTContext &Context, const char *attrName, SourceLocation LParenLoc, SourceLocation &Loc)
Reading or writing from this object requires a barrier call.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups, surround it with a ExprWithCleanups node.
SourceLocation getIdentifierLoc() const
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D...
Compatible - the types are compatible according to the standard.
bool isReadOnly() const
isReadOnly - Return true iff the property has a setter.
ObjCIvarDecl - Represents an ObjC instance variable.
static unsigned deducePropertyOwnershipFromType(Sema &S, QualType T)
ObjCPropertyQueryKind getQueryKind() const
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
void setPropertyAttributes(PropertyAttributeKind PRVal)
void DiagnosePropertyMismatch(ObjCPropertyDecl *Property, ObjCPropertyDecl *SuperProperty, const IdentifierInfo *Name, bool OverridingProtocolProperty)
DiagnosePropertyMismatch - Compares two properties for their attributes and types and warns on a vari...
ObjCInterfaceDecl * getSuperClass() const
PropertyAttributeKind getPropertyAttributesAsWritten() const
bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD, ObjCMethodDecl *Getter, SourceLocation Loc)
bool isFragile() const
The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ...
static const unsigned OwnershipMask
A reference to a declared variable, function, enum, etc.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
void addPropertyImplementation(ObjCPropertyImplDecl *property)
An l-value expression is a reference to an object with independent storage.
A trivial tuple used to represent a source range.
bool isArithmeticType() const
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
llvm::DenseMap< const Stmt *, CFGBlock * > SMap
IdentifierInfo * getDefaultSynthIvarName(ASTContext &Ctx) const
Get the default name of the synthesized ivar.
void setType(QualType newType)
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
This class handles loading and caching of source files into memory.
Preprocessor & getPreprocessor() const
static void checkPropertyDeclWithOwnership(Sema &S, ObjCPropertyDecl *property)
Check the internal consistency of a property declaration with an explicit ownership qualifier...
TypeSourceInfo * GetTypeForDeclarator(Declarator &D, Scope *S)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.