23 #include "llvm/ADT/DenseSet.h" 24 #include "llvm/ADT/SmallString.h" 26 using namespace clang;
70 =
property->getPropertyAttributes();
72 =
property->getType().getObjCLifetime();
78 if (!expectedLifetime) {
92 property->setPropertyAttributes(attr);
96 if (propertyLifetime == expectedLifetime)
return;
98 property->setInvalidDecl();
100 diag::err_arc_inconsistent_property_ownership)
111 llvm::SmallPtrSetImpl<ObjCProtocolDecl *> &Known) {
113 if (!Known.insert(Proto).second)
118 for (
unsigned I = 0, N = R.
size(); I != N; ++I) {
149 llvm_unreachable(
"bad qualifier");
200 if (CDecl->IsClassExtension()) {
205 isReadWrite, Attributes,
207 T, TSI, MethodImplKind);
225 (isa<ObjCInterfaceDecl>(ClassDecl) ||
226 isa<ObjCProtocolDecl>(ClassDecl)));
229 if (Res->getType().getObjCLifetime())
232 llvm::SmallPtrSet<ObjCProtocolDecl *, 16> KnownProtos;
235 bool FoundInSuper =
false;
239 for (
unsigned I = 0, N = R.
size(); I != N; ++I) {
249 CurrentInterfaceDecl = Super;
254 for (
auto *
P : CurrentInterfaceDecl->
protocols()) {
259 for (
auto *
P : IFace->all_referenced_protocols()) {
267 if (!Cat->IsClassExtension())
268 for (
auto *
P : Cat->protocols())
282 unsigned attributesAsWritten = 0;
321 bool invalidTemp =
false;
322 StringRef file = SM.
getBufferData(locInfo.first, &invalidTemp);
325 const char *tokenBegin = file.data() + locInfo.second;
330 file.begin(), tokenBegin, file.end());
333 lexer.LexFromRawLexer(Tok);
334 if (Tok.is(tok::raw_identifier) && Tok.getRawIdentifier() == attrName) {
335 Loc = Tok.getLocation();
338 }
while (Tok.isNot(tok::r_paren));
346 bool PropagateAtomicity) {
354 if (OldIsAtomic == NewIsAtomic)
return;
360 auto Attrs =
Property->getPropertyAttributes();
367 if (
Property->getPropertyAttributesAsWritten() &
376 const unsigned AtomicityMask =
378 if (PropagateAtomicity &&
381 Attrs = Attrs & ~AtomicityMask;
393 if ((OldIsAtomic && isImplicitlyReadonlyAtomic(OldProperty)) ||
394 (NewIsAtomic && isImplicitlyReadonlyAtomic(NewProperty)))
400 if (
auto Category = dyn_cast<ObjCCategoryDecl>(OldDC))
401 OldContextName =
Category->getClassInterface()->getIdentifier();
403 OldContextName = cast<ObjCContainerDecl>(OldDC)->
getIdentifier();
420 const bool isReadWrite,
421 unsigned &Attributes,
422 const unsigned AttributesAsWritten,
449 Diag(AtLoc, diag::err_duplicate_property);
468 ? diag::err_use_continuation_class_redeclaration_readwrite
469 : diag::err_use_continuation_class;
480 Diag(AtLoc, diag::warn_property_redecl_getter_mismatch)
491 unsigned ExistingOwnership
494 if (ExistingOwnership && NewOwnership != ExistingOwnership) {
497 Diag(AtLoc, diag::warn_property_attr_mismatch);
502 Attributes = (Attributes & ~
OwnershipMask) | ExistingOwnership;
511 Diag(AtLoc, diag::warn_property_implicitly_mismatched);
519 FD, GetterSel, GetterNameLoc,
520 SetterSel, SetterNameLoc,
522 Attributes, AttributesAsWritten,
523 T, TSI, MethodImplKind, DC);
533 bool IncompatibleObjC =
false;
543 if (!isa<ObjCObjectPointerType>(PrimaryClassPropertyT) ||
544 !isa<ObjCObjectPointerType>(ClassExtPropertyT) ||
546 ConvertedType, IncompatibleObjC))
547 || IncompatibleObjC) {
549 diag::err_type_mismatch_continuation_class) << PDecl->getType();
573 const bool isReadWrite,
574 const unsigned Attributes,
575 const unsigned AttributesAsWritten,
606 Diag(AtLoc, diag::warn_implements_nscopying) << PropertyId;
624 LParenLoc, T, TInfo);
632 Diag(prevDecl->getLocation(), diag::note_property_declare);
641 if (T->isArrayType() || T->isFunctionType()) {
642 Diag(AtLoc, diag::err_property_type) << T;
692 if (Attributes & ObjCDeclSpec::DQ_PR_unsafe_unretained)
697 if (MethodImplKind == tok::objc_required)
699 else if (MethodImplKind == tok::objc_optional)
708 if (Attributes & ObjCDeclSpec::DQ_PR_class)
725 property->getType());
728 if (propertyLifetime == ivarLifetime)
return;
754 switch (propertyLifetime) {
772 << ((
property->getPropertyAttributesAsWritten()
777 llvm_unreachable(
"properties cannot be autoreleasing");
786 S.
Diag(propertyImplLoc, diag::note_property_synthesize);
798 property->getType());
819 return (Attr1 & Kind) != (Attr2 &
Kind);
824 return ((Attr1 & Kinds) != 0) != ((Attr2 & Kinds) != 0);
837 "Expected a property from a protocol");
842 PDecl->collectInheritedProtocolProperties(Property, ProtocolSet,
847 for (
const auto *PI : SDecl->all_referenced_protocols()) {
849 PDecl->collectInheritedProtocolProperties(Property, ProtocolSet,
852 SDecl = SDecl->getSuperClass();
856 if (Properties.empty())
860 size_t SelectedIndex = 0;
861 for (
const auto &Prop : llvm::enumerate(Properties)) {
863 if (Property->
isReadOnly() && !Prop.value()->isReadOnly()) {
864 Property = Prop.value();
865 SelectedIndex = Prop.index();
868 if (Property != OriginalProperty) {
870 Properties[SelectedIndex] = OriginalProperty;
876 IncompatibleType = 0,
877 HasNoExpectedAttribute,
878 HasUnexpectedAttribute,
884 struct MismatchingProperty {
887 StringRef AttributeName;
892 unsigned Attr = Prop->getPropertyAttributesAsWritten();
893 if (Attr != OriginalAttributes) {
894 auto Diag = [&](
bool OriginalHasAttribute, StringRef AttributeName) {
895 MismatchKind
Kind = OriginalHasAttribute ? HasNoExpectedAttribute
896 : HasUnexpectedAttribute;
897 Mismatches.push_back({Prop,
Kind, AttributeName});
914 OriginalAttributes, Attr,
919 "retain (or strong)");
929 Mismatches.push_back({Prop, DifferentGetter,
""});
932 if (!Property->
isReadOnly() && !Prop->isReadOnly() &&
934 Mismatches.push_back({Prop, DifferentSetter,
""});
939 bool IncompatibleObjC =
false;
942 || IncompatibleObjC) {
943 Mismatches.push_back({Prop, IncompatibleType,
""});
949 if (Mismatches.empty())
954 bool HasIncompatibleAttributes =
false;
955 for (
const auto &
Note : Mismatches)
956 HasIncompatibleAttributes =
957 Note.Kind != IncompatibleType ?
true : HasIncompatibleAttributes;
961 Property != OriginalProperty || HasIncompatibleAttributes
962 ? diag::err_protocol_property_mismatch
963 : diag::warn_protocol_property_mismatch);
964 Diag << Mismatches[0].Kind;
965 switch (Mismatches[0].
Kind) {
966 case IncompatibleType:
969 case HasNoExpectedAttribute:
970 case HasUnexpectedAttribute:
971 Diag << Mismatches[0].AttributeName;
973 case DifferentGetter:
976 case DifferentSetter:
981 for (
const auto &
Note : Mismatches) {
983 S.
Diag(
Note.Prop->getLocation(), diag::note_protocol_property_declare)
986 case IncompatibleType:
989 case HasNoExpectedAttribute:
990 case HasUnexpectedAttribute:
993 case DifferentGetter:
996 case DifferentSetter:
1002 S.
Diag(AtLoc, diag::note_property_synthesize);
1024 auto OrigClass =
Category->getClassInterface();
1025 for (
auto Found : OrigClass->lookup(Prop->
getDeclName())) {
1027 return OrigProp->getPropertyAttributesAsWritten() &
OwnershipMask;
1031 for (
const auto *Proto : OrigClass->all_referenced_protocols()) {
1034 return OrigProp->getPropertyAttributesAsWritten() &
OwnershipMask;
1055 if (!ClassImpDecl) {
1056 Diag(AtLoc, diag::err_missing_property_context);
1060 PropertyIvarLoc = PropertyLoc;
1070 if ((IC = dyn_cast<ObjCImplementationDecl>(ClassImpDecl))) {
1075 "ActOnPropertyImplDecl - @implementation without @interface");
1080 Diag(PropertyLoc, diag::err_bad_property_decl) << IDecl->
getDeclName();
1083 if (property->isClassProperty() && Synthesize) {
1084 Diag(PropertyLoc, diag::err_synthesize_on_class_property) << PropertyId;
1087 unsigned PIkind =
property->getPropertyAttributesAsWritten();
1091 Diag(AtLoc, diag::warn_implicit_atomic_property);
1094 Diag(property->getLocation(), diag::note_property_declare);
1098 dyn_cast<ObjCCategoryDecl>(property->getDeclContext())) {
1099 if (!CD->IsClassExtension()) {
1100 Diag(PropertyLoc, diag::err_category_property) << CD->getDeclName();
1101 Diag(property->getLocation(), diag::note_property_declare);
1107 property->hasAttr<IBOutletAttr>() &&
1109 bool ReadWriteProperty =
false;
1116 PIkind = ExtProp->getPropertyAttributesAsWritten();
1118 ReadWriteProperty =
true;
1124 if (!ReadWriteProperty) {
1125 Diag(property->getLocation(), diag::warn_auto_readonly_iboutlet_property)
1129 property->getLParenLoc(), readonlyLoc)) {
1132 SourceRange ReadonlySourceRange(readonlyLoc, endLoc);
1133 Diag(property->getLocation(),
1134 diag::note_auto_readonly_iboutlet_fixup_suggest) <<
1139 if (Synthesize && isa<ObjCProtocolDecl>(property->getDeclContext()))
1143 }
else if ((CatImplClass = dyn_cast<ObjCCategoryImplDecl>(ClassImpDecl))) {
1145 Diag(AtLoc, diag::err_synthesize_category_decl);
1150 Diag(AtLoc, diag::err_missing_property_interface);
1163 Diag(PropertyLoc, diag::err_bad_category_property_decl)
1168 Diag(AtLoc, diag::err_bad_property_context);
1172 bool CompleteTypeErr =
false;
1178 PropertyIvar = PropertyId;
1182 QualType PropType =
property->getType();
1186 diag::err_incomplete_synthesized_property,
1187 property->getDeclName())) {
1188 Diag(property->getLocation(), diag::note_property_declare);
1189 CompleteTypeErr =
true;
1193 (
property->getPropertyAttributesAsWritten() &
1200 =
property->getPropertyAttributes();
1202 bool isARCWeak =
false;
1208 Diag(PropertyDiagLoc, diag::err_gc_weak_property_strong_type);
1209 Diag(property->getLocation(), diag::note_property_declare);
1221 Diag(PropertyDiagLoc,
1223 ? diag::err_synthesizing_arc_weak_property_disabled
1224 : diag::err_synthesizing_arc_weak_property_no_runtime);
1225 Diag(property->getLocation(), diag::note_property_declare);
1227 CompleteTypeErr =
true;
1234 Diag(property->getLocation(),
1235 diag::err_arc_weak_unavailable_property)
1236 << PropertyIvarType;
1255 Diag(PropertyDiagLoc,
1256 diag::warn_autosynthesis_property_ivar_match)
1257 << PropertyId << (Ivar ==
nullptr) << PropertyIvar
1259 Diag(property->getLocation(), diag::note_property_declare);
1267 if ((
getLangOpts().ObjCAutoRefCount || isARCWeak) &&
1275 Diag(PropertyDiagLoc,
1276 diag::err_arc_objc_property_default_assign_on_object);
1277 Diag(property->getLocation(), diag::note_property_declare);
1281 assert(lifetime &&
"no lifetime for property?");
1290 PropertyIvarLoc,PropertyIvarLoc, PropertyIvar,
1291 PropertyIvarType,
nullptr,
1293 (
Expr *)
nullptr,
true);
1296 diag::err_abstract_type_in_decl,
1298 Diag(property->getLocation(), diag::note_property_declare);
1300 CompleteTypeErr =
true;
1302 if (!CompleteTypeErr) {
1305 Diag(PropertyIvarLoc, diag::err_synthesize_variable_sized_ivar)
1306 << PropertyIvarType;
1307 CompleteTypeErr =
true;
1310 if (CompleteTypeErr)
1316 Diag(PropertyDiagLoc, diag::err_missing_property_ivar_decl)
1322 Diag(PropertyDiagLoc, diag::err_ivar_in_superclass_use)
1329 property->setPropertyIvarDecl(Ivar);
1335 if (isa<ObjCObjectPointerType>(PropertyIvarType)
1336 && isa<ObjCObjectPointerType>(IvarType))
1347 Diag(PropertyDiagLoc, diag::err_property_ivar_type)
1348 <<
property->getDeclName() << PropType
1360 if (lhsType != rhsType &&
1362 Diag(PropertyDiagLoc, diag::err_property_ivar_type)
1363 <<
property->getDeclName() << PropType
1372 Diag(PropertyDiagLoc, diag::err_weak_property)
1373 <<
property->getDeclName() << Ivar->
getDeclName();
1378 if ((property->getType()->isObjCObjectPointerType() ||
1381 Diag(PropertyDiagLoc, diag::err_strong_property)
1382 <<
property->getDeclName() << Ivar->
getDeclName();
1386 if (
getLangOpts().ObjCAutoRefCount || isARCWeak ||
1389 }
else if (PropertyIvar)
1391 Diag(PropertyDiagLoc, diag::err_dynamic_property_ivar_decl);
1393 assert (property &&
"ActOnPropertyImplDecl - property declaration missing");
1400 Ivar, PropertyIvarLoc);
1402 if (CompleteTypeErr || !compat)
1405 if (
ObjCMethodDecl *getterMethod = property->getGetterMethodDecl()) {
1406 getterMethod->createImplicitParams(
Context, IDecl);
1418 Expr *LoadSelfExpr =
1420 CK_LValueToRValue, SelfExpr,
nullptr,
1427 LoadSelfExpr,
true,
true);
1430 getterMethod->getReturnType(),
1432 PropertyDiagLoc, IvarRefExpr);
1440 if (property->hasAttr<NSReturnsNotRetainedAttr>() &&
1441 !getterMethod->hasAttr<NSReturnsNotRetainedAttr>()) {
1442 Diag(getterMethod->getLocation(),
1443 diag::warn_property_getter_owning_mismatch);
1444 Diag(property->getLocation(), diag::note_property_declare);
1447 switch (getterMethod->getMethodFamily()) {
1452 Diag(getterMethod->getLocation(), diag::err_arc_illegal_method_def)
1453 << 1 << getterMethod->getSelector();
1459 if (
ObjCMethodDecl *setterMethod = property->getSetterMethodDecl()) {
1460 setterMethod->createImplicitParams(
Context, IDecl);
1470 Expr *LoadSelfExpr =
1472 CK_LValueToRValue, SelfExpr,
nullptr,
1479 LoadSelfExpr,
true,
true);
1487 BO_Assign, lhs, rhs);
1488 if (property->getPropertyAttributes() &
1492 dyn_cast_or_null<CXXOperatorCallExpr>(callExpr))
1493 if (
const FunctionDecl *FuncDecl = CXXCE->getDirectCallee())
1494 if (!FuncDecl->isTrivial())
1495 if (property->getType()->isReferenceType()) {
1496 Diag(PropertyDiagLoc,
1497 diag::err_atomic_property_nontrivial_assign_op)
1498 <<
property->getType();
1499 Diag(FuncDecl->getBeginLoc(), diag::note_callee_decl)
1511 Diag(PropertyLoc, diag::err_duplicate_ivar_use)
1512 << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()
1514 Diag(PPIDecl->getLocation(), diag::note_previous_use);
1519 Diag(PropertyLoc, diag::err_property_implemented) << PropertyId;
1520 Diag(PPIDecl->getLocation(), diag::note_previous_declaration);
1535 if (PropertyIvar && PropertyIvar != PropertyId)
1550 Diag(PropertyDiagLoc, diag::err_duplicate_ivar_use)
1551 << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()
1553 Diag(PPIDecl->getLocation(), diag::note_previous_use);
1558 Diag(PropertyDiagLoc, diag::err_property_implemented) << PropertyId;
1559 Diag(PPIDecl->getLocation(), diag::note_previous_declaration);
1579 bool OverridingProtocolProperty) {
1588 if (!OverridingProtocolProperty &&
1597 != (SAttr & ObjCPropertyDecl::OBJC_PR_copy))
1599 << Property->
getDeclName() <<
"copy" << inheritedName;
1600 else if (!(SAttr & ObjCPropertyDecl::OBJC_PR_readonly)){
1601 unsigned CAttrRetain =
1604 unsigned SAttrRetain =
1607 bool CStrong = (CAttrRetain != 0);
1608 bool SStrong = (SAttrRetain != 0);
1609 if (CStrong != SStrong)
1611 << Property->
getDeclName() <<
"retain (or strong)" << inheritedName;
1625 << Property->
getDeclName() <<
"setter" << inheritedName;
1630 << Property->
getDeclName() <<
"getter" << inheritedName;
1642 bool IncompatibleObjC =
false;
1645 ConvertedType, IncompatibleObjC) ||
1647 Diag(Property->
getLocation(), diag::warn_property_types_are_incompatible)
1648 << Property->
getType() << SuperProperty->
getType() << inheritedName;
1661 property->getType().getNonReferenceType().getAtomicUnqualifiedType();
1666 if ((propertyObjCPtr =
1672 Diag(Loc, diag::err_property_accessor_type)
1673 <<
property->getDeclName() << PropertyRValueType
1687 Diag(Loc, diag::warn_accessor_property_type_mismatch)
1688 <<
property->getDeclName()
1703 bool CollectClassPropsOnly =
false,
1704 bool IncludeProtocols =
true) {
1706 for (
auto *Prop : IDecl->properties()) {
1707 if (CollectClassPropsOnly && !Prop->isClassProperty())
1709 PropMap[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] =
1714 for (
auto *Ext : IDecl->visible_extensions())
1716 CollectClassPropsOnly, IncludeProtocols);
1718 if (IncludeProtocols) {
1720 for (
auto *PI : IDecl->all_referenced_protocols())
1722 CollectClassPropsOnly);
1726 for (
auto *Prop : CATDecl->properties()) {
1727 if (CollectClassPropsOnly && !Prop->isClassProperty())
1729 PropMap[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] =
1732 if (IncludeProtocols) {
1734 for (
auto *PI : CATDecl->protocols())
1736 CollectClassPropsOnly);
1740 for (
auto *Prop : PDecl->properties()) {
1741 if (CollectClassPropsOnly && !Prop->isClassProperty())
1744 SuperPropMap[std::make_pair(Prop->getIdentifier(),
1745 Prop->isClassProperty())];
1748 if (!PropertyFromSuper ||
1749 PropertyFromSuper->
getIdentifier() != Prop->getIdentifier()) {
1751 PropMap[std::make_pair(Prop->getIdentifier(),
1752 Prop->isClassProperty())];
1758 for (
auto *PI : PDecl->protocols())
1760 CollectClassPropsOnly);
1772 SDecl->collectPropertiesToImplement(PropMap, PO);
1773 SDecl = SDecl->getSuperClass();
1796 (
Property->getPropertyIvarDecl() == IV))
1802 for (
const auto *
Property : Ext->instance_properties())
1805 (
Property->getPropertyIvarDecl() == IV))
1812 bool SuperClassImplementsGetter =
false;
1813 bool SuperClassImplementsSetter =
false;
1815 SuperClassImplementsSetter =
true;
1820 SuperClassImplementsGetter =
true;
1823 SuperClassImplementsSetter =
true;
1824 if (SuperClassImplementsGetter && SuperClassImplementsSetter)
1839 if (PropMap.empty())
1844 for (
unsigned i = 0, e = PropertyOrder.size(); i != e; i++) {
1863 Diag(Prop->
getLocation(), diag::warn_no_autosynthesis_shared_ivar_property)
1865 if (PID->getLocation().isValid())
1866 Diag(PID->getLocation(), diag::note_property_synthesize);
1880 diag::warn_auto_synthesizing_protocol_property)
1884 (Twine(
"@synthesize ") + Prop->
getName() +
";\n\n").str();
1885 Diag(AtEnd, diag::note_add_synthesize_directive)
1891 if (PropInSuperClass) {
1902 Diag(Prop->
getLocation(), diag::warn_autosynthesis_property_in_superclass)
1934 if (!IDecl->isObjCRequiresPropertyDefs())
1942 llvm::SmallPtrSet<const ObjCMethodDecl *, 8> &
SMap) {
1953 if (I == SMap.end() &&
1954 (PrimaryClass ==
nullptr ||
1958 isa<ObjCCategoryDecl>(CDecl)
1960 ? diag::warn_impl_required_in_category_for_class_property
1961 : diag::warn_setter_getter_impl_required_in_category)
1963 ? diag::warn_impl_required_for_class_property
1964 : diag::warn_setter_getter_impl_required);
1967 if (S.
LangOpts.ObjCDefaultSynthProperties &&
1971 S.
Diag(RID->getLocation(), diag::note_suppressed_class_declare);
1977 bool SynthesizeProperties) {
1991 if ((IDecl =
C->getClassInterface())) {
2001 SynthesizeProperties);
2007 std::unique_ptr<ObjCContainerDecl::PropertyMap> LazyMap;
2010 if (!PDecl->hasAttr<ObjCExplicitProtocolImplAttr>())
2028 for (
auto *PropDecl : PDecl->properties()) {
2029 if ((*LazyMap)[std::make_pair(PropDecl->getIdentifier(),
2030 PropDecl->isClassProperty())])
2032 PropMap[std::make_pair(PropDecl->getIdentifier(),
2033 PropDecl->isClassProperty())] = PropDecl;
2038 if (PropMap.empty())
2043 PropImplMap.insert(I->getPropertyDecl());
2045 llvm::SmallPtrSet<const ObjCMethodDecl *, 8> InsMap;
2047 for (
const auto *I : IMPDecl->
methods())
2055 if (
ObjCImplDecl *IMP = PrimaryClass->getImplementation()) {
2059 for (
const auto *I : IMP->methods())
2063 for (ObjCContainerDecl::PropertyMap::iterator
2064 P = PropMap.begin(), E = PropMap.end();
P != E; ++
P) {
2069 PropImplMap.count(Prop) ||
2075 PrimaryClass, Prop->
getGetterName(), IMPDecl, CDecl,
C, Prop, InsMap);
2076 if (!Prop->isReadOnly())
2078 PrimaryClass, Prop->getSetterName(),
2079 IMPDecl, CDecl,
C, Prop, InsMap);
2085 const auto *
property = propertyImpl->getPropertyDecl();
2089 if (propertyImpl->getPropertyImplementation()
2091 (
property->getPropertyAttributes() &
2093 property->getGetterMethodDecl() &&
2094 property->getSetterMethodDecl()) {
2095 auto *getterMethod =
property->getGetterMethodDecl();
2096 auto *setterMethod =
property->getSetterMethodDecl();
2103 Diag(loc, diag::warn_null_resettable_setter)
2104 << setterMethod->getSelector() <<
property->getDeclName();
2118 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
2120 for (
auto *Prop : Ext->properties())
2121 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
2123 for (ObjCContainerDecl::PropertyMap::iterator I = PM.begin(), E = PM.end();
2128 bool LookedUpGetterSetter =
false;
2141 LookedUpGetterSetter =
true;
2144 diag::warn_default_atomic_custom_getter_setter)
2150 diag::warn_default_atomic_custom_getter_setter)
2157 if ((Attributes & ObjCPropertyDecl::OBJC_PR_nonatomic) ||
2164 if (!LookedUpGetterSetter) {
2172 if ((GetterMethod && !SetterMethod) || (!GetterMethod && SetterMethod)) {
2176 Diag(MethodLoc, diag::warn_atomic_property_rule)
2178 << (SetterMethod !=
nullptr);
2185 StringRef NonatomicStr = AttributesAsWritten?
"nonatomic, " 2188 diag::note_atomic_property_fixup_suggest)
2195 diag::note_atomic_property_fixup_suggest)
2199 Diag(MethodLoc, diag::note_atomic_property_fixup_suggest);
2212 if (PD && !PD->
hasAttr<NSReturnsNotRetainedAttr>() &&
2230 for (
auto *getterRedecl : method->
redecls()) {
2231 if (getterRedecl->isImplicit())
2235 noteLoc = getterRedecl->getLocation();
2236 fixItLoc = getterRedecl->getEndLoc();
2241 tok::kw___attribute, tok::l_paren, tok::l_paren,
2244 tok::r_paren, tok::r_paren
2246 StringRef spelling =
"__attribute__((objc_method_family(none)))";
2248 if (!macroName.empty())
2249 spelling = macroName;
2251 auto noteDiag =
Diag(noteLoc, diag::note_cocoa_naming_declare_family)
2255 fixItText += spelling;
2273 if (I->getMethodFamily() ==
OMF_init)
2274 InitSelSet.insert(I->getSelector());
2277 SuperD->getDesignatedInitializers(DesignatedInits);
2279 I = DesignatedInits.begin(), E = DesignatedInits.end(); I != E; ++I) {
2284 bool Ignore =
false;
2290 if (
auto *IMD = Ext->getInstanceMethod(MD->
getSelector())) {
2291 Ignore = IMD->isUnavailable();
2297 diag::warn_objc_implementation_missing_designated_init_override)
2310 for (
const auto *A : Property->
attrs()) {
2311 if (isa<DeprecatedAttr>(A) ||
2312 isa<UnavailableAttr>(A) ||
2313 isa<AvailabilityAttr>(A))
2328 bool IsClassProperty =
property->isClassProperty();
2329 GetterMethod = IsClassProperty ?
2337 if (CatDecl->IsClassExtension())
2340 CatDecl->getClassInterface()->
2343 SetterMethod = IsClassProperty ?
2348 if (CatDecl->IsClassExtension())
2351 CatDecl->getClassInterface()->
2356 if (!property->
isReadOnly() && SetterMethod) {
2359 Diag(SetterMethod->getLocation(), diag::err_setter_type_void);
2360 if (SetterMethod->param_size() != 1 ||
2362 (*SetterMethod->param_begin())->getType().getNonReferenceType(),
2363 property->getType().getNonReferenceType())) {
2365 diag::warn_accessor_property_type_mismatch)
2367 << SetterMethod->getSelector();
2368 Diag(SetterMethod->getLocation(), diag::note_declared_at);
2378 if (!GetterMethod) {
2386 QualType resultTy =
property->getType().getAtomicUnqualifiedType();
2395 modifiedTy, modifiedTy);
2401 resultTy,
nullptr, CD,
2402 !IsClassProperty,
false,
2405 (
property->getPropertyImplementation() ==
2409 CD->addDecl(GetterMethod);
2413 if (property->
hasAttr<NSReturnsNotRetainedAttr>())
2414 GetterMethod->
addAttr(NSReturnsNotRetainedAttr::CreateImplicit(
Context,
2417 if (property->
hasAttr<ObjCReturnsInnerPointerAttr>())
2419 ObjCReturnsInnerPointerAttr::CreateImplicit(
Context, Loc));
2421 if (
const SectionAttr *SA = property->
getAttr<SectionAttr>())
2422 GetterMethod->
addAttr(SectionAttr::CreateImplicit(
2424 SectionAttr::GNU_section));
2432 property->setGetterMethodDecl(GetterMethod);
2437 if (!SetterMethod) {
2447 nullptr, CD, !IsClassProperty,
2452 (
property->getPropertyImplementation() ==
2459 property->getType().getUnqualifiedType().getAtomicUnqualifiedType();
2469 modifiedTy, modifiedTy);
2482 SetterMethod->setMethodParams(
Context, Argument, None);
2487 if (
const SectionAttr *SA = property->
getAttr<SectionAttr>())
2488 SetterMethod->addAttr(SectionAttr::CreateImplicit(
2490 SectionAttr::GNU_section));
2498 SetterMethod->setPropertyAccessor(
true);
2499 property->setSetterMethodDecl(SetterMethod);
2513 if (!IsClassProperty) {
2526 if (!CurrentClass) {
2528 CurrentClass = Cat->getClassInterface();
2529 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(CD))
2530 CurrentClass = Impl->getClassInterface();
2540 unsigned &Attributes,
2541 bool propertyInPrimaryClass) {
2548 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2549 <<
"readonly" <<
"readwrite";
2557 !PropertyTy->isObjCRetainableType() &&
2558 !PropertyDecl->
hasAttr<ObjCNSObjectAttr>()) {
2559 Diag(Loc, diag::err_objc_property_requires_object)
2570 PropertyTy->isObjCRetainableType() &&
2571 !PropertyTy->isObjCARCImplicitlyUnretainedType()) {
2572 Diag(Loc, diag::warn_objc_property_assign_on_object);
2576 if (Attributes & ObjCDeclSpec::DQ_PR_assign) {
2578 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2579 <<
"assign" <<
"copy";
2583 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2584 <<
"assign" <<
"retain";
2588 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2589 <<
"assign" <<
"strong";
2594 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2595 <<
"assign" <<
"weak";
2598 if (PropertyDecl->
hasAttr<IBOutletCollectionAttr>())
2599 Diag(Loc, diag::warn_iboutletcollection_property_assign);
2600 }
else if (Attributes & ObjCDeclSpec::DQ_PR_unsafe_unretained) {
2602 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2603 <<
"unsafe_unretained" <<
"copy";
2607 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2608 <<
"unsafe_unretained" <<
"retain";
2612 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2613 <<
"unsafe_unretained" <<
"strong";
2618 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2619 <<
"unsafe_unretained" <<
"weak";
2624 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2625 <<
"copy" <<
"retain";
2629 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2630 <<
"copy" <<
"strong";
2634 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2635 <<
"copy" <<
"weak";
2641 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2642 <<
"retain" <<
"weak";
2646 (Attributes & ObjCDeclSpec::DQ_PR_weak)) {
2647 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2648 <<
"strong" <<
"weak";
2652 if (Attributes & ObjCDeclSpec::DQ_PR_weak) {
2654 if (
auto nullability = PropertyTy->getNullability(
Context)) {
2656 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2657 <<
"nonnull" <<
"weak";
2663 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
2664 <<
"atomic" <<
"nonatomic";
2671 if (Attributes & ObjCDeclSpec::DQ_PR_readonly) {
2677 }
else if (PropertyTy->isObjCObjectPointerType()) {
2679 (PropertyTy->isObjCClassType() ||
2680 PropertyTy->isObjCQualifiedClassType());
2685 else if (propertyInPrimaryClass) {
2690 Diag(Loc, diag::warn_objc_property_no_assignment_attribute);
2694 Diag(Loc, diag::warn_objc_property_default_assign_on_object);
2704 if (!(Attributes & ObjCDeclSpec::DQ_PR_copy)
2707 && PropertyTy->isBlockPointerType())
2708 Diag(Loc, diag::warn_objc_property_copy_missing_on_block);
2709 else if ((Attributes & ObjCDeclSpec::DQ_PR_retain) &&
2711 !(Attributes & ObjCDeclSpec::DQ_PR_strong) &&
2712 PropertyTy->isBlockPointerType())
2713 Diag(Loc, diag::warn_objc_property_retain_of_block);
2715 if ((Attributes & ObjCDeclSpec::DQ_PR_readonly) &&
2717 Diag(Loc, diag::warn_objc_readonly_property_has_setter);
A call to an overloaded operator written using operator syntax.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
ObjCPropertyQueryKind getQueryKind() const
const internal::VariadicDynCastAllOfMatcher< Stmt, CallExpr > callExpr
Matches call expressions.
bool isClassMethod() const
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Represents a function declaration or definition.
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.
SourceLocation getBeginLoc() const LLVM_READONLY
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()
void setPropertyImplementation(PropertyControl pc)
A container of type source information.
void ProcessPropertyDecl(ObjCPropertyDecl *property)
Process the specified property declaration and create decls for the setters and getters as needed...
void setPropertyAccessor(bool isAccessor)
SourceLocation getEndLoc() const
Get the end source location.
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
Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
Parse and apply any fixits to the source.
The collection of all-type qualifiers we support.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
static void CollectImmediateProperties(ObjCContainerDecl *CDecl, ObjCContainerDecl::PropertyMap &PropMap, ObjCContainerDecl::PropertyMap &SuperPropMap, bool CollectClassPropsOnly=false, bool IncludeProtocols=true)
CollectImmediateProperties - This routine collects all properties in the class and its conforming pro...
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
instprop_range instance_properties() const
One of these records is kept for each identifier that is lexed.
SourceLocation getSetterNameLoc() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The results of name lookup within a DeclContext.
ObjCMethodDecl * getClassMethod(Selector Sel, bool AllowHidden=false) const
ObjCMethodFamily
A family of Objective-C methods.
instmeth_range instance_methods() const
method_range methods() const
Token - This structure provides full information about a lexed token.
prop_range properties() const
This little struct is used to capture information about structure field declarators, which is basically just a bitfield size.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
bool isClassProperty() const
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
void collectPropertiesToImplement(PropertyMap &PM, PropertyDeclOrder &PO) const override
This routine collects list of properties to be implemented in the class.
void setObjCWeakProperty(bool Val=true)
bool isNonFragile() const
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?
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" ...
visible_extensions_range visible_extensions() const
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
llvm::SmallPtrSet< Selector, 8 > SelectorSet
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
void addObjCLifetime(ObjCLifetime type)
QualType getUsageType(QualType objectType) const
Retrieve the type of this instance variable when viewed as a member of a specific object type...
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
SourceLocation getBeginLoc() const
Get the begin source location.
bool isObjCGCStrong() const
true when Type is objc's strong.
This represents one expression.
known_extensions_range known_extensions() const
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.
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
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
Stores token information for comparing actual tokens with predefined values.
ObjCPropertyDecl * FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyVisibleInPrimaryClass - Finds declaration of the property with name 'PropertyId' in the p...
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
static StringRef getIdentifier(const Token &Tok)
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const
Return the uniqued reference to the type for an Objective-C gc-qualified type.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType)
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
RecordDecl * getDecl() const
There is no lifetime qualification on this type.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
Assigning into this object requires the old value to be released and the new value to be retained...
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Encodes a location in the source.
bool getSynthesize() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
void setPropertyAttributesAsWritten(PropertyAttributeKind PRVal)
static Qualifiers::ObjCLifetime getImpliedARCOwnership(ObjCPropertyDecl::PropertyAttributeKind attrs, QualType type)
getImpliedARCOwnership - Given a set of property attributes and a type, infer an expected lifetime...
ObjCPropertyAttributeKind getPropertyAttributes() const
ObjCCategoryDecl - Represents a category declaration.
void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl *IMPDecl, ObjCContainerDecl *CDecl, bool SynthesizeProperties)
DiagnoseUnimplementedProperties - This routine warns on those properties which must be implemented by...
Represents one property declaration in an Objective-C interface.
ObjCMethodDecl * lookupPropertyAccessor(const Selector Sel, const ObjCCategoryDecl *Cat, bool IsClassProperty) const
Lookup a setter or getter in the class hierarchy, including in all categories except for category pas...
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=NotForRedeclaration)
Find the protocol with the given name, if any.
ObjCPropertyImplDecl * FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const
FindPropertyImplIvarDecl - This method lookup the ivar in the list of properties implemented in this ...
Indicates that the nullability of the type was spelled with a property attribute rather than a type q...
Assigning into this object requires a lifetime extension.
bool hasFlexibleArrayMember() const
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void DiagnoseOwningPropertyGetterSynthesis(const ObjCImplementationDecl *D)
void setSetterCXXAssignment(Expr *setterCXXAssignment)
static void checkARCPropertyImpl(Sema &S, SourceLocation propertyImplLoc, ObjCPropertyDecl *property, ObjCIvarDecl *ivar)
bool isObjCGCWeak() const
true when Type is objc's weak.
bool propertyTypesAreCompatible(QualType, QualType)
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
const ObjCInterfaceDecl * getClassInterface() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
static void setImpliedPropertyAttributeForReadOnlyProperty(ObjCPropertyDecl *property, ObjCIvarDecl *ivar)
setImpliedPropertyAttributeForReadOnlyProperty - This routine evaludates life-time attributes for a '...
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
void diagnoseNullResettableSynthesizedSetters(const ObjCImplDecl *impDecl)
Diagnose any null-resettable synthesized setters.
void setGetterName(Selector Sel, SourceLocation Loc=SourceLocation())
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
static bool SuperClassImplementsProperty(ObjCInterfaceDecl *IDecl, ObjCPropertyDecl *Prop)
PropertyAttributeKind getPropertyAttributesAsWritten() const
The basic abstraction for the target Objective-C runtime.
bool CheckARCMethodDecl(ObjCMethodDecl *method)
Check a method declaration for compatibility with the Objective-C ARC conventions.
llvm::DenseMap< std::pair< IdentifierInfo *, unsigned >, ObjCPropertyDecl * > PropertyMap
bool hasObjCLifetime() const
bool hasDesignatedInitializers() const
Returns true if this interface decl contains at least one initializer marked with the 'objc_designate...
Represents a pointer to an Objective C object.
static ObjCIvarDecl * Create(ASTContext &C, ObjCContainerDecl *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW=nullptr, bool synthesized=false)
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
void overwritePropertyAttributes(unsigned PRVal)
SourceLocation getGetterNameLoc() const
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
void addDecl(Decl *D)
Add the declaration D into this context.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance, bool shallowCategoryLookup=false, bool followSuper=true, const ObjCCategoryDecl *C=nullptr) const
lookupMethod - This method returns an instance/class method by looking in the class, its categories, and its super classes (using a linear search).
void setSetterName(Selector Sel, SourceLocation Loc=SourceLocation())
static void checkAtomicPropertyMismatch(Sema &S, ObjCPropertyDecl *OldProperty, ObjCPropertyDecl *NewProperty, bool PropagateAtomicity)
Check for a mismatch in the atomicity of the given properties.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
SourceManager & getSourceManager()
bool isObjCObjectType() const
bool IsClassExtension() const
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.
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
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...