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:
980 case HasNoExpectedAttribute:
981 case HasUnexpectedAttribute:
984 case DifferentGetter:
987 case DifferentSetter:
993 S.
Diag(AtLoc, diag::note_property_synthesize);
1015 auto OrigClass =
Category->getClassInterface();
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) {
1296 Diag(PropertyIvarLoc, diag::err_synthesize_variable_sized_ivar)
1297 << PropertyIvarType;
1298 CompleteTypeErr =
true;
1301 if (CompleteTypeErr)
1307 Diag(PropertyDiagLoc, diag::err_missing_property_ivar_decl)
1313 Diag(PropertyDiagLoc, diag::err_ivar_in_superclass_use)
1320 property->setPropertyIvarDecl(Ivar);
1326 if (isa<ObjCObjectPointerType>(PropertyIvarType)
1327 && isa<ObjCObjectPointerType>(IvarType))
1338 Diag(PropertyDiagLoc, diag::err_property_ivar_type)
1339 <<
property->getDeclName() << PropType
1351 if (lhsType != rhsType &&
1353 Diag(PropertyDiagLoc, diag::err_property_ivar_type)
1354 <<
property->getDeclName() << PropType
1363 Diag(PropertyDiagLoc, diag::err_weak_property)
1364 <<
property->getDeclName() << Ivar->
getDeclName();
1369 if ((property->getType()->isObjCObjectPointerType() ||
1372 Diag(PropertyDiagLoc, diag::err_strong_property)
1373 <<
property->getDeclName() << Ivar->
getDeclName();
1377 if (
getLangOpts().ObjCAutoRefCount || isARCWeak ||
1380 }
else if (PropertyIvar)
1382 Diag(PropertyDiagLoc, diag::err_dynamic_property_ivar_decl);
1384 assert (property &&
"ActOnPropertyImplDecl - property declaration missing");
1391 Ivar, PropertyIvarLoc);
1393 if (CompleteTypeErr || !compat)
1396 if (
ObjCMethodDecl *getterMethod = property->getGetterMethodDecl()) {
1397 getterMethod->createImplicitParams(
Context, IDecl);
1409 Expr *LoadSelfExpr =
1411 CK_LValueToRValue, SelfExpr,
nullptr,
1418 LoadSelfExpr,
true,
true);
1421 getterMethod->getReturnType(),
1423 PropertyDiagLoc, IvarRefExpr);
1431 if (property->hasAttr<NSReturnsNotRetainedAttr>() &&
1432 !getterMethod->hasAttr<NSReturnsNotRetainedAttr>()) {
1433 Diag(getterMethod->getLocation(),
1434 diag::warn_property_getter_owning_mismatch);
1435 Diag(property->getLocation(), diag::note_property_declare);
1438 switch (getterMethod->getMethodFamily()) {
1443 Diag(getterMethod->getLocation(), diag::err_arc_illegal_method_def)
1444 << 1 << getterMethod->getSelector();
1450 if (
ObjCMethodDecl *setterMethod = property->getSetterMethodDecl()) {
1451 setterMethod->createImplicitParams(
Context, IDecl);
1461 Expr *LoadSelfExpr =
1463 CK_LValueToRValue, SelfExpr,
nullptr,
1470 LoadSelfExpr,
true,
true);
1478 BO_Assign, lhs, rhs);
1479 if (property->getPropertyAttributes() &
1483 dyn_cast_or_null<CXXOperatorCallExpr>(callExpr))
1484 if (
const FunctionDecl *FuncDecl = CXXCE->getDirectCallee())
1485 if (!FuncDecl->isTrivial())
1486 if (property->getType()->isReferenceType()) {
1487 Diag(PropertyDiagLoc,
1488 diag::err_atomic_property_nontrivial_assign_op)
1489 <<
property->getType();
1490 Diag(FuncDecl->getLocStart(),
1491 diag::note_callee_decl) << FuncDecl;
1502 Diag(PropertyLoc, diag::err_duplicate_ivar_use)
1503 << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()
1505 Diag(PPIDecl->getLocation(), diag::note_previous_use);
1510 Diag(PropertyLoc, diag::err_property_implemented) << PropertyId;
1511 Diag(PPIDecl->getLocation(), diag::note_previous_declaration);
1526 if (PropertyIvar && PropertyIvar != PropertyId)
1541 Diag(PropertyDiagLoc, diag::err_duplicate_ivar_use)
1542 << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()
1544 Diag(PPIDecl->getLocation(), diag::note_previous_use);
1549 Diag(PropertyDiagLoc, diag::err_property_implemented) << PropertyId;
1550 Diag(PPIDecl->getLocation(), diag::note_previous_declaration);
1570 bool OverridingProtocolProperty) {
1579 if (!OverridingProtocolProperty &&
1588 != (SAttr & ObjCPropertyDecl::OBJC_PR_copy))
1590 << Property->
getDeclName() <<
"copy" << inheritedName;
1591 else if (!(SAttr & ObjCPropertyDecl::OBJC_PR_readonly)){
1592 unsigned CAttrRetain =
1595 unsigned SAttrRetain =
1598 bool CStrong = (CAttrRetain != 0);
1599 bool SStrong = (SAttrRetain != 0);
1600 if (CStrong != SStrong)
1602 << Property->
getDeclName() <<
"retain (or strong)" << inheritedName;
1616 << Property->
getDeclName() <<
"setter" << inheritedName;
1621 << Property->
getDeclName() <<
"getter" << inheritedName;
1633 bool IncompatibleObjC =
false;
1636 ConvertedType, IncompatibleObjC) ||
1638 Diag(Property->
getLocation(), diag::warn_property_types_are_incompatible)
1639 << Property->
getType() << SuperProperty->
getType() << inheritedName;
1652 property->getType().getNonReferenceType().getAtomicUnqualifiedType();
1657 if ((propertyObjCPtr =
1663 Diag(Loc, diag::err_property_accessor_type)
1664 <<
property->getDeclName() << PropertyRValueType
1678 Diag(Loc, diag::warn_accessor_property_type_mismatch)
1679 <<
property->getDeclName()
1694 bool CollectClassPropsOnly =
false,
1695 bool IncludeProtocols =
true) {
1697 for (
auto *Prop : IDecl->properties()) {
1698 if (CollectClassPropsOnly && !Prop->isClassProperty())
1700 PropMap[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] =
1705 for (
auto *Ext : IDecl->visible_extensions())
1707 CollectClassPropsOnly, IncludeProtocols);
1709 if (IncludeProtocols) {
1711 for (
auto *PI : IDecl->all_referenced_protocols())
1713 CollectClassPropsOnly);
1717 for (
auto *Prop : CATDecl->properties()) {
1718 if (CollectClassPropsOnly && !Prop->isClassProperty())
1720 PropMap[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] =
1723 if (IncludeProtocols) {
1725 for (
auto *PI : CATDecl->protocols())
1727 CollectClassPropsOnly);
1731 for (
auto *Prop : PDecl->properties()) {
1732 if (CollectClassPropsOnly && !Prop->isClassProperty())
1735 SuperPropMap[std::make_pair(Prop->getIdentifier(),
1736 Prop->isClassProperty())];
1739 if (!PropertyFromSuper ||
1740 PropertyFromSuper->
getIdentifier() != Prop->getIdentifier()) {
1742 PropMap[std::make_pair(Prop->getIdentifier(),
1743 Prop->isClassProperty())];
1749 for (
auto *PI : PDecl->protocols())
1751 CollectClassPropsOnly);
1763 SDecl->collectPropertiesToImplement(PropMap, PO);
1764 SDecl = SDecl->getSuperClass();
1787 (
Property->getPropertyIvarDecl() == IV))
1793 for (
const auto *
Property : Ext->instance_properties())
1796 (
Property->getPropertyIvarDecl() == IV))
1803 bool SuperClassImplementsGetter =
false;
1804 bool SuperClassImplementsSetter =
false;
1806 SuperClassImplementsSetter =
true;
1811 SuperClassImplementsGetter =
true;
1814 SuperClassImplementsSetter =
true;
1815 if (SuperClassImplementsGetter && SuperClassImplementsSetter)
1830 if (PropMap.empty())
1835 for (
unsigned i = 0, e = PropertyOrder.size(); i != e; i++) {
1854 Diag(Prop->
getLocation(), diag::warn_no_autosynthesis_shared_ivar_property)
1856 if (PID->getLocation().isValid())
1857 Diag(PID->getLocation(), diag::note_property_synthesize);
1871 diag::warn_auto_synthesizing_protocol_property)
1875 (Twine(
"@synthesize ") + Prop->
getName() +
";\n\n").str();
1876 Diag(AtEnd, diag::note_add_synthesize_directive)
1882 if (PropInSuperClass) {
1893 Diag(Prop->
getLocation(), diag::warn_autosynthesis_property_in_superclass)
1925 if (!IDecl->isObjCRequiresPropertyDefs())
1933 llvm::SmallPtrSet<const ObjCMethodDecl *, 8> &
SMap) {
1936 auto I = std::find_if(SMap.begin(), SMap.end(),
1938 return x->getSelector() == Method &&
1945 if (I == SMap.end() &&
1946 (PrimaryClass ==
nullptr ||
1950 isa<ObjCCategoryDecl>(CDecl)
1952 ? diag::warn_impl_required_in_category_for_class_property
1953 : diag::warn_setter_getter_impl_required_in_category)
1955 ? diag::warn_impl_required_for_class_property
1956 : diag::warn_setter_getter_impl_required);
1959 if (S.
LangOpts.ObjCDefaultSynthProperties &&
1963 S.
Diag(RID->getLocation(), diag::note_suppressed_class_declare);
1969 bool SynthesizeProperties) {
1983 if ((IDecl =
C->getClassInterface())) {
1993 SynthesizeProperties);
1999 std::unique_ptr<ObjCContainerDecl::PropertyMap> LazyMap;
2002 if (!PDecl->hasAttr<ObjCExplicitProtocolImplAttr>())
2020 for (
auto *PropDecl : PDecl->properties()) {
2021 if ((*LazyMap)[std::make_pair(PropDecl->getIdentifier(),
2022 PropDecl->isClassProperty())])
2024 PropMap[std::make_pair(PropDecl->getIdentifier(),
2025 PropDecl->isClassProperty())] = PropDecl;
2030 if (PropMap.empty())
2035 PropImplMap.insert(I->getPropertyDecl());
2037 llvm::SmallPtrSet<const ObjCMethodDecl *, 8> InsMap;
2039 for (
const auto *I : IMPDecl->
methods())
2047 if (
ObjCImplDecl *IMP = PrimaryClass->getImplementation()) {
2051 for (
const auto *I : IMP->methods())
2055 for (ObjCContainerDecl::PropertyMap::iterator
2056 P = PropMap.begin(), E = PropMap.end();
P != E; ++
P) {
2061 PropImplMap.count(Prop) ||
2067 PrimaryClass, Prop->
getGetterName(), IMPDecl, CDecl,
C, Prop, InsMap);
2068 if (!Prop->isReadOnly())
2070 PrimaryClass, Prop->getSetterName(),
2071 IMPDecl, CDecl,
C, Prop, InsMap);
2077 const auto *
property = propertyImpl->getPropertyDecl();
2081 if (propertyImpl->getPropertyImplementation()
2083 (
property->getPropertyAttributes() &
2085 property->getGetterMethodDecl() &&
2086 property->getSetterMethodDecl()) {
2087 auto *getterMethod =
property->getGetterMethodDecl();
2088 auto *setterMethod =
property->getSetterMethodDecl();
2095 Diag(loc, diag::warn_null_resettable_setter)
2096 << setterMethod->getSelector() <<
property->getDeclName();
2110 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
2112 for (
auto *Prop : Ext->properties())
2113 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
2115 for (ObjCContainerDecl::PropertyMap::iterator I = PM.begin(), E = PM.end();
2120 bool LookedUpGetterSetter =
false;
2133 LookedUpGetterSetter =
true;
2136 diag::warn_default_atomic_custom_getter_setter)
2142 diag::warn_default_atomic_custom_getter_setter)
2149 if ((Attributes & ObjCPropertyDecl::OBJC_PR_nonatomic) ||
2156 if (!LookedUpGetterSetter) {
2164 if ((GetterMethod && !SetterMethod) || (!GetterMethod && SetterMethod)) {
2168 Diag(MethodLoc, diag::warn_atomic_property_rule)
2170 << (SetterMethod !=
nullptr);
2177 StringRef NonatomicStr = AttributesAsWritten?
"nonatomic, " 2180 diag::note_atomic_property_fixup_suggest)
2187 diag::note_atomic_property_fixup_suggest)
2191 Diag(MethodLoc, diag::note_atomic_property_fixup_suggest);
2204 if (PD && !PD->
hasAttr<NSReturnsNotRetainedAttr>() &&
2222 for (
auto *getterRedecl : method->
redecls()) {
2223 if (getterRedecl->isImplicit())
2227 noteLoc = getterRedecl->getLocation();
2228 fixItLoc = getterRedecl->getLocEnd();
2233 tok::kw___attribute, tok::l_paren, tok::l_paren,
2236 tok::r_paren, tok::r_paren
2238 StringRef spelling =
"__attribute__((objc_method_family(none)))";
2240 if (!macroName.empty())
2241 spelling = macroName;
2243 auto noteDiag =
Diag(noteLoc, diag::note_cocoa_naming_declare_family)
2247 fixItText += spelling;
2265 if (I->getMethodFamily() ==
OMF_init)
2266 InitSelSet.insert(I->getSelector());
2269 SuperD->getDesignatedInitializers(DesignatedInits);
2271 I = DesignatedInits.begin(), E = DesignatedInits.end(); I != E; ++I) {
2274 bool Ignore =
false;
2276 Ignore = IMD->isUnavailable();
2280 diag::warn_objc_implementation_missing_designated_init_override)
2293 for (
const auto *A : Property->
attrs()) {
2294 if (isa<DeprecatedAttr>(A) ||
2295 isa<UnavailableAttr>(A) ||
2296 isa<AvailabilityAttr>(A))
2311 bool IsClassProperty =
property->isClassProperty();
2312 GetterMethod = IsClassProperty ?
2320 if (CatDecl->IsClassExtension())
2323 CatDecl->getClassInterface()->
2326 SetterMethod = IsClassProperty ?
2331 if (CatDecl->IsClassExtension())
2334 CatDecl->getClassInterface()->
2339 if (!property->
isReadOnly() && SetterMethod) {
2342 Diag(SetterMethod->getLocation(), diag::err_setter_type_void);
2343 if (SetterMethod->param_size() != 1 ||
2345 (*SetterMethod->param_begin())->getType().getNonReferenceType(),
2346 property->getType().getNonReferenceType())) {
2348 diag::warn_accessor_property_type_mismatch)
2350 << SetterMethod->getSelector();
2351 Diag(SetterMethod->getLocation(), diag::note_declared_at);
2361 if (!GetterMethod) {
2369 QualType resultTy =
property->getType().getAtomicUnqualifiedType();
2378 modifiedTy, modifiedTy);
2384 resultTy,
nullptr, CD,
2385 !IsClassProperty,
false,
2388 (
property->getPropertyImplementation() ==
2392 CD->addDecl(GetterMethod);
2396 if (property->
hasAttr<NSReturnsNotRetainedAttr>())
2397 GetterMethod->
addAttr(NSReturnsNotRetainedAttr::CreateImplicit(
Context,
2400 if (property->
hasAttr<ObjCReturnsInnerPointerAttr>())
2402 ObjCReturnsInnerPointerAttr::CreateImplicit(
Context, Loc));
2404 if (
const SectionAttr *SA = property->
getAttr<SectionAttr>())
2406 SectionAttr::CreateImplicit(
Context, SectionAttr::GNU_section,
2407 SA->getName(), Loc));
2415 property->setGetterMethodDecl(GetterMethod);
2420 if (!SetterMethod) {
2430 nullptr, CD, !IsClassProperty,
2435 (
property->getPropertyImplementation() ==
2442 property->getType().getUnqualifiedType().getAtomicUnqualifiedType();
2452 modifiedTy, modifiedTy);
2465 SetterMethod->setMethodParams(
Context, Argument,
None);
2470 if (
const SectionAttr *SA = property->
getAttr<SectionAttr>())
2471 SetterMethod->addAttr(
2472 SectionAttr::CreateImplicit(
Context, SectionAttr::GNU_section,
2473 SA->getName(), Loc));
2481 SetterMethod->setPropertyAccessor(
true);
2482 property->setSetterMethodDecl(SetterMethod);
2496 if (!IsClassProperty) {
2509 if (!CurrentClass) {
2511 CurrentClass = Cat->getClassInterface();
2512 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(CD))
2513 CurrentClass = Impl->getClassInterface();
2523 unsigned &Attributes,
2524 bool propertyInPrimaryClass) {
2531 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2532 <<
"readonly" <<
"readwrite";
2540 !PropertyTy->isObjCRetainableType() &&
2541 !PropertyDecl->
hasAttr<ObjCNSObjectAttr>()) {
2542 Diag(Loc, diag::err_objc_property_requires_object)
2553 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2554 <<
"assign" <<
"copy";
2558 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2559 <<
"assign" <<
"retain";
2563 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2564 <<
"assign" <<
"strong";
2569 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2570 <<
"assign" <<
"weak";
2573 if (PropertyDecl->
hasAttr<IBOutletCollectionAttr>())
2574 Diag(Loc, diag::warn_iboutletcollection_property_assign);
2577 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2578 <<
"unsafe_unretained" <<
"copy";
2582 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2583 <<
"unsafe_unretained" <<
"retain";
2587 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2588 <<
"unsafe_unretained" <<
"strong";
2593 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2594 <<
"unsafe_unretained" <<
"weak";
2599 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2600 <<
"copy" <<
"retain";
2604 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2605 <<
"copy" <<
"strong";
2609 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2610 <<
"copy" <<
"weak";
2616 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2617 <<
"retain" <<
"weak";
2621 (Attributes & ObjCDeclSpec::DQ_PR_weak)) {
2622 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2623 <<
"strong" <<
"weak";
2627 if (Attributes & ObjCDeclSpec::DQ_PR_weak) {
2629 if (
auto nullability = PropertyTy->getNullability(
Context)) {
2631 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2632 <<
"nonnull" <<
"weak";
2638 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2639 <<
"atomic" <<
"nonatomic";
2646 if (Attributes & ObjCDeclSpec::DQ_PR_readonly) {
2652 }
else if (PropertyTy->isObjCObjectPointerType()) {
2654 (PropertyTy->isObjCClassType() ||
2655 PropertyTy->isObjCQualifiedClassType());
2660 else if (propertyInPrimaryClass) {
2665 Diag(Loc, diag::warn_objc_property_no_assignment_attribute);
2669 Diag(Loc, diag::warn_objc_property_default_assign_on_object);
2679 if (!(Attributes & ObjCDeclSpec::DQ_PR_copy)
2682 && PropertyTy->isBlockPointerType())
2683 Diag(Loc, diag::warn_objc_property_copy_missing_on_block);
2684 else if ((Attributes & ObjCDeclSpec::DQ_PR_retain) &&
2686 !(Attributes & ObjCDeclSpec::DQ_PR_strong) &&
2687 PropertyTy->isBlockPointerType())
2688 Diag(Loc, diag::warn_objc_property_retain_of_block);
2690 if ((Attributes & ObjCDeclSpec::DQ_PR_readonly) &&
2692 Diag(Loc, diag::warn_objc_readonly_property_has_setter);
A call to an overloaded operator written using operator syntax.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
ObjCPropertyQueryKind getQueryKind() const
const internal::VariadicDynCastAllOfMatcher< Stmt, CallExpr > callExpr
Matches call expressions.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
An instance of this class is created to represent a function declaration or definition.
Lexer - This provides a simple interface that turns a text buffer into a stream of tokens...
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
protocol_range protocols() const
Smart pointer class that efficiently represents Objective-C method names.
A (possibly-)qualified type.
ObjCInterfaceDecl * getClassInterface()
all_protocol_range all_referenced_protocols() const
ObjCInterfaceDecl * getClassInterface()
bool IvarBacksCurrentMethodAccessor(ObjCInterfaceDecl *IFace, ObjCMethodDecl *Method, ObjCIvarDecl *IV)
IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is an ivar synthesized for 'Meth...
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
bool isObjCPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType, bool &IncompatibleObjC)
isObjCPointerConversion - Determines whether this is an Objective-C pointer conversion.
bool isArithmeticType() const
Decl * ActOnProperty(Scope *S, SourceLocation AtLoc, SourceLocation LParenLoc, FieldDeclarator &FD, ObjCDeclSpec &ODS, Selector GetterSel, Selector SetterSel, tok::ObjCKeywordKind MethodImplKind, DeclContext *lexicalDC=nullptr)
Defines the SourceManager interface.
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
void setObjCLifetime(ObjCLifetime type)
static void CollectSuperClassPropertyImplementations(ObjCInterfaceDecl *CDecl, ObjCInterfaceDecl::PropertyMap &PropMap)
CollectSuperClassPropertyImplementations - This routine collects list of properties to be implemented...
bool isRecordType() const
llvm::SmallVector< ObjCPropertyDecl *, 8 > PropertyDeclOrder
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
void DiagnoseMissingDesignatedInitOverrides(const ObjCImplementationDecl *ImplD, const ObjCInterfaceDecl *IFD)
void CheckObjCPropertyAttributes(Decl *PropertyPtrTy, SourceLocation Loc, unsigned &Attributes, bool propertyInPrimaryClass)
Ensure attributes are consistent with type.
Captures information about "declaration specifiers" specific to Objective-C.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
static ObjCPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, SourceLocation AtLocation, SourceLocation LParenLocation, QualType T, TypeSourceInfo *TSI, PropertyControl propControl=None)
void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
StringRef getLastMacroWithSpelling(SourceLocation Loc, ArrayRef< TokenValue > Tokens) const
Return the name of the macro defined before Loc that has spelling Tokens.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
A container of type source information.
void ProcessPropertyDecl(ObjCPropertyDecl *property)
Process the specified property declaration and create decls for the setters and getters as needed...
void setPropertyAccessor(bool isAccessor)
static bool areIncompatiblePropertyAttributes(unsigned Attr1, unsigned Attr2, unsigned Kinds)
Decl * ActOnPropertyImplDecl(Scope *S, SourceLocation AtLoc, SourceLocation PropertyLoc, bool ImplKind, IdentifierInfo *PropertyId, IdentifierInfo *PropertyIvar, SourceLocation PropertyIvarLoc, ObjCPropertyQueryKind QueryKind)
ActOnPropertyImplDecl - This routine performs semantic checks and builds the AST node for a property ...
StringRef getBufferData(FileID FID, bool *Invalid=nullptr) const
Return a StringRef to the source buffer data for the specified FileID.
RAII object to handle the state changes required to synthesize a function body.
const T * getAs() const
Member-template getAs<specific type>'.
static unsigned getOwnershipRule(unsigned attr)
ObjCMethodDecl - Represents an instance or class method declaration.
ObjCPropertyDecl * HandlePropertyInClassExtension(Scope *S, SourceLocation AtLoc, SourceLocation LParenLoc, FieldDeclarator &FD, Selector GetterSel, SourceLocation GetterNameLoc, Selector SetterSel, SourceLocation SetterNameLoc, const bool isReadWrite, unsigned &Attributes, const unsigned AttributesAsWritten, QualType T, TypeSourceInfo *TSI, tok::ObjCKeywordKind MethodImplKind)
Called by ActOnProperty to handle @property declarations in class extensions.
bool ClassImplementsProtocol(ObjCProtocolDecl *lProto, bool lookupCategory, bool RHSIsQualifiedID=false)
ClassImplementsProtocol - Checks that 'lProto' protocol has been implemented in IDecl class...
bool isInvalidDecl() const
static InitializedEntity InitializeResult(SourceLocation ReturnLoc, QualType Type, bool NRVO)
Create the initialization entity for the result of a function.
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
protocol_range protocols() const
ParmVarDecl - Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
Parse and apply any fixits to the source.
The collection of all-type qualifiers we support.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
static void CollectImmediateProperties(ObjCContainerDecl *CDecl, ObjCContainerDecl::PropertyMap &PropMap, ObjCContainerDecl::PropertyMap &SuperPropMap, bool CollectClassPropsOnly=false, bool IncludeProtocols=true)
CollectImmediateProperties - This routine collects all properties in the class and its conforming pro...
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
instprop_range instance_properties() const
One of these records is kept for each identifier that is lexed.
SourceLocation getSetterNameLoc() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The results of name lookup within a DeclContext.
ObjCMethodDecl * getClassMethod(Selector Sel, bool AllowHidden=false) const
ObjCMethodFamily
A family of Objective-C methods.
instmeth_range instance_methods() const
method_range methods() const
Token - This structure provides full information about a lexed token.
prop_range properties() const
This little struct is used to capture information about structure field declarators, which is basically just a bitfield size.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
bool isClassProperty() const
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
void collectPropertiesToImplement(PropertyMap &PM, PropertyDeclOrder &PO) const override
This routine collects list of properties to be implemented in the class.
void setObjCWeakProperty(bool Val=true)
bool isNonFragile() const
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?
ObjCContainerDecl - Represents a container for method declarations.
static ObjCPropertyImplDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation atLoc, SourceLocation L, ObjCPropertyDecl *property, Kind PK, ObjCIvarDecl *ivarDecl, SourceLocation ivarLoc)
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing, variable initialization, and function return values.
Whether values of this type can be null is (explicitly) unspecified.
PropertyAttributeKind getPropertyAttributes() const
const ObjCInterfaceDecl * isObjCRequiresPropertyDefs() const
isObjCRequiresPropertyDefs - Checks that a class or one of its super classes must not be auto-synthes...
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
static void DiagnoseUnimplementedAccessor(Sema &S, ObjCInterfaceDecl *PrimaryClass, Selector Method, ObjCImplDecl *IMPDecl, ObjCContainerDecl *CDecl, ObjCCategoryDecl *C, ObjCPropertyDecl *Prop, llvm::SmallPtrSet< const ObjCMethodDecl *, 8 > &SMap)
bool isReadOnly() const
isReadOnly - Return true iff the property has a setter.
Values of this type can never be null.
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
Scope - A scope is a transient data structure that is used while parsing the program.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
Represents an Objective-C protocol declaration.
const LangOptions & getLangOpts() const
PropertyControl getPropertyImplementation() const
Represents an ObjC class declaration.
ObjCPropertyDecl * CreatePropertyDecl(Scope *S, ObjCContainerDecl *CDecl, SourceLocation AtLoc, SourceLocation LParenLoc, FieldDeclarator &FD, Selector GetterSel, SourceLocation GetterNameLoc, Selector SetterSel, SourceLocation SetterNameLoc, const bool isReadWrite, const unsigned Attributes, const unsigned AttributesAsWritten, QualType T, TypeSourceInfo *TSI, tok::ObjCKeywordKind MethodImplKind, DeclContext *lexicalDC=nullptr)
Called by ActOnProperty and HandlePropertyInClassExtension to handle creating the ObjcPropertyDecl fo...
QualType getReturnType() const
IdentifierInfo * getIdentifier() const
const LangOptions & LangOpts
This object can be modified without requiring retains or releases.
void AtomicPropertySetterGetterRules(ObjCImplDecl *IMPDecl, ObjCInterfaceDecl *IDecl)
AtomicPropertySetterGetterRules - This routine enforces the rule (via warning) when atomic property h...
void setGetterCXXConstructor(Expr *getterCXXConstructor)
void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddInstanceMethodToGlobalPool - All instance methods in a translation unit are added to a global pool...
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
void CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod, ObjCInterfaceDecl *CurrentClass, ResultTypeCompatibilityKind RTC)
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Sema - This implements semantic analysis and AST building for C.
static void AddPropertyAttrs(Sema &S, ObjCMethodDecl *PropertyMethod, ObjCPropertyDecl *Property)
AddPropertyAttrs - Propagates attributes from a property to the implicitly-declared getter or setter ...
bool isFragile() const
The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ...
llvm::SmallPtrSet< Selector, 8 > SelectorSet
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
void addObjCLifetime(ObjCLifetime type)
QualType getUsageType(QualType objectType) const
Retrieve the type of this instance variable when viewed as a member of a specific object type...
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
SourceLocation getBeginLoc() const
Get the begin source location.
bool isObjCGCStrong() const
true when Type is objc's strong.
Expr - This represents one expression.
known_extensions_range known_extensions() const
static ObjCMethodDecl * Create(ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc, Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo, DeclContext *contextDecl, bool isInstance=true, bool isVariadic=false, bool isPropertyAccessor=false, bool isImplicitlyDeclared=false, bool isDefined=false, ImplementationControl impControl=None, bool HasRelatedResultType=false)
Selector getSetterName() const
bool HasUserDeclaredSetterMethod(const ObjCPropertyDecl *P) const
This routine returns 'true' if a user declared setter method was found in the class, its protocols, its super classes or categories.
IdentifierInfo * getDefaultSynthIvarName(ASTContext &Ctx) const
Get the default name of the synthesized ivar.
const FunctionProtoType * T
bool isObjCARCImplicitlyUnretainedType() const
Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...
TypeSourceInfo * getTypeSourceInfo() const
bool isObjCRetainableType() const
static ObjCPropertyDecl::PropertyAttributeKind makePropertyAttributesAsWritten(unsigned Attributes)
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
static bool hasWrittenStorageAttribute(ObjCPropertyDecl *Prop, ObjCPropertyQueryKind QueryKind)
Determine whether any storage attributes were written on the property.
Defines the clang::Preprocessor interface.
DeclContext * getDeclContext()
ObjCInterfaceDecl * getSuperClass() const
Stores token information for comparing actual tokens with predefined values.
ObjCPropertyDecl * FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyVisibleInPrimaryClass - Finds declaration of the property with name 'PropertyId' in the p...
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
ParmVarDecl *const * param_iterator
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
clang::ObjCRuntime ObjCRuntime
propimpl_range property_impls() const
Qualifiers Quals
The local qualifiers.
llvm::SmallDenseSet< const ObjCProtocolDecl *, 8 > ProtocolPropertySet
bool isInstanceMethod() const
Preprocessor & getPreprocessor() const
Selector getSelector() const
SourceLocation getLocEnd() const LLVM_READONLY
static StringRef getIdentifier(const Token &Tok)
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const
Return the uniqued reference to the type for an Objective-C gc-qualified type.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
RecordDecl * getDecl() const
SourceLocation getLocStart() const LLVM_READONLY
There is no lifetime qualification on this type.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
Assigning into this object requires the old value to be released and the new value to be retained...
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Encodes a location in the source.
bool getSynthesize() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static Qualifiers::ObjCLifetime getImpliedARCOwnership(ObjCPropertyDecl::PropertyAttributeKind attrs, QualType type)
getImpliedARCOwnership - Given a set of property attributes and a type, infer an expected lifetime...
ObjCPropertyAttributeKind getPropertyAttributes() const
ObjCCategoryDecl - Represents a category declaration.
void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl *IMPDecl, ObjCContainerDecl *CDecl, bool SynthesizeProperties)
DiagnoseUnimplementedProperties - This routine warns on those properties which must be implemented by...
Represents one property declaration in an Objective-C interface.
ObjCMethodDecl * lookupPropertyAccessor(const Selector Sel, const ObjCCategoryDecl *Cat, bool IsClassProperty) const
Lookup a setter or getter in the class hierarchy, including in all categories except for category pas...
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=NotForRedeclaration)
Find the protocol with the given name, if any.
ObjCPropertyImplDecl * FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const
FindPropertyImplIvarDecl - This method lookup the ivar in the list of properties implemented in this ...
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
Indicates that the nullability of the type was spelled with a property attribute rather than a type q...
Assigning into this object requires a lifetime extension.
bool hasFlexibleArrayMember() const
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void DiagnoseOwningPropertyGetterSynthesis(const ObjCImplementationDecl *D)
void setSetterCXXAssignment(Expr *setterCXXAssignment)
static void checkARCPropertyImpl(Sema &S, SourceLocation propertyImplLoc, ObjCPropertyDecl *property, ObjCIvarDecl *ivar)
bool isObjCGCWeak() const
true when Type is objc's weak.
bool propertyTypesAreCompatible(QualType, QualType)
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
const ObjCInterfaceDecl * getClassInterface() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
static void setImpliedPropertyAttributeForReadOnlyProperty(ObjCPropertyDecl *property, ObjCIvarDecl *ivar)
setImpliedPropertyAttributeForReadOnlyProperty - This routine evaludates life-time attributes for a '...
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
void diagnoseNullResettableSynthesizedSetters(const ObjCImplDecl *impDecl)
Diagnose any null-resettable synthesized setters.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
static bool SuperClassImplementsProperty(ObjCInterfaceDecl *IDecl, ObjCPropertyDecl *Prop)
PropertyAttributeKind getPropertyAttributesAsWritten() const
The basic abstraction for the target Objective-C runtime.
SourceLocation getLocStart() const LLVM_READONLY
bool CheckARCMethodDecl(ObjCMethodDecl *method)
Check a method declaration for compatibility with the Objective-C ARC conventions.
llvm::DenseMap< std::pair< IdentifierInfo *, unsigned >, ObjCPropertyDecl * > PropertyMap
bool hasObjCLifetime() const
bool hasDesignatedInitializers() const
Returns true if this interface decl contains at least one initializer marked with the 'objc_designate...
Represents a pointer to an Objective C object.
static ObjCIvarDecl * Create(ASTContext &C, ObjCContainerDecl *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW=nullptr, bool synthesized=false)
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
void overwritePropertyAttributes(unsigned PRVal)
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple()) const
Determine the availability of the given declaration.
SourceLocation getGetterNameLoc() const
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
void addDecl(Decl *D)
Add the declaration D into this context.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance, bool shallowCategoryLookup=false, bool followSuper=true, const ObjCCategoryDecl *C=nullptr) const
lookupMethod - This method returns an instance/class method by looking in the class, its categories, and its super classes (using a linear search).
static void checkAtomicPropertyMismatch(Sema &S, ObjCPropertyDecl *OldProperty, ObjCPropertyDecl *NewProperty, bool PropagateAtomicity)
Check for a mismatch in the atomicity of the given properties.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
SourceManager & getSourceManager()
bool isObjCObjectType() const
bool IsClassExtension() const
SourceLocation getIdentifierLoc() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
static bool LocPropertyAttribute(ASTContext &Context, const char *attrName, SourceLocation LParenLoc, SourceLocation &Loc)
Reading or writing from this object requires a barrier call.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups, surround it with a ExprWithCleanups node.
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D...
Compatible - the types are compatible according to the standard.
ObjCPropertyImplDecl * FindPropertyImplDecl(IdentifierInfo *propertyId, ObjCPropertyQueryKind queryKind) const
FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl added to the list of thos...
ObjCIvarDecl - Represents an ObjC instance variable.
static unsigned deducePropertyOwnershipFromType(Sema &S, QualType T)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
void setPropertyAttributes(PropertyAttributeKind PRVal)
void DiagnosePropertyMismatch(ObjCPropertyDecl *Property, ObjCPropertyDecl *SuperProperty, const IdentifierInfo *Name, bool OverridingProtocolProperty)
DiagnosePropertyMismatch - Compares two properties for their attributes and types and warns on a vari...
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
bool isArcWeakrefUnavailable() const
isArcWeakrefUnavailable - Checks for a class or one of its super classes to be incompatible with __we...
static ObjCPropertyDecl * SelectPropertyForSynthesisFromProtocols(Sema &S, SourceLocation AtLoc, ObjCInterfaceDecl *ClassDecl, ObjCPropertyDecl *Property)
SelectPropertyForSynthesisFromProtocols - Finds the most appropriate property declaration that should...
bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD, ObjCMethodDecl *Getter, SourceLocation Loc)
void DefaultSynthesizeProperties(Scope *S, ObjCImplDecl *IMPDecl, ObjCInterfaceDecl *IDecl, SourceLocation AtEnd)
DefaultSynthesizeProperties - This routine default synthesizes all properties which must be synthesiz...
static const unsigned OwnershipMask
A reference to a declared variable, function, enum, etc.
void addPropertyImplementation(ObjCPropertyImplDecl *property)
static void CheckPropertyAgainstProtocol(Sema &S, ObjCPropertyDecl *Prop, ObjCProtocolDecl *Proto, llvm::SmallPtrSetImpl< ObjCProtocolDecl *> &Known)
Check this Objective-C property against a property declared in the given protocol.
An l-value expression is a reference to an object with independent storage.
A trivial tuple used to represent a source range.
void setLexicalDeclContext(DeclContext *DC)
ObjCMethodDecl * getGetterMethodDecl() const
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
llvm::DenseMap< const Stmt *, CFGBlock * > SMap
AccessControl getAccessControl() const
bool isPropertyAccessor() const
Selector getGetterName() const
SourceLocation getLParenLoc() const
void setType(QualType newType)
const LangOptions & getLangOpts() const
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
This class handles loading and caching of source files into memory.
static void checkPropertyDeclWithOwnership(Sema &S, ObjCPropertyDecl *property)
Check the internal consistency of a property declaration with an explicit ownership qualifier...
Attr - This represents one attribute.
SourceLocation getLocation() const
TypeSourceInfo * GetTypeForDeclarator(Declarator &D, Scope *S)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
QualType getType() const
Return the type wrapped by this type source info.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
static bool isIncompatiblePropertyAttribute(unsigned Attr1, unsigned Attr2, ObjCPropertyDecl::PropertyAttributeKind Kind)
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
ObjCCategoryDecl * FindCategoryDeclaration(IdentifierInfo *CategoryId) const
FindCategoryDeclaration - Finds category declaration in the list of categories for this class and ret...