24 #include "llvm/ADT/DenseSet.h"
25 #include "llvm/ADT/SmallString.h"
27 using namespace clang;
71 =
property->getPropertyAttributes();
73 =
property->getType().getObjCLifetime();
79 if (!expectedLifetime) {
93 property->setPropertyAttributes(attr);
97 if (propertyLifetime == expectedLifetime)
return;
99 property->setInvalidDecl();
101 diag::err_arc_inconsistent_property_ownership)
112 llvm::SmallPtrSetImpl<ObjCProtocolDecl *> &Known) {
114 if (!Known.insert(Proto).second)
119 for (
unsigned I = 0, N = R.
size();
I != N; ++
I) {
150 llvm_unreachable(
"bad qualifier");
201 if (CDecl->IsClassExtension()) {
206 isReadWrite, Attributes,
208 T, TSI, MethodImplKind);
226 (isa<ObjCInterfaceDecl>(ClassDecl) ||
227 isa<ObjCProtocolDecl>(ClassDecl)));
230 if (Res->getType().getObjCLifetime())
233 llvm::SmallPtrSet<ObjCProtocolDecl *, 16> KnownProtos;
236 bool FoundInSuper =
false;
240 for (
unsigned I = 0, N = R.
size();
I != N; ++
I) {
250 CurrentInterfaceDecl = Super;
255 for (
auto *
P : CurrentInterfaceDecl->
protocols()) {
260 for (
auto *
P : IFace->all_referenced_protocols()) {
268 if (!Cat->IsClassExtension())
269 for (
auto *
P : Cat->protocols())
283 unsigned attributesAsWritten = 0;
322 bool invalidTemp =
false;
323 StringRef file = SM.
getBufferData(locInfo.first, &invalidTemp);
326 const char *tokenBegin = file.data() + locInfo.second;
331 file.begin(), tokenBegin, file.end());
334 lexer.LexFromRawLexer(Tok);
335 if (Tok.is(tok::raw_identifier) && Tok.getRawIdentifier() == attrName) {
336 Loc = Tok.getLocation();
339 }
while (Tok.isNot(tok::r_paren));
347 bool PropagateAtomicity) {
355 if (OldIsAtomic == NewIsAtomic)
return;
361 auto Attrs =
Property->getPropertyAttributes();
368 if (
Property->getPropertyAttributesAsWritten() &
377 const unsigned AtomicityMask =
379 if (PropagateAtomicity &&
382 Attrs = Attrs & ~AtomicityMask;
394 if ((OldIsAtomic && isImplicitlyReadonlyAtomic(OldProperty)) ||
395 (NewIsAtomic && isImplicitlyReadonlyAtomic(NewProperty)))
401 if (
auto Category = dyn_cast<ObjCCategoryDecl>(OldDC))
402 OldContextName =
Category->getClassInterface()->getIdentifier();
404 OldContextName = cast<ObjCContainerDecl>(OldDC)->
getIdentifier();
421 const bool isReadWrite,
422 unsigned &Attributes,
423 const unsigned AttributesAsWritten,
450 Diag(AtLoc, diag::err_duplicate_property);
469 ? diag::err_use_continuation_class_redeclaration_readwrite
470 : diag::err_use_continuation_class;
481 Diag(AtLoc, diag::warn_property_redecl_getter_mismatch)
492 unsigned ExistingOwnership
495 if (ExistingOwnership && NewOwnership != ExistingOwnership) {
498 Diag(AtLoc, diag::warn_property_attr_mismatch);
503 Attributes = (Attributes & ~
OwnershipMask) | ExistingOwnership;
512 Diag(AtLoc, diag::warn_property_implicitly_mismatched);
520 FD, GetterSel, GetterNameLoc,
521 SetterSel, SetterNameLoc,
523 Attributes, AttributesAsWritten,
524 T, TSI, MethodImplKind, DC);
534 bool IncompatibleObjC =
false;
544 if (!isa<ObjCObjectPointerType>(PrimaryClassPropertyT) ||
545 !isa<ObjCObjectPointerType>(ClassExtPropertyT) ||
547 ConvertedType, IncompatibleObjC))
548 || IncompatibleObjC) {
550 diag::err_type_mismatch_continuation_class) << PDecl->
getType();
574 const bool isReadWrite,
575 const unsigned Attributes,
576 const unsigned AttributesAsWritten,
607 Diag(AtLoc, diag::warn_implements_nscopying) << PropertyId;
625 LParenLoc, T, TInfo);
632 Diag(PDecl->getLocation(), diag::err_duplicate_property);
633 Diag(prevDecl->getLocation(), diag::note_property_declare);
634 PDecl->setInvalidDecl();
639 PDecl->setLexicalDeclContext(lexicalDC);
642 if (T->isArrayType() || T->isFunctionType()) {
643 Diag(AtLoc, diag::err_property_type) << T;
644 PDecl->setInvalidDecl();
651 PDecl->setGetterName(GetterSel, GetterNameLoc);
652 PDecl->setSetterName(SetterSel, SetterNameLoc);
653 PDecl->setPropertyAttributesAsWritten(
693 if (Attributes & ObjCDeclSpec::DQ_PR_unsafe_unretained)
698 if (MethodImplKind == tok::objc_required)
700 else if (MethodImplKind == tok::objc_optional)
709 if (Attributes & ObjCDeclSpec::DQ_PR_class)
726 property->getType());
729 if (propertyLifetime == ivarLifetime)
return;
755 switch (propertyLifetime) {
773 << ((
property->getPropertyAttributesAsWritten()
778 llvm_unreachable(
"properties cannot be autoreleasing");
787 S.
Diag(propertyImplLoc, diag::note_property_synthesize);
799 property->getType());
820 return (Attr1 & Kind) != (Attr2 &
Kind);
825 return ((Attr1 & Kinds) != 0) != ((Attr2 & Kinds) != 0);
838 "Expected a property from a protocol");
843 PDecl->collectInheritedProtocolProperties(Property, ProtocolSet,
848 for (
const auto *PI : SDecl->all_referenced_protocols()) {
850 PDecl->collectInheritedProtocolProperties(Property, ProtocolSet,
853 SDecl = SDecl->getSuperClass();
857 if (Properties.empty())
861 size_t SelectedIndex = 0;
862 for (
const auto &Prop : llvm::enumerate(Properties)) {
864 if (Property->
isReadOnly() && !Prop.value()->isReadOnly()) {
865 Property = Prop.value();
866 SelectedIndex = Prop.index();
869 if (Property != OriginalProperty) {
871 Properties[SelectedIndex] = OriginalProperty;
877 IncompatibleType = 0,
878 HasNoExpectedAttribute,
879 HasUnexpectedAttribute,
885 struct MismatchingProperty {
888 StringRef AttributeName;
893 unsigned Attr = Prop->getPropertyAttributesAsWritten();
894 if (Attr != OriginalAttributes) {
895 auto Diag = [&](
bool OriginalHasAttribute, StringRef AttributeName) {
896 MismatchKind
Kind = OriginalHasAttribute ? HasNoExpectedAttribute
897 : HasUnexpectedAttribute;
898 Mismatches.push_back({Prop,
Kind, AttributeName});
910 "retain (or strong)");
920 Mismatches.push_back({Prop, DifferentGetter,
""});
923 if (!Property->
isReadOnly() && !Prop->isReadOnly() &&
925 Mismatches.push_back({Prop, DifferentSetter,
""});
930 bool IncompatibleObjC =
false;
933 || IncompatibleObjC) {
934 Mismatches.push_back({Prop, IncompatibleType,
""});
940 if (Mismatches.empty())
945 bool HasIncompatibleAttributes =
false;
946 for (
const auto &Note : Mismatches)
947 HasIncompatibleAttributes =
948 Note.Kind != IncompatibleType ?
true : HasIncompatibleAttributes;
952 Property != OriginalProperty || HasIncompatibleAttributes
953 ? diag::err_protocol_property_mismatch
954 : diag::warn_protocol_property_mismatch);
955 Diag << Mismatches[0].Kind;
956 switch (Mismatches[0].
Kind) {
957 case IncompatibleType:
960 case HasNoExpectedAttribute:
961 case HasUnexpectedAttribute:
962 Diag << Mismatches[0].AttributeName;
964 case DifferentGetter:
967 case DifferentSetter:
972 for (
const auto &Note : Mismatches) {
974 S.
Diag(Note.Prop->getLocation(), diag::note_protocol_property_declare)
977 case IncompatibleType:
978 Diag << Note.Prop->getType();
980 case HasNoExpectedAttribute:
981 case HasUnexpectedAttribute:
982 Diag << Note.AttributeName;
984 case DifferentGetter:
985 Diag << Note.Prop->getGetterName();
987 case DifferentSetter:
988 Diag << Note.Prop->getSetterName();
993 S.
Diag(AtLoc, diag::note_property_synthesize);
1015 auto OrigClass =
Category->getClassInterface();
1016 for (
auto Found : OrigClass->lookup(Prop->
getDeclName())) {
1018 return OrigProp->getPropertyAttributesAsWritten() &
OwnershipMask;
1022 for (
const auto *Proto : OrigClass->all_referenced_protocols()) {
1025 return OrigProp->getPropertyAttributesAsWritten() &
OwnershipMask;
1046 if (!ClassImpDecl) {
1047 Diag(AtLoc, diag::err_missing_property_context);
1051 PropertyIvarLoc = PropertyLoc;
1061 if ((IC = dyn_cast<ObjCImplementationDecl>(ClassImpDecl))) {
1066 "ActOnPropertyImplDecl - @implementation without @interface");
1071 Diag(PropertyLoc, diag::err_bad_property_decl) << IDecl->
getDeclName();
1074 if (property->isClassProperty() && Synthesize) {
1075 Diag(PropertyLoc, diag::err_synthesize_on_class_property) << PropertyId;
1078 unsigned PIkind =
property->getPropertyAttributesAsWritten();
1082 Diag(AtLoc, diag::warn_implicit_atomic_property);
1085 Diag(property->getLocation(), diag::note_property_declare);
1089 dyn_cast<ObjCCategoryDecl>(property->getDeclContext())) {
1090 if (!CD->IsClassExtension()) {
1091 Diag(PropertyLoc, diag::err_category_property) << CD->getDeclName();
1092 Diag(property->getLocation(), diag::note_property_declare);
1098 property->hasAttr<IBOutletAttr>() &&
1100 bool ReadWriteProperty =
false;
1107 PIkind = ExtProp->getPropertyAttributesAsWritten();
1109 ReadWriteProperty =
true;
1115 if (!ReadWriteProperty) {
1116 Diag(property->getLocation(), diag::warn_auto_readonly_iboutlet_property)
1120 property->getLParenLoc(), readonlyLoc)) {
1123 SourceRange ReadonlySourceRange(readonlyLoc, endLoc);
1124 Diag(property->getLocation(),
1125 diag::note_auto_readonly_iboutlet_fixup_suggest) <<
1130 if (Synthesize && isa<ObjCProtocolDecl>(property->getDeclContext()))
1134 }
else if ((CatImplClass = dyn_cast<ObjCCategoryImplDecl>(ClassImpDecl))) {
1136 Diag(AtLoc, diag::err_synthesize_category_decl);
1141 Diag(AtLoc, diag::err_missing_property_interface);
1154 Diag(PropertyLoc, diag::err_bad_category_property_decl)
1159 Diag(AtLoc, diag::err_bad_property_context);
1163 bool CompleteTypeErr =
false;
1169 PropertyIvar = PropertyId;
1173 QualType PropType =
property->getType();
1177 diag::err_incomplete_synthesized_property,
1178 property->getDeclName())) {
1179 Diag(property->getLocation(), diag::note_property_declare);
1180 CompleteTypeErr =
true;
1184 (
property->getPropertyAttributesAsWritten() &
1191 =
property->getPropertyAttributes();
1193 bool isARCWeak =
false;
1199 Diag(PropertyDiagLoc, diag::err_gc_weak_property_strong_type);
1200 Diag(property->getLocation(), diag::note_property_declare);
1212 Diag(PropertyDiagLoc,
1214 ? diag::err_synthesizing_arc_weak_property_disabled
1215 : diag::err_synthesizing_arc_weak_property_no_runtime);
1216 Diag(property->getLocation(), diag::note_property_declare);
1218 CompleteTypeErr =
true;
1225 Diag(property->getLocation(),
1226 diag::err_arc_weak_unavailable_property)
1227 << PropertyIvarType;
1246 Diag(PropertyDiagLoc,
1247 diag::warn_autosynthesis_property_ivar_match)
1248 << PropertyId << (Ivar ==
nullptr) << PropertyIvar
1250 Diag(property->getLocation(), diag::note_property_declare);
1258 if ((
getLangOpts().ObjCAutoRefCount || isARCWeak) &&
1266 Diag(PropertyDiagLoc,
1267 diag::err_arc_objc_property_default_assign_on_object);
1268 Diag(property->getLocation(), diag::note_property_declare);
1272 assert(lifetime &&
"no lifetime for property?");
1281 PropertyIvarLoc,PropertyIvarLoc, PropertyIvar,
1282 PropertyIvarType,
nullptr,
1284 (
Expr *)
nullptr,
true);
1287 diag::err_abstract_type_in_decl,
1289 Diag(property->getLocation(), diag::note_property_declare);
1291 CompleteTypeErr =
true;
1293 if (CompleteTypeErr)
1299 Diag(PropertyDiagLoc, diag::err_missing_property_ivar_decl)
1305 Diag(PropertyDiagLoc, diag::err_ivar_in_superclass_use)
1312 property->setPropertyIvarDecl(Ivar);
1318 if (isa<ObjCObjectPointerType>(PropertyIvarType)
1319 && isa<ObjCObjectPointerType>(IvarType))
1330 Diag(PropertyDiagLoc, diag::err_property_ivar_type)
1331 <<
property->getDeclName() << PropType
1343 if (lhsType != rhsType &&
1345 Diag(PropertyDiagLoc, diag::err_property_ivar_type)
1346 <<
property->getDeclName() << PropType
1355 Diag(PropertyDiagLoc, diag::err_weak_property)
1356 <<
property->getDeclName() << Ivar->
getDeclName();
1361 if ((property->getType()->isObjCObjectPointerType() ||
1364 Diag(PropertyDiagLoc, diag::err_strong_property)
1365 <<
property->getDeclName() << Ivar->
getDeclName();
1369 if (
getLangOpts().ObjCAutoRefCount || isARCWeak ||
1372 }
else if (PropertyIvar)
1374 Diag(PropertyDiagLoc, diag::err_dynamic_property_ivar_decl);
1376 assert (property &&
"ActOnPropertyImplDecl - property declaration missing");
1383 Ivar, PropertyIvarLoc);
1385 if (CompleteTypeErr || !compat)
1388 if (
ObjCMethodDecl *getterMethod = property->getGetterMethodDecl()) {
1389 getterMethod->createImplicitParams(
Context, IDecl);
1401 Expr *LoadSelfExpr =
1403 CK_LValueToRValue, SelfExpr,
nullptr,
1410 LoadSelfExpr,
true,
true);
1413 getterMethod->getReturnType(),
1415 PropertyDiagLoc, IvarRefExpr);
1423 if (property->hasAttr<NSReturnsNotRetainedAttr>() &&
1424 !getterMethod->hasAttr<NSReturnsNotRetainedAttr>()) {
1425 Diag(getterMethod->getLocation(),
1426 diag::warn_property_getter_owning_mismatch);
1427 Diag(property->getLocation(), diag::note_property_declare);
1430 switch (getterMethod->getMethodFamily()) {
1435 Diag(getterMethod->getLocation(), diag::err_arc_illegal_method_def)
1436 << 1 << getterMethod->getSelector();
1442 if (
ObjCMethodDecl *setterMethod = property->getSetterMethodDecl()) {
1443 setterMethod->createImplicitParams(
Context, IDecl);
1453 Expr *LoadSelfExpr =
1455 CK_LValueToRValue, SelfExpr,
nullptr,
1462 LoadSelfExpr,
true,
true);
1470 BO_Assign, lhs, rhs);
1471 if (property->getPropertyAttributes() &
1475 dyn_cast_or_null<CXXOperatorCallExpr>(callExpr))
1476 if (
const FunctionDecl *FuncDecl = CXXCE->getDirectCallee())
1477 if (!FuncDecl->isTrivial())
1478 if (property->getType()->isReferenceType()) {
1479 Diag(PropertyDiagLoc,
1480 diag::err_atomic_property_nontrivial_assign_op)
1481 <<
property->getType();
1482 Diag(FuncDecl->getLocStart(),
1483 diag::note_callee_decl) << FuncDecl;
1494 Diag(PropertyLoc, diag::err_duplicate_ivar_use)
1495 << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()
1497 Diag(PPIDecl->getLocation(), diag::note_previous_use);
1502 Diag(PropertyLoc, diag::err_property_implemented) << PropertyId;
1503 Diag(PPIDecl->getLocation(), diag::note_previous_declaration);
1518 if (PropertyIvar && PropertyIvar != PropertyId)
1533 Diag(PropertyDiagLoc, diag::err_duplicate_ivar_use)
1534 << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()
1536 Diag(PPIDecl->getLocation(), diag::note_previous_use);
1541 Diag(PropertyDiagLoc, diag::err_property_implemented) << PropertyId;
1542 Diag(PPIDecl->getLocation(), diag::note_previous_declaration);
1562 bool OverridingProtocolProperty) {
1571 if (!OverridingProtocolProperty &&
1580 != (SAttr & ObjCPropertyDecl::OBJC_PR_copy))
1582 << Property->
getDeclName() <<
"copy" << inheritedName;
1583 else if (!(SAttr & ObjCPropertyDecl::OBJC_PR_readonly)){
1584 unsigned CAttrRetain =
1587 unsigned SAttrRetain =
1590 bool CStrong = (CAttrRetain != 0);
1591 bool SStrong = (SAttrRetain != 0);
1592 if (CStrong != SStrong)
1594 << Property->
getDeclName() <<
"retain (or strong)" << inheritedName;
1604 << Property->
getDeclName() <<
"setter" << inheritedName;
1609 << Property->
getDeclName() <<
"getter" << inheritedName;
1621 bool IncompatibleObjC =
false;
1624 ConvertedType, IncompatibleObjC) ||
1626 Diag(Property->
getLocation(), diag::warn_property_types_are_incompatible)
1627 << Property->
getType() << SuperProperty->
getType() << inheritedName;
1640 property->getType().getNonReferenceType().getAtomicUnqualifiedType();
1645 if ((propertyObjCPtr =
1651 Diag(Loc, diag::err_property_accessor_type)
1652 <<
property->getDeclName() << PropertyRValueType
1666 Diag(Loc, diag::warn_accessor_property_type_mismatch)
1667 <<
property->getDeclName()
1682 bool CollectClassPropsOnly =
false,
1683 bool IncludeProtocols =
true) {
1685 for (
auto *Prop : IDecl->properties()) {
1686 if (CollectClassPropsOnly && !Prop->isClassProperty())
1688 PropMap[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] =
1693 for (
auto *Ext : IDecl->visible_extensions())
1695 CollectClassPropsOnly, IncludeProtocols);
1697 if (IncludeProtocols) {
1699 for (
auto *PI : IDecl->all_referenced_protocols())
1701 CollectClassPropsOnly);
1705 for (
auto *Prop : CATDecl->properties()) {
1706 if (CollectClassPropsOnly && !Prop->isClassProperty())
1708 PropMap[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] =
1711 if (IncludeProtocols) {
1713 for (
auto *PI : CATDecl->protocols())
1715 CollectClassPropsOnly);
1719 for (
auto *Prop : PDecl->properties()) {
1720 if (CollectClassPropsOnly && !Prop->isClassProperty())
1723 SuperPropMap[std::make_pair(Prop->getIdentifier(),
1724 Prop->isClassProperty())];
1727 if (!PropertyFromSuper ||
1728 PropertyFromSuper->
getIdentifier() != Prop->getIdentifier()) {
1730 PropMap[std::make_pair(Prop->getIdentifier(),
1731 Prop->isClassProperty())];
1737 for (
auto *PI : PDecl->protocols())
1739 CollectClassPropsOnly);
1751 SDecl->collectPropertiesToImplement(PropMap, PO);
1752 SDecl = SDecl->getSuperClass();
1775 (
Property->getPropertyIvarDecl() == IV))
1781 for (
const auto *
Property : Ext->instance_properties())
1784 (
Property->getPropertyIvarDecl() == IV))
1791 bool SuperClassImplementsGetter =
false;
1792 bool SuperClassImplementsSetter =
false;
1794 SuperClassImplementsSetter =
true;
1799 SuperClassImplementsGetter =
true;
1802 SuperClassImplementsSetter =
true;
1803 if (SuperClassImplementsGetter && SuperClassImplementsSetter)
1818 if (PropMap.empty())
1823 for (
unsigned i = 0, e = PropertyOrder.size(); i != e; i++) {
1842 Diag(Prop->
getLocation(), diag::warn_no_autosynthesis_shared_ivar_property)
1844 if (PID->getLocation().isValid())
1845 Diag(PID->getLocation(), diag::note_property_synthesize);
1859 diag::warn_auto_synthesizing_protocol_property)
1863 (Twine(
"@synthesize ") + Prop->
getName() +
";\n\n").str();
1864 Diag(AtEnd, diag::note_add_synthesize_directive)
1870 if (PropInSuperClass) {
1881 Diag(Prop->
getLocation(), diag::warn_autosynthesis_property_in_superclass)
1913 if (!IDecl->isObjCRequiresPropertyDefs())
1921 llvm::SmallPtrSet<const ObjCMethodDecl *, 8> &
SMap) {
1924 auto I = std::find_if(SMap.begin(), SMap.end(),
1926 return x->getSelector() == Method &&
1933 if (
I == SMap.end() &&
1934 (PrimaryClass ==
nullptr ||
1938 isa<ObjCCategoryDecl>(CDecl)
1940 ? diag::warn_impl_required_in_category_for_class_property
1941 : diag::warn_setter_getter_impl_required_in_category)
1943 ? diag::warn_impl_required_for_class_property
1944 : diag::warn_setter_getter_impl_required);
1947 if (S.
LangOpts.ObjCDefaultSynthProperties &&
1951 S.
Diag(RID->getLocation(), diag::note_suppressed_class_declare);
1957 bool SynthesizeProperties) {
1971 if ((IDecl = C->getClassInterface())) {
1981 SynthesizeProperties);
1987 std::unique_ptr<ObjCContainerDecl::PropertyMap> LazyMap;
1990 if (!PDecl->hasAttr<ObjCExplicitProtocolImplAttr>())
2008 for (
auto *PropDecl : PDecl->properties()) {
2009 if ((*LazyMap)[std::make_pair(PropDecl->getIdentifier(),
2010 PropDecl->isClassProperty())])
2012 PropMap[std::make_pair(PropDecl->getIdentifier(),
2013 PropDecl->isClassProperty())] = PropDecl;
2018 if (PropMap.empty())
2023 PropImplMap.insert(
I->getPropertyDecl());
2025 llvm::SmallPtrSet<const ObjCMethodDecl *, 8> InsMap;
2027 for (
const auto *
I : IMPDecl->
methods())
2035 if (
ObjCImplDecl *IMP = PrimaryClass->getImplementation()) {
2039 for (
const auto *
I : IMP->methods())
2043 for (ObjCContainerDecl::PropertyMap::iterator
2044 P = PropMap.begin(),
E = PropMap.end();
P !=
E; ++
P) {
2049 PropImplMap.count(Prop) ||
2055 PrimaryClass, Prop->
getGetterName(), IMPDecl, CDecl, C, Prop, InsMap);
2056 if (!Prop->isReadOnly())
2058 PrimaryClass, Prop->getSetterName(),
2059 IMPDecl, CDecl, C, Prop, InsMap);
2065 const auto *
property = propertyImpl->getPropertyDecl();
2069 if (propertyImpl->getPropertyImplementation()
2071 (
property->getPropertyAttributes() &
2073 property->getGetterMethodDecl() &&
2074 property->getSetterMethodDecl()) {
2075 auto *getterMethod =
property->getGetterMethodDecl();
2076 auto *setterMethod =
property->getSetterMethodDecl();
2083 Diag(loc, diag::warn_null_resettable_setter)
2084 << setterMethod->getSelector() <<
property->getDeclName();
2098 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
2100 for (
auto *Prop : Ext->properties())
2101 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
2103 for (ObjCContainerDecl::PropertyMap::iterator
I = PM.begin(),
E = PM.end();
2108 bool LookedUpGetterSetter =
false;
2121 LookedUpGetterSetter =
true;
2124 diag::warn_default_atomic_custom_getter_setter)
2130 diag::warn_default_atomic_custom_getter_setter)
2137 if ((Attributes & ObjCPropertyDecl::OBJC_PR_nonatomic) ||
2144 if (!LookedUpGetterSetter) {
2152 if ((GetterMethod && !SetterMethod) || (!GetterMethod && SetterMethod)) {
2156 Diag(MethodLoc, diag::warn_atomic_property_rule)
2158 << (SetterMethod !=
nullptr);
2165 StringRef NonatomicStr = AttributesAsWritten?
"nonatomic, "
2168 diag::note_atomic_property_fixup_suggest)
2175 diag::note_atomic_property_fixup_suggest)
2179 Diag(MethodLoc, diag::note_atomic_property_fixup_suggest);
2192 if (PD && !PD->
hasAttr<NSReturnsNotRetainedAttr>() &&
2210 for (
auto *getterRedecl : method->
redecls()) {
2211 if (getterRedecl->isImplicit())
2215 noteLoc = getterRedecl->getLocation();
2216 fixItLoc = getterRedecl->getLocEnd();
2221 tok::kw___attribute, tok::l_paren, tok::l_paren,
2224 tok::r_paren, tok::r_paren
2226 StringRef spelling =
"__attribute__((objc_method_family(none)))";
2228 if (!macroName.empty())
2229 spelling = macroName;
2231 auto noteDiag =
Diag(noteLoc, diag::note_cocoa_naming_declare_family)
2235 fixItText += spelling;
2254 InitSelSet.insert(
I->getSelector());
2257 SuperD->getDesignatedInitializers(DesignatedInits);
2259 I = DesignatedInits.begin(),
E = DesignatedInits.end();
I !=
E; ++
I) {
2262 bool Ignore =
false;
2264 Ignore = IMD->isUnavailable();
2268 diag::warn_objc_implementation_missing_designated_init_override)
2281 for (
const auto *A : Property->
attrs()) {
2282 if (isa<DeprecatedAttr>(A) ||
2283 isa<UnavailableAttr>(A) ||
2284 isa<AvailabilityAttr>(A))
2299 bool IsClassProperty =
property->isClassProperty();
2300 GetterMethod = IsClassProperty ?
2308 if (CatDecl->IsClassExtension())
2311 CatDecl->getClassInterface()->
2314 SetterMethod = IsClassProperty ?
2319 if (CatDecl->IsClassExtension())
2322 CatDecl->getClassInterface()->
2327 if (!property->
isReadOnly() && SetterMethod) {
2330 Diag(SetterMethod->getLocation(), diag::err_setter_type_void);
2331 if (SetterMethod->param_size() != 1 ||
2333 (*SetterMethod->param_begin())->getType().getNonReferenceType(),
2334 property->getType().getNonReferenceType())) {
2336 diag::warn_accessor_property_type_mismatch)
2338 << SetterMethod->getSelector();
2339 Diag(SetterMethod->getLocation(), diag::note_declared_at);
2349 if (!GetterMethod) {
2357 QualType resultTy =
property->getType().getAtomicUnqualifiedType();
2366 modifiedTy, modifiedTy);
2372 resultTy,
nullptr, CD,
2373 !IsClassProperty,
false,
2376 (
property->getPropertyImplementation() ==
2380 CD->addDecl(GetterMethod);
2384 if (property->
hasAttr<NSReturnsNotRetainedAttr>())
2385 GetterMethod->
addAttr(NSReturnsNotRetainedAttr::CreateImplicit(
Context,
2388 if (property->
hasAttr<ObjCReturnsInnerPointerAttr>())
2390 ObjCReturnsInnerPointerAttr::CreateImplicit(
Context, Loc));
2392 if (
const SectionAttr *SA = property->
getAttr<SectionAttr>())
2394 SectionAttr::CreateImplicit(
Context, SectionAttr::GNU_section,
2395 SA->getName(), Loc));
2403 property->setGetterMethodDecl(GetterMethod);
2408 if (!SetterMethod) {
2418 nullptr, CD, !IsClassProperty,
2423 (
property->getPropertyImplementation() ==
2430 property->getType().getUnqualifiedType().getAtomicUnqualifiedType();
2440 modifiedTy, modifiedTy);
2453 SetterMethod->setMethodParams(
Context, Argument,
None);
2458 if (
const SectionAttr *SA = property->
getAttr<SectionAttr>())
2459 SetterMethod->addAttr(
2460 SectionAttr::CreateImplicit(
Context, SectionAttr::GNU_section,
2461 SA->getName(), Loc));
2469 SetterMethod->setPropertyAccessor(
true);
2470 property->setSetterMethodDecl(SetterMethod);
2484 if (!IsClassProperty) {
2497 if (!CurrentClass) {
2499 CurrentClass = Cat->getClassInterface();
2500 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(CD))
2501 CurrentClass = Impl->getClassInterface();
2511 unsigned &Attributes,
2512 bool propertyInPrimaryClass) {
2519 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2520 <<
"readonly" <<
"readwrite";
2528 !PropertyTy->isObjCRetainableType() &&
2529 !PropertyDecl->
hasAttr<ObjCNSObjectAttr>()) {
2530 Diag(Loc, diag::err_objc_property_requires_object)
2541 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2542 <<
"assign" <<
"copy";
2546 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2547 <<
"assign" <<
"retain";
2551 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2552 <<
"assign" <<
"strong";
2557 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2558 <<
"assign" <<
"weak";
2561 if (PropertyDecl->
hasAttr<IBOutletCollectionAttr>())
2562 Diag(Loc, diag::warn_iboutletcollection_property_assign);
2565 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2566 <<
"unsafe_unretained" <<
"copy";
2570 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2571 <<
"unsafe_unretained" <<
"retain";
2575 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2576 <<
"unsafe_unretained" <<
"strong";
2581 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2582 <<
"unsafe_unretained" <<
"weak";
2587 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2588 <<
"copy" <<
"retain";
2592 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2593 <<
"copy" <<
"strong";
2597 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2598 <<
"copy" <<
"weak";
2604 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2605 <<
"retain" <<
"weak";
2609 (Attributes & ObjCDeclSpec::DQ_PR_weak)) {
2610 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2611 <<
"strong" <<
"weak";
2615 if (Attributes & ObjCDeclSpec::DQ_PR_weak) {
2617 if (
auto nullability = PropertyTy->getNullability(
Context)) {
2619 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2620 <<
"nonnull" <<
"weak";
2626 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2627 <<
"atomic" <<
"nonatomic";
2634 if (Attributes & ObjCDeclSpec::DQ_PR_readonly) {
2640 }
else if (PropertyTy->isObjCObjectPointerType()) {
2642 (PropertyTy->isObjCClassType() ||
2643 PropertyTy->isObjCQualifiedClassType());
2648 else if (propertyInPrimaryClass) {
2653 Diag(Loc, diag::warn_objc_property_no_assignment_attribute);
2657 Diag(Loc, diag::warn_objc_property_default_assign_on_object);
2667 if (!(Attributes & ObjCDeclSpec::DQ_PR_copy)
2670 && PropertyTy->isBlockPointerType())
2671 Diag(Loc, diag::warn_objc_property_copy_missing_on_block);
2672 else if ((Attributes & ObjCDeclSpec::DQ_PR_retain) &&
2674 !(Attributes & ObjCDeclSpec::DQ_PR_strong) &&
2675 PropertyTy->isBlockPointerType())
2676 Diag(Loc, diag::warn_objc_property_retain_of_block);
2678 if ((Attributes & ObjCDeclSpec::DQ_PR_readonly) &&
2680 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...
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
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...
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple()) const
Determine the availability of the given declaration.
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.
Decl - This represents one declaration (or definition), e.g.
void DiagnoseMissingDesignatedInitOverrides(const ObjCImplementationDecl *ImplD, const ObjCInterfaceDecl *IFD)
void CheckObjCPropertyAttributes(Decl *PropertyPtrTy, SourceLocation Loc, unsigned &Attributes, bool propertyInPrimaryClass)
Ensure attributes are consistent with type.
Captures information about "declaration specifiers" specific to Objective-C.
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.
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...
SourceLocation getSetterNameLoc() const
bool isArcWeakrefUnavailable() const
isArcWeakrefUnavailable - Checks for a class or one of its super classes to be incompatible with __we...
void setPropertyAccessor(bool isAccessor)
static bool areIncompatiblePropertyAttributes(unsigned Attr1, unsigned Attr2, unsigned Kinds)
Decl * ActOnPropertyImplDecl(Scope *S, SourceLocation AtLoc, SourceLocation PropertyLoc, bool ImplKind, IdentifierInfo *PropertyId, IdentifierInfo *PropertyIvar, SourceLocation PropertyIvarLoc, ObjCPropertyQueryKind QueryKind)
ActOnPropertyImplDecl - This routine performs semantic checks and builds the AST node for a property ...
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...
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...
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.
Parse and apply any fixits to the source.
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
llvm::SmallDenseSet< const ObjCProtocolDecl *, 8 > ProtocolPropertySet
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 ...
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
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.
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...
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)
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
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.
DeclContext * getDeclContext()
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.
SourceLocation getGetterNameLoc() const
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...
static StringRef getIdentifier(const Token &Tok)
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
bool hasObjCLifetime() const
SourceLocation getLocStart() const LLVM_READONLY
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.
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.
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)
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)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
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 isInvalidDecl() const
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 ...
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
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...
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.
SourceLocation getLocation() const
void setLexicalDeclContext(DeclContext *DC)
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...
Attr - This represents one attribute.
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.
static bool isIncompatiblePropertyAttribute(unsigned Attr1, unsigned Attr2, ObjCPropertyDecl::PropertyAttributeKind Kind)