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