clang: lib/AST/DeclObjC.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
27#include "llvm/ADT/SmallVector.h"
28#include "llvm/Support/ErrorHandling.h"
29#include "llvm/Support/raw_ostream.h"
30#include
31#include
32#include
33#include
34#include
35#include
36
37using namespace clang;
38
39
40
41
42
44 List = nullptr;
45 if (Elts == 0) return;
46
47 List = new (Ctx) void*[Elts];
49 memcpy(List, InList, sizeof(void*)*Elts);
50}
51
54 if (Elts == 0)
55 return;
56
59 set(InList, Elts, Ctx);
60}
61
62
63
64
65
72}
73
74void ObjCContainerDecl::anchor() {}
75
76
77
82 Ivar != IvarEnd; ++Ivar) {
83 if (auto *ivar = dyn_cast(*Ivar))
84 return ivar;
85 }
86 return nullptr;
87}
88
89
92 bool AllowHidden) const {
93
94
95 if (const auto *Proto = dyn_cast(this)) {
97 if (!Def->isUnconditionallyVisible() && !AllowHidden)
98 return nullptr;
99 }
100
101
102
103
104
105
106
107
110 Meth != MethEnd; ++Meth) {
111 auto *MD = dyn_cast(*Meth);
112 if (MD && MD->isInstanceMethod() == isInstance)
113 return MD;
114 }
115 return nullptr;
116}
117
118
119
120
121
122
128 Meth != MethEnd; ++Meth) {
129 auto *MD = dyn_cast(*Meth);
130 if (MD && MD->isInstanceMethod() && !MD->isImplicit())
131 return true;
132 }
133
134 if (const auto *ID = dyn_cast(this)) {
135
136
137 for (const auto *Cat : ID->visible_categories()) {
138 if (ObjCMethodDecl *MD = Cat->getInstanceMethod(Sel))
139 if (!MD->isImplicit())
140 return true;
141 if (Cat->IsClassExtension())
142 continue;
143
144
145
146
147 for (const auto *P : Cat->properties())
148 if (P->getIdentifier() == Property->getIdentifier()) {
149 if (P->getPropertyAttributes() &
151 return true;
152 break;
153 }
154 }
155
156
157 for (const auto *Proto : ID->all_referenced_protocols())
158 if (Proto->HasUserDeclaredSetterMethod(Property))
159 return true;
160
161
163 while (OSC) {
165 return true;
167 }
168 }
169 if (const auto *PD = dyn_cast(this))
170 for (const auto *PI : PD->protocols())
171 if (PI->HasUserDeclaredSetterMethod(Property))
172 return true;
173 return false;
174}
175
180
181
182 if (const auto *Proto = dyn_cast(DC)) {
184 if (!Def->isUnconditionallyVisible())
185 return nullptr;
186 }
187
188
189
190 if (auto *IDecl = dyn_cast(DC)) {
191 for (const auto *Ext : IDecl->visible_extensions())
193 propertyID,
194 queryKind))
195 return PD;
196 }
197
201 ++I)
202 if (auto *PD = dyn_cast(*I)) {
203
204
206 !PD->isClassProperty()) ||
208 PD->isClassProperty()) ||
210 !PD->isClassProperty()))
211 return PD;
212
213 if (PD->isClassProperty())
214 classProp = PD;
215 }
216
218
219 return classProp;
220
221 return nullptr;
222}
223
227 {
228 llvm::raw_svector_ostream os(ivarName);
230 }
231 return &Ctx.Idents.get(ivarName.str());
232}
233
235 bool IsInstance) const {
237 if (auto *Prop = dyn_cast(LookupResult)) {
238 if (Prop->isInstanceProperty() == IsInstance) {
239 return Prop;
240 }
241 }
242 }
243 return nullptr;
244}
245
246
247
251
252 if (const auto *Proto = dyn_cast(this)) {
254 if (!Def->isUnconditionallyVisible())
255 return nullptr;
256 }
257
258
259
260 if (const auto *ClassDecl = dyn_cast(this)) {
261 for (const auto *Ext : ClassDecl->visible_extensions()) {
262 if (auto *P = Ext->FindPropertyDeclaration(PropertyId, QueryKind))
263 return P;
264 }
265 }
266
269 QueryKind))
270 return PD;
271
273 default:
274 break;
275 case Decl::ObjCProtocol: {
276 const auto *PID = cast(this);
277 for (const auto *I : PID->protocols())
279 QueryKind))
280 return P;
281 break;
282 }
283 case Decl::ObjCInterface: {
284 const auto *OID = cast(this);
285
286 for (const auto *Cat : OID->visible_categories()) {
287 if (!Cat->IsClassExtension())
289 PropertyId, QueryKind))
290 return P;
291 }
292
293
294 for (const auto *I : OID->all_referenced_protocols())
296 QueryKind))
297 return P;
298
299
301 return superClass->FindPropertyDeclaration(PropertyId, QueryKind);
302 break;
303 }
304 case Decl::ObjCCategory: {
305 const auto *OCD = cast(this);
306
307 if (!OCD->IsClassExtension())
308 for (const auto *I : OCD->protocols())
310 QueryKind))
311 return P;
312 break;
313 }
314 }
315 return nullptr;
316}
317
318void ObjCInterfaceDecl::anchor() {}
319
321
323 return written;
324
325
327 return def->getTypeParamListAsWritten();
328
329
330
331
333 decl = decl->getPreviousDecl()) {
335 return written;
336 }
337
338 return nullptr;
339}
340
342 TypeParamList = TPL;
343 if (!TPL)
344 return;
345
346 for (auto *typeParam : *TypeParamList)
347 typeParam->setDeclContext(this);
348}
349
351
353 return nullptr;
354
355 if (data().ExternallyCompleted)
356 LoadExternalDefinition();
357
361 return superDef;
362
363 return superDecl;
364 }
365 }
366
367 return nullptr;
368}
369
372 return superTInfo->getTypeLoc().getBeginLoc();
373
375}
376
377
378
379
382
384 return nullptr;
385
386 if (data().ExternallyCompleted)
387 LoadExternalDefinition();
388
391 QueryKind))
392 return PD;
393
394
397 QueryKind))
398 return P;
399
400 return nullptr;
401}
402
405 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
406 }
409 for (auto *Prop : ClassExt->properties()) {
410 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
411 }
412 }
415
416
417
418}
419
423 if (Class->hasAttr())
424 return true;
426 }
427 return false;
428}
429
433 if (Class->hasAttr())
436 }
437 return nullptr;
438}
439
443 if (data().ExternallyCompleted)
444 LoadExternalDefinition();
445
446 if (data().AllReferencedProtocols.empty() &&
447 data().ReferencedProtocols.empty()) {
448 data().AllReferencedProtocols.set(ExtList, ExtNum, C);
449 return;
450 }
451
452
453
454
456 for (unsigned i = 0; i < ExtNum; i++) {
457 bool protocolExists = false;
460 if (C.ProtocolCompatibleWithProtocol(ProtoInExtension, Proto)) {
461 protocolExists = true;
462 break;
463 }
464 }
465
466
467 if (!protocolExists)
468 ProtocolRefs.push_back(ProtoInExtension);
469 }
470
471 if (ProtocolRefs.empty())
472 return;
473
474
477
478 data().AllReferencedProtocols.set(ProtocolRefs.data(), ProtocolRefs.size(),C);
479}
480
482ObjCInterfaceDecl::findInterfaceWithDesignatedInitializers() const {
484 while (IFace) {
486 return IFace;
487 if (!IFace->inheritsDesignatedInitializers())
488 break;
490 }
491 return nullptr;
492}
493
495 for (const auto *MD : D->instance_methods()) {
496 if (MD->getMethodFamily() == OMF_init && !MD->isOverriding())
497 return true;
498 }
499 for (const auto *Ext : D->visible_extensions()) {
500 for (const auto *MD : Ext->instance_methods()) {
501 if (MD->getMethodFamily() == OMF_init && !MD->isOverriding())
502 return true;
503 }
504 }
505 if (const auto *ImplD = D->getImplementation()) {
506 for (const auto *MD : ImplD->instance_methods()) {
507 if (MD->getMethodFamily() == OMF_init && !MD->isOverriding())
508 return true;
509 }
510 }
511 return false;
512}
513
514bool ObjCInterfaceDecl::inheritsDesignatedInitializers() const {
515 switch (data().InheritedDesignatedInitializers) {
516 case DefinitionData::IDI_Inherited:
517 return true;
518 case DefinitionData::IDI_NotInherited:
519 return false;
520 case DefinitionData::IDI_Unknown:
521
522
523
525 data().InheritedDesignatedInitializers = DefinitionData::IDI_NotInherited;
526 } else {
528 data().InheritedDesignatedInitializers =
529 SuperD->declaresOrInheritsDesignatedInitializers() ?
530 DefinitionData::IDI_Inherited :
531 DefinitionData::IDI_NotInherited;
532 } else {
533 data().InheritedDesignatedInitializers =
534 DefinitionData::IDI_NotInherited;
535 }
536 }
537 assert(data().InheritedDesignatedInitializers
538 != DefinitionData::IDI_Unknown);
539 return data().InheritedDesignatedInitializers ==
540 DefinitionData::IDI_Inherited;
541 }
542
543 llvm_unreachable("unexpected InheritedDesignatedInitializers value");
544}
545
548
550 return;
551 if (data().ExternallyCompleted)
552 LoadExternalDefinition();
553
554 const ObjCInterfaceDecl *IFace= findInterfaceWithDesignatedInitializers();
555 if (!IFace)
556 return;
557
559 if (MD->isThisDeclarationADesignatedInitializer())
560 Methods.push_back(MD);
562 for (const auto *MD : Ext->instance_methods())
563 if (MD->isThisDeclarationADesignatedInitializer())
564 Methods.push_back(MD);
565 }
566}
567
571
572
573
576 HasCompleteDef = true;
577
578
579 if (!HasCompleteDef)
580 return false;
581
582 if (data().ExternallyCompleted)
583 LoadExternalDefinition();
584
585 const ObjCInterfaceDecl *IFace= findInterfaceWithDesignatedInitializers();
586 if (!IFace)
587 return false;
588
590 if (MD->isThisDeclarationADesignatedInitializer()) {
591 if (InitMethod)
592 *InitMethod = MD;
593 return true;
594 }
595 }
597 if (const ObjCMethodDecl *MD = Ext->getInstanceMethod(Sel)) {
598 if (MD->isThisDeclarationADesignatedInitializer()) {
599 if (InitMethod)
600 *InitMethod = MD;
601 return true;
602 }
603 }
604 }
605 return false;
606}
607
608void ObjCInterfaceDecl::allocateDefinitionData() {
609 assert(() && "ObjC class already has a definition");
610 Data.setPointer(new (getASTContext()) DefinitionData());
611 Data.getPointer()->Definition = this;
612}
613
615 allocateDefinitionData();
616
617
618 for (auto *RD : redecls()) {
619 if (RD != this)
620 RD->Data = Data;
621 }
622}
623
625 Data.setPointer(nullptr);
626 allocateDefinitionData();
627
628}
629
633}
634
637
639 return nullptr;
640
641 if (data().ExternallyCompleted)
642 LoadExternalDefinition();
643
645 while (ClassDecl != nullptr) {
647 clsDeclared = ClassDecl;
648 return I;
649 }
650
652 if (ObjCIvarDecl *I = Ext->getIvarDecl(ID)) {
653 clsDeclared = ClassDecl;
654 return I;
655 }
656 }
657
659 }
660 return nullptr;
661}
662
663
664
665
668
670 return nullptr;
671
672 if (data().ExternallyCompleted)
673 LoadExternalDefinition();
674
676 while (ClassDecl != nullptr) {
678 return ClassDecl;
680 }
681 return nullptr;
682}
683
687 if (P->lookupProtocolNamed(Name))
688 return P;
691}
692
693
694
695
696
698 bool isInstance,
699 bool shallowCategoryLookup,
700 bool followSuper,
702{
703
705 return nullptr;
706
709
710 if (data().ExternallyCompleted)
711 LoadExternalDefinition();
712
713 while (ClassDecl) {
714
715 if ((MethodDecl = ClassDecl->getMethod(Sel, isInstance)))
716 return MethodDecl;
717
718
720 if ((MethodDecl = Cat->getMethod(Sel, isInstance)))
721 if (C != Cat || !MethodDecl->isImplicit())
722 return MethodDecl;
723
724
725 for (const auto *I : ClassDecl->protocols())
726 if ((MethodDecl = I->lookupMethod(Sel, isInstance)))
727 return MethodDecl;
728
729
730 if (!shallowCategoryLookup)
732
734 Cat->getReferencedProtocols();
735 for (auto *Protocol : Protocols)
736 if ((MethodDecl = Protocol->lookupMethod(Sel, isInstance)))
737 if (C != Cat || !MethodDecl->isImplicit())
738 return MethodDecl;
739 }
740
741
742 if (!followSuper)
743 return nullptr;
744
745
747 }
748 return nullptr;
749}
750
751
752
753
756 bool Instance) const {
757
759 return nullptr;
760
761 if (data().ExternallyCompleted)
762 LoadExternalDefinition();
763
766 Method = Instance ? ImpDecl->getInstanceMethod(Sel)
767 : ImpDecl->getClassMethod(Sel);
768
769
770 if (!Method)
772
773
774
775
778
779
780 if (!Method)
782 }
783
786 return Method;
787}
788
790 assert(hasDefinition() && "ODRHash only for records with definitions");
791
792
793 if (hasODRHash())
794 return data().ODRHash;
795
796
800 setHasODRHash(true);
801
802 return data().ODRHash;
803}
804
805bool ObjCInterfaceDecl::hasODRHash() const {
807 return false;
808 return data().HasODRHash;
809}
810
811void ObjCInterfaceDecl::setHasODRHash(bool HasHash) {
812 assert(hasDefinition() && "Cannot set ODRHash without definition");
813 data().HasODRHash = HasHash;
814}
815
816
817
818
819
820ObjCMethodDecl::ObjCMethodDecl(
823 bool isInstance, bool isVariadic, bool isPropertyAccessor,
824 bool isSynthesizedAccessorStub, bool isImplicitlyDeclared, bool isDefined,
826 : NamedDecl(ObjCMethod, contextDecl, beginLoc, SelInfo),
827 DeclContext(ObjCMethod), MethodDeclType(T), ReturnTInfo(ReturnTInfo),
828 DeclEndLoc(endLoc) {
829
830
833 setInstanceMethod(isInstance);
834 setVariadic(isVariadic);
835 setPropertyAccessor(isPropertyAccessor);
836 setSynthesizedAccessorStub(isSynthesizedAccessorStub);
837 setDefined(isDefined);
838 setIsRedeclaration(false);
839 setHasRedeclaration(false);
840 setDeclImplementation(impControl);
842 setRelatedResultType(HasRelatedResultType);
844 setOverriding(false);
845 setHasSkippedBody(false);
846
848}
849
853 DeclContext *contextDecl, bool isInstance, bool isVariadic,
854 bool isPropertyAccessor, bool isSynthesizedAccessorStub,
855 bool isImplicitlyDeclared, bool isDefined,
858 beginLoc, endLoc, SelInfo, T, ReturnTInfo, contextDecl, isInstance,
860 isImplicitlyDeclared, isDefined, impControl, HasRelatedResultType);
861}
862
867}
868
870 return hasAttr() &&
872}
873
876 hasAttr();
877}
878
880 if (const auto *PD = dyn_cast(getDeclContext()))
882 if (const auto *ID = dyn_cast(getDeclContext()))
884 return false;
885}
886
890 return false;
892 if (isa(DC))
893 return false;
895 return ID->isDesignatedInitializer(getSelector(), InitMethod);
896 return false;
897}
898
901 if (param->isDestroyedInCallee())
902 return true;
903 }
904 return false;
905}
906
909}
910
912 assert(PrevMethod);
916}
917
918void ObjCMethodDecl::setParamsAndSelLocs(ASTContext &C,
921 ParamsAndSelLocs = nullptr;
922 NumParams = Params.size();
923 if (Params.empty() && SelLocs.empty())
924 return;
925
927 "Alignment not sufficient for SourceLocation");
928
929 unsigned Size = sizeof(ParmVarDecl *) * NumParams +
931 ParamsAndSelLocs = C.Allocate(Size);
932 std::uninitialized_copy(Params.begin(), Params.end(), getParams());
933 std::uninitialized_copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs());
934}
935
940}
941
945 assert((!SelLocs.empty() || isImplicit()) &&
946 "No selector locs for non-implicit method");
948 return setParamsAndSelLocs(C, Params, {});
949
951 DeclEndLoc));
953 return setParamsAndSelLocs(C, Params, {});
954
955 setParamsAndSelLocs(C, Params, SelLocs);
956}
957
958
959
960
961ObjCMethodDecl *ObjCMethodDecl::getNextRedeclarationImpl() {
966 if (Redecl)
967 return Redecl;
968
970
971 if (!CtxD->isInvalidDecl()) {
972 if (auto *IFD = dyn_cast(CtxD)) {
974 if (!ImplD->isInvalidDecl())
976
977 } else if (auto *CD = dyn_cast(CtxD)) {
979 if (!ImplD->isInvalidDecl())
981
982 } else if (auto *ImplD = dyn_cast(CtxD)) {
984 if (!IFD->isInvalidDecl())
986
987 } else if (auto *CImplD = dyn_cast(CtxD)) {
989 if (!CatD->isInvalidDecl())
991 }
992 }
993
994
995
996
997 if (Redecl && cast(Redecl->getDeclContext())->isInvalidDecl())
998 Redecl = nullptr;
999
1001
1002 return cast(CtxD)->getMethod(getSelector(),
1004 true);
1005 }
1006
1007 return Redecl ? Redecl : this;
1008}
1009
1013
1014 if (auto *ImplD = dyn_cast(CtxD)) {
1016
1017
1018
1019
1020
1021
1023 return MD;
1024 for (auto *Ext : IFD->known_extensions())
1026 return MD;
1027 }
1028 } else if (auto *CImplD = dyn_cast(CtxD)) {
1031 return MD;
1032 }
1033
1035
1037 cast(CtxD)->getMethod(Sel, isInstanceMethod(),
1038 true);
1039 return MD ? MD : this;
1040 }
1041
1042 return this;
1043}
1044
1047 return Body->getEndLoc();
1048 return DeclEndLoc;
1049}
1050
1054 return family;
1055
1056
1057 if (const ObjCMethodFamilyAttr *attr = getAttr()) {
1058
1059
1060 switch (attr->getFamily()) {
1061 case ObjCMethodFamilyAttr::OMF_None: family = OMF_None; break;
1062 case ObjCMethodFamilyAttr::OMF_alloc: family = OMF_alloc; break;
1063 case ObjCMethodFamilyAttr::OMF_copy: family = OMF_copy; break;
1064 case ObjCMethodFamilyAttr::OMF_init: family = OMF_init; break;
1065 case ObjCMethodFamilyAttr::OMF_mutableCopy: family = OMF_mutableCopy; break;
1066 case ObjCMethodFamilyAttr::OMF_new: family = OMF_new; break;
1067 }
1069 return family;
1070 }
1071
1073 switch (family) {
1075
1076
1077
1081 break;
1082
1083
1084
1089 if (()->isObjCObjectPointerType())
1091 break;
1092
1093
1103 break;
1104
1108 break;
1109
1113 else {
1115 if (noParams < 1 || noParams > 3)
1117 else {
1122 break;
1123 }
1124 while (--noParams) {
1125 it++;
1126 ArgT = (*it);
1129 break;
1130 }
1131 }
1132 }
1133 }
1134 break;
1135
1136 }
1137
1138
1140 return family;
1141}
1142
1145 bool &selfIsPseudoStrong,
1146 bool &selfIsConsumed) const {
1148 selfIsPseudoStrong = false;
1149 selfIsConsumed = false;
1151
1152
1153 if (OID) {
1156 } else {
1158 }
1159 } else
1161
1162 if (Context.getLangOpts().ObjCAutoRefCount) {
1164 selfIsConsumed = hasAttr();
1165
1166
1167
1171
1172
1175 selfIsPseudoStrong = true;
1176 }
1177 }
1178 else {
1180
1182 selfIsPseudoStrong = true;
1183 }
1184 }
1185 return selfTy;
1186}
1187
1190 bool selfIsPseudoStrong, selfIsConsumed;
1192 getSelfType(Context, OID, selfIsPseudoStrong, selfIsConsumed);
1194 &Context.Idents.get("self"), selfTy,
1197
1198 if (selfIsConsumed)
1199 Self->addAttr(NSConsumedAttr::CreateImplicit(Context));
1200
1201 if (selfIsPseudoStrong)
1202 Self->setARCPseudoStrong(true);
1203
1207}
1208
1210 if (auto *ID = dyn_cast(getDeclContext()))
1211 return ID;
1212 if (auto *CD = dyn_cast(getDeclContext()))
1213 return CD->getClassInterface();
1214 if (auto *IMD = dyn_cast(getDeclContext()))
1215 return IMD->getClassInterface();
1217 return nullptr;
1218 llvm_unreachable("unknown method context");
1219}
1220
1222 if (auto *CD = dyn_cast(getDeclContext()))
1223 return CD;
1224 if (auto *IMD = dyn_cast(getDeclContext()))
1225 return IMD->getCategoryDecl();
1226 return nullptr;
1227}
1228
1231 if (TSI)
1232 return TSI->getTypeLoc().getSourceRange();
1234}
1235
1240}
1241
1243
1244
1248}
1249
1253 bool MovedToSuper) {
1254 if (!Container)
1255 return;
1256
1257
1258
1259
1260 if (const auto *Category = dyn_cast(Container)) {
1261
1262
1263 if (MovedToSuper)
1265 Overridden = Container->getMethod(Method->getSelector(),
1267 true))
1268 if (Method != Overridden) {
1269
1270
1271 Methods.push_back(Overridden);
1272 return;
1273 }
1274
1275 for (const auto *P : Category->protocols())
1277 return;
1278 }
1279
1280
1282 Overridden = Container->getMethod(Method->getSelector(),
1284 true))
1285 if (Method != Overridden) {
1286
1287
1288 Methods.push_back(Overridden);
1289 return;
1290 }
1291
1292 if (const auto *Protocol = dyn_cast(Container)){
1293 for (const auto *P : Protocol->protocols())
1295 }
1296
1297 if (const auto *Interface = dyn_cast(Container)) {
1298 for (const auto *P : Interface->protocols())
1300
1301 for (const auto *Cat : Interface->known_categories())
1303
1306 true);
1307 }
1308}
1309
1314 false);
1315}
1316
1320
1321 if (const auto *ProtD =
1322 dyn_cast(Method->getDeclContext())) {
1324
1325 } else if (const auto *IMD =
1328 if (!ID)
1329 return;
1330
1331
1334 true))
1335 Method = IFaceMeth;
1337
1338 } else if (const auto *CatD =
1339 dyn_cast(Method->getDeclContext())) {
1341 if (!ID)
1342 return;
1343
1344
1347 true))
1348 Method = IFaceMeth;
1350
1351 } else {
1353 dyn_cast_or_null(Method->getDeclContext()),
1354 Method, overridden);
1355 }
1356}
1357
1361
1363 Method = cast(Method->getDeclContext())
1365 true);
1366 }
1367
1370 assert(!Overridden.empty() &&
1371 "ObjCMethodDecl's overriding bit is not as expected");
1372 }
1373}
1374
1378 unsigned NumArgs = Sel.getNumArgs();
1379 if (NumArgs > 1)
1380 return nullptr;
1381
1383 const auto *Container = cast(getParent());
1384
1385 if (auto *ImplDecl = dyn_cast(Container))
1387 Container = ImplDecl->getClassInterface();
1388
1389 bool IsGetter = (NumArgs == 0);
1391
1392
1393
1394 auto findMatchingProperty =
1396 if (IsInstance) {
1397 for (const auto *I : Container->instance_properties()) {
1398 Selector NextSel = IsGetter ? I->getGetterName()
1399 : I->getSetterName();
1400 if (NextSel == Sel)
1401 return I;
1402 }
1403 } else {
1404 for (const auto *I : Container->class_properties()) {
1405 Selector NextSel = IsGetter ? I->getGetterName()
1406 : I->getSetterName();
1407 if (NextSel == Sel)
1408 return I;
1409 }
1410 }
1411
1412 return nullptr;
1413 };
1414
1415
1416 if (const auto *Found = findMatchingProperty(Container))
1418
1419
1421 if (const auto *Category = dyn_cast(Container)) {
1422 ClassDecl = Category->getClassInterface();
1423 if (const auto *Found = findMatchingProperty(ClassDecl))
1425 } else {
1426
1427 ClassDecl = cast(Container);
1428 }
1429 assert(ClassDecl && "Failed to find main class");
1430
1431
1433 if (Ext == Container)
1434 continue;
1435 if (const auto *Found = findMatchingProperty(Ext))
1437 }
1438
1440
1442 if (Cat == Container)
1443 continue;
1444 if (const auto *Found = findMatchingProperty(Cat))
1446 }
1447
1448 llvm_unreachable("Marked as a property accessor but no property found!");
1449 }
1450
1451 if (!CheckOverrides)
1452 return nullptr;
1453
1455
1456 OverridesTy Overrides;
1458 for (const auto *Override : Overrides)
1460 return Prop;
1461
1462 return nullptr;
1463}
1464
1465
1466
1467
1468
1469void ObjCTypeParamDecl::anchor() {}
1470
1474 unsigned index,
1479 auto *TPDecl =
1480 new (ctx, dc) ObjCTypeParamDecl(ctx, dc, variance, varianceLoc, index,
1481 nameLoc, name, colonLoc, boundInfo);
1483 TPDecl->setTypeForDecl(TPType.getTypePtr());
1484 return TPDecl;
1485}
1486
1493}
1494
1499
1503 }
1504
1506}
1507
1508
1509
1510
1511ObjCTypeParamList::ObjCTypeParamList(SourceLocation lAngleLoc,
1514 : Brackets(lAngleLoc, rAngleLoc), NumParams(typeParams.size()) {
1515 std::copy(typeParams.begin(), typeParams.end(), begin());
1516}
1517
1523 void *mem =
1524 ctx.Allocate(totalSizeToAlloc<ObjCTypeParamDecl *>(typeParams.size()),
1526 return new (mem) ObjCTypeParamList(lAngleLoc, typeParams, rAngleLoc);
1527}
1528
1531 typeArgs.reserve(size());
1532 for (auto *typeParam : *this)
1533 typeArgs.push_back(typeParam->getUnderlyingType());
1534}
1535
1536
1537
1538
1539
1544 auto *Result = new (C, DC)
1546 isInternal);
1547 Result->Data.setInt(.getLangOpts().Modules);
1548 C.getObjCInterfaceType(Result, PrevDecl);
1550}
1551
1554 auto *Result = new (C, ID)
1557 Result->Data.setInt(.getLangOpts().Modules);
1559}
1560
1561ObjCInterfaceDecl::ObjCInterfaceDecl(
1566 redeclarable_base(C) {
1568
1569
1570 if (PrevDecl)
1571 Data = PrevDecl->Data;
1572
1574
1576}
1577
1578void ObjCInterfaceDecl::LoadExternalDefinition() const {
1579 assert(data().ExternallyCompleted && "Class is not externally completed");
1580 data().ExternallyCompleted = false;
1583}
1584
1587 "Class can't be externally completed without an external source");
1589 "Forward declarations can't be externally completed");
1590 data().ExternallyCompleted = true;
1591}
1592
1594
1596 return;
1597 data().HasDesignatedInitializers = true;
1598}
1599
1601
1603 return false;
1604 if (data().ExternallyCompleted)
1605 LoadExternalDefinition();
1606
1607 return data().HasDesignatedInitializers;
1608}
1609
1610StringRef
1612 if (const auto *ObjCRTName = getAttr())
1613 return ObjCRTName->getMetadataName();
1614
1616}
1617
1618StringRef
1622 return ID->getObjCRuntimeNameAsString();
1623
1625}
1626
1629 if (data().ExternallyCompleted)
1630 LoadExternalDefinition();
1631
1634 }
1635
1636
1637 return nullptr;
1638}
1639
1642}
1643
1644namespace {
1645
1646struct SynthesizeIvarChunk {
1647 uint64_t Size;
1649
1650 SynthesizeIvarChunk(uint64_t size, ObjCIvarDecl *ivar)
1651 : Size(size), Ivar(ivar) {}
1652};
1653
1654bool operator<(const SynthesizeIvarChunk & LHS,
1655 const SynthesizeIvarChunk &RHS) {
1656 return LHS.Size < RHS.Size;
1657}
1658
1659}
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1671
1673 return nullptr;
1674
1676 if (!data().IvarList) {
1677
1680 (void)Ext->ivar_empty();
1681 }
1684 data().IvarList = *I; ++I;
1685 for (curIvar = data().IvarList; I != E; curIvar = *I, ++I)
1687 }
1688
1690 if (!Ext->ivar_empty()) {
1692 I = Ext->ivar_begin(),
1693 E = Ext->ivar_end();
1694 if (!data().IvarList) {
1695 data().IvarList = *I; ++I;
1696 curIvar = data().IvarList;
1697 }
1698 for ( ;I != E; curIvar = *I, ++I)
1700 }
1701 }
1702 data().IvarListMissingImplementation = true;
1703 }
1704
1705
1706 if (!data().IvarListMissingImplementation)
1707 return data().IvarList;
1708
1710 data().IvarListMissingImplementation = false;
1711 if (!ImplDecl->ivar_empty()) {
1713 for (auto *IV : ImplDecl->ivars()) {
1714 if (IV->getSynthesize() && !IV->isInvalidDecl()) {
1715 layout.push_back(SynthesizeIvarChunk(
1716 IV->getASTContext().getTypeSize(IV->getType()), IV));
1717 continue;
1718 }
1719 if (!data().IvarList)
1720 data().IvarList = IV;
1721 else
1723 curIvar = IV;
1724 }
1725
1726 if (!layout.empty()) {
1727
1728 llvm::stable_sort(layout);
1729 unsigned Ix = 0, EIx = layout.size();
1730 if (!data().IvarList) {
1731 data().IvarList = layout[0].Ivar; Ix++;
1732 curIvar = data().IvarList;
1733 }
1734 for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++)
1736 }
1737 }
1738 }
1739 return data().IvarList;
1740}
1741
1742
1743
1744
1745
1748
1750 return nullptr;
1751
1752 if (data().ExternallyCompleted)
1753 LoadExternalDefinition();
1754
1756 if (Cat->getIdentifier() == CategoryId)
1757 return Cat;
1758
1759 return nullptr;
1760}
1761
1766 if (ObjCMethodDecl *MD = Impl->getInstanceMethod(Sel))
1767 return MD;
1768 }
1769
1770 return nullptr;
1771}
1772
1777 return MD;
1778 }
1779
1780 return nullptr;
1781}
1782
1783
1784
1785
1787 bool lookupCategory,
1788 bool RHSIsQualifiedID) {
1790 return false;
1791
1793
1794 for (auto *PI : IDecl->protocols()){
1795 if (getASTContext().ProtocolCompatibleWithProtocol(lProto, PI))
1796 return true;
1797
1798
1799
1800
1801
1802
1803 if (RHSIsQualifiedID &&
1804 getASTContext().ProtocolCompatibleWithProtocol(PI, lProto))
1805 return true;
1806 }
1807
1808
1809 if (lookupCategory)
1811 for (auto *PI : Cat->protocols())
1812 if (getASTContext().ProtocolCompatibleWithProtocol(lProto, PI))
1813 return true;
1814 }
1815
1816
1818 return
1820 RHSIsQualifiedID);
1821
1822 return false;
1823}
1824
1825
1826
1827
1828
1829void ObjCIvarDecl::anchor() {}
1830
1836 Expr *BW, bool synthesized) {
1837 if (DC) {
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848 assert((isa(DC) || isa(DC) ||
1849 isa(DC)) &&
1850 "Invalid ivar decl context!");
1851
1852
1853 auto *ID = dyn_cast(DC);
1854 if (!ID) {
1855 if (auto *IM = dyn_cast(DC))
1856 ID = IM->getClassInterface();
1857 else
1858 ID = cast(DC)->getClassInterface();
1859 }
1860 ID->setIvarList(nullptr);
1861 }
1862
1863 return new (C, DC) ObjCIvarDecl(DC, StartLoc, IdLoc, Id, T, TInfo, ac, BW,
1864 synthesized);
1865}
1866
1869 nullptr, QualType(), nullptr,
1871}
1872
1874 auto *DC = cast(getDeclContext());
1875
1876 switch (DC->getKind()) {
1877 default:
1878 case ObjCCategoryImpl:
1879 case ObjCProtocol:
1880 llvm_unreachable("invalid ivar container!");
1881
1882
1883 case ObjCCategory: {
1884 auto *CD = cast(DC);
1885 assert(CD->IsClassExtension() && "invalid container for ivar!");
1886 return CD->getClassInterface();
1887 }
1888
1889 case ObjCImplementation:
1890 return cast(DC)->getClassInterface();
1891
1892 case ObjCInterface:
1893 return cast(DC);
1894 }
1895}
1896
1900}
1901
1902
1903
1904
1905
1906void ObjCAtDefsFieldDecl::anchor() {}
1907
1913}
1914
1919 nullptr);
1920}
1921
1922
1923
1924
1925
1926void ObjCProtocolDecl::anchor() {}
1927
1933 redeclarable_base(C) {
1934 setPreviousDecl(PrevDecl);
1935 if (PrevDecl)
1936 Data = PrevDecl->Data;
1937}
1938
1946 Result->Data.setInt(.getLangOpts().Modules);
1948}
1949
1955 Result->Data.setInt(.getLangOpts().Modules);
1957}
1958
1960 return hasAttr();
1961}
1962
1964 llvm::DenseSet<const ObjCProtocolDecl *> &IPs) const {
1965 std::queue<const ObjCProtocolDecl *> WorkQueue;
1966 WorkQueue.push(this);
1967
1968 while (!WorkQueue.empty()) {
1969 const auto *PD = WorkQueue.front();
1970 WorkQueue.pop();
1971 for (const auto *Parent : PD->protocols()) {
1972 const auto *Can = Parent->getCanonicalDecl();
1973 auto Result = IPs.insert(Can);
1975 WorkQueue.push(Parent);
1976 }
1977 }
1978}
1979
1982
1984 return PDecl;
1985
1988 return PDecl;
1989
1990 return nullptr;
1991}
1992
1993
1994
1996 bool isInstance) const {
1998
1999
2000
2003 return nullptr;
2004
2005 if ((MethodDecl = getMethod(Sel, isInstance)))
2006 return MethodDecl;
2007
2008 for (const auto *I : protocols())
2009 if ((MethodDecl = I->lookupMethod(Sel, isInstance)))
2010 return MethodDecl;
2011 return nullptr;
2012}
2013
2014void ObjCProtocolDecl::allocateDefinitionData() {
2015 assert(!Data.getPointer() && "Protocol already has a definition!");
2016 Data.setPointer(new (getASTContext()) DefinitionData);
2017 Data.getPointer()->Definition = this;
2018 Data.getPointer()->HasODRHash = false;
2019}
2020
2022 allocateDefinitionData();
2023
2024
2025 for (auto *RD : redecls())
2026 RD->Data = this->Data;
2027}
2028
2030 Data.setPointer(nullptr);
2031 allocateDefinitionData();
2032
2033}
2034
2038}
2039
2042 for (auto *Prop : PDecl->properties()) {
2043
2044 PM.insert(std::make_pair(
2045 std::make_pair(Prop->getIdentifier(), Prop->isClassProperty()),
2046 Prop));
2047 }
2048
2049 for (const auto *PI : PDecl->protocols())
2050 PI->collectPropertiesToImplement(PM);
2051 }
2052}
2053
2058 if (!PS.insert(PDecl).second)
2059 return;
2060 for (auto *Prop : PDecl->properties()) {
2062 continue;
2063 if (Prop->getIdentifier() == Property->getIdentifier()) {
2064 PO.push_back(Prop);
2065 return;
2066 }
2067 }
2068
2069 for (const auto *PI : PDecl->protocols())
2070 PI->collectInheritedProtocolProperties(Property, PS, PO);
2071 }
2072}
2073
2074StringRef
2076 if (const auto *ObjCRTName = getAttr())
2077 return ObjCRTName->getMetadataName();
2078
2080}
2081
2083 assert(hasDefinition() && "ODRHash only for records with definitions");
2084
2085
2086 if (hasODRHash())
2087 return data().ODRHash;
2088
2089
2093 setHasODRHash(true);
2094
2095 return data().ODRHash;
2096}
2097
2098bool ObjCProtocolDecl::hasODRHash() const {
2100 return false;
2101 return data().HasODRHash;
2102}
2103
2104void ObjCProtocolDecl::setHasODRHash(bool HasHash) {
2105 assert(hasDefinition() && "Cannot set ODRHash without definition");
2106 data().HasODRHash = HasHash;
2107}
2108
2109
2110
2111
2112
2113void ObjCCategoryDecl::anchor() {}
2114
2115ObjCCategoryDecl::ObjCCategoryDecl(
2121 ClassInterface(IDecl), CategoryNameLoc(CategoryNameLoc),
2122 IvarLBraceLoc(IvarLBraceLoc), IvarRBraceLoc(IvarRBraceLoc) {
2123 setTypeParamList(typeParamList);
2124}
2125
2132 auto *CatDecl =
2133 new (C, DC) ObjCCategoryDecl(DC, AtLoc, ClassNameLoc, CategoryNameLoc, Id,
2134 IDecl, typeParamList, IvarLBraceLoc,
2135 IvarRBraceLoc);
2136 if (IDecl) {
2137
2142 L->AddedObjCCategoryToInterface(CatDecl, IDecl);
2143 }
2144 }
2145
2146 return CatDecl;
2147}
2148
2153 nullptr, nullptr, nullptr);
2154}
2155
2159}
2160
2163}
2164
2166 TypeParamList = TPL;
2167 if (!TPL)
2168 return;
2169
2170 for (auto *typeParam : *TypeParamList)
2171 typeParam->setDeclContext(this);
2172}
2173
2174
2175
2176
2177
2178void ObjCCategoryImplDecl::anchor() {}
2179
2184 if (ClassInterface && ClassInterface->hasDefinition())
2185 ClassInterface = ClassInterface->getDefinition();
2187 atStartLoc, CategoryNameLoc);
2188}
2189
2195}
2196
2198
2200 return ID->FindCategoryDeclaration(getIdentifier());
2201 return nullptr;
2202}
2203
2204void ObjCImplDecl::anchor() {}
2205
2207
2208 property->setLexicalDeclContext(this);
2210}
2211
2214
2215 if (auto *ImplD = dyn_cast_or_null(this)) {
2216 if (IFace)
2218
2219 } else if (auto *ImplD = dyn_cast_or_null(this)) {
2222 }
2223
2224 ClassInterface = IFace;
2225}
2226
2227
2228
2229
2233 if (PID->getPropertyIvarDecl() &&
2234 PID->getPropertyIvarDecl()->getIdentifier() == ivarId)
2235 return PID;
2236 return nullptr;
2237}
2238
2239
2240
2241
2247
2248
2249 if (PID->getPropertyDecl()->getIdentifier() == Id) {
2251 !PID->getPropertyDecl()->isClassProperty()) ||
2253 PID->getPropertyDecl()->isClassProperty()) ||
2255 !PID->getPropertyDecl()->isClassProperty()))
2256 return PID;
2257
2258 if (PID->getPropertyDecl()->isClassProperty())
2259 ClassPropImpl = PID;
2260 }
2261
2263
2264 return ClassPropImpl;
2265
2266 return nullptr;
2267}
2268
2272 return OS;
2273}
2274
2275
2276
2277
2278
2279void ObjCImplementationDecl::anchor() {}
2280
2290 if (ClassInterface && ClassInterface->hasDefinition())
2291 ClassInterface = ClassInterface->getDefinition();
2293 nameLoc, atStartLoc, superLoc,
2294 IvarLBraceLoc, IvarRBraceLoc);
2295}
2296
2301}
2302
2305 unsigned numInitializers) {
2306 if (numInitializers > 0) {
2307 NumIvarInitializers = numInitializers;
2308 auto **ivarInitializers = new (C) CXXCtorInitializer*[NumIvarInitializers];
2309 memcpy(ivarInitializers, initializers,
2311 IvarInitializers = ivarInitializers;
2312 }
2313}
2314
2317 return IvarInitializers.get(getASTContext().getExternalSource());
2318}
2319
2322 OS << ID.getName();
2323 return OS;
2324}
2325
2326
2327
2328
2329
2330void ObjCCompatibleAliasDecl::anchor() {}
2331
2338}
2339
2343 nullptr, nullptr);
2344}
2345
2346
2347
2348
2349
2350void ObjCPropertyDecl::anchor() {}
2351
2358 propControl);
2359}
2360
2366}
2367
2371}
2372
2376}
2377
2378
2379
2380
2381
2391 ivarLoc);
2392}
2393
2399}
2400
2404 EndLoc = IvarLoc;
2405
2407}
Defines the clang::ASTContext interface.
static void CollectOverriddenMethodsRecurse(const ObjCContainerDecl *Container, const ObjCMethodDecl *Method, SmallVectorImpl< const ObjCMethodDecl * > &Methods, bool MovedToSuper)
static bool isIntroducingInitializers(const ObjCInterfaceDecl *D)
static void collectOverriddenMethodsSlow(const ObjCMethodDecl *Method, SmallVectorImpl< const ObjCMethodDecl * > &overridden)
static void CollectOverriddenMethods(const ObjCContainerDecl *Container, const ObjCMethodDecl *Method, SmallVectorImpl< const ObjCMethodDecl * > &Methods)
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
This file contains the declaration of the ODRHash class, which calculates a hash based on AST nodes,...
Defines the clang::SourceLocation class and associated facilities.
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
QualType getObjCClassType() const
Represents the Objective-C Class type.
void setObjCImplementation(ObjCInterfaceDecl *IFaceD, ObjCImplementationDecl *ImplD)
Set the implementation of ObjCInterfaceDecl.
const LangOptions & getLangOpts() const
IdentifierInfo * getNSObjectName() const
Retrieve the identifier 'NSObject'.
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
const ObjCMethodDecl * getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const
Get the duplicate declaration of a ObjCMethod in the same interface, or null if none exists.
QualType getObjCIdType() const
Represents the Objective-CC id type.
void * Allocate(size_t Size, unsigned Align=8) const
QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl, ArrayRef< ObjCProtocolDecl * > protocols) const
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
ObjCImplementationDecl * getObjCImplementation(ObjCInterfaceDecl *D)
Get the implementation of the ObjCInterfaceDecl D, or nullptr if none exists.
void setObjCMethodRedeclaration(const ObjCMethodDecl *MD, const ObjCMethodDecl *Redecl)
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Represents a C++ base or member initializer.
The results of name lookup within a DeclContext.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
ObjCMethodDeclBitfields ObjCMethodDeclBits
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
void addDecl(Decl *D)
Add the declaration D into this context.
SourceLocation getEndLoc() const LLVM_READONLY
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
Kind
Lists the kind of concrete classes of Decl.
SourceLocation getLocation() const
void setImplicit(bool I=true)
DeclContext * getDeclContext()
This represents one expression.
virtual void CompleteType(TagDecl *Tag)
Gives the external AST source an opportunity to complete an incomplete type.
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
Represents the results of name lookup.
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
void AddObjCProtocolDecl(const ObjCProtocolDecl *P)
void AddObjCInterfaceDecl(const ObjCInterfaceDecl *Record)
Represents a field declaration created by an @defs(...).
static ObjCAtDefsFieldDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
static ObjCAtDefsFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, Expr *BW)
ObjCCategoryDecl - Represents a category declaration.
static ObjCCategoryDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation AtLoc, SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc, const IdentifierInfo *Id, ObjCInterfaceDecl *IDecl, ObjCTypeParamList *typeParamList, SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this category.
static ObjCCategoryDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
ObjCCategoryImplDecl * getImplementation() const
void setImplementation(ObjCCategoryImplDecl *ImplD)
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
ObjCCategoryDecl * getCategoryDecl() const
static ObjCCategoryImplDecl * Create(ASTContext &C, DeclContext *DC, const IdentifierInfo *Id, ObjCInterfaceDecl *classInterface, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation CategoryNameLoc)
static ObjCCategoryImplDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
ObjCCompatibleAliasDecl - Represents alias of a class.
static ObjCCompatibleAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, ObjCInterfaceDecl *aliasedClass)
static ObjCCompatibleAliasDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
ObjCContainerDecl - Represents a container for method declarations.
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
void setAtStartLoc(SourceLocation Loc)
llvm::MapVector< std::pair< IdentifierInfo *, unsigned >, ObjCPropertyDecl * > PropertyMap
instmeth_range instance_methods() const
llvm::SmallDenseSet< const ObjCProtocolDecl *, 8 > ProtocolPropertySet
ObjCPropertyDecl * getProperty(const IdentifierInfo *Id, bool IsInstance) const
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
virtual void collectPropertiesToImplement(PropertyMap &PM) const
This routine collects list of properties to be implemented in the class.
prop_range properties() const
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
ObjCContainerDecl(Kind DK, DeclContext *DC, const IdentifierInfo *Id, SourceLocation nameLoc, SourceLocation atStartLoc)
bool HasUserDeclaredSetterMethod(const ObjCPropertyDecl *P) const
This routine returns 'true' if a user declared setter method was found in the class,...
void addPropertyImplementation(ObjCPropertyImplDecl *property)
propimpl_range property_impls() const
void setClassInterface(ObjCInterfaceDecl *IFace)
ObjCPropertyImplDecl * FindPropertyImplDecl(IdentifierInfo *propertyId, ObjCPropertyQueryKind queryKind) const
FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl added to the list of thos...
const ObjCInterfaceDecl * getClassInterface() const
ObjCPropertyImplDecl * FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const
FindPropertyImplIvarDecl - This method lookup the ivar in the list of properties implemented in this ...
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
static ObjCImplementationDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
static ObjCImplementationDecl * Create(ASTContext &C, DeclContext *DC, ObjCInterfaceDecl *classInterface, ObjCInterfaceDecl *superDecl, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation superLoc=SourceLocation(), SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for class's metadata.
CXXCtorInitializer *const * init_const_iterator
init_const_iterator - Iterates through the ivar initializer list.
StringRef getName() const
getName - Get the name of identifier for the class interface associated with this implementation as a...
init_iterator init_begin()
init_begin() - Retrieve an iterator to the first initializer.
void setIvarInitializers(ASTContext &C, CXXCtorInitializer **initializers, unsigned numInitializers)
Represents an ObjC class declaration.
void mergeClassExtensionProtocolList(ObjCProtocolDecl *const *List, unsigned Num, ASTContext &C)
mergeClassExtensionProtocolList - Merge class extension's protocol list into the protocol list for th...
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
all_protocol_iterator all_referenced_protocol_end() const
ObjCInterfaceDecl * lookupInheritedClass(const IdentifierInfo *ICName)
lookupInheritedClass - This method returns ObjCInterfaceDecl * of the super class whose name is passe...
ivar_iterator ivar_end() const
ObjCPropertyDecl * FindPropertyVisibleInPrimaryClass(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyVisibleInPrimaryClass - Finds declaration of the property with name 'PropertyId' in the p...
ObjCMethodDecl * getCategoryMethod(Selector Sel, bool isInstance) const
static ObjCInterfaceDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc, const IdentifierInfo *Id, ObjCTypeParamList *typeParamList, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc=SourceLocation(), bool isInternal=false)
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
void setCategoryListRaw(ObjCCategoryDecl *category)
Set the raw pointer to the start of the category/extension list.
bool hasDefinition() const
Determine whether this class has been defined.
all_protocol_range all_referenced_protocols() const
visible_extensions_range visible_extensions() const
ObjCTypeParamList * getTypeParamListAsWritten() const
Retrieve the type parameters written on this particular declaration of the class.
ObjCIvarDecl * all_declared_ivar_begin()
all_declared_ivar_begin - return first ivar declared in this class, its extensions and its implementa...
ObjCCategoryDecl * FindCategoryDeclaration(const IdentifierInfo *CategoryId) const
FindCategoryDeclaration - Finds category declaration in the list of categories for this class and ret...
ivar_iterator ivar_begin() const
protocol_range protocols() const
ObjCMethodDecl * lookupInstanceMethod(Selector Sel) const
Lookup an instance method for a given selector.
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
void setImplementation(ObjCImplementationDecl *ImplD)
known_categories_range known_categories() const
const ObjCInterfaceDecl * isObjCRequiresPropertyDefs() const
isObjCRequiresPropertyDefs - Checks that a class or one of its super classes must not be auto-synthes...
SourceLocation getSuperClassLoc() const
Retrieve the starting location of the superclass.
all_protocol_iterator all_referenced_protocol_begin() const
void setExternallyCompleted()
Indicate that this Objective-C class is complete, but that the external AST source will be responsibl...
ObjCMethodDecl * getCategoryClassMethod(Selector Sel) const
ObjCCategoryDecl * getCategoryListRaw() const
Retrieve the raw pointer to the start of the category/extension list.
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
ObjCMethodDecl * lookupPrivateMethod(const Selector &Sel, bool Instance=true) const
Lookup a method in the classes implementation hierarchy.
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this class.
ObjCMethodDecl * getCategoryInstanceMethod(Selector Sel) const
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance, bool shallowCategoryLookup=false, bool followSuper=true, const ObjCCategoryDecl *C=nullptr) const
lookupMethod - This method returns an instance/class method by looking in the class,...
ObjCProtocolDecl * lookupNestedProtocol(IdentifierInfo *Name)
bool ClassImplementsProtocol(ObjCProtocolDecl *lProto, bool lookupCategory, bool RHSIsQualifiedID=false)
ClassImplementsProtocol - Checks that 'lProto' protocol has been implemented in IDecl class,...
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for class's metadata.
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
ObjCImplementationDecl * getImplementation() const
static ObjCInterfaceDecl * CreateDeserialized(const ASTContext &C, GlobalDeclID ID)
bool hasDesignatedInitializers() const
Returns true if this interface decl contains at least one initializer marked with the 'objc_designate...
void getDesignatedInitializers(llvm::SmallVectorImpl< const ObjCMethodDecl * > &Methods) const
Returns the designated initializers for the interface.
void startDefinition()
Starts the definition of this Objective-C class, taking it from a forward declaration (@class) to a d...
void collectPropertiesToImplement(PropertyMap &PM) const override
This routine collects list of properties to be implemented in the class.
bool isArcWeakrefUnavailable() const
isArcWeakrefUnavailable - Checks for a class or one of its super classes to be incompatible with __we...
visible_categories_range visible_categories() const
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
ObjCInterfaceDecl * getSuperClass() const
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
TypeSourceInfo * getSuperClassTInfo() const
bool isDesignatedInitializer(Selector Sel, const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the given selector is a designated initializer for the interface.
void startDuplicateDefinitionForComparison()
Starts the definition without sharing it with other redeclarations.
void setHasDesignatedInitializers()
Indicate that this interface decl contains at least one initializer marked with the 'objc_designated_...
void mergeDuplicateDefinitionWithCommon(const ObjCInterfaceDecl *Definition)
known_extensions_range known_extensions() const
ObjCIvarDecl - Represents an ObjC instance variable.
void setNextIvar(ObjCIvarDecl *ivar)
ObjCInterfaceDecl * getContainingInterface()
Return the class interface that this ivar is logically contained in; this is either the interface whe...
static ObjCIvarDecl * Create(ASTContext &C, ObjCContainerDecl *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW=nullptr, bool synthesized=false)
static ObjCIvarDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
QualType getUsageType(QualType objectType) const
Retrieve the type of this instance variable when viewed as a member of a specific object type.
void ** List
List is an array of pointers to objects that are not owned by this object.
void set(void *const *InList, unsigned Elts, ASTContext &Ctx)
ObjCList - This is a simple template class used to hold various lists of decls etc,...
ObjCMethodDecl - Represents an instance or class method declaration.
bool isDesignatedInitializerForTheInterface(const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the method selector resolves to a designated initializer in the class's interface.
bool isOverriding() const
Whether this method overrides any other in the class hierarchy.
ArrayRef< ParmVarDecl * > parameters() const
unsigned param_size() const
void setSelfDecl(ImplicitParamDecl *SD)
bool isPropertyAccessor() const
void getOverriddenMethods(SmallVectorImpl< const ObjCMethodDecl * > &Overridden) const
Return overridden methods for the given Method.
static ObjCMethodDecl * Create(ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc, Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo, DeclContext *contextDecl, bool isInstance=true, bool isVariadic=false, bool isPropertyAccessor=false, bool isSynthesizedAccessorStub=false, bool isImplicitlyDeclared=false, bool isDefined=false, ObjCImplementationControl impControl=ObjCImplementationControl::None, bool HasRelatedResultType=false)
void setHasRedeclaration(bool HRD) const
const ObjCPropertyDecl * findPropertyDecl(bool CheckOverrides=true) const
Returns the property associated with this method's selector.
QualType getSendResultType() const
Determine the type of an expression that sends a message to this function.
bool hasParamDestroyedInCallee() const
True if the method has a parameter that's destroyed in the callee.
void setIsRedeclaration(bool RD)
void setCmdDecl(ImplicitParamDecl *CD)
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
ObjCMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SourceLocation getEndLoc() const LLVM_READONLY
TypeSourceInfo * getReturnTypeSourceInfo() const
QualType getSelfType(ASTContext &Context, const ObjCInterfaceDecl *OID, bool &selfIsPseudoStrong, bool &selfIsConsumed) const
bool hasRedeclaration() const
True if redeclared in the same interface.
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl * > Params, ArrayRef< SourceLocation > SelLocs={})
Sets the method's parameters and selector source locations.
void setAsRedeclaration(const ObjCMethodDecl *PrevMethod)
param_type_iterator param_type_begin() const
bool isSynthesizedAccessorStub() const
SourceLocation getSelectorLoc(unsigned Index) const
SourceRange getReturnTypeSourceRange() const
bool isRedeclaration() const
True if this is a method redeclaration in the same interface.
bool isDirectMethod() const
True if the method is tagged as objc_direct.
llvm::mapped_iterator< param_const_iterator, GetTypeFn > param_type_iterator
Selector getSelector() const
bool isInstanceMethod() const
static ObjCMethodDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
bool isThisDeclarationADesignatedInitializer() const
Returns true if this specific method declaration is marked with the designated initializer attribute.
ObjCCategoryDecl * getCategory()
If this method is declared or implemented in a category, return that category.
bool definedInNSObject(const ASTContext &) const
Is this method defined in the NSObject base class?
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID)
createImplicitParams - Used to lazily create the self and cmd implicit parameters.
QualType getReturnType() const
unsigned getNumSelectorLocs() const
bool isClassMethod() const
ObjCInterfaceDecl * getClassInterface()
void getSelectorLocs(SmallVectorImpl< SourceLocation > &SelLocs) const
Represents a class type in Objective C.
Represents one property declaration in an Objective-C interface.
QualType getUsageType(QualType objectType) const
Retrieve the type when this property is used with a specific base object type.
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
static ObjCPropertyDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
bool isDirectProperty() const
IdentifierInfo * getDefaultSynthIvarName(ASTContext &Ctx) const
Get the default name of the synthesized ivar.
static ObjCPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, const IdentifierInfo *Id, SourceLocation AtLocation, SourceLocation LParenLocation, QualType T, TypeSourceInfo *TSI, PropertyControl propControl=None)
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
static ObjCPropertyImplDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
static ObjCPropertyImplDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation atLoc, SourceLocation L, ObjCPropertyDecl *property, Kind PK, ObjCIvarDecl *ivarDecl, SourceLocation ivarLoc)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Represents an Objective-C protocol declaration.
void mergeDuplicateDefinitionWithCommon(const ObjCProtocolDecl *Definition)
void startDuplicateDefinitionForComparison()
Starts the definition without sharing it with other redeclarations.
bool hasDefinition() const
Determine whether this protocol has a definition.
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance) const
static ObjCProtocolDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, SourceLocation nameLoc, SourceLocation atStartLoc, ObjCProtocolDecl *PrevDecl)
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for protocol's metadata.
void getImpliedProtocols(llvm::DenseSet< const ObjCProtocolDecl * > &IPs) const
Get the set of all protocols implied by this protocols inheritance hierarchy.
void startDefinition()
Starts the definition of this Objective-C protocol.
static ObjCProtocolDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
bool isNonRuntimeProtocol() const
This is true iff the protocol is tagged with the objc_non_runtime_protocol attribute.
void collectInheritedProtocolProperties(const ObjCPropertyDecl *Property, ProtocolPropertySet &PS, PropertyDeclOrder &PO) const
ObjCProtocolDecl * lookupProtocolNamed(IdentifierInfo *PName)
protocol_range protocols() const
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
void collectPropertiesToImplement(PropertyMap &PM) const override
This routine collects list of properties to be implemented in the class.
void set(ObjCProtocolDecl *const *InList, unsigned Elts, const SourceLocation *Locs, ASTContext &Ctx)
Represents the declaration of an Objective-C type parameter.
static ObjCTypeParamDecl * Create(ASTContext &ctx, DeclContext *dc, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, SourceLocation nameLoc, IdentifierInfo *name, SourceLocation colonLoc, TypeSourceInfo *boundInfo)
bool hasExplicitBound() const
Whether this type parameter has an explicitly-written type bound, e.g., "T : NSView".
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static ObjCTypeParamDecl * CreateDeserialized(ASTContext &ctx, GlobalDeclID ID)
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
void gatherDefaultTypeArgs(SmallVectorImpl< QualType > &typeArgs) const
Gather the default set of type arguments to be substituted for these type parameters when dealing wit...
unsigned size() const
Determine the number of type parameters in this list.
static ObjCTypeParamList * create(ASTContext &ctx, SourceLocation lAngleLoc, ArrayRef< ObjCTypeParamDecl * > typeParams, SourceLocation rAngleLoc)
Create a new Objective-C type parameter list.
Represents a parameter to a function.
A (possibly-)qualified type.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
QualType withConst() const
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
QualType substObjCMemberType(QualType objectType, const DeclContext *dc, ObjCSubstitutionContext context) const
Substitute type arguments from an object type for the Objective-C type parameters used in the subject...
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type.
The collection of all-type qualifiers we support.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
void setObjCLifetime(ObjCLifetime type)
ObjCInterfaceDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
void setPreviousDecl(ObjCInterfaceDecl *PrevDecl)
Set the previous declaration.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Smart pointer class that efficiently represents Objective-C method names.
ObjCMethodFamily getMethodFamily() const
Derive the conventional family of this method.
unsigned getNumArgs() const
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
A container of type source information.
bool isObjCSelType() const
bool isObjCIdType() const
TypeSourceInfo * getTypeSourceInfo() const
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
The JSON file list parser is used to communicate input to InstallAPI.
@ SelLoc_NonStandard
Non-standard.
@ SelLoc_StandardNoSpace
For nullary selectors, immediately before the end: "[foo release]" / "-(void)release;" Or immediately...
@ InvalidObjCMethodFamily
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
ObjCMethodFamily
A family of Objective-C methods.
@ OMF_None
No particular method family.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
SelectorLocationsKind hasStandardSelectorLocs(Selector Sel, ArrayRef< SourceLocation > SelLocs, ArrayRef< Expr * > Args, SourceLocation EndLoc)
Returns true if all SelLocs are in a "standard" location.
@ Property
The type of a property.
@ Result
The result type of a method or function.
ObjCImplementationControl
const FunctionProtoType * T
ObjCTypeParamVariance
Describes the variance of a given generic parameter.
@ Invariant
The parameter is invariant: must match exactly.
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ ObjCSelf
Parameter for Objective-C 'self' argument.
@ ObjCCmd
Parameter for Objective-C '_cmd' argument.
T * get(ExternalASTSource *Source) const
Retrieve the pointer to the AST node that this lazy pointer points to.