clang  16.0.0git
DeclObjC.cpp
Go to the documentation of this file.
1 //===- DeclObjC.cpp - ObjC Declaration AST Node Implementation ------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the Objective-C related Decl classes.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "clang/AST/DeclObjC.h"
14 #include "clang/AST/ASTContext.h"
16 #include "clang/AST/Attr.h"
17 #include "clang/AST/Decl.h"
18 #include "clang/AST/DeclBase.h"
19 #include "clang/AST/ODRHash.h"
20 #include "clang/AST/Stmt.h"
21 #include "clang/AST/Type.h"
22 #include "clang/AST/TypeLoc.h"
24 #include "clang/Basic/LLVM.h"
27 #include "llvm/ADT/None.h"
28 #include "llvm/ADT/SmallString.h"
29 #include "llvm/ADT/SmallVector.h"
30 #include "llvm/Support/Casting.h"
31 #include "llvm/Support/ErrorHandling.h"
32 #include "llvm/Support/raw_ostream.h"
33 #include <algorithm>
34 #include <cassert>
35 #include <cstdint>
36 #include <cstring>
37 #include <queue>
38 #include <utility>
39 
40 using namespace clang;
41 
42 //===----------------------------------------------------------------------===//
43 // ObjCListBase
44 //===----------------------------------------------------------------------===//
45 
46 void ObjCListBase::set(void *const* InList, unsigned Elts, ASTContext &Ctx) {
47  List = nullptr;
48  if (Elts == 0) return; // Setting to an empty list is a noop.
49 
50  List = new (Ctx) void*[Elts];
51  NumElts = Elts;
52  memcpy(List, InList, sizeof(void*)*Elts);
53 }
54 
55 void ObjCProtocolList::set(ObjCProtocolDecl* const* InList, unsigned Elts,
56  const SourceLocation *Locs, ASTContext &Ctx) {
57  if (Elts == 0)
58  return;
59 
60  Locations = new (Ctx) SourceLocation[Elts];
61  memcpy(Locations, Locs, sizeof(SourceLocation) * Elts);
62  set(InList, Elts, Ctx);
63 }
64 
65 //===----------------------------------------------------------------------===//
66 // ObjCInterfaceDecl
67 //===----------------------------------------------------------------------===//
68 
71  SourceLocation atStartLoc)
72  : NamedDecl(DK, DC, nameLoc, Id), DeclContext(DK) {
73  setAtStartLoc(atStartLoc);
74 }
75 
76 void ObjCContainerDecl::anchor() {}
77 
78 /// getIvarDecl - This method looks up an ivar in this ContextDecl.
79 ///
82  lookup_result R = lookup(Id);
83  for (lookup_iterator Ivar = R.begin(), IvarEnd = R.end();
84  Ivar != IvarEnd; ++Ivar) {
85  if (auto *ivar = dyn_cast<ObjCIvarDecl>(*Ivar))
86  return ivar;
87  }
88  return nullptr;
89 }
90 
91 // Get the local instance/class method declared in this interface.
94  bool AllowHidden) const {
95  // If this context is a hidden protocol definition, don't find any
96  // methods there.
97  if (const auto *Proto = dyn_cast<ObjCProtocolDecl>(this)) {
98  if (const ObjCProtocolDecl *Def = Proto->getDefinition())
99  if (!Def->isUnconditionallyVisible() && !AllowHidden)
100  return nullptr;
101  }
102 
103  // Since instance & class methods can have the same name, the loop below
104  // ensures we get the correct method.
105  //
106  // @interface Whatever
107  // - (int) class_method;
108  // + (float) class_method;
109  // @end
110  lookup_result R = lookup(Sel);
111  for (lookup_iterator Meth = R.begin(), MethEnd = R.end();
112  Meth != MethEnd; ++Meth) {
113  auto *MD = dyn_cast<ObjCMethodDecl>(*Meth);
114  if (MD && MD->isInstanceMethod() == isInstance)
115  return MD;
116  }
117  return nullptr;
118 }
119 
120 /// This routine returns 'true' if a user declared setter method was
121 /// found in the class, its protocols, its super classes or categories.
122 /// It also returns 'true' if one of its categories has declared a 'readwrite'
123 /// property. This is because, user must provide a setter method for the
124 /// category's 'readwrite' property.
126  const ObjCPropertyDecl *Property) const {
127  Selector Sel = Property->getSetterName();
128  lookup_result R = lookup(Sel);
129  for (lookup_iterator Meth = R.begin(), MethEnd = R.end();
130  Meth != MethEnd; ++Meth) {
131  auto *MD = dyn_cast<ObjCMethodDecl>(*Meth);
132  if (MD && MD->isInstanceMethod() && !MD->isImplicit())
133  return true;
134  }
135 
136  if (const auto *ID = dyn_cast<ObjCInterfaceDecl>(this)) {
137  // Also look into categories, including class extensions, looking
138  // for a user declared instance method.
139  for (const auto *Cat : ID->visible_categories()) {
140  if (ObjCMethodDecl *MD = Cat->getInstanceMethod(Sel))
141  if (!MD->isImplicit())
142  return true;
143  if (Cat->IsClassExtension())
144  continue;
145  // Also search through the categories looking for a 'readwrite'
146  // declaration of this property. If one found, presumably a setter will
147  // be provided (properties declared in categories will not get
148  // auto-synthesized).
149  for (const auto *P : Cat->properties())
150  if (P->getIdentifier() == Property->getIdentifier()) {
151  if (P->getPropertyAttributes() &
153  return true;
154  break;
155  }
156  }
157 
158  // Also look into protocols, for a user declared instance method.
159  for (const auto *Proto : ID->all_referenced_protocols())
160  if (Proto->HasUserDeclaredSetterMethod(Property))
161  return true;
162 
163  // And in its super class.
164  ObjCInterfaceDecl *OSC = ID->getSuperClass();
165  while (OSC) {
167  return true;
168  OSC = OSC->getSuperClass();
169  }
170  }
171  if (const auto *PD = dyn_cast<ObjCProtocolDecl>(this))
172  for (const auto *PI : PD->protocols())
173  if (PI->HasUserDeclaredSetterMethod(Property))
174  return true;
175  return false;
176 }
177 
180  const IdentifierInfo *propertyID,
181  ObjCPropertyQueryKind queryKind) {
182  // If this context is a hidden protocol definition, don't find any
183  // property.
184  if (const auto *Proto = dyn_cast<ObjCProtocolDecl>(DC)) {
185  if (const ObjCProtocolDecl *Def = Proto->getDefinition())
186  if (!Def->isUnconditionallyVisible())
187  return nullptr;
188  }
189 
190  // If context is class, then lookup property in its visible extensions.
191  // This comes before property is looked up in primary class.
192  if (auto *IDecl = dyn_cast<ObjCInterfaceDecl>(DC)) {
193  for (const auto *Ext : IDecl->visible_extensions())
195  propertyID,
196  queryKind))
197  return PD;
198  }
199 
200  DeclContext::lookup_result R = DC->lookup(propertyID);
201  ObjCPropertyDecl *classProp = nullptr;
202  for (DeclContext::lookup_iterator I = R.begin(), E = R.end(); I != E;
203  ++I)
204  if (auto *PD = dyn_cast<ObjCPropertyDecl>(*I)) {
205  // If queryKind is unknown, we return the instance property if one
206  // exists; otherwise we return the class property.
208  !PD->isClassProperty()) ||
210  PD->isClassProperty()) ||
212  !PD->isClassProperty()))
213  return PD;
214 
215  if (PD->isClassProperty())
216  classProp = PD;
217  }
218 
220  // We can't find the instance property, return the class property.
221  return classProp;
222 
223  return nullptr;
224 }
225 
228  SmallString<128> ivarName;
229  {
230  llvm::raw_svector_ostream os(ivarName);
231  os << '_' << getIdentifier()->getName();
232  }
233  return &Ctx.Idents.get(ivarName.str());
234 }
235 
237  bool IsInstance) const {
238  for (auto *LookupResult : lookup(Id)) {
239  if (auto *Prop = dyn_cast<ObjCPropertyDecl>(LookupResult)) {
240  if (Prop->isInstanceProperty() == IsInstance) {
241  return Prop;
242  }
243  }
244  }
245  return nullptr;
246 }
247 
248 /// FindPropertyDeclaration - Finds declaration of the property given its name
249 /// in 'PropertyId' and returns it. It returns 0, if not found.
251  const IdentifierInfo *PropertyId,
252  ObjCPropertyQueryKind QueryKind) const {
253  // Don't find properties within hidden protocol definitions.
254  if (const auto *Proto = dyn_cast<ObjCProtocolDecl>(this)) {
255  if (const ObjCProtocolDecl *Def = Proto->getDefinition())
256  if (!Def->isUnconditionallyVisible())
257  return nullptr;
258  }
259 
260  // Search the extensions of a class first; they override what's in
261  // the class itself.
262  if (const auto *ClassDecl = dyn_cast<ObjCInterfaceDecl>(this)) {
263  for (const auto *Ext : ClassDecl->visible_extensions()) {
264  if (auto *P = Ext->FindPropertyDeclaration(PropertyId, QueryKind))
265  return P;
266  }
267  }
268 
269  if (ObjCPropertyDecl *PD =
270  ObjCPropertyDecl::findPropertyDecl(cast<DeclContext>(this), PropertyId,
271  QueryKind))
272  return PD;
273 
274  switch (getKind()) {
275  default:
276  break;
277  case Decl::ObjCProtocol: {
278  const auto *PID = cast<ObjCProtocolDecl>(this);
279  for (const auto *I : PID->protocols())
280  if (ObjCPropertyDecl *P = I->FindPropertyDeclaration(PropertyId,
281  QueryKind))
282  return P;
283  break;
284  }
285  case Decl::ObjCInterface: {
286  const auto *OID = cast<ObjCInterfaceDecl>(this);
287  // Look through categories (but not extensions; they were handled above).
288  for (const auto *Cat : OID->visible_categories()) {
289  if (!Cat->IsClassExtension())
290  if (ObjCPropertyDecl *P = Cat->FindPropertyDeclaration(
291  PropertyId, QueryKind))
292  return P;
293  }
294 
295  // Look through protocols.
296  for (const auto *I : OID->all_referenced_protocols())
297  if (ObjCPropertyDecl *P = I->FindPropertyDeclaration(PropertyId,
298  QueryKind))
299  return P;
300 
301  // Finally, check the super class.
302  if (const ObjCInterfaceDecl *superClass = OID->getSuperClass())
303  return superClass->FindPropertyDeclaration(PropertyId, QueryKind);
304  break;
305  }
306  case Decl::ObjCCategory: {
307  const auto *OCD = cast<ObjCCategoryDecl>(this);
308  // Look through protocols.
309  if (!OCD->IsClassExtension())
310  for (const auto *I : OCD->protocols())
311  if (ObjCPropertyDecl *P = I->FindPropertyDeclaration(PropertyId,
312  QueryKind))
313  return P;
314  break;
315  }
316  }
317  return nullptr;
318 }
319 
320 void ObjCInterfaceDecl::anchor() {}
321 
323  // If this particular declaration has a type parameter list, return it.
325  return written;
326 
327  // If there is a definition, return its type parameter list.
328  if (const ObjCInterfaceDecl *def = getDefinition())
329  return def->getTypeParamListAsWritten();
330 
331  // Otherwise, look at previous declarations to determine whether any
332  // of them has a type parameter list, skipping over those
333  // declarations that do not.
334  for (const ObjCInterfaceDecl *decl = getMostRecentDecl(); decl;
335  decl = decl->getPreviousDecl()) {
336  if (ObjCTypeParamList *written = decl->getTypeParamListAsWritten())
337  return written;
338  }
339 
340  return nullptr;
341 }
342 
344  TypeParamList = TPL;
345  if (!TPL)
346  return;
347  // Set the declaration context of each of the type parameters.
348  for (auto *typeParam : *TypeParamList)
349  typeParam->setDeclContext(this);
350 }
351 
353  // FIXME: Should make sure no callers ever do this.
354  if (!hasDefinition())
355  return nullptr;
356 
357  if (data().ExternallyCompleted)
358  LoadExternalDefinition();
359 
360  if (const ObjCObjectType *superType = getSuperClassType()) {
361  if (ObjCInterfaceDecl *superDecl = superType->getInterface()) {
362  if (ObjCInterfaceDecl *superDef = superDecl->getDefinition())
363  return superDef;
364 
365  return superDecl;
366  }
367  }
368 
369  return nullptr;
370 }
371 
373  if (TypeSourceInfo *superTInfo = getSuperClassTInfo())
374  return superTInfo->getTypeLoc().getBeginLoc();
375 
376  return SourceLocation();
377 }
378 
379 /// FindPropertyVisibleInPrimaryClass - Finds declaration of the property
380 /// with name 'PropertyId' in the primary class; including those in protocols
381 /// (direct or indirect) used by the primary class.
384  IdentifierInfo *PropertyId,
385  ObjCPropertyQueryKind QueryKind) const {
386  // FIXME: Should make sure no callers ever do this.
387  if (!hasDefinition())
388  return nullptr;
389 
390  if (data().ExternallyCompleted)
391  LoadExternalDefinition();
392 
393  if (ObjCPropertyDecl *PD =
394  ObjCPropertyDecl::findPropertyDecl(cast<DeclContext>(this), PropertyId,
395  QueryKind))
396  return PD;
397 
398  // Look through protocols.
399  for (const auto *I : all_referenced_protocols())
400  if (ObjCPropertyDecl *P = I->FindPropertyDeclaration(PropertyId,
401  QueryKind))
402  return P;
403 
404  return nullptr;
405 }
406 
408  for (auto *Prop : properties()) {
409  PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
410  }
411  for (const auto *Ext : known_extensions()) {
412  const ObjCCategoryDecl *ClassExt = Ext;
413  for (auto *Prop : ClassExt->properties()) {
414  PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
415  }
416  }
417  for (const auto *PI : all_referenced_protocols())
419  // Note, the properties declared only in class extensions are still copied
420  // into the main @interface's property list, and therefore we don't
421  // explicitly, have to search class extension properties.
422 }
423 
425  const ObjCInterfaceDecl *Class = this;
426  while (Class) {
427  if (Class->hasAttr<ArcWeakrefUnavailableAttr>())
428  return true;
429  Class = Class->getSuperClass();
430  }
431  return false;
432 }
433 
435  const ObjCInterfaceDecl *Class = this;
436  while (Class) {
437  if (Class->hasAttr<ObjCRequiresPropertyDefsAttr>())
438  return Class;
439  Class = Class->getSuperClass();
440  }
441  return nullptr;
442 }
443 
445  ObjCProtocolDecl *const* ExtList, unsigned ExtNum,
446  ASTContext &C) {
447  if (data().ExternallyCompleted)
448  LoadExternalDefinition();
449 
450  if (data().AllReferencedProtocols.empty() &&
451  data().ReferencedProtocols.empty()) {
452  data().AllReferencedProtocols.set(ExtList, ExtNum, C);
453  return;
454  }
455 
456  // Check for duplicate protocol in class's protocol list.
457  // This is O(n*m). But it is extremely rare and number of protocols in
458  // class or its extension are very few.
460  for (unsigned i = 0; i < ExtNum; i++) {
461  bool protocolExists = false;
462  ObjCProtocolDecl *ProtoInExtension = ExtList[i];
463  for (auto *Proto : all_referenced_protocols()) {
464  if (C.ProtocolCompatibleWithProtocol(ProtoInExtension, Proto)) {
465  protocolExists = true;
466  break;
467  }
468  }
469  // Do we want to warn on a protocol in extension class which
470  // already exist in the class? Probably not.
471  if (!protocolExists)
472  ProtocolRefs.push_back(ProtoInExtension);
473  }
474 
475  if (ProtocolRefs.empty())
476  return;
477 
478  // Merge ProtocolRefs into class's protocol list;
479  ProtocolRefs.append(all_referenced_protocol_begin(),
481 
482  data().AllReferencedProtocols.set(ProtocolRefs.data(), ProtocolRefs.size(),C);
483 }
484 
485 const ObjCInterfaceDecl *
486 ObjCInterfaceDecl::findInterfaceWithDesignatedInitializers() const {
487  const ObjCInterfaceDecl *IFace = this;
488  while (IFace) {
489  if (IFace->hasDesignatedInitializers())
490  return IFace;
491  if (!IFace->inheritsDesignatedInitializers())
492  break;
493  IFace = IFace->getSuperClass();
494  }
495  return nullptr;
496 }
497 
499  for (const auto *MD : D->instance_methods()) {
500  if (MD->getMethodFamily() == OMF_init && !MD->isOverriding())
501  return true;
502  }
503  for (const auto *Ext : D->visible_extensions()) {
504  for (const auto *MD : Ext->instance_methods()) {
505  if (MD->getMethodFamily() == OMF_init && !MD->isOverriding())
506  return true;
507  }
508  }
509  if (const auto *ImplD = D->getImplementation()) {
510  for (const auto *MD : ImplD->instance_methods()) {
511  if (MD->getMethodFamily() == OMF_init && !MD->isOverriding())
512  return true;
513  }
514  }
515  return false;
516 }
517 
518 bool ObjCInterfaceDecl::inheritsDesignatedInitializers() const {
519  switch (data().InheritedDesignatedInitializers) {
520  case DefinitionData::IDI_Inherited:
521  return true;
522  case DefinitionData::IDI_NotInherited:
523  return false;
524  case DefinitionData::IDI_Unknown:
525  // If the class introduced initializers we conservatively assume that we
526  // don't know if any of them is a designated initializer to avoid possible
527  // misleading warnings.
528  if (isIntroducingInitializers(this)) {
529  data().InheritedDesignatedInitializers = DefinitionData::IDI_NotInherited;
530  } else {
531  if (auto SuperD = getSuperClass()) {
532  data().InheritedDesignatedInitializers =
533  SuperD->declaresOrInheritsDesignatedInitializers() ?
534  DefinitionData::IDI_Inherited :
535  DefinitionData::IDI_NotInherited;
536  } else {
537  data().InheritedDesignatedInitializers =
538  DefinitionData::IDI_NotInherited;
539  }
540  }
541  assert(data().InheritedDesignatedInitializers
542  != DefinitionData::IDI_Unknown);
543  return data().InheritedDesignatedInitializers ==
544  DefinitionData::IDI_Inherited;
545  }
546 
547  llvm_unreachable("unexpected InheritedDesignatedInitializers value");
548 }
549 
552  // Check for a complete definition and recover if not so.
554  return;
555  if (data().ExternallyCompleted)
556  LoadExternalDefinition();
557 
558  const ObjCInterfaceDecl *IFace= findInterfaceWithDesignatedInitializers();
559  if (!IFace)
560  return;
561 
562  for (const auto *MD : IFace->instance_methods())
563  if (MD->isThisDeclarationADesignatedInitializer())
564  Methods.push_back(MD);
565  for (const auto *Ext : IFace->visible_extensions()) {
566  for (const auto *MD : Ext->instance_methods())
567  if (MD->isThisDeclarationADesignatedInitializer())
568  Methods.push_back(MD);
569  }
570 }
571 
573  const ObjCMethodDecl **InitMethod) const {
574  bool HasCompleteDef = isThisDeclarationADefinition();
575  // During deserialization the data record for the ObjCInterfaceDecl could
576  // be made invariant by reusing the canonical decl. Take this into account
577  // when checking for the complete definition.
578  if (!HasCompleteDef && getCanonicalDecl()->hasDefinition() &&
580  HasCompleteDef = true;
581 
582  // Check for a complete definition and recover if not so.
583  if (!HasCompleteDef)
584  return false;
585 
586  if (data().ExternallyCompleted)
587  LoadExternalDefinition();
588 
589  const ObjCInterfaceDecl *IFace= findInterfaceWithDesignatedInitializers();
590  if (!IFace)
591  return false;
592 
593  if (const ObjCMethodDecl *MD = IFace->getInstanceMethod(Sel)) {
594  if (MD->isThisDeclarationADesignatedInitializer()) {
595  if (InitMethod)
596  *InitMethod = MD;
597  return true;
598  }
599  }
600  for (const auto *Ext : IFace->visible_extensions()) {
601  if (const ObjCMethodDecl *MD = Ext->getInstanceMethod(Sel)) {
602  if (MD->isThisDeclarationADesignatedInitializer()) {
603  if (InitMethod)
604  *InitMethod = MD;
605  return true;
606  }
607  }
608  }
609  return false;
610 }
611 
612 void ObjCInterfaceDecl::allocateDefinitionData() {
613  assert(!hasDefinition() && "ObjC class already has a definition");
614  Data.setPointer(new (getASTContext()) DefinitionData());
615  Data.getPointer()->Definition = this;
616 }
617 
619  allocateDefinitionData();
620 
621  // Update all of the declarations with a pointer to the definition.
622  for (auto *RD : redecls()) {
623  if (RD != this)
624  RD->Data = Data;
625  }
626 }
627 
629  ObjCInterfaceDecl *&clsDeclared) {
630  // FIXME: Should make sure no callers ever do this.
631  if (!hasDefinition())
632  return nullptr;
633 
634  if (data().ExternallyCompleted)
635  LoadExternalDefinition();
636 
637  ObjCInterfaceDecl* ClassDecl = this;
638  while (ClassDecl != nullptr) {
639  if (ObjCIvarDecl *I = ClassDecl->getIvarDecl(ID)) {
640  clsDeclared = ClassDecl;
641  return I;
642  }
643 
644  for (const auto *Ext : ClassDecl->visible_extensions()) {
645  if (ObjCIvarDecl *I = Ext->getIvarDecl(ID)) {
646  clsDeclared = ClassDecl;
647  return I;
648  }
649  }
650 
651  ClassDecl = ClassDecl->getSuperClass();
652  }
653  return nullptr;
654 }
655 
656 /// lookupInheritedClass - This method returns ObjCInterfaceDecl * of the super
657 /// class whose name is passed as argument. If it is not one of the super classes
658 /// the it returns NULL.
660  const IdentifierInfo*ICName) {
661  // FIXME: Should make sure no callers ever do this.
662  if (!hasDefinition())
663  return nullptr;
664 
665  if (data().ExternallyCompleted)
666  LoadExternalDefinition();
667 
668  ObjCInterfaceDecl* ClassDecl = this;
669  while (ClassDecl != nullptr) {
670  if (ClassDecl->getIdentifier() == ICName)
671  return ClassDecl;
672  ClassDecl = ClassDecl->getSuperClass();
673  }
674  return nullptr;
675 }
676 
679  for (auto *P : all_referenced_protocols())
680  if (P->lookupProtocolNamed(Name))
681  return P;
682  ObjCInterfaceDecl *SuperClass = getSuperClass();
683  return SuperClass ? SuperClass->lookupNestedProtocol(Name) : nullptr;
684 }
685 
686 /// lookupMethod - This method returns an instance/class method by looking in
687 /// the class, its categories, and its super classes (using a linear search).
688 /// When argument category "C" is specified, any implicit method found
689 /// in this category is ignored.
691  bool isInstance,
692  bool shallowCategoryLookup,
693  bool followSuper,
694  const ObjCCategoryDecl *C) const
695 {
696  // FIXME: Should make sure no callers ever do this.
697  if (!hasDefinition())
698  return nullptr;
699 
700  const ObjCInterfaceDecl* ClassDecl = this;
701  ObjCMethodDecl *MethodDecl = nullptr;
702 
703  if (data().ExternallyCompleted)
704  LoadExternalDefinition();
705 
706  while (ClassDecl) {
707  // 1. Look through primary class.
708  if ((MethodDecl = ClassDecl->getMethod(Sel, isInstance)))
709  return MethodDecl;
710 
711  // 2. Didn't find one yet - now look through categories.
712  for (const auto *Cat : ClassDecl->visible_categories())
713  if ((MethodDecl = Cat->getMethod(Sel, isInstance)))
714  if (C != Cat || !MethodDecl->isImplicit())
715  return MethodDecl;
716 
717  // 3. Didn't find one yet - look through primary class's protocols.
718  for (const auto *I : ClassDecl->protocols())
719  if ((MethodDecl = I->lookupMethod(Sel, isInstance)))
720  return MethodDecl;
721 
722  // 4. Didn't find one yet - now look through categories' protocols
723  if (!shallowCategoryLookup)
724  for (const auto *Cat : ClassDecl->visible_categories()) {
725  // Didn't find one yet - look through protocols.
726  const ObjCList<ObjCProtocolDecl> &Protocols =
727  Cat->getReferencedProtocols();
728  for (auto *Protocol : Protocols)
729  if ((MethodDecl = Protocol->lookupMethod(Sel, isInstance)))
730  if (C != Cat || !MethodDecl->isImplicit())
731  return MethodDecl;
732  }
733 
734 
735  if (!followSuper)
736  return nullptr;
737 
738  // 5. Get to the super class (if any).
739  ClassDecl = ClassDecl->getSuperClass();
740  }
741  return nullptr;
742 }
743 
744 // Will search "local" class/category implementations for a method decl.
745 // If failed, then we search in class's root for an instance method.
746 // Returns 0 if no method is found.
748  const Selector &Sel,
749  bool Instance) const {
750  // FIXME: Should make sure no callers ever do this.
751  if (!hasDefinition())
752  return nullptr;
753 
754  if (data().ExternallyCompleted)
755  LoadExternalDefinition();
756 
757  ObjCMethodDecl *Method = nullptr;
758  if (ObjCImplementationDecl *ImpDecl = getImplementation())
759  Method = Instance ? ImpDecl->getInstanceMethod(Sel)
760  : ImpDecl->getClassMethod(Sel);
761 
762  // Look through local category implementations associated with the class.
763  if (!Method)
764  Method = getCategoryMethod(Sel, Instance);
765 
766  // Before we give up, check if the selector is an instance method.
767  // But only in the root. This matches gcc's behavior and what the
768  // runtime expects.
769  if (!Instance && !Method && !getSuperClass()) {
770  Method = lookupInstanceMethod(Sel);
771  // Look through local category implementations associated
772  // with the root class.
773  if (!Method)
774  Method = lookupPrivateMethod(Sel, true);
775  }
776 
777  if (!Method && getSuperClass())
778  return getSuperClass()->lookupPrivateMethod(Sel, Instance);
779  return Method;
780 }
781 
782 //===----------------------------------------------------------------------===//
783 // ObjCMethodDecl
784 //===----------------------------------------------------------------------===//
785 
786 ObjCMethodDecl::ObjCMethodDecl(
787  SourceLocation beginLoc, SourceLocation endLoc, Selector SelInfo,
788  QualType T, TypeSourceInfo *ReturnTInfo, DeclContext *contextDecl,
789  bool isInstance, bool isVariadic, bool isPropertyAccessor,
790  bool isSynthesizedAccessorStub, bool isImplicitlyDeclared, bool isDefined,
791  ImplementationControl impControl, bool HasRelatedResultType)
792  : NamedDecl(ObjCMethod, contextDecl, beginLoc, SelInfo),
793  DeclContext(ObjCMethod), MethodDeclType(T), ReturnTInfo(ReturnTInfo),
794  DeclEndLoc(endLoc) {
795 
796  // Initialized the bits stored in DeclContext.
797  ObjCMethodDeclBits.Family =
799  setInstanceMethod(isInstance);
800  setVariadic(isVariadic);
801  setPropertyAccessor(isPropertyAccessor);
802  setSynthesizedAccessorStub(isSynthesizedAccessorStub);
803  setDefined(isDefined);
804  setIsRedeclaration(false);
805  setHasRedeclaration(false);
806  setDeclImplementation(impControl);
807  setObjCDeclQualifier(OBJC_TQ_None);
808  setRelatedResultType(HasRelatedResultType);
809  setSelLocsKind(SelLoc_StandardNoSpace);
810  setOverriding(false);
811  setHasSkippedBody(false);
812 
813  setImplicit(isImplicitlyDeclared);
814 }
815 
817  ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc,
818  Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo,
819  DeclContext *contextDecl, bool isInstance, bool isVariadic,
820  bool isPropertyAccessor, bool isSynthesizedAccessorStub,
821  bool isImplicitlyDeclared, bool isDefined, ImplementationControl impControl,
822  bool HasRelatedResultType) {
823  return new (C, contextDecl) ObjCMethodDecl(
824  beginLoc, endLoc, SelInfo, T, ReturnTInfo, contextDecl, isInstance,
826  isImplicitlyDeclared, isDefined, impControl, HasRelatedResultType);
827 }
828 
830  return new (C, ID) ObjCMethodDecl(SourceLocation(), SourceLocation(),
831  Selector(), QualType(), nullptr, nullptr);
832 }
833 
835  return hasAttr<ObjCDirectAttr>() &&
836  !getASTContext().getLangOpts().ObjCDisableDirectMethodsForTesting;
837 }
838 
840  return getMethodFamily() == OMF_init &&
841  hasAttr<ObjCDesignatedInitializerAttr>();
842 }
843 
845  if (const auto *PD = dyn_cast<const ObjCProtocolDecl>(getDeclContext()))
846  return PD->getIdentifier() == Ctx.getNSObjectName();
847  if (const auto *ID = dyn_cast<const ObjCInterfaceDecl>(getDeclContext()))
848  return ID->getIdentifier() == Ctx.getNSObjectName();
849  return false;
850 }
851 
853  const ObjCMethodDecl **InitMethod) const {
854  if (getMethodFamily() != OMF_init)
855  return false;
856  const DeclContext *DC = getDeclContext();
857  if (isa<ObjCProtocolDecl>(DC))
858  return false;
859  if (const ObjCInterfaceDecl *ID = getClassInterface())
860  return ID->isDesignatedInitializer(getSelector(), InitMethod);
861  return false;
862 }
863 
865  for (auto *param : parameters()) {
866  if (param->isDestroyedInCallee())
867  return true;
868  }
869  return false;
870 }
871 
873  return Body.get(getASTContext().getExternalSource());
874 }
875 
877  assert(PrevMethod);
878  getASTContext().setObjCMethodRedeclaration(PrevMethod, this);
879  setIsRedeclaration(true);
880  PrevMethod->setHasRedeclaration(true);
881 }
882 
883 void ObjCMethodDecl::setParamsAndSelLocs(ASTContext &C,
884  ArrayRef<ParmVarDecl*> Params,
885  ArrayRef<SourceLocation> SelLocs) {
886  ParamsAndSelLocs = nullptr;
887  NumParams = Params.size();
888  if (Params.empty() && SelLocs.empty())
889  return;
890 
891  static_assert(alignof(ParmVarDecl *) >= alignof(SourceLocation),
892  "Alignment not sufficient for SourceLocation");
893 
894  unsigned Size = sizeof(ParmVarDecl *) * NumParams +
895  sizeof(SourceLocation) * SelLocs.size();
896  ParamsAndSelLocs = C.Allocate(Size);
897  std::copy(Params.begin(), Params.end(), getParams());
898  std::copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs());
899 }
900 
902  SmallVectorImpl<SourceLocation> &SelLocs) const {
903  for (unsigned i = 0, e = getNumSelectorLocs(); i != e; ++i)
904  SelLocs.push_back(getSelectorLoc(i));
905 }
906 
908  ArrayRef<ParmVarDecl*> Params,
909  ArrayRef<SourceLocation> SelLocs) {
910  assert((!SelLocs.empty() || isImplicit()) &&
911  "No selector locs for non-implicit method");
912  if (isImplicit())
913  return setParamsAndSelLocs(C, Params, std::nullopt);
914 
915  setSelLocsKind(hasStandardSelectorLocs(getSelector(), SelLocs, Params,
916  DeclEndLoc));
917  if (getSelLocsKind() != SelLoc_NonStandard)
918  return setParamsAndSelLocs(C, Params, std::nullopt);
919 
920  setParamsAndSelLocs(C, Params, SelLocs);
921 }
922 
923 /// A definition will return its interface declaration.
924 /// An interface declaration will return its definition.
925 /// Otherwise it will return itself.
926 ObjCMethodDecl *ObjCMethodDecl::getNextRedeclarationImpl() {
927  ASTContext &Ctx = getASTContext();
928  ObjCMethodDecl *Redecl = nullptr;
929  if (hasRedeclaration())
930  Redecl = const_cast<ObjCMethodDecl*>(Ctx.getObjCMethodRedeclaration(this));
931  if (Redecl)
932  return Redecl;
933 
934  auto *CtxD = cast<Decl>(getDeclContext());
935 
936  if (!CtxD->isInvalidDecl()) {
937  if (auto *IFD = dyn_cast<ObjCInterfaceDecl>(CtxD)) {
938  if (ObjCImplementationDecl *ImplD = Ctx.getObjCImplementation(IFD))
939  if (!ImplD->isInvalidDecl())
940  Redecl = ImplD->getMethod(getSelector(), isInstanceMethod());
941 
942  } else if (auto *CD = dyn_cast<ObjCCategoryDecl>(CtxD)) {
943  if (ObjCCategoryImplDecl *ImplD = Ctx.getObjCImplementation(CD))
944  if (!ImplD->isInvalidDecl())
945  Redecl = ImplD->getMethod(getSelector(), isInstanceMethod());
946 
947  } else if (auto *ImplD = dyn_cast<ObjCImplementationDecl>(CtxD)) {
948  if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface())
949  if (!IFD->isInvalidDecl())
950  Redecl = IFD->getMethod(getSelector(), isInstanceMethod());
951 
952  } else if (auto *CImplD = dyn_cast<ObjCCategoryImplDecl>(CtxD)) {
953  if (ObjCCategoryDecl *CatD = CImplD->getCategoryDecl())
954  if (!CatD->isInvalidDecl())
955  Redecl = CatD->getMethod(getSelector(), isInstanceMethod());
956  }
957  }
958 
959  // Ensure that the discovered method redeclaration has a valid declaration
960  // context. Used to prevent infinite loops when iterating redeclarations in
961  // a partially invalid AST.
962  if (Redecl && cast<Decl>(Redecl->getDeclContext())->isInvalidDecl())
963  Redecl = nullptr;
964 
965  if (!Redecl && isRedeclaration()) {
966  // This is the last redeclaration, go back to the first method.
967  return cast<ObjCContainerDecl>(CtxD)->getMethod(getSelector(),
969  /*AllowHidden=*/true);
970  }
971 
972  return Redecl ? Redecl : this;
973 }
974 
976  auto *CtxD = cast<Decl>(getDeclContext());
977  const auto &Sel = getSelector();
978 
979  if (auto *ImplD = dyn_cast<ObjCImplementationDecl>(CtxD)) {
980  if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface()) {
981  // When the container is the ObjCImplementationDecl (the primary
982  // @implementation), then the canonical Decl is either in
983  // the class Interface, or in any of its extension.
984  //
985  // So when we don't find it in the ObjCInterfaceDecl,
986  // sift through extensions too.
987  if (ObjCMethodDecl *MD = IFD->getMethod(Sel, isInstanceMethod()))
988  return MD;
989  for (auto *Ext : IFD->known_extensions())
990  if (ObjCMethodDecl *MD = Ext->getMethod(Sel, isInstanceMethod()))
991  return MD;
992  }
993  } else if (auto *CImplD = dyn_cast<ObjCCategoryImplDecl>(CtxD)) {
994  if (ObjCCategoryDecl *CatD = CImplD->getCategoryDecl())
995  if (ObjCMethodDecl *MD = CatD->getMethod(Sel, isInstanceMethod()))
996  return MD;
997  }
998 
999  if (isRedeclaration()) {
1000  // It is possible that we have not done deserializing the ObjCMethod yet.
1001  ObjCMethodDecl *MD =
1002  cast<ObjCContainerDecl>(CtxD)->getMethod(Sel, isInstanceMethod(),
1003  /*AllowHidden=*/true);
1004  return MD ? MD : this;
1005  }
1006 
1007  return this;
1008 }
1009 
1011  if (Stmt *Body = getBody())
1012  return Body->getEndLoc();
1013  return DeclEndLoc;
1014 }
1015 
1017  auto family = static_cast<ObjCMethodFamily>(ObjCMethodDeclBits.Family);
1018  if (family != static_cast<unsigned>(InvalidObjCMethodFamily))
1019  return family;
1020 
1021  // Check for an explicit attribute.
1022  if (const ObjCMethodFamilyAttr *attr = getAttr<ObjCMethodFamilyAttr>()) {
1023  // The unfortunate necessity of mapping between enums here is due
1024  // to the attributes framework.
1025  switch (attr->getFamily()) {
1026  case ObjCMethodFamilyAttr::OMF_None: family = OMF_None; break;
1027  case ObjCMethodFamilyAttr::OMF_alloc: family = OMF_alloc; break;
1028  case ObjCMethodFamilyAttr::OMF_copy: family = OMF_copy; break;
1029  case ObjCMethodFamilyAttr::OMF_init: family = OMF_init; break;
1031  case ObjCMethodFamilyAttr::OMF_new: family = OMF_new; break;
1032  }
1033  ObjCMethodDeclBits.Family = family;
1034  return family;
1035  }
1036 
1037  family = getSelector().getMethodFamily();
1038  switch (family) {
1039  case OMF_None: break;
1040 
1041  // init only has a conventional meaning for an instance method, and
1042  // it has to return an object.
1043  case OMF_init:
1044  if (!isInstanceMethod() || !getReturnType()->isObjCObjectPointerType())
1045  family = OMF_None;
1046  break;
1047 
1048  // alloc/copy/new have a conventional meaning for both class and
1049  // instance methods, but they require an object return.
1050  case OMF_alloc:
1051  case OMF_copy:
1052  case OMF_mutableCopy:
1053  case OMF_new:
1054  if (!getReturnType()->isObjCObjectPointerType())
1055  family = OMF_None;
1056  break;
1057 
1058  // These selectors have a conventional meaning only for instance methods.
1059  case OMF_dealloc:
1060  case OMF_finalize:
1061  case OMF_retain:
1062  case OMF_release:
1063  case OMF_autorelease:
1064  case OMF_retainCount:
1065  case OMF_self:
1066  if (!isInstanceMethod())
1067  family = OMF_None;
1068  break;
1069 
1070  case OMF_initialize:
1071  if (isInstanceMethod() || !getReturnType()->isVoidType())
1072  family = OMF_None;
1073  break;
1074 
1075  case OMF_performSelector:
1076  if (!isInstanceMethod() || !getReturnType()->isObjCIdType())
1077  family = OMF_None;
1078  else {
1079  unsigned noParams = param_size();
1080  if (noParams < 1 || noParams > 3)
1081  family = OMF_None;
1082  else {
1084  QualType ArgT = (*it);
1085  if (!ArgT->isObjCSelType()) {
1086  family = OMF_None;
1087  break;
1088  }
1089  while (--noParams) {
1090  it++;
1091  ArgT = (*it);
1092  if (!ArgT->isObjCIdType()) {
1093  family = OMF_None;
1094  break;
1095  }
1096  }
1097  }
1098  }
1099  break;
1100 
1101  }
1102 
1103  // Cache the result.
1104  ObjCMethodDeclBits.Family = family;
1105  return family;
1106 }
1107 
1109  const ObjCInterfaceDecl *OID,
1110  bool &selfIsPseudoStrong,
1111  bool &selfIsConsumed) const {
1112  QualType selfTy;
1113  selfIsPseudoStrong = false;
1114  selfIsConsumed = false;
1115  if (isInstanceMethod()) {
1116  // There may be no interface context due to error in declaration
1117  // of the interface (which has been reported). Recover gracefully.
1118  if (OID) {
1119  selfTy = Context.getObjCInterfaceType(OID);
1120  selfTy = Context.getObjCObjectPointerType(selfTy);
1121  } else {
1122  selfTy = Context.getObjCIdType();
1123  }
1124  } else // we have a factory method.
1125  selfTy = Context.getObjCClassType();
1126 
1127  if (Context.getLangOpts().ObjCAutoRefCount) {
1128  if (isInstanceMethod()) {
1129  selfIsConsumed = hasAttr<NSConsumesSelfAttr>();
1130 
1131  // 'self' is always __strong. It's actually pseudo-strong except
1132  // in init methods (or methods labeled ns_consumes_self), though.
1133  Qualifiers qs;
1135  selfTy = Context.getQualifiedType(selfTy, qs);
1136 
1137  // In addition, 'self' is const unless this is an init method.
1138  if (getMethodFamily() != OMF_init && !selfIsConsumed) {
1139  selfTy = selfTy.withConst();
1140  selfIsPseudoStrong = true;
1141  }
1142  }
1143  else {
1144  assert(isClassMethod());
1145  // 'self' is always const in class methods.
1146  selfTy = selfTy.withConst();
1147  selfIsPseudoStrong = true;
1148  }
1149  }
1150  return selfTy;
1151 }
1152 
1154  const ObjCInterfaceDecl *OID) {
1155  bool selfIsPseudoStrong, selfIsConsumed;
1156  QualType selfTy =
1157  getSelfType(Context, OID, selfIsPseudoStrong, selfIsConsumed);
1158  auto *Self = ImplicitParamDecl::Create(Context, this, SourceLocation(),
1159  &Context.Idents.get("self"), selfTy,
1161  setSelfDecl(Self);
1162 
1163  if (selfIsConsumed)
1164  Self->addAttr(NSConsumedAttr::CreateImplicit(Context));
1165 
1166  if (selfIsPseudoStrong)
1167  Self->setARCPseudoStrong(true);
1168 
1170  Context, this, SourceLocation(), &Context.Idents.get("_cmd"),
1172 }
1173 
1175  if (auto *ID = dyn_cast<ObjCInterfaceDecl>(getDeclContext()))
1176  return ID;
1177  if (auto *CD = dyn_cast<ObjCCategoryDecl>(getDeclContext()))
1178  return CD->getClassInterface();
1179  if (auto *IMD = dyn_cast<ObjCImplDecl>(getDeclContext()))
1180  return IMD->getClassInterface();
1181  if (isa<ObjCProtocolDecl>(getDeclContext()))
1182  return nullptr;
1183  llvm_unreachable("unknown method context");
1184 }
1185 
1187  if (auto *CD = dyn_cast<ObjCCategoryDecl>(getDeclContext()))
1188  return CD;
1189  if (auto *IMD = dyn_cast<ObjCCategoryImplDecl>(getDeclContext()))
1190  return IMD->getCategoryDecl();
1191  return nullptr;
1192 }
1193 
1195  const auto *TSI = getReturnTypeSourceInfo();
1196  if (TSI)
1197  return TSI->getTypeLoc().getSourceRange();
1198  return SourceRange();
1199 }
1200 
1202  ASTContext &Ctx = getASTContext();
1203  return getReturnType().getNonLValueExprType(Ctx)
1205 }
1206 
1208  // FIXME: Handle related result types here.
1209 
1211  .substObjCMemberType(receiverType, getDeclContext(),
1213 }
1214 
1216  const ObjCMethodDecl *Method,
1218  bool MovedToSuper) {
1219  if (!Container)
1220  return;
1221 
1222  // In categories look for overridden methods from protocols. A method from
1223  // category is not "overridden" since it is considered as the "same" method
1224  // (same USR) as the one from the interface.
1225  if (const auto *Category = dyn_cast<ObjCCategoryDecl>(Container)) {
1226  // Check whether we have a matching method at this category but only if we
1227  // are at the super class level.
1228  if (MovedToSuper)
1229  if (ObjCMethodDecl *
1230  Overridden = Container->getMethod(Method->getSelector(),
1231  Method->isInstanceMethod(),
1232  /*AllowHidden=*/true))
1233  if (Method != Overridden) {
1234  // We found an override at this category; there is no need to look
1235  // into its protocols.
1236  Methods.push_back(Overridden);
1237  return;
1238  }
1239 
1240  for (const auto *P : Category->protocols())
1241  CollectOverriddenMethodsRecurse(P, Method, Methods, MovedToSuper);
1242  return;
1243  }
1244 
1245  // Check whether we have a matching method at this level.
1246  if (const ObjCMethodDecl *
1247  Overridden = Container->getMethod(Method->getSelector(),
1248  Method->isInstanceMethod(),
1249  /*AllowHidden=*/true))
1250  if (Method != Overridden) {
1251  // We found an override at this level; there is no need to look
1252  // into other protocols or categories.
1253  Methods.push_back(Overridden);
1254  return;
1255  }
1256 
1257  if (const auto *Protocol = dyn_cast<ObjCProtocolDecl>(Container)){
1258  for (const auto *P : Protocol->protocols())
1259  CollectOverriddenMethodsRecurse(P, Method, Methods, MovedToSuper);
1260  }
1261 
1262  if (const auto *Interface = dyn_cast<ObjCInterfaceDecl>(Container)) {
1263  for (const auto *P : Interface->protocols())
1264  CollectOverriddenMethodsRecurse(P, Method, Methods, MovedToSuper);
1265 
1266  for (const auto *Cat : Interface->known_categories())
1267  CollectOverriddenMethodsRecurse(Cat, Method, Methods, MovedToSuper);
1268 
1269  if (const ObjCInterfaceDecl *Super = Interface->getSuperClass())
1270  return CollectOverriddenMethodsRecurse(Super, Method, Methods,
1271  /*MovedToSuper=*/true);
1272  }
1273 }
1274 
1275 static inline void CollectOverriddenMethods(const ObjCContainerDecl *Container,
1276  const ObjCMethodDecl *Method,
1278  CollectOverriddenMethodsRecurse(Container, Method, Methods,
1279  /*MovedToSuper=*/false);
1280 }
1281 
1284  assert(Method->isOverriding());
1285 
1286  if (const auto *ProtD =
1287  dyn_cast<ObjCProtocolDecl>(Method->getDeclContext())) {
1288  CollectOverriddenMethods(ProtD, Method, overridden);
1289 
1290  } else if (const auto *IMD =
1291  dyn_cast<ObjCImplDecl>(Method->getDeclContext())) {
1292  const ObjCInterfaceDecl *ID = IMD->getClassInterface();
1293  if (!ID)
1294  return;
1295  // Start searching for overridden methods using the method from the
1296  // interface as starting point.
1297  if (const ObjCMethodDecl *IFaceMeth = ID->getMethod(Method->getSelector(),
1298  Method->isInstanceMethod(),
1299  /*AllowHidden=*/true))
1300  Method = IFaceMeth;
1301  CollectOverriddenMethods(ID, Method, overridden);
1302 
1303  } else if (const auto *CatD =
1304  dyn_cast<ObjCCategoryDecl>(Method->getDeclContext())) {
1305  const ObjCInterfaceDecl *ID = CatD->getClassInterface();
1306  if (!ID)
1307  return;
1308  // Start searching for overridden methods using the method from the
1309  // interface as starting point.
1310  if (const ObjCMethodDecl *IFaceMeth = ID->getMethod(Method->getSelector(),
1311  Method->isInstanceMethod(),
1312  /*AllowHidden=*/true))
1313  Method = IFaceMeth;
1314  CollectOverriddenMethods(ID, Method, overridden);
1315 
1316  } else {
1318  dyn_cast_or_null<ObjCContainerDecl>(Method->getDeclContext()),
1319  Method, overridden);
1320  }
1321 }
1322 
1324  SmallVectorImpl<const ObjCMethodDecl *> &Overridden) const {
1325  const ObjCMethodDecl *Method = this;
1326 
1327  if (Method->isRedeclaration()) {
1328  Method = cast<ObjCContainerDecl>(Method->getDeclContext())
1329  ->getMethod(Method->getSelector(), Method->isInstanceMethod(),
1330  /*AllowHidden=*/true);
1331  }
1332 
1333  if (Method->isOverriding()) {
1334  collectOverriddenMethodsSlow(Method, Overridden);
1335  assert(!Overridden.empty() &&
1336  "ObjCMethodDecl's overriding bit is not as expected");
1337  }
1338 }
1339 
1340 const ObjCPropertyDecl *
1341 ObjCMethodDecl::findPropertyDecl(bool CheckOverrides) const {
1342  Selector Sel = getSelector();
1343  unsigned NumArgs = Sel.getNumArgs();
1344  if (NumArgs > 1)
1345  return nullptr;
1346 
1347  if (isPropertyAccessor()) {
1348  const auto *Container = cast<ObjCContainerDecl>(getParent());
1349  // For accessor stubs, go back to the interface.
1350  if (auto *ImplDecl = dyn_cast<ObjCImplDecl>(Container))
1352  Container = ImplDecl->getClassInterface();
1353 
1354  bool IsGetter = (NumArgs == 0);
1355  bool IsInstance = isInstanceMethod();
1356 
1357  /// Local function that attempts to find a matching property within the
1358  /// given Objective-C container.
1359  auto findMatchingProperty =
1360  [&](const ObjCContainerDecl *Container) -> const ObjCPropertyDecl * {
1361  if (IsInstance) {
1362  for (const auto *I : Container->instance_properties()) {
1363  Selector NextSel = IsGetter ? I->getGetterName()
1364  : I->getSetterName();
1365  if (NextSel == Sel)
1366  return I;
1367  }
1368  } else {
1369  for (const auto *I : Container->class_properties()) {
1370  Selector NextSel = IsGetter ? I->getGetterName()
1371  : I->getSetterName();
1372  if (NextSel == Sel)
1373  return I;
1374  }
1375  }
1376 
1377  return nullptr;
1378  };
1379 
1380  // Look in the container we were given.
1381  if (const auto *Found = findMatchingProperty(Container))
1382  return Found;
1383 
1384  // If we're in a category or extension, look in the main class.
1385  const ObjCInterfaceDecl *ClassDecl = nullptr;
1386  if (const auto *Category = dyn_cast<ObjCCategoryDecl>(Container)) {
1387  ClassDecl = Category->getClassInterface();
1388  if (const auto *Found = findMatchingProperty(ClassDecl))
1389  return Found;
1390  } else {
1391  // Determine whether the container is a class.
1392  ClassDecl = cast<ObjCInterfaceDecl>(Container);
1393  }
1394  assert(ClassDecl && "Failed to find main class");
1395 
1396  // If we have a class, check its visible extensions.
1397  for (const auto *Ext : ClassDecl->visible_extensions()) {
1398  if (Ext == Container)
1399  continue;
1400  if (const auto *Found = findMatchingProperty(Ext))
1401  return Found;
1402  }
1403 
1404  assert(isSynthesizedAccessorStub() && "expected an accessor stub");
1405 
1406  for (const auto *Cat : ClassDecl->known_categories()) {
1407  if (Cat == Container)
1408  continue;
1409  if (const auto *Found = findMatchingProperty(Cat))
1410  return Found;
1411  }
1412 
1413  llvm_unreachable("Marked as a property accessor but no property found!");
1414  }
1415 
1416  if (!CheckOverrides)
1417  return nullptr;
1418 
1419  using OverridesTy = SmallVector<const ObjCMethodDecl *, 8>;
1420 
1421  OverridesTy Overrides;
1422  getOverriddenMethods(Overrides);
1423  for (const auto *Override : Overrides)
1424  if (const ObjCPropertyDecl *Prop = Override->findPropertyDecl(false))
1425  return Prop;
1426 
1427  return nullptr;
1428 }
1429 
1430 //===----------------------------------------------------------------------===//
1431 // ObjCTypeParamDecl
1432 //===----------------------------------------------------------------------===//
1433 
1434 void ObjCTypeParamDecl::anchor() {}
1435 
1437  ObjCTypeParamVariance variance,
1438  SourceLocation varianceLoc,
1439  unsigned index,
1440  SourceLocation nameLoc,
1442  SourceLocation colonLoc,
1443  TypeSourceInfo *boundInfo) {
1444  auto *TPDecl =
1445  new (ctx, dc) ObjCTypeParamDecl(ctx, dc, variance, varianceLoc, index,
1446  nameLoc, name, colonLoc, boundInfo);
1447  QualType TPType = ctx.getObjCTypeParamType(TPDecl, {});
1448  TPDecl->setTypeForDecl(TPType.getTypePtr());
1449  return TPDecl;
1450 }
1451 
1453  unsigned ID) {
1454  return new (ctx, ID) ObjCTypeParamDecl(ctx, nullptr,
1457  nullptr, SourceLocation(), nullptr);
1458 }
1459 
1461  SourceLocation startLoc = VarianceLoc;
1462  if (startLoc.isInvalid())
1463  startLoc = getLocation();
1464 
1465  if (hasExplicitBound()) {
1466  return SourceRange(startLoc,
1467  getTypeSourceInfo()->getTypeLoc().getEndLoc());
1468  }
1469 
1470  return SourceRange(startLoc);
1471 }
1472 
1473 //===----------------------------------------------------------------------===//
1474 // ObjCTypeParamList
1475 //===----------------------------------------------------------------------===//
1476 ObjCTypeParamList::ObjCTypeParamList(SourceLocation lAngleLoc,
1477  ArrayRef<ObjCTypeParamDecl *> typeParams,
1478  SourceLocation rAngleLoc)
1479  : Brackets(lAngleLoc, rAngleLoc), NumParams(typeParams.size()) {
1480  std::copy(typeParams.begin(), typeParams.end(), begin());
1481 }
1482 
1484  ASTContext &ctx,
1485  SourceLocation lAngleLoc,
1486  ArrayRef<ObjCTypeParamDecl *> typeParams,
1487  SourceLocation rAngleLoc) {
1488  void *mem =
1489  ctx.Allocate(totalSizeToAlloc<ObjCTypeParamDecl *>(typeParams.size()),
1490  alignof(ObjCTypeParamList));
1491  return new (mem) ObjCTypeParamList(lAngleLoc, typeParams, rAngleLoc);
1492 }
1493 
1495  SmallVectorImpl<QualType> &typeArgs) const {
1496  typeArgs.reserve(size());
1497  for (auto *typeParam : *this)
1498  typeArgs.push_back(typeParam->getUnderlyingType());
1499 }
1500 
1501 //===----------------------------------------------------------------------===//
1502 // ObjCInterfaceDecl
1503 //===----------------------------------------------------------------------===//
1504 
1506  DeclContext *DC,
1507  SourceLocation atLoc,
1508  IdentifierInfo *Id,
1509  ObjCTypeParamList *typeParamList,
1510  ObjCInterfaceDecl *PrevDecl,
1511  SourceLocation ClassLoc,
1512  bool isInternal){
1513  auto *Result = new (C, DC)
1514  ObjCInterfaceDecl(C, DC, atLoc, Id, typeParamList, ClassLoc, PrevDecl,
1515  isInternal);
1516  Result->Data.setInt(!C.getLangOpts().Modules);
1517  C.getObjCInterfaceType(Result, PrevDecl);
1518  return Result;
1519 }
1520 
1522  unsigned ID) {
1523  auto *Result = new (C, ID)
1524  ObjCInterfaceDecl(C, nullptr, SourceLocation(), nullptr, nullptr,
1525  SourceLocation(), nullptr, false);
1526  Result->Data.setInt(!C.getLangOpts().Modules);
1527  return Result;
1528 }
1529 
1530 ObjCInterfaceDecl::ObjCInterfaceDecl(const ASTContext &C, DeclContext *DC,
1532  ObjCTypeParamList *typeParamList,
1533  SourceLocation CLoc,
1534  ObjCInterfaceDecl *PrevDecl,
1535  bool IsInternal)
1536  : ObjCContainerDecl(ObjCInterface, DC, Id, CLoc, AtLoc),
1537  redeclarable_base(C) {
1538  setPreviousDecl(PrevDecl);
1539 
1540  // Copy the 'data' pointer over.
1541  if (PrevDecl)
1542  Data = PrevDecl->Data;
1543 
1544  setImplicit(IsInternal);
1545 
1546  setTypeParamList(typeParamList);
1547 }
1548 
1549 void ObjCInterfaceDecl::LoadExternalDefinition() const {
1550  assert(data().ExternallyCompleted && "Class is not externally completed");
1551  data().ExternallyCompleted = false;
1553  const_cast<ObjCInterfaceDecl *>(this));
1554 }
1555 
1557  assert(getASTContext().getExternalSource() &&
1558  "Class can't be externally completed without an external source");
1559  assert(hasDefinition() &&
1560  "Forward declarations can't be externally completed");
1561  data().ExternallyCompleted = true;
1562 }
1563 
1565  // Check for a complete definition and recover if not so.
1567  return;
1568  data().HasDesignatedInitializers = true;
1569 }
1570 
1572  // Check for a complete definition and recover if not so.
1574  return false;
1575  if (data().ExternallyCompleted)
1576  LoadExternalDefinition();
1577 
1578  return data().HasDesignatedInitializers;
1579 }
1580 
1581 StringRef
1583  if (const auto *ObjCRTName = getAttr<ObjCRuntimeNameAttr>())
1584  return ObjCRTName->getMetadataName();
1585 
1586  return getName();
1587 }
1588 
1589 StringRef
1591  if (ObjCInterfaceDecl *ID =
1592  const_cast<ObjCImplementationDecl*>(this)->getClassInterface())
1593  return ID->getObjCRuntimeNameAsString();
1594 
1595  return getName();
1596 }
1597 
1599  if (const ObjCInterfaceDecl *Def = getDefinition()) {
1600  if (data().ExternallyCompleted)
1601  LoadExternalDefinition();
1602 
1604  const_cast<ObjCInterfaceDecl*>(Def));
1605  }
1606 
1607  // FIXME: Should make sure no callers ever do this.
1608  return nullptr;
1609 }
1610 
1613 }
1614 
1615 namespace {
1616 
1617 struct SynthesizeIvarChunk {
1618  uint64_t Size;
1619  ObjCIvarDecl *Ivar;
1620 
1621  SynthesizeIvarChunk(uint64_t size, ObjCIvarDecl *ivar)
1622  : Size(size), Ivar(ivar) {}
1623 };
1624 
1625 bool operator<(const SynthesizeIvarChunk & LHS,
1626  const SynthesizeIvarChunk &RHS) {
1627  return LHS.Size < RHS.Size;
1628 }
1629 
1630 } // namespace
1631 
1632 /// all_declared_ivar_begin - return first ivar declared in this class,
1633 /// its extensions and its implementation. Lazily build the list on first
1634 /// access.
1635 ///
1636 /// Caveat: The list returned by this method reflects the current
1637 /// state of the parser. The cache will be updated for every ivar
1638 /// added by an extension or the implementation when they are
1639 /// encountered.
1640 /// See also ObjCIvarDecl::Create().
1642  // FIXME: Should make sure no callers ever do this.
1643  if (!hasDefinition())
1644  return nullptr;
1645 
1646  ObjCIvarDecl *curIvar = nullptr;
1647  if (!data().IvarList) {
1648  // Force ivar deserialization upfront, before building IvarList.
1649  (void)ivar_empty();
1650  for (const auto *Ext : known_extensions()) {
1651  (void)Ext->ivar_empty();
1652  }
1653  if (!ivar_empty()) {
1655  data().IvarList = *I; ++I;
1656  for (curIvar = data().IvarList; I != E; curIvar = *I, ++I)
1657  curIvar->setNextIvar(*I);
1658  }
1659 
1660  for (const auto *Ext : known_extensions()) {
1661  if (!Ext->ivar_empty()) {
1663  I = Ext->ivar_begin(),
1664  E = Ext->ivar_end();
1665  if (!data().IvarList) {
1666  data().IvarList = *I; ++I;
1667  curIvar = data().IvarList;
1668  }
1669  for ( ;I != E; curIvar = *I, ++I)
1670  curIvar->setNextIvar(*I);
1671  }
1672  }
1673  data().IvarListMissingImplementation = true;
1674  }
1675 
1676  // cached and complete!
1677  if (!data().IvarListMissingImplementation)
1678  return data().IvarList;
1679 
1680  if (ObjCImplementationDecl *ImplDecl = getImplementation()) {
1681  data().IvarListMissingImplementation = false;
1682  if (!ImplDecl->ivar_empty()) {
1684  for (auto *IV : ImplDecl->ivars()) {
1685  if (IV->getSynthesize() && !IV->isInvalidDecl()) {
1686  layout.push_back(SynthesizeIvarChunk(
1687  IV->getASTContext().getTypeSize(IV->getType()), IV));
1688  continue;
1689  }
1690  if (!data().IvarList)
1691  data().IvarList = IV;
1692  else
1693  curIvar->setNextIvar(IV);
1694  curIvar = IV;
1695  }
1696 
1697  if (!layout.empty()) {
1698  // Order synthesized ivars by their size.
1699  llvm::stable_sort(layout);
1700  unsigned Ix = 0, EIx = layout.size();
1701  if (!data().IvarList) {
1702  data().IvarList = layout[0].Ivar; Ix++;
1703  curIvar = data().IvarList;
1704  }
1705  for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++)
1706  curIvar->setNextIvar(layout[Ix].Ivar);
1707  }
1708  }
1709  }
1710  return data().IvarList;
1711 }
1712 
1713 /// FindCategoryDeclaration - Finds category declaration in the list of
1714 /// categories for this class and returns it. Name of the category is passed
1715 /// in 'CategoryId'. If category not found, return 0;
1716 ///
1719  // FIXME: Should make sure no callers ever do this.
1720  if (!hasDefinition())
1721  return nullptr;
1722 
1723  if (data().ExternallyCompleted)
1724  LoadExternalDefinition();
1725 
1726  for (auto *Cat : visible_categories())
1727  if (Cat->getIdentifier() == CategoryId)
1728  return Cat;
1729 
1730  return nullptr;
1731 }
1732 
1735  for (const auto *Cat : visible_categories()) {
1736  if (ObjCCategoryImplDecl *Impl = Cat->getImplementation())
1737  if (ObjCMethodDecl *MD = Impl->getInstanceMethod(Sel))
1738  return MD;
1739  }
1740 
1741  return nullptr;
1742 }
1743 
1745  for (const auto *Cat : visible_categories()) {
1746  if (ObjCCategoryImplDecl *Impl = Cat->getImplementation())
1747  if (ObjCMethodDecl *MD = Impl->getClassMethod(Sel))
1748  return MD;
1749  }
1750 
1751  return nullptr;
1752 }
1753 
1754 /// ClassImplementsProtocol - Checks that 'lProto' protocol
1755 /// has been implemented in IDecl class, its super class or categories (if
1756 /// lookupCategory is true).
1758  bool lookupCategory,
1759  bool RHSIsQualifiedID) {
1760  if (!hasDefinition())
1761  return false;
1762 
1763  ObjCInterfaceDecl *IDecl = this;
1764  // 1st, look up the class.
1765  for (auto *PI : IDecl->protocols()){
1766  if (getASTContext().ProtocolCompatibleWithProtocol(lProto, PI))
1767  return true;
1768  // This is dubious and is added to be compatible with gcc. In gcc, it is
1769  // also allowed assigning a protocol-qualified 'id' type to a LHS object
1770  // when protocol in qualified LHS is in list of protocols in the rhs 'id'
1771  // object. This IMO, should be a bug.
1772  // FIXME: Treat this as an extension, and flag this as an error when GCC
1773  // extensions are not enabled.
1774  if (RHSIsQualifiedID &&
1775  getASTContext().ProtocolCompatibleWithProtocol(PI, lProto))
1776  return true;
1777  }
1778 
1779  // 2nd, look up the category.
1780  if (lookupCategory)
1781  for (const auto *Cat : visible_categories()) {
1782  for (auto *PI : Cat->protocols())
1783  if (getASTContext().ProtocolCompatibleWithProtocol(lProto, PI))
1784  return true;
1785  }
1786 
1787  // 3rd, look up the super class(s)
1788  if (IDecl->getSuperClass())
1789  return
1790  IDecl->getSuperClass()->ClassImplementsProtocol(lProto, lookupCategory,
1791  RHSIsQualifiedID);
1792 
1793  return false;
1794 }
1795 
1796 //===----------------------------------------------------------------------===//
1797 // ObjCIvarDecl
1798 //===----------------------------------------------------------------------===//
1799 
1800 void ObjCIvarDecl::anchor() {}
1801 
1803  SourceLocation StartLoc,
1805  QualType T, TypeSourceInfo *TInfo,
1806  AccessControl ac, Expr *BW,
1807  bool synthesized) {
1808  if (DC) {
1809  // Ivar's can only appear in interfaces, implementations (via synthesized
1810  // properties), and class extensions (via direct declaration, or synthesized
1811  // properties).
1812  //
1813  // FIXME: This should really be asserting this:
1814  // (isa<ObjCCategoryDecl>(DC) &&
1815  // cast<ObjCCategoryDecl>(DC)->IsClassExtension()))
1816  // but unfortunately we sometimes place ivars into non-class extension
1817  // categories on error. This breaks an AST invariant, and should not be
1818  // fixed.
1819  assert((isa<ObjCInterfaceDecl>(DC) || isa<ObjCImplementationDecl>(DC) ||
1820  isa<ObjCCategoryDecl>(DC)) &&
1821  "Invalid ivar decl context!");
1822  // Once a new ivar is created in any of class/class-extension/implementation
1823  // decl contexts, the previously built IvarList must be rebuilt.
1824  auto *ID = dyn_cast<ObjCInterfaceDecl>(DC);
1825  if (!ID) {
1826  if (auto *IM = dyn_cast<ObjCImplementationDecl>(DC))
1827  ID = IM->getClassInterface();
1828  else
1829  ID = cast<ObjCCategoryDecl>(DC)->getClassInterface();
1830  }
1831  ID->setIvarList(nullptr);
1832  }
1833 
1834  return new (C, DC) ObjCIvarDecl(DC, StartLoc, IdLoc, Id, T, TInfo, ac, BW,
1835  synthesized);
1836 }
1837 
1839  return new (C, ID) ObjCIvarDecl(nullptr, SourceLocation(), SourceLocation(),
1840  nullptr, QualType(), nullptr,
1841  ObjCIvarDecl::None, nullptr, false);
1842 }
1843 
1845  auto *DC = cast<ObjCContainerDecl>(getDeclContext());
1846 
1847  switch (DC->getKind()) {
1848  default:
1849  case ObjCCategoryImpl:
1850  case ObjCProtocol:
1851  llvm_unreachable("invalid ivar container!");
1852 
1853  // Ivars can only appear in class extension categories.
1854  case ObjCCategory: {
1855  auto *CD = cast<ObjCCategoryDecl>(DC);
1856  assert(CD->IsClassExtension() && "invalid container for ivar!");
1857  return CD->getClassInterface();
1858  }
1859 
1860  case ObjCImplementation:
1861  return cast<ObjCImplementationDecl>(DC)->getClassInterface();
1862 
1863  case ObjCInterface:
1864  return cast<ObjCInterfaceDecl>(DC);
1865  }
1866 }
1867 
1869  return getType().substObjCMemberType(objectType, getDeclContext(),
1871 }
1872 
1873 //===----------------------------------------------------------------------===//
1874 // ObjCAtDefsFieldDecl
1875 //===----------------------------------------------------------------------===//
1876 
1877 void ObjCAtDefsFieldDecl::anchor() {}
1878 
1881  SourceLocation StartLoc, SourceLocation IdLoc,
1882  IdentifierInfo *Id, QualType T, Expr *BW) {
1883  return new (C, DC) ObjCAtDefsFieldDecl(DC, StartLoc, IdLoc, Id, T, BW);
1884 }
1885 
1887  unsigned ID) {
1888  return new (C, ID) ObjCAtDefsFieldDecl(nullptr, SourceLocation(),
1889  SourceLocation(), nullptr, QualType(),
1890  nullptr);
1891 }
1892 
1893 //===----------------------------------------------------------------------===//
1894 // ObjCProtocolDecl
1895 //===----------------------------------------------------------------------===//
1896 
1897 void ObjCProtocolDecl::anchor() {}
1898 
1899 ObjCProtocolDecl::ObjCProtocolDecl(ASTContext &C, DeclContext *DC,
1900  IdentifierInfo *Id, SourceLocation nameLoc,
1901  SourceLocation atStartLoc,
1902  ObjCProtocolDecl *PrevDecl)
1903  : ObjCContainerDecl(ObjCProtocol, DC, Id, nameLoc, atStartLoc),
1904  redeclarable_base(C) {
1905  setPreviousDecl(PrevDecl);
1906  if (PrevDecl)
1907  Data = PrevDecl->Data;
1908 }
1909 
1911  IdentifierInfo *Id,
1912  SourceLocation nameLoc,
1913  SourceLocation atStartLoc,
1914  ObjCProtocolDecl *PrevDecl) {
1915  auto *Result =
1916  new (C, DC) ObjCProtocolDecl(C, DC, Id, nameLoc, atStartLoc, PrevDecl);
1917  Result->Data.setInt(!C.getLangOpts().Modules);
1918  return Result;
1919 }
1920 
1922  unsigned ID) {
1923  ObjCProtocolDecl *Result =
1924  new (C, ID) ObjCProtocolDecl(C, nullptr, nullptr, SourceLocation(),
1925  SourceLocation(), nullptr);
1926  Result->Data.setInt(!C.getLangOpts().Modules);
1927  return Result;
1928 }
1929 
1931  return hasAttr<ObjCNonRuntimeProtocolAttr>();
1932 }
1933 
1936  std::queue<const ObjCProtocolDecl *> WorkQueue;
1937  WorkQueue.push(this);
1938 
1939  while (!WorkQueue.empty()) {
1940  const auto *PD = WorkQueue.front();
1941  WorkQueue.pop();
1942  for (const auto *Parent : PD->protocols()) {
1943  const auto *Can = Parent->getCanonicalDecl();
1944  auto Result = IPs.insert(Can);
1945  if (Result.second)
1946  WorkQueue.push(Parent);
1947  }
1948  }
1949 }
1950 
1952  ObjCProtocolDecl *PDecl = this;
1953 
1954  if (Name == getIdentifier())
1955  return PDecl;
1956 
1957  for (auto *I : protocols())
1958  if ((PDecl = I->lookupProtocolNamed(Name)))
1959  return PDecl;
1960 
1961  return nullptr;
1962 }
1963 
1964 // lookupMethod - Lookup a instance/class method in the protocol and protocols
1965 // it inherited.
1967  bool isInstance) const {
1968  ObjCMethodDecl *MethodDecl = nullptr;
1969 
1970  // If there is no definition or the definition is hidden, we don't find
1971  // anything.
1972  const ObjCProtocolDecl *Def = getDefinition();
1973  if (!Def || !Def->isUnconditionallyVisible())
1974  return nullptr;
1975 
1976  if ((MethodDecl = getMethod(Sel, isInstance)))
1977  return MethodDecl;
1978 
1979  for (const auto *I : protocols())
1980  if ((MethodDecl = I->lookupMethod(Sel, isInstance)))
1981  return MethodDecl;
1982  return nullptr;
1983 }
1984 
1985 void ObjCProtocolDecl::allocateDefinitionData() {
1986  assert(!Data.getPointer() && "Protocol already has a definition!");
1987  Data.setPointer(new (getASTContext()) DefinitionData);
1988  Data.getPointer()->Definition = this;
1989  Data.getPointer()->HasODRHash = false;
1990 }
1991 
1993  allocateDefinitionData();
1994 
1995  // Update all of the declarations with a pointer to the definition.
1996  for (auto *RD : redecls())
1997  RD->Data = this->Data;
1998 }
1999 
2001  Data.setPointer(nullptr);
2002  allocateDefinitionData();
2003  // Don't propagate data to other redeclarations.
2004 }
2005 
2007  const ObjCProtocolDecl *Definition) {
2008  Data = Definition->Data;
2009 }
2010 
2012  if (const ObjCProtocolDecl *PDecl = getDefinition()) {
2013  for (auto *Prop : PDecl->properties()) {
2014  // Insert into PM if not there already.
2015  PM.insert(std::make_pair(
2016  std::make_pair(Prop->getIdentifier(), Prop->isClassProperty()),
2017  Prop));
2018  }
2019  // Scan through protocol's protocols.
2020  for (const auto *PI : PDecl->protocols())
2021  PI->collectPropertiesToImplement(PM);
2022  }
2023 }
2024 
2026  const ObjCPropertyDecl *Property, ProtocolPropertySet &PS,
2027  PropertyDeclOrder &PO) const {
2028  if (const ObjCProtocolDecl *PDecl = getDefinition()) {
2029  if (!PS.insert(PDecl).second)
2030  return;
2031  for (auto *Prop : PDecl->properties()) {
2032  if (Prop == Property)
2033  continue;
2034  if (Prop->getIdentifier() == Property->getIdentifier()) {
2035  PO.push_back(Prop);
2036  return;
2037  }
2038  }
2039  // Scan through protocol's protocols which did not have a matching property.
2040  for (const auto *PI : PDecl->protocols())
2041  PI->collectInheritedProtocolProperties(Property, PS, PO);
2042  }
2043 }
2044 
2045 StringRef
2047  if (const auto *ObjCRTName = getAttr<ObjCRuntimeNameAttr>())
2048  return ObjCRTName->getMetadataName();
2049 
2050  return getName();
2051 }
2052 
2054  assert(hasDefinition() && "ODRHash only for records with definitions");
2055 
2056  // Previously calculated hash is stored in DefinitionData.
2057  if (hasODRHash())
2058  return data().ODRHash;
2059 
2060  // Only calculate hash on first call of getODRHash per record.
2061  ODRHash Hasher;
2063  data().ODRHash = Hasher.CalculateHash();
2064  setHasODRHash(true);
2065 
2066  return data().ODRHash;
2067 }
2068 
2069 bool ObjCProtocolDecl::hasODRHash() const {
2070  if (!hasDefinition())
2071  return false;
2072  return data().HasODRHash;
2073 }
2074 
2075 void ObjCProtocolDecl::setHasODRHash(bool HasHash) {
2076  assert(hasDefinition() && "Cannot set ODRHash without definition");
2077  data().HasODRHash = HasHash;
2078 }
2079 
2080 //===----------------------------------------------------------------------===//
2081 // ObjCCategoryDecl
2082 //===----------------------------------------------------------------------===//
2083 
2084 void ObjCCategoryDecl::anchor() {}
2085 
2086 ObjCCategoryDecl::ObjCCategoryDecl(DeclContext *DC, SourceLocation AtLoc,
2087  SourceLocation ClassNameLoc,
2088  SourceLocation CategoryNameLoc,
2090  ObjCTypeParamList *typeParamList,
2091  SourceLocation IvarLBraceLoc,
2092  SourceLocation IvarRBraceLoc)
2093  : ObjCContainerDecl(ObjCCategory, DC, Id, ClassNameLoc, AtLoc),
2094  ClassInterface(IDecl), CategoryNameLoc(CategoryNameLoc),
2095  IvarLBraceLoc(IvarLBraceLoc), IvarRBraceLoc(IvarRBraceLoc) {
2096  setTypeParamList(typeParamList);
2097 }
2098 
2100  SourceLocation AtLoc,
2101  SourceLocation ClassNameLoc,
2102  SourceLocation CategoryNameLoc,
2103  IdentifierInfo *Id,
2104  ObjCInterfaceDecl *IDecl,
2105  ObjCTypeParamList *typeParamList,
2106  SourceLocation IvarLBraceLoc,
2107  SourceLocation IvarRBraceLoc) {
2108  auto *CatDecl =
2109  new (C, DC) ObjCCategoryDecl(DC, AtLoc, ClassNameLoc, CategoryNameLoc, Id,
2110  IDecl, typeParamList, IvarLBraceLoc,
2111  IvarRBraceLoc);
2112  if (IDecl) {
2113  // Link this category into its class's category list.
2114  CatDecl->NextClassCategory = IDecl->getCategoryListRaw();
2115  if (IDecl->hasDefinition()) {
2116  IDecl->setCategoryListRaw(CatDecl);
2117  if (ASTMutationListener *L = C.getASTMutationListener())
2118  L->AddedObjCCategoryToInterface(CatDecl, IDecl);
2119  }
2120  }
2121 
2122  return CatDecl;
2123 }
2124 
2126  unsigned ID) {
2127  return new (C, ID) ObjCCategoryDecl(nullptr, SourceLocation(),
2129  nullptr, nullptr, nullptr);
2130 }
2131 
2134  const_cast<ObjCCategoryDecl*>(this));
2135 }
2136 
2138  getASTContext().setObjCImplementation(this, ImplD);
2139 }
2140 
2142  TypeParamList = TPL;
2143  if (!TPL)
2144  return;
2145  // Set the declaration context of each of the type parameters.
2146  for (auto *typeParam : *TypeParamList)
2147  typeParam->setDeclContext(this);
2148 }
2149 
2150 //===----------------------------------------------------------------------===//
2151 // ObjCCategoryImplDecl
2152 //===----------------------------------------------------------------------===//
2153 
2154 void ObjCCategoryImplDecl::anchor() {}
2155 
2158  IdentifierInfo *Id,
2159  ObjCInterfaceDecl *ClassInterface,
2160  SourceLocation nameLoc,
2161  SourceLocation atStartLoc,
2162  SourceLocation CategoryNameLoc) {
2163  if (ClassInterface && ClassInterface->hasDefinition())
2164  ClassInterface = ClassInterface->getDefinition();
2165  return new (C, DC) ObjCCategoryImplDecl(DC, Id, ClassInterface, nameLoc,
2166  atStartLoc, CategoryNameLoc);
2167 }
2168 
2170  unsigned ID) {
2171  return new (C, ID) ObjCCategoryImplDecl(nullptr, nullptr, nullptr,
2173  SourceLocation());
2174 }
2175 
2177  // The class interface might be NULL if we are working with invalid code.
2178  if (const ObjCInterfaceDecl *ID = getClassInterface())
2179  return ID->FindCategoryDeclaration(getIdentifier());
2180  return nullptr;
2181 }
2182 
2183 void ObjCImplDecl::anchor() {}
2184 
2186  // FIXME: The context should be correct before we get here.
2187  property->setLexicalDeclContext(this);
2188  addDecl(property);
2189 }
2190 
2192  ASTContext &Ctx = getASTContext();
2193 
2194  if (auto *ImplD = dyn_cast_or_null<ObjCImplementationDecl>(this)) {
2195  if (IFace)
2196  Ctx.setObjCImplementation(IFace, ImplD);
2197 
2198  } else if (auto *ImplD = dyn_cast_or_null<ObjCCategoryImplDecl>(this)) {
2200  Ctx.setObjCImplementation(CD, ImplD);
2201  }
2202 
2203  ClassInterface = IFace;
2204 }
2205 
2206 /// FindPropertyImplIvarDecl - This method lookup the ivar in the list of
2207 /// properties implemented in this \@implementation block and returns
2208 /// the implemented property that uses it.
2211  for (auto *PID : property_impls())
2212  if (PID->getPropertyIvarDecl() &&
2213  PID->getPropertyIvarDecl()->getIdentifier() == ivarId)
2214  return PID;
2215  return nullptr;
2216 }
2217 
2218 /// FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl
2219 /// added to the list of those properties \@synthesized/\@dynamic in this
2220 /// category \@implementation block.
2223  ObjCPropertyQueryKind QueryKind) const {
2224  ObjCPropertyImplDecl *ClassPropImpl = nullptr;
2225  for (auto *PID : property_impls())
2226  // If queryKind is unknown, we return the instance property if one
2227  // exists; otherwise we return the class property.
2228  if (PID->getPropertyDecl()->getIdentifier() == Id) {
2230  !PID->getPropertyDecl()->isClassProperty()) ||
2232  PID->getPropertyDecl()->isClassProperty()) ||
2234  !PID->getPropertyDecl()->isClassProperty()))
2235  return PID;
2236 
2237  if (PID->getPropertyDecl()->isClassProperty())
2238  ClassPropImpl = PID;
2239  }
2240 
2242  // We can't find the instance property, return the class property.
2243  return ClassPropImpl;
2244 
2245  return nullptr;
2246 }
2247 
2248 raw_ostream &clang::operator<<(raw_ostream &OS,
2249  const ObjCCategoryImplDecl &CID) {
2250  OS << CID.getName();
2251  return OS;
2252 }
2253 
2254 //===----------------------------------------------------------------------===//
2255 // ObjCImplementationDecl
2256 //===----------------------------------------------------------------------===//
2257 
2258 void ObjCImplementationDecl::anchor() {}
2259 
2262  ObjCInterfaceDecl *ClassInterface,
2263  ObjCInterfaceDecl *SuperDecl,
2264  SourceLocation nameLoc,
2265  SourceLocation atStartLoc,
2266  SourceLocation superLoc,
2267  SourceLocation IvarLBraceLoc,
2268  SourceLocation IvarRBraceLoc) {
2269  if (ClassInterface && ClassInterface->hasDefinition())
2270  ClassInterface = ClassInterface->getDefinition();
2271  return new (C, DC) ObjCImplementationDecl(DC, ClassInterface, SuperDecl,
2272  nameLoc, atStartLoc, superLoc,
2273  IvarLBraceLoc, IvarRBraceLoc);
2274 }
2275 
2278  return new (C, ID) ObjCImplementationDecl(nullptr, nullptr, nullptr,
2280 }
2281 
2283  CXXCtorInitializer ** initializers,
2284  unsigned numInitializers) {
2285  if (numInitializers > 0) {
2286  NumIvarInitializers = numInitializers;
2287  auto **ivarInitializers = new (C) CXXCtorInitializer*[NumIvarInitializers];
2288  memcpy(ivarInitializers, initializers,
2289  numInitializers * sizeof(CXXCtorInitializer*));
2290  IvarInitializers = ivarInitializers;
2291  }
2292 }
2293 
2296  return IvarInitializers.get(getASTContext().getExternalSource());
2297 }
2298 
2299 raw_ostream &clang::operator<<(raw_ostream &OS,
2300  const ObjCImplementationDecl &ID) {
2301  OS << ID.getName();
2302  return OS;
2303 }
2304 
2305 //===----------------------------------------------------------------------===//
2306 // ObjCCompatibleAliasDecl
2307 //===----------------------------------------------------------------------===//
2308 
2309 void ObjCCompatibleAliasDecl::anchor() {}
2310 
2313  SourceLocation L,
2314  IdentifierInfo *Id,
2315  ObjCInterfaceDecl* AliasedClass) {
2316  return new (C, DC) ObjCCompatibleAliasDecl(DC, L, Id, AliasedClass);
2317 }
2318 
2321  return new (C, ID) ObjCCompatibleAliasDecl(nullptr, SourceLocation(),
2322  nullptr, nullptr);
2323 }
2324 
2325 //===----------------------------------------------------------------------===//
2326 // ObjCPropertyDecl
2327 //===----------------------------------------------------------------------===//
2328 
2329 void ObjCPropertyDecl::anchor() {}
2330 
2332  SourceLocation L,
2333  IdentifierInfo *Id,
2334  SourceLocation AtLoc,
2335  SourceLocation LParenLoc,
2336  QualType T,
2337  TypeSourceInfo *TSI,
2338  PropertyControl propControl) {
2339  return new (C, DC) ObjCPropertyDecl(DC, L, Id, AtLoc, LParenLoc, T, TSI,
2340  propControl);
2341 }
2342 
2344  unsigned ID) {
2345  return new (C, ID) ObjCPropertyDecl(nullptr, SourceLocation(), nullptr,
2347  QualType(), nullptr, None);
2348 }
2349 
2351  return DeclType.substObjCMemberType(objectType, getDeclContext(),
2353 }
2354 
2356  return (PropertyAttributes & ObjCPropertyAttribute::kind_direct) &&
2357  !getASTContext().getLangOpts().ObjCDisableDirectMethodsForTesting;
2358 }
2359 
2360 //===----------------------------------------------------------------------===//
2361 // ObjCPropertyImplDecl
2362 //===----------------------------------------------------------------------===//
2363 
2365  DeclContext *DC,
2366  SourceLocation atLoc,
2367  SourceLocation L,
2368  ObjCPropertyDecl *property,
2369  Kind PK,
2370  ObjCIvarDecl *ivar,
2371  SourceLocation ivarLoc) {
2372  return new (C, DC) ObjCPropertyImplDecl(DC, atLoc, L, property, PK, ivar,
2373  ivarLoc);
2374 }
2375 
2377  unsigned ID) {
2378  return new (C, ID) ObjCPropertyImplDecl(nullptr, SourceLocation(),
2379  SourceLocation(), nullptr, Dynamic,
2380  nullptr, SourceLocation());
2381 }
2382 
2384  SourceLocation EndLoc = getLocation();
2385  if (IvarLoc.isValid())
2386  EndLoc = IvarLoc;
2387 
2388  return SourceRange(AtLoc, EndLoc);
2389 }
clang::ASTContext::setObjCImplementation
void setObjCImplementation(ObjCInterfaceDecl *IFaceD, ObjCImplementationDecl *ImplD)
Set the implementation of ObjCInterfaceDecl.
Definition: ASTContext.cpp:2960
clang::QualType::substObjCTypeArgs
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type.
Definition: Type.cpp:1485
clang::ObjCInterfaceDecl
Represents an ObjC class declaration.
Definition: DeclObjC.h:1148
clang::ObjCMethodDecl::setHasRedeclaration
void setHasRedeclaration(bool HRD) const
Definition: DeclObjC.h:275
clang::ObjCTypeParamDecl::hasExplicitBound
bool hasExplicitBound() const
Whether this type parameter has an explicitly-written type bound, e.g., "T : NSView".
Definition: DeclObjC.h:641
clang::ASTContext::getQualifiedType
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
Definition: ASTContext.h:2112
clang::ObjCInterfaceDecl::CreateDeserialized
static ObjCInterfaceDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:1521
clang::ObjCCompatibleAliasDecl
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition: DeclObjC.h:2740
clang::Decl::getASTContext
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:428
clang::ObjCPropertyDecl::getUsageType
QualType getUsageType(QualType objectType) const
Retrieve the type when this property is used with a specific base object type.
Definition: DeclObjC.cpp:2350
clang::ObjCMethodDecl::hasRedeclaration
bool hasRedeclaration() const
True if redeclared in the same interface.
Definition: DeclObjC.h:274
clang::OMF_autorelease
@ OMF_autorelease
Definition: IdentifierTable.h:713
clang::ObjCProtocolDecl::protocols
protocol_range protocols() const
Definition: DeclObjC.h:2125
clang::ObjCImplementationDecl::getName
StringRef getName() const
getName - Get the name of identifier for the class interface associated with this implementation as a...
Definition: DeclObjC.h:2686
clang::ObjCProtocolDecl::getODRHash
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
Definition: DeclObjC.cpp:2053
clang::DeclContext::specific_decl_iterator
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
Definition: DeclBase.h:2198
clang::ObjCContainerDecl::getProperty
ObjCPropertyDecl * getProperty(const IdentifierInfo *Id, bool IsInstance) const
Definition: DeclObjC.cpp:236
clang::ObjCIvarDecl::None
@ None
Definition: DeclObjC.h:1925
clang::ASTContext::getNSObjectName
IdentifierInfo * getNSObjectName() const
Retrieve the identifier 'NSObject'.
Definition: ASTContext.h:1858
clang::ObjCInterfaceDecl::setHasDesignatedInitializers
void setHasDesignatedInitializers()
Indicate that this interface decl contains at least one initializer marked with the 'objc_designated_...
Definition: DeclObjC.cpp:1564
clang::Decl::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclBase.h:428
clang::ObjCInterfaceDecl::lookupMethod
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,...
Definition: DeclObjC.cpp:690
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:210
clang::ObjCMethodFamily
ObjCMethodFamily
A family of Objective-C methods.
Definition: IdentifierTable.h:697
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1389
clang::ObjCPropertyAttribute::kind_direct
@ kind_direct
Definition: DeclObjCCommon.h:41
clang::ObjCImplementationDecl::init_const_iterator
CXXCtorInitializer *const * init_const_iterator
init_const_iterator - Iterates through the ivar initializer list.
Definition: DeclObjC.h:2622
clang::ObjCImplementationDecl
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2565
clang::ObjCMethodDecl::getSelfType
QualType getSelfType(ASTContext &Context, const ObjCInterfaceDecl *OID, bool &selfIsPseudoStrong, bool &selfIsConsumed) const
Definition: DeclObjC.cpp:1108
clang::ObjCTypeParamVariance::Invariant
@ Invariant
The parameter is invariant: must match exactly.
clang::ObjCTypeParamList::gatherDefaultTypeArgs
void gatherDefaultTypeArgs(SmallVectorImpl< QualType > &typeArgs) const
Gather the default set of type arguments to be substituted for these type parameters when dealing wit...
Definition: DeclObjC.cpp:1494
clang::ObjCImplementationDecl::init_begin
init_iterator init_begin()
init_begin() - Retrieve an iterator to the first initializer.
Definition: DeclObjC.h:2634
llvm::SmallVector
Definition: LLVM.h:38
clang::ObjCInterfaceDecl::setExternallyCompleted
void setExternallyCompleted()
Indicate that this Objective-C class is complete, but that the external AST source will be responsibl...
Definition: DeclObjC.cpp:1556
clang::IdentifierTable::get
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
Definition: IdentifierTable.h:597
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::OMF_None
@ OMF_None
No particular method family.
Definition: IdentifierTable.h:699
clang::ObjCInterfaceDecl::hasDesignatedInitializers
bool hasDesignatedInitializers() const
Returns true if this interface decl contains at least one initializer marked with the 'objc_designate...
Definition: DeclObjC.cpp:1571
clang::OMF_release
@ OMF_release
Definition: IdentifierTable.h:716
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::ObjCInterfaceDecl::ivar_begin
ivar_iterator ivar_begin() const
Definition: DeclObjC.h:1436
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:737
clang::ObjCProtocolDecl::Create
static ObjCProtocolDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, SourceLocation nameLoc, SourceLocation atStartLoc, ObjCProtocolDecl *PrevDecl)
Definition: DeclObjC.cpp:1910
clang::ObjCInterfaceDecl::isArcWeakrefUnavailable
bool isArcWeakrefUnavailable() const
isArcWeakrefUnavailable - Checks for a class or one of its super classes to be incompatible with __we...
Definition: DeclObjC.cpp:424
Attr.h
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:56
clang::TypedefNameDecl::getTypeSourceInfo
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:3325
clang::SelLoc_NonStandard
@ SelLoc_NonStandard
Non-standard.
Definition: SelectorLocationsKind.h:29
clang::OMF_finalize
@ OMF_finalize
Definition: IdentifierTable.h:715
clang::OMF_init
@ OMF_init
Definition: IdentifierTable.h:707
clang::ImplicitParamDecl::ObjCCmd
@ ObjCCmd
Parameter for Objective-C '_cmd' argument.
Definition: Decl.h:1657
clang::ObjCInterfaceDecl::getCategoryMethod
ObjCMethodDecl * getCategoryMethod(Selector Sel, bool isInstance) const
Definition: DeclObjC.h:1334
clang::LookupResult
Represents the results of name lookup.
Definition: Lookup.h:46
clang::Qualifiers
The collection of all-type qualifiers we support.
Definition: Type.h:147
clang::DeclListNode::iterator
Definition: DeclBase.h:1286
clang::ParmVarDecl
Represents a parameter to a function.
Definition: Decl.h:1712
clang::ObjCContainerDecl::instance_methods
instmeth_range instance_methods() const
Definition: DeclObjC.h:1028
memcpy
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Definition: __clang_cuda_device_functions.h:1549
clang::Type::isObjCSelType
bool isObjCSelType() const
Definition: Type.h:7056
clang::ObjCMethodDecl::getClassInterface
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.cpp:1174
clang::ObjCPropertyDecl::isDirectProperty
bool isDirectProperty() const
Definition: DeclObjC.cpp:2355
clang::OMF_retainCount
@ OMF_retainCount
Definition: IdentifierTable.h:718
clang::ObjCPropertyImplDecl
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2770
clang::ASTContext::getObjCMethodRedeclaration
const ObjCMethodDecl * getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const
Get the duplicate declaration of a ObjCMethod in the same interface, or null if none exists.
Definition: ASTContext.cpp:2974
clang::ObjCContainerDecl::HasUserDeclaredSetterMethod
bool HasUserDeclaredSetterMethod(const ObjCPropertyDecl *P) const
This routine returns 'true' if a user declared setter method was found in the class,...
Definition: DeclObjC.cpp:125
clang::ObjCContainerDecl::ProtocolPropertySet
llvm::SmallDenseSet< const ObjCProtocolDecl *, 8 > ProtocolPropertySet
Definition: DeclObjC.h:1083
clang::ObjCInterfaceDecl::visible_extensions
visible_extensions_range visible_extensions() const
Definition: DeclObjC.h:1699
clang::ObjCCompatibleAliasDecl::CreateDeserialized
static ObjCCompatibleAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:2320
clang::DeclContext::ObjCMethodDeclBits
ObjCMethodDeclBitfields ObjCMethodDeclBits
Definition: DeclBase.h:1862
clang::ObjCMethodDecl::isThisDeclarationADesignatedInitializer
bool isThisDeclarationADesignatedInitializer() const
Returns true if this specific method declaration is marked with the designated initializer attribute.
Definition: DeclObjC.cpp:839
clang::ObjCMethodDecl::Create
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, ImplementationControl impControl=None, bool HasRelatedResultType=false)
Definition: DeclObjC.cpp:816
clang::ObjCMethodDecl::isOverriding
bool isOverriding() const
Whether this method overrides any other in the class hierarchy.
Definition: DeclObjC.h:466
clang::ObjCMethodDecl::getNumSelectorLocs
unsigned getNumSelectorLocs() const
Definition: DeclObjC.h:309
clang::DeclContextLookupResult::begin
iterator begin()
Definition: DeclBase.h:1348
clang::ObjCInterfaceDecl::known_extensions
known_extensions_range known_extensions() const
Definition: DeclObjC.h:1737
clang::ObjCImplDecl::getClassInterface
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2453
isIntroducingInitializers
static bool isIntroducingInitializers(const ObjCInterfaceDecl *D)
Definition: DeclObjC.cpp:498
clang::ObjCMethodDecl::createImplicitParams
void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID)
createImplicitParams - Used to lazily create the self and cmd implicit parameters.
Definition: DeclObjC.cpp:1153
clang::ObjCIvarDecl::AccessControl
AccessControl
Definition: DeclObjC.h:1924
Decl.h
clang::ObjCImplementationDecl::setIvarInitializers
void setIvarInitializers(ASTContext &C, CXXCtorInitializer **initializers, unsigned numInitializers)
Definition: DeclObjC.cpp:2282
clang::ObjCObjectType
Represents a class type in Objective C.
Definition: Type.h:6014
DeclObjC.h
clang::ObjCIvarDecl::getContainingInterface
ObjCInterfaceDecl * getContainingInterface()
Return the class interface that this ivar is logically contained in; this is either the interface whe...
Definition: DeclObjC.cpp:1844
clang::ObjCCategoryDecl::setTypeParamList
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this category.
Definition: DeclObjC.cpp:2141
clang::ObjCInterfaceDecl::isThisDeclarationADefinition
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
Definition: DeclObjC.h:1506
clang::ObjCTypeParamDecl::Create
static ObjCTypeParamDecl * Create(ASTContext &ctx, DeclContext *dc, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, SourceLocation nameLoc, IdentifierInfo *name, SourceLocation colonLoc, TypeSourceInfo *boundInfo)
Definition: DeclObjC.cpp:1436
clang::OMF_copy
@ OMF_copy
Definition: IdentifierTable.h:706
clang::Redeclarable< ObjCInterfaceDecl >::setPreviousDecl
void setPreviousDecl(ObjCInterfaceDecl *PrevDecl)
Set the previous declaration.
Definition: Decl.h:4811
clang::ASTContext::Allocate
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:707
clang::ObjCMethodDecl::getReturnTypeSourceRange
SourceRange getReturnTypeSourceRange() const
Definition: DeclObjC.cpp:1194
clang::ObjCListBase::List
void ** List
List is an array of pointers to objects that are not owned by this object.
Definition: DeclObjC.h:63
clang::ObjCInterfaceDecl::getDesignatedInitializers
void getDesignatedInitializers(llvm::SmallVectorImpl< const ObjCMethodDecl * > &Methods) const
Returns the designated initializers for the interface.
Definition: DeclObjC.cpp:550
clang::ObjCInterfaceDecl::lookupNestedProtocol
ObjCProtocolDecl * lookupNestedProtocol(IdentifierInfo *Name)
Definition: DeclObjC.cpp:678
clang::ObjCProtocolDecl::collectInheritedProtocolProperties
void collectInheritedProtocolProperties(const ObjCPropertyDecl *Property, ProtocolPropertySet &PS, PropertyDeclOrder &PO) const
Definition: DeclObjC.cpp:2025
clang::ASTContext::getObjCIdType
QualType getObjCIdType() const
Represents the Objective-CC id type.
Definition: ASTContext.h:2019
clang::ASTContext::getExternalSource
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
Definition: ASTContext.h:1167
clang::ObjCInterfaceDecl::mergeClassExtensionProtocolList
void mergeClassExtensionProtocolList(ObjCProtocolDecl *const *List, unsigned Num, ASTContext &C)
mergeClassExtensionProtocolList - Merge class extension's protocol list into the protocol list for th...
Definition: DeclObjC.cpp:444
clang::ObjCMethodDecl::setMethodParams
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl * > Params, ArrayRef< SourceLocation > SelLocs=std::nullopt)
Sets the method's parameters and selector source locations.
Definition: DeclObjC.cpp:907
clang::ObjCInterfaceDecl::lookupInstanceMethod
ObjCMethodDecl * lookupInstanceMethod(Selector Sel) const
Lookup an instance method for a given selector.
Definition: DeclObjC.h:1822
clang::ast_matchers::attr
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
Definition: ASTMatchersInternal.cpp:1032
clang::Decl::Kind
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:86
clang::ObjCMethodDecl::setSelfDecl
void setSelfDecl(ImplicitParamDecl *SD)
Definition: DeclObjC.h:423
clang::InvalidObjCMethodFamily
@ InvalidObjCMethodFamily
Definition: IdentifierTable.h:731
clang::ObjCProtocolDecl::collectPropertiesToImplement
void collectPropertiesToImplement(PropertyMap &PM) const override
This routine collects list of properties to be implemented in the class.
Definition: DeclObjC.cpp:2011
clang::OMF_retain
@ OMF_retain
Definition: IdentifierTable.h:717
clang::QualType::getNonLValueExprType
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
Definition: Type.cpp:3126
clang::Decl::getKind
Kind getKind() const
Definition: DeclBase.h:435
clang::ObjCInterfaceDecl::getImplementation
ObjCImplementationDecl * getImplementation() const
Definition: DeclObjC.cpp:1598
clang::ASTContext::getObjCImplementation
ObjCImplementationDecl * getObjCImplementation(ObjCInterfaceDecl *D)
Get the implementation of the ObjCInterfaceDecl D, or nullptr if none exists.
Definition: ASTContext.cpp:2941
clang::ObjCMethodDecl::isDefined
bool isDefined() const
Definition: DeclObjC.h:456
Id
int Id
Definition: ASTDiff.cpp:189
clang::ObjCInterfaceDecl::protocols
protocol_range protocols() const
Definition: DeclObjC.h:1342
DeclBase.h
clang::ObjCCategoryImplDecl::CreateDeserialized
static ObjCCategoryImplDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:2169
clang::Qualifiers::OCL_Strong
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
Definition: Type.h:175
hlsl::uint64_t
unsigned long uint64_t
Definition: hlsl_basic_types.h:25
clang::ObjCInterfaceDecl::visible_categories
visible_categories_range visible_categories() const
Definition: DeclObjC.h:1629
clang::ObjCListBase::set
void set(void *const *InList, unsigned Elts, ASTContext &Ctx)
Definition: DeclObjC.cpp:46
clang::ObjCPropertyImplDecl::Create
static ObjCPropertyImplDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation atLoc, SourceLocation L, ObjCPropertyDecl *property, Kind PK, ObjCIvarDecl *ivarDecl, SourceLocation ivarLoc)
Definition: DeclObjC.cpp:2364
clang::ObjCInterfaceDecl::ClassImplementsProtocol
bool ClassImplementsProtocol(ObjCProtocolDecl *lProto, bool lookupCategory, bool RHSIsQualifiedID=false)
ClassImplementsProtocol - Checks that 'lProto' protocol has been implemented in IDecl class,...
Definition: DeclObjC.cpp:1757
clang::Type::isObjCIdType
bool isObjCIdType() const
Definition: Type.h:7044
clang::OMF_dealloc
@ OMF_dealloc
Definition: IdentifierTable.h:714
clang::ObjCMethodDecl::getMethodFamily
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
Definition: DeclObjC.cpp:1016
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:182
clang::ObjCSubstitutionContext::Result
@ Result
The result type of a method or function.
clang::SelLoc_StandardNoSpace
@ SelLoc_StandardNoSpace
For nullary selectors, immediately before the end: "[foo release]" / "-(void)release;" Or immediately...
Definition: SelectorLocationsKind.h:35
clang::ObjCInterfaceDecl::lookupPrivateMethod
ObjCMethodDecl * lookupPrivateMethod(const Selector &Sel, bool Instance=true) const
Lookup a method in the classes implementation hierarchy.
Definition: DeclObjC.cpp:747
LangOptions.h
clang::Selector::getNumArgs
unsigned getNumArgs() const
Definition: IdentifierTable.cpp:563
clang::ObjCContainerDecl::collectPropertiesToImplement
virtual void collectPropertiesToImplement(PropertyMap &PM) const
This routine collects list of properties to be implemented in the class.
Definition: DeclObjC.h:1089
clang::ObjCProtocolDecl::startDefinition
void startDefinition()
Starts the definition of this Objective-C protocol.
Definition: DeclObjC.cpp:1992
clang::ObjCMethodDecl::setIsRedeclaration
void setIsRedeclaration(bool RD)
Definition: DeclObjC.h:270
clang::ObjCMethodDecl::getSelector
Selector getSelector() const
Definition: DeclObjC.h:330
clang::ASTMutationListener
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Definition: ASTMutationListener.h:46
clang::ObjCCategoryDecl::getImplementation
ObjCCategoryImplDecl * getImplementation() const
Definition: DeclObjC.cpp:2132
clang::ObjCInterfaceDecl::lookupInstanceVariable
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
Definition: DeclObjC.cpp:628
clang::ObjCPropertyQueryKind::OBJC_PR_query_class
@ OBJC_PR_query_class
clang::ObjCMethodDecl::CreateDeserialized
static ObjCMethodDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:829
clang::ObjCMethodDecl::isDirectMethod
bool isDirectMethod() const
True if the method is tagged as objc_direct.
Definition: DeclObjC.cpp:834
clang::ASTContext::getObjCInterfaceType
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
Definition: ASTContext.cpp:5629
clang::ObjCCategoryDecl::setImplementation
void setImplementation(ObjCCategoryImplDecl *ImplD)
Definition: DeclObjC.cpp:2137
clang::ObjCAtDefsFieldDecl::CreateDeserialized
static ObjCAtDefsFieldDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:1886
clang::ObjCImplementationDecl::getObjCRuntimeNameAsString
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for class's metadata.
Definition: DeclObjC.cpp:1590
clang::ObjCInterfaceDecl::all_referenced_protocol_begin
all_protocol_iterator all_referenced_protocol_begin() const
Definition: DeclObjC.h:1405
clang::ObjCInterfaceDecl::getTypeParamList
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
Definition: DeclObjC.cpp:322
IdentifierTable.h
clang::ObjCImplDecl::addPropertyImplementation
void addPropertyImplementation(ObjCPropertyImplDecl *property)
Definition: DeclObjC.cpp:2185
clang::ObjCInterfaceDecl::getCategoryListRaw
ObjCCategoryDecl * getCategoryListRaw() const
Retrieve the raw pointer to the start of the category/extension list.
Definition: DeclObjC.h:1760
Type.h
clang::ObjCMethodDecl::setAsRedeclaration
void setAsRedeclaration(const ObjCMethodDecl *PrevMethod)
Definition: DeclObjC.cpp:876
llvm::SmallString< 128 >
clang::ObjCTypeParamDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclObjC.cpp:1460
CollectOverriddenMethodsRecurse
static void CollectOverriddenMethodsRecurse(const ObjCContainerDecl *Container, const ObjCMethodDecl *Method, SmallVectorImpl< const ObjCMethodDecl * > &Methods, bool MovedToSuper)
Definition: DeclObjC.cpp:1215
clang::Redeclarable< ObjCInterfaceDecl >::redecls
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Definition: Redeclarable.h:296
ASTContext.h
clang::ObjCMethodDecl::getReturnType
QualType getReturnType() const
Definition: DeclObjC.h:332
clang::ASTContext::getObjCClassType
QualType getObjCClassType() const
Represents the Objective-C Class type.
Definition: ASTContext.h:2041
Category
int Category
Definition: Format.cpp:2718
clang::ObjCProtocolDecl::lookupProtocolNamed
ObjCProtocolDecl * lookupProtocolNamed(IdentifierInfo *PName)
Definition: DeclObjC.cpp:1951
clang::ObjCListBase::NumElts
unsigned NumElts
Definition: DeclObjC.h:64
clang::ObjCInterfaceDecl::setTypeParamList
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this class.
Definition: DeclObjC.cpp:343
clang::ObjCTypeParamVariance
ObjCTypeParamVariance
Describes the variance of a given generic parameter.
Definition: DeclObjC.h:556
clang::ObjCCategoryImplDecl
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Definition: DeclObjC.h:2512
clang::ASTContext::setObjCMethodRedeclaration
void setObjCMethodRedeclaration(const ObjCMethodDecl *MD, const ObjCMethodDecl *Redecl)
Definition: ASTContext.cpp:2978
llvm::DenseSet
Definition: Sema.h:77
clang::ObjCContainerDecl::ObjCContainerDecl
ObjCContainerDecl(Kind DK, DeclContext *DC, IdentifierInfo *Id, SourceLocation nameLoc, SourceLocation atStartLoc)
Definition: DeclObjC.cpp:69
clang::ObjCMethodDecl::getSelectorLocs
void getSelectorLocs(SmallVectorImpl< SourceLocation > &SelLocs) const
Definition: DeclObjC.cpp:901
clang::ObjCContainerDecl::setAtStartLoc
void setAtStartLoc(SourceLocation Loc)
Definition: DeclObjC.h:1093
clang::ObjCInterfaceDecl::getTypeParamListAsWritten
ObjCTypeParamList * getTypeParamListAsWritten() const
Retrieve the type parameters written on this particular declaration of the class.
Definition: DeclObjC.h:1287
clang::ObjCMethodDecl::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclObjC.cpp:1010
clang::ObjCContainerDecl::getIvarDecl
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
Definition: DeclObjC.cpp:81
clang::ObjCInterfaceDecl::getCategoryClassMethod
ObjCMethodDecl * getCategoryClassMethod(Selector Sel) const
Definition: DeclObjC.cpp:1744
clang::ObjCMethodDecl::getReturnTypeSourceInfo
TypeSourceInfo * getReturnTypeSourceInfo() const
Definition: DeclObjC.h:346
clang::OMF_initialize
@ OMF_initialize
Definition: IdentifierTable.h:720
clang::operator<<
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
Definition: ASTContext.cpp:13391
clang::Decl::setImplicit
void setImplicit(bool I=true)
Definition: DeclBase.h:577
clang::ObjCContainerDecl::properties
prop_range properties() const
Definition: DeclObjC.h:962
clang::Selector::getMethodFamily
ObjCMethodFamily getMethodFamily() const
Derive the conventional family of this method.
Definition: IdentifierTable.h:883
clang::ObjCMethodDecl::getCanonicalDecl
ObjCMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclObjC.cpp:975
clang::OMF_self
@ OMF_self
Definition: IdentifierTable.h:719
clang::Decl::isImplicit
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:576
clang::Qualifiers::setObjCLifetime
void setObjCLifetime(ObjCLifetime type)
Definition: Type.h:355
clang::ODRHash
Definition: ODRHash.h:41
clang::ASTContext::getObjCTypeParamType
QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl, ArrayRef< ObjCProtocolDecl * > protocols) const
Definition: ASTContext.cpp:5490
clang::ObjCProtocolDecl::getObjCRuntimeNameAsString
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for protocol's metadata.
Definition: DeclObjC.cpp:2046
clang::ObjCInterfaceDecl::lookupInheritedClass
ObjCInterfaceDecl * lookupInheritedClass(const IdentifierInfo *ICName)
lookupInheritedClass - This method returns ObjCInterfaceDecl * of the super class whose name is passe...
Definition: DeclObjC.cpp:659
clang::ObjCCategoryDecl
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2293
clang::ObjCInterfaceDecl::isObjCRequiresPropertyDefs
const ObjCInterfaceDecl * isObjCRequiresPropertyDefs() const
isObjCRequiresPropertyDefs - Checks that a class or one of its super classes must not be auto-synthes...
Definition: DeclObjC.cpp:434
clang::ObjCImplementationDecl::CreateDeserialized
static ObjCImplementationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:2277
clang::ObjCProtocolDecl::mergeDuplicateDefinitionWithCommon
void mergeDuplicateDefinitionWithCommon(const ObjCProtocolDecl *Definition)
Definition: DeclObjC.cpp:2006
clang::OMF_performSelector
@ OMF_performSelector
Definition: IdentifierTable.h:723
clang::ObjCInterfaceDecl::ivar_empty
bool ivar_empty() const
Definition: DeclObjC.h:1456
clang::ObjCImplementationDecl::Create
static ObjCImplementationDecl * Create(ASTContext &C, DeclContext *DC, ObjCInterfaceDecl *classInterface, ObjCInterfaceDecl *superDecl, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation superLoc=SourceLocation(), SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
Definition: DeclObjC.cpp:2261
SourceLocation.h
clang::ast_matchers::decl
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
Definition: ASTMatchersInternal.cpp:735
clang::ObjCImplDecl::property_impls
propimpl_range property_impls() const
Definition: DeclObjC.h:2480
P
StringRef P
Definition: ASTMatchersInternal.cpp:564
clang::ObjCInterfaceDecl::getCategoryInstanceMethod
ObjCMethodDecl * getCategoryInstanceMethod(Selector Sel) const
Definition: DeclObjC.cpp:1734
clang::ObjCInterfaceDecl::setCategoryListRaw
void setCategoryListRaw(ObjCCategoryDecl *category)
Set the raw pointer to the start of the category/extension list.
Definition: DeclObjC.h:1773
clang::ObjCMethodDecl::getOverriddenMethods
void getOverriddenMethods(SmallVectorImpl< const ObjCMethodDecl * > &Overridden) const
Return overridden methods for the given Method.
Definition: DeclObjC.cpp:1323
clang::ObjCImplDecl::FindPropertyImplIvarDecl
ObjCPropertyImplDecl * FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const
FindPropertyImplIvarDecl - This method lookup the ivar in the list of properties implemented in this ...
Definition: DeclObjC.cpp:2210
clang::ObjCPropertyDecl::getDefaultSynthIvarName
IdentifierInfo * getDefaultSynthIvarName(ASTContext &Ctx) const
Get the default name of the synthesized ivar.
Definition: DeclObjC.cpp:227
clang::ObjCPropertyQueryKind::OBJC_PR_query_unknown
@ OBJC_PR_query_unknown
clang::ObjCInterfaceDecl::all_referenced_protocol_end
all_protocol_iterator all_referenced_protocol_end() const
Definition: DeclObjC.h:1418
clang::QualType::substObjCMemberType
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...
Definition: Type.cpp:1492
clang::ExternalASTSource::CompleteType
virtual void CompleteType(TagDecl *Tag)
Gives the external AST source an opportunity to complete an incomplete type.
Definition: ExternalASTSource.cpp:49
clang::NamedDecl::getIdentifier
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:268
clang::hasStandardSelectorLocs
SelectorLocationsKind hasStandardSelectorLocs(Selector Sel, ArrayRef< SourceLocation > SelLocs, ArrayRef< Expr * > Args, SourceLocation EndLoc)
Returns true if all SelLocs are in a "standard" location.
Definition: SelectorLocationsKind.cpp:96
clang::DeclContext::addDecl
void addDecl(Decl *D)
Add the declaration D into this context.
Definition: DeclBase.cpp:1607
clang::ASTContext::Idents
IdentifierTable & Idents
Definition: ASTContext.h:633
clang::ObjCPropertyDecl::CreateDeserialized
static ObjCPropertyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:2343
clang::DeclContext::getParent
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1923
clang::ObjCInterfaceDecl::getSuperClassType
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
Definition: DeclObjC.h:1541
clang::ObjCMethodDecl::isSynthesizedAccessorStub
bool isSynthesizedAccessorStub() const
Definition: DeclObjC.h:448
clang::ObjCPropertyDecl::None
@ None
Definition: DeclObjC.h:736
llvm::ArrayRef
Definition: LLVM.h:34
clang::ObjCCompatibleAliasDecl::Create
static ObjCCompatibleAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, ObjCInterfaceDecl *aliasedClass)
Definition: DeclObjC.cpp:2312
clang::ObjCPropertyQueryKind
ObjCPropertyQueryKind
Definition: DeclObjC.h:719
clang::ObjCPropertyDecl
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:731
collectOverriddenMethodsSlow
static void collectOverriddenMethodsSlow(const ObjCMethodDecl *Method, SmallVectorImpl< const ObjCMethodDecl * > &overridden)
Definition: DeclObjC.cpp:1282
clang::ObjCMethodDecl::isInstanceMethod
bool isInstanceMethod() const
Definition: DeclObjC.h:430
clang::ObjCCategoryImplDecl::getCategoryDecl
ObjCCategoryDecl * getCategoryDecl() const
Definition: DeclObjC.cpp:2176
ASTMutationListener.h
clang::ObjCContainerDecl::getMethod
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
Definition: DeclObjC.cpp:93
clang::ObjCMethodDecl::definedInNSObject
bool definedInNSObject(const ASTContext &) const
Is this method defined in the NSObject base class?
Definition: DeclObjC.cpp:844
clang::ObjCInterfaceDecl::hasDefinition
bool hasDefinition() const
Determine whether this class has been defined.
Definition: DeclObjC.h:1511
clang::ObjCTypeParamList::size
unsigned size() const
Determine the number of type parameters in this list.
Definition: DeclObjC.h:687
clang::ObjCMethodDecl::getSelectorLoc
SourceLocation getSelectorLoc(unsigned Index) const
Definition: DeclObjC.h:297
LLVM.h
clang::DeclContextLookupResult::end
iterator end()
Definition: DeclBase.h:1349
clang::ObjCPropertyImplDecl::Dynamic
@ Dynamic
Definition: DeclObjC.h:2774
clang::ObjCInterfaceDecl::getSuperClass
ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.cpp:352
clang::ObjCAtDefsFieldDecl::Create
static ObjCAtDefsFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, Expr *BW)
Definition: DeclObjC.cpp:1880
clang::ASTContext::getObjCSelType
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
Definition: ASTContext.h:2029
clang::ObjCInterfaceDecl::setImplementation
void setImplementation(ObjCImplementationDecl *ImplD)
Definition: DeclObjC.cpp:1611
clang::ImplicitParamDecl::ObjCSelf
@ ObjCSelf
Parameter for Objective-C 'self' argument.
Definition: Decl.h:1654
clang::Redeclarable< ObjCInterfaceDecl >::getMostRecentDecl
ObjCInterfaceDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
Definition: Redeclarable.h:226
clang::ObjCAtDefsFieldDecl
Represents a field declaration created by an @defs(...).
Definition: DeclObjC.h:1997
clang::ObjCIvarDecl::setNextIvar
void setNextIvar(ObjCIvarDecl *ivar)
Definition: DeclObjC.h:1958
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:85
clang::ObjCCategoryDecl::CreateDeserialized
static ObjCCategoryDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:2125
ODRHash.h
clang::OMF_new
@ OMF_new
Definition: IdentifierTable.h:709
clang::ObjCInterfaceDecl::getCanonicalDecl
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
Definition: DeclObjC.h:1890
clang::ObjCInterfaceDecl::FindPropertyVisibleInPrimaryClass
ObjCPropertyDecl * FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyVisibleInPrimaryClass - Finds declaration of the property with name 'PropertyId' in the p...
Definition: DeclObjC.cpp:383
clang::ObjCTypeParamDecl
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:581
clang::ObjCMethodDecl::getBody
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
Definition: DeclObjC.cpp:872
clang::ObjCProtocolDecl::CreateDeserialized
static ObjCProtocolDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:1921
clang::LazyOffsetPtr::get
T * get(ExternalASTSource *Source) const
Retrieve the pointer to the AST node that this lazy pointer points to.
Definition: ExternalASTSource.h:374
clang::ObjCMethodDecl
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:139
clang::Decl::isUnconditionallyVisible
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
Definition: DeclBase.h:824
clang::ObjCImplDecl::FindPropertyImplDecl
ObjCPropertyImplDecl * FindPropertyImplDecl(IdentifierInfo *propertyId, ObjCPropertyQueryKind queryKind) const
FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl added to the list of thos...
Definition: DeclObjC.cpp:2222
clang::ObjCMethodDecl::param_type_begin
param_type_iterator param_type_begin() const
Definition: DeclObjC.h:403
clang::ObjCPropertyQueryKind::OBJC_PR_query_instance
@ OBJC_PR_query_instance
clang::ObjCInterfaceDecl::FindCategoryDeclaration
ObjCCategoryDecl * FindCategoryDeclaration(IdentifierInfo *CategoryId) const
FindCategoryDeclaration - Finds category declaration in the list of categories for this class and ret...
Definition: DeclObjC.cpp:1718
clang::ObjCPropertyAttribute::kind_readwrite
@ kind_readwrite
Definition: DeclObjCCommon.h:27
clang::ObjCImplDecl::setClassInterface
void setClassInterface(ObjCInterfaceDecl *IFace)
Definition: DeclObjC.cpp:2191
clang::ImplicitParamDecl::Create
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
Definition: Decl.cpp:5030
clang::ObjCMethodDecl::findPropertyDecl
const ObjCPropertyDecl * findPropertyDecl(bool CheckOverrides=true) const
Returns the property associated with this method's selector.
Definition: DeclObjC.cpp:1341
clang::IdentifierInfo::getName
StringRef getName() const
Return the actual identifier string.
Definition: IdentifierTable.h:196
clang::ObjCInterfaceDecl::known_categories
known_categories_range known_categories() const
Definition: DeclObjC.h:1663
clang::Builtin::ID
ID
Definition: Builtins.h:52
clang::SourceLocation::isInvalid
bool isInvalid() const
Definition: SourceLocation.h:111
clang::ObjCTypeParamList
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition: DeclObjC.h:659
clang::ObjCIvarDecl::Create
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)
Definition: DeclObjC.cpp:1802
clang
Definition: CalledOnceCheck.h:17
clang::ObjCContainerDecl::getInstanceMethod
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
Definition: DeclObjC.h:1061
clang::DeclContext::lookup
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Definition: DeclBase.cpp:1693
clang::Selector
Smart pointer class that efficiently represents Objective-C method names.
Definition: IdentifierTable.h:759
clang::ObjCMethodDecl::isDesignatedInitializerForTheInterface
bool isDesignatedInitializerForTheInterface(const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the method selector resolves to a designated initializer in the class's interface.
Definition: DeclObjC.cpp:852
clang::ObjCInterfaceDecl::getSuperClassTInfo
TypeSourceInfo * getSuperClassTInfo() const
Definition: DeclObjC.h:1549
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:71
clang::ObjCIvarDecl
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1920
clang::QualType::withConst
QualType withConst() const
Definition: Type.h:914
clang::ObjCProtocolDecl::isNonRuntimeProtocol
bool isNonRuntimeProtocol() const
This is true iff the protocol is tagged with the objc_non_runtime_protocol attribute.
Definition: DeclObjC.cpp:1930
clang::ODRHash::AddObjCProtocolDecl
void AddObjCProtocolDecl(const ObjCProtocolDecl *P)
Definition: ODRHash.cpp:703
clang::ObjCInterfaceDecl::ivar_end
ivar_iterator ivar_end() const
Definition: DeclObjC.h:1444
clang::OMF_alloc
@ OMF_alloc
Definition: IdentifierTable.h:705
clang::operator<
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
Definition: DeclarationName.h:549
clang::ObjCProtocolDecl
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2049
clang::SourceLocation::isValid
bool isValid() const
Return true if this is a valid SourceLocation object.
Definition: SourceLocation.h:110
clang::OMF_mutableCopy
@ OMF_mutableCopy
Definition: IdentifierTable.h:708
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6593
clang::ObjCSubstitutionContext::Property
@ Property
The type of a property.
clang::ObjCContainerDecl::FindPropertyDeclaration
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
Definition: DeclObjC.cpp:250
clang::ObjCMethodDecl::hasParamDestroyedInCallee
bool hasParamDestroyedInCallee() const
True if the method has a parameter that's destroyed in the callee.
Definition: DeclObjC.cpp:864
clang::ObjCProtocolDecl::lookupMethod
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance) const
Definition: DeclObjC.cpp:1966
clang::ObjCInterfaceDecl::all_referenced_protocols
all_protocol_range all_referenced_protocols() const
Definition: DeclObjC.h:1400
clang::ObjCInterfaceDecl::all_declared_ivar_begin
ObjCIvarDecl * all_declared_ivar_begin()
all_declared_ivar_begin - return first ivar declared in this class, its extensions and its implementa...
Definition: DeclObjC.cpp:1641
clang::ObjCContainerDecl
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:943
clang::DeclContextLookupResult
The results of name lookup within a DeclContext.
Definition: DeclBase.h:1334
clang::ObjCTypeParamList::create
static ObjCTypeParamList * create(ASTContext &ctx, SourceLocation lAngleLoc, ArrayRef< ObjCTypeParamDecl * > typeParams, SourceLocation rAngleLoc)
Create a new Objective-C type parameter list.
Definition: DeclObjC.cpp:1483
clang::ObjCMethodDecl::isPropertyAccessor
bool isPropertyAccessor() const
Definition: DeclObjC.h:440
clang::QualType::getTypePtr
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:6622
clang::ObjCMethodDecl::parameters
ArrayRef< ParmVarDecl * > parameters() const
Definition: DeclObjC.h:376
Parent
NodeId Parent
Definition: ASTDiff.cpp:190
clang::ObjCIvarDecl::CreateDeserialized
static ObjCIvarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:1838
clang::ObjCMethodDecl::isRedeclaration
bool isRedeclaration() const
True if this is a method redeclaration in the same interface.
Definition: DeclObjC.h:269
clang::ObjCInterfaceDecl::getSuperClassLoc
SourceLocation getSuperClassLoc() const
Retrieve the starting location of the superclass.
Definition: DeclObjC.cpp:372
Stmt.h
clang::ODRHash::CalculateHash
unsigned CalculateHash()
Definition: ODRHash.cpp:208
clang::ObjCCategoryDecl::Create
static ObjCCategoryDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation AtLoc, SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc, IdentifierInfo *Id, ObjCInterfaceDecl *IDecl, ObjCTypeParamList *typeParamList, SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
Definition: DeclObjC.cpp:2099
llvm::SmallVectorImpl
Definition: Randstruct.h:18
clang::ObjCMethodDecl::getCategory
ObjCCategoryDecl * getCategory()
If this method is declared or implemented in a category, return that category.
Definition: DeclObjC.cpp:1186
clang::ObjCTypeParamDecl::CreateDeserialized
static ObjCTypeParamDecl * CreateDeserialized(ASTContext &ctx, unsigned ID)
Definition: DeclObjC.cpp:1452
clang::ObjCIvarDecl::getUsageType
QualType getUsageType(QualType objectType) const
Retrieve the type of this instance variable when viewed as a member of a specific object type.
Definition: DeclObjC.cpp:1868
clang::ValueDecl::getType
QualType getType() const
Definition: Decl.h:712
clang::ObjCPropertyDecl::PropertyControl
PropertyControl
Definition: DeclObjC.h:736
clang::ObjCMethodDecl::ImplementationControl
ImplementationControl
Definition: DeclObjC.h:144
clang::ObjCProtocolDecl::getImpliedProtocols
void getImpliedProtocols(llvm::DenseSet< const ObjCProtocolDecl * > &IPs) const
Get the set of all protocols implied by this protocols inheritance hierarchy.
Definition: DeclObjC.cpp:1934
CollectOverriddenMethods
static void CollectOverriddenMethods(const ObjCContainerDecl *Container, const ObjCMethodDecl *Method, SmallVectorImpl< const ObjCMethodDecl * > &Methods)
Definition: DeclObjC.cpp:1275
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::ObjCPropertyImplDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclObjC.cpp:2383
clang::ObjCInterfaceDecl::isDesignatedInitializer
bool isDesignatedInitializer(Selector Sel, const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the given selector is a designated initializer for the interface.
Definition: DeclObjC.cpp:572
clang::ObjCMethodDecl::setCmdDecl
void setCmdDecl(ImplicitParamDecl *CD)
Definition: DeclObjC.h:425
clang::CXXCtorInitializer
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2207
clang::transformer::name
RangeSelector name(std::string ID)
Given a node with a "name", (like NamedDecl, DeclRefExpr, CxxCtorInitializer, and TypeLoc) selects th...
Definition: RangeSelector.cpp:200
clang::ObjCMethodDecl::isClassMethod
bool isClassMethod() const
Definition: DeclObjC.h:438
clang::ASTContext::getObjCObjectPointerType
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
Definition: ASTContext.cpp:5599
clang::Decl::getLocation
SourceLocation getLocation() const
Definition: DeclBase.h:432
clang::ObjCPropertyImplDecl::CreateDeserialized
static ObjCPropertyImplDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:2376
clang::ObjCProtocolDecl::hasDefinition
bool hasDefinition() const
Determine whether this protocol has a definition.
Definition: DeclObjC.h:2202
clang::ObjCInterfaceDecl::startDefinition
void startDefinition()
Starts the definition of this Objective-C class, taking it from a forward declaration (@class) to a d...
Definition: DeclObjC.cpp:618
clang::ObjCList< ObjCProtocolDecl >
clang::ObjCMethodDecl::getSendResultType
QualType getSendResultType() const
Determine the type of an expression that sends a message to this function.
Definition: DeclObjC.cpp:1201
clang::ObjCPropertyDecl::findPropertyDecl
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
Definition: DeclObjC.cpp:179
clang::ASTContext::getLangOpts
const LangOptions & getLangOpts() const
Definition: ASTContext.h:764
clang::ObjCProtocolList::set
void set(ObjCProtocolDecl *const *InList, unsigned Elts, const SourceLocation *Locs, ASTContext &Ctx)
Definition: DeclObjC.cpp:55
clang::ObjCPropertyDecl::Create
static ObjCPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, SourceLocation AtLocation, SourceLocation LParenLocation, QualType T, TypeSourceInfo *TSI, PropertyControl propControl=None)
Definition: DeclObjC.cpp:2331
clang::ObjCInterfaceDecl::Create
static ObjCInterfaceDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, ObjCTypeParamList *typeParamList, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc=SourceLocation(), bool isInternal=false)
Definition: DeclObjC.cpp:1505
clang::ObjCProtocolDecl::getDefinition
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
Definition: DeclObjC.h:2214
clang::ObjCInterfaceDecl::collectPropertiesToImplement
void collectPropertiesToImplement(PropertyMap &PM) const override
This routine collects list of properties to be implemented in the class.
Definition: DeclObjC.cpp:407
clang::Decl::OBJC_TQ_None
@ OBJC_TQ_None
Definition: DeclBase.h:196
clang::ObjCMethodDecl::isVariadic
bool isVariadic() const
Definition: DeclObjC.h:435
clang::ObjCMethodDecl::param_type_iterator
llvm::mapped_iterator< param_const_iterator, GetTypeFn > param_type_iterator
Definition: DeclObjC.h:401
clang::ObjCProtocolDecl::startDuplicateDefinitionForComparison
void startDuplicateDefinitionForComparison()
Starts the definition without sharing it with other redeclarations.
Definition: DeclObjC.cpp:2000
clang::ObjCMethodDecl::param_size
unsigned param_size() const
Definition: DeclObjC.h:350
TypeLoc.h
clang::ObjCInterfaceDecl::getDefinition
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
Definition: DeclObjC.h:1525
clang::ObjCContainerDecl::PropertyMap
llvm::MapVector< std::pair< IdentifierInfo *, unsigned >, ObjCPropertyDecl * > PropertyMap
Definition: DeclObjC.h:1082
clang::Decl::getDeclContext
DeclContext * getDeclContext()
Definition: DeclBase.h:441
clang::ObjCInterfaceDecl::getObjCRuntimeNameAsString
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for class's metadata.
Definition: DeclObjC.cpp:1582
clang::ObjCCategoryImplDecl::Create
static ObjCCategoryImplDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, ObjCInterfaceDecl *classInterface, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation CategoryNameLoc)
Definition: DeclObjC.cpp:2157
clang::NamedDecl::getName
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:274