clang  3.8.0
DeclCXX.cpp
Go to the documentation of this file.
1 //===--- DeclCXX.cpp - C++ Declaration AST Node Implementation ------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the C++ related Decl classes.
11 //
12 //===----------------------------------------------------------------------===//
13 #include "clang/AST/DeclCXX.h"
14 #include "clang/AST/ASTContext.h"
15 #include "clang/AST/ASTLambda.h"
18 #include "clang/AST/DeclTemplate.h"
19 #include "clang/AST/Expr.h"
20 #include "clang/AST/ExprCXX.h"
21 #include "clang/AST/TypeLoc.h"
23 #include "llvm/ADT/STLExtras.h"
24 #include "llvm/ADT/SmallPtrSet.h"
25 using namespace clang;
26 
27 //===----------------------------------------------------------------------===//
28 // Decl Allocation/Deallocation Method Implementations
29 //===----------------------------------------------------------------------===//
30 
31 void AccessSpecDecl::anchor() { }
32 
34  return new (C, ID) AccessSpecDecl(EmptyShell());
35 }
36 
37 void LazyASTUnresolvedSet::getFromExternalSource(ASTContext &C) const {
39  assert(Impl.Decls.isLazy() && "getFromExternalSource for non-lazy set");
40  assert(Source && "getFromExternalSource with no external source");
41 
42  for (ASTUnresolvedSet::iterator I = Impl.begin(); I != Impl.end(); ++I)
43  I.setDecl(cast<NamedDecl>(Source->GetExternalDecl(
44  reinterpret_cast<uintptr_t>(I.getDecl()) >> 2)));
45  Impl.Decls.setLazy(false);
46 }
47 
48 CXXRecordDecl::DefinitionData::DefinitionData(CXXRecordDecl *D)
49  : UserDeclaredConstructor(false), UserDeclaredSpecialMembers(0),
50  Aggregate(true), PlainOldData(true), Empty(true), Polymorphic(false),
51  Abstract(false), IsStandardLayout(true), HasNoNonEmptyBases(true),
52  HasPrivateFields(false), HasProtectedFields(false), HasPublicFields(false),
53  HasMutableFields(false), HasVariantMembers(false), HasOnlyCMembers(true),
54  HasInClassInitializer(false), HasUninitializedReferenceMember(false),
55  NeedOverloadResolutionForMoveConstructor(false),
56  NeedOverloadResolutionForMoveAssignment(false),
57  NeedOverloadResolutionForDestructor(false),
58  DefaultedMoveConstructorIsDeleted(false),
59  DefaultedMoveAssignmentIsDeleted(false),
60  DefaultedDestructorIsDeleted(false),
61  HasTrivialSpecialMembers(SMF_All),
62  DeclaredNonTrivialSpecialMembers(0),
63  HasIrrelevantDestructor(true),
64  HasConstexprNonCopyMoveConstructor(false),
65  DefaultedDefaultConstructorIsConstexpr(true),
66  HasConstexprDefaultConstructor(false),
67  HasNonLiteralTypeFieldsOrBases(false), ComputedVisibleConversions(false),
68  UserProvidedDefaultConstructor(false), DeclaredSpecialMembers(0),
69  ImplicitCopyConstructorHasConstParam(true),
70  ImplicitCopyAssignmentHasConstParam(true),
71  HasDeclaredCopyConstructorWithConstParam(false),
72  HasDeclaredCopyAssignmentWithConstParam(false),
73  IsLambda(false), IsParsingBaseSpecifiers(false), NumBases(0), NumVBases(0),
74  Bases(), VBases(),
75  Definition(D), FirstFriend() {
76 }
77 
78 CXXBaseSpecifier *CXXRecordDecl::DefinitionData::getBasesSlowCase() const {
79  return Bases.get(Definition->getASTContext().getExternalSource());
80 }
81 
82 CXXBaseSpecifier *CXXRecordDecl::DefinitionData::getVBasesSlowCase() const {
83  return VBases.get(Definition->getASTContext().getExternalSource());
84 }
85 
87  DeclContext *DC, SourceLocation StartLoc,
88  SourceLocation IdLoc, IdentifierInfo *Id,
89  CXXRecordDecl *PrevDecl)
90  : RecordDecl(K, TK, C, DC, StartLoc, IdLoc, Id, PrevDecl),
91  DefinitionData(PrevDecl ? PrevDecl->DefinitionData
92  : DefinitionDataPtr(this)),
93  TemplateOrInstantiation() {}
94 
96  DeclContext *DC, SourceLocation StartLoc,
97  SourceLocation IdLoc, IdentifierInfo *Id,
98  CXXRecordDecl* PrevDecl,
99  bool DelayTypeCreation) {
100  CXXRecordDecl *R = new (C, DC) CXXRecordDecl(CXXRecord, TK, C, DC, StartLoc,
101  IdLoc, Id, PrevDecl);
102  R->MayHaveOutOfDateDef = C.getLangOpts().Modules;
103 
104  // FIXME: DelayTypeCreation seems like such a hack
105  if (!DelayTypeCreation)
106  C.getTypeDeclType(R, PrevDecl);
107  return R;
108 }
109 
112  TypeSourceInfo *Info, SourceLocation Loc,
113  bool Dependent, bool IsGeneric,
114  LambdaCaptureDefault CaptureDefault) {
115  CXXRecordDecl *R =
116  new (C, DC) CXXRecordDecl(CXXRecord, TTK_Class, C, DC, Loc, Loc,
117  nullptr, nullptr);
118  R->IsBeingDefined = true;
119  R->DefinitionData =
120  new (C) struct LambdaDefinitionData(R, Info, Dependent, IsGeneric,
121  CaptureDefault);
122  R->MayHaveOutOfDateDef = false;
123  R->setImplicit(true);
124  C.getTypeDeclType(R, /*PrevDecl=*/nullptr);
125  return R;
126 }
127 
130  CXXRecordDecl *R = new (C, ID) CXXRecordDecl(
131  CXXRecord, TTK_Struct, C, nullptr, SourceLocation(), SourceLocation(),
132  nullptr, nullptr);
133  R->MayHaveOutOfDateDef = false;
134  return R;
135 }
136 
137 void
139  unsigned NumBases) {
140  ASTContext &C = getASTContext();
141 
142  if (!data().Bases.isOffset() && data().NumBases > 0)
143  C.Deallocate(data().getBases());
144 
145  if (NumBases) {
146  // C++ [dcl.init.aggr]p1:
147  // An aggregate is [...] a class with [...] no base classes [...].
148  data().Aggregate = false;
149 
150  // C++ [class]p4:
151  // A POD-struct is an aggregate class...
152  data().PlainOldData = false;
153  }
154 
155  // The set of seen virtual base types.
156  llvm::SmallPtrSet<CanQualType, 8> SeenVBaseTypes;
157 
158  // The virtual bases of this class.
160 
161  data().Bases = new(C) CXXBaseSpecifier [NumBases];
162  data().NumBases = NumBases;
163  for (unsigned i = 0; i < NumBases; ++i) {
164  data().getBases()[i] = *Bases[i];
165  // Keep track of inherited vbases for this base class.
166  const CXXBaseSpecifier *Base = Bases[i];
167  QualType BaseType = Base->getType();
168  // Skip dependent types; we can't do any checking on them now.
169  if (BaseType->isDependentType())
170  continue;
171  CXXRecordDecl *BaseClassDecl
172  = cast<CXXRecordDecl>(BaseType->getAs<RecordType>()->getDecl());
173 
174  // A class with a non-empty base class is not empty.
175  // FIXME: Standard ref?
176  if (!BaseClassDecl->isEmpty()) {
177  if (!data().Empty) {
178  // C++0x [class]p7:
179  // A standard-layout class is a class that:
180  // [...]
181  // -- either has no non-static data members in the most derived
182  // class and at most one base class with non-static data members,
183  // or has no base classes with non-static data members, and
184  // If this is the second non-empty base, then neither of these two
185  // clauses can be true.
186  data().IsStandardLayout = false;
187  }
188 
189  data().Empty = false;
190  data().HasNoNonEmptyBases = false;
191  }
192 
193  // C++ [class.virtual]p1:
194  // A class that declares or inherits a virtual function is called a
195  // polymorphic class.
196  if (BaseClassDecl->isPolymorphic())
197  data().Polymorphic = true;
198 
199  // C++0x [class]p7:
200  // A standard-layout class is a class that: [...]
201  // -- has no non-standard-layout base classes
202  if (!BaseClassDecl->isStandardLayout())
203  data().IsStandardLayout = false;
204 
205  // Record if this base is the first non-literal field or base.
206  if (!hasNonLiteralTypeFieldsOrBases() && !BaseType->isLiteralType(C))
207  data().HasNonLiteralTypeFieldsOrBases = true;
208 
209  // Now go through all virtual bases of this base and add them.
210  for (const auto &VBase : BaseClassDecl->vbases()) {
211  // Add this base if it's not already in the list.
212  if (SeenVBaseTypes.insert(C.getCanonicalType(VBase.getType())).second) {
213  VBases.push_back(&VBase);
214 
215  // C++11 [class.copy]p8:
216  // The implicitly-declared copy constructor for a class X will have
217  // the form 'X::X(const X&)' if each [...] virtual base class B of X
218  // has a copy constructor whose first parameter is of type
219  // 'const B&' or 'const volatile B&' [...]
220  if (CXXRecordDecl *VBaseDecl = VBase.getType()->getAsCXXRecordDecl())
221  if (!VBaseDecl->hasCopyConstructorWithConstParam())
222  data().ImplicitCopyConstructorHasConstParam = false;
223  }
224  }
225 
226  if (Base->isVirtual()) {
227  // Add this base if it's not already in the list.
228  if (SeenVBaseTypes.insert(C.getCanonicalType(BaseType)).second)
229  VBases.push_back(Base);
230 
231  // C++0x [meta.unary.prop] is_empty:
232  // T is a class type, but not a union type, with ... no virtual base
233  // classes
234  data().Empty = false;
235 
236  // C++11 [class.ctor]p5, C++11 [class.copy]p12, C++11 [class.copy]p25:
237  // A [default constructor, copy/move constructor, or copy/move assignment
238  // operator for a class X] is trivial [...] if:
239  // -- class X has [...] no virtual base classes
240  data().HasTrivialSpecialMembers &= SMF_Destructor;
241 
242  // C++0x [class]p7:
243  // A standard-layout class is a class that: [...]
244  // -- has [...] no virtual base classes
245  data().IsStandardLayout = false;
246 
247  // C++11 [dcl.constexpr]p4:
248  // In the definition of a constexpr constructor [...]
249  // -- the class shall not have any virtual base classes
250  data().DefaultedDefaultConstructorIsConstexpr = false;
251  } else {
252  // C++ [class.ctor]p5:
253  // A default constructor is trivial [...] if:
254  // -- all the direct base classes of its class have trivial default
255  // constructors.
256  if (!BaseClassDecl->hasTrivialDefaultConstructor())
257  data().HasTrivialSpecialMembers &= ~SMF_DefaultConstructor;
258 
259  // C++0x [class.copy]p13:
260  // A copy/move constructor for class X is trivial if [...]
261  // [...]
262  // -- the constructor selected to copy/move each direct base class
263  // subobject is trivial, and
264  if (!BaseClassDecl->hasTrivialCopyConstructor())
265  data().HasTrivialSpecialMembers &= ~SMF_CopyConstructor;
266  // If the base class doesn't have a simple move constructor, we'll eagerly
267  // declare it and perform overload resolution to determine which function
268  // it actually calls. If it does have a simple move constructor, this
269  // check is correct.
270  if (!BaseClassDecl->hasTrivialMoveConstructor())
271  data().HasTrivialSpecialMembers &= ~SMF_MoveConstructor;
272 
273  // C++0x [class.copy]p27:
274  // A copy/move assignment operator for class X is trivial if [...]
275  // [...]
276  // -- the assignment operator selected to copy/move each direct base
277  // class subobject is trivial, and
278  if (!BaseClassDecl->hasTrivialCopyAssignment())
279  data().HasTrivialSpecialMembers &= ~SMF_CopyAssignment;
280  // If the base class doesn't have a simple move assignment, we'll eagerly
281  // declare it and perform overload resolution to determine which function
282  // it actually calls. If it does have a simple move assignment, this
283  // check is correct.
284  if (!BaseClassDecl->hasTrivialMoveAssignment())
285  data().HasTrivialSpecialMembers &= ~SMF_MoveAssignment;
286 
287  // C++11 [class.ctor]p6:
288  // If that user-written default constructor would satisfy the
289  // requirements of a constexpr constructor, the implicitly-defined
290  // default constructor is constexpr.
291  if (!BaseClassDecl->hasConstexprDefaultConstructor())
292  data().DefaultedDefaultConstructorIsConstexpr = false;
293  }
294 
295  // C++ [class.ctor]p3:
296  // A destructor is trivial if all the direct base classes of its class
297  // have trivial destructors.
298  if (!BaseClassDecl->hasTrivialDestructor())
299  data().HasTrivialSpecialMembers &= ~SMF_Destructor;
300 
301  if (!BaseClassDecl->hasIrrelevantDestructor())
302  data().HasIrrelevantDestructor = false;
303 
304  // C++11 [class.copy]p18:
305  // The implicitly-declared copy assignment oeprator for a class X will
306  // have the form 'X& X::operator=(const X&)' if each direct base class B
307  // of X has a copy assignment operator whose parameter is of type 'const
308  // B&', 'const volatile B&', or 'B' [...]
309  if (!BaseClassDecl->hasCopyAssignmentWithConstParam())
310  data().ImplicitCopyAssignmentHasConstParam = false;
311 
312  // C++11 [class.copy]p8:
313  // The implicitly-declared copy constructor for a class X will have
314  // the form 'X::X(const X&)' if each direct [...] base class B of X
315  // has a copy constructor whose first parameter is of type
316  // 'const B&' or 'const volatile B&' [...]
317  if (!BaseClassDecl->hasCopyConstructorWithConstParam())
318  data().ImplicitCopyConstructorHasConstParam = false;
319 
320  // A class has an Objective-C object member if... or any of its bases
321  // has an Objective-C object member.
322  if (BaseClassDecl->hasObjectMember())
323  setHasObjectMember(true);
324 
325  if (BaseClassDecl->hasVolatileMember())
326  setHasVolatileMember(true);
327 
328  // Keep track of the presence of mutable fields.
329  if (BaseClassDecl->hasMutableFields())
330  data().HasMutableFields = true;
331 
332  if (BaseClassDecl->hasUninitializedReferenceMember())
333  data().HasUninitializedReferenceMember = true;
334 
335  addedClassSubobject(BaseClassDecl);
336  }
337 
338  if (VBases.empty()) {
339  data().IsParsingBaseSpecifiers = false;
340  return;
341  }
342 
343  // Create base specifier for any direct or indirect virtual bases.
344  data().VBases = new (C) CXXBaseSpecifier[VBases.size()];
345  data().NumVBases = VBases.size();
346  for (int I = 0, E = VBases.size(); I != E; ++I) {
347  QualType Type = VBases[I]->getType();
348  if (!Type->isDependentType())
349  addedClassSubobject(Type->getAsCXXRecordDecl());
350  data().getVBases()[I] = *VBases[I];
351  }
352 
353  data().IsParsingBaseSpecifiers = false;
354 }
355 
356 void CXXRecordDecl::addedClassSubobject(CXXRecordDecl *Subobj) {
357  // C++11 [class.copy]p11:
358  // A defaulted copy/move constructor for a class X is defined as
359  // deleted if X has:
360  // -- a direct or virtual base class B that cannot be copied/moved [...]
361  // -- a non-static data member of class type M (or array thereof)
362  // that cannot be copied or moved [...]
363  if (!Subobj->hasSimpleMoveConstructor())
364  data().NeedOverloadResolutionForMoveConstructor = true;
365 
366  // C++11 [class.copy]p23:
367  // A defaulted copy/move assignment operator for a class X is defined as
368  // deleted if X has:
369  // -- a direct or virtual base class B that cannot be copied/moved [...]
370  // -- a non-static data member of class type M (or array thereof)
371  // that cannot be copied or moved [...]
372  if (!Subobj->hasSimpleMoveAssignment())
373  data().NeedOverloadResolutionForMoveAssignment = true;
374 
375  // C++11 [class.ctor]p5, C++11 [class.copy]p11, C++11 [class.dtor]p5:
376  // A defaulted [ctor or dtor] for a class X is defined as
377  // deleted if X has:
378  // -- any direct or virtual base class [...] has a type with a destructor
379  // that is deleted or inaccessible from the defaulted [ctor or dtor].
380  // -- any non-static data member has a type with a destructor
381  // that is deleted or inaccessible from the defaulted [ctor or dtor].
382  if (!Subobj->hasSimpleDestructor()) {
383  data().NeedOverloadResolutionForMoveConstructor = true;
384  data().NeedOverloadResolutionForDestructor = true;
385  }
386 }
387 
389  if (!isDependentContext())
390  return false;
391 
392  return !forallBases([](const CXXRecordDecl *) { return true; });
393 }
394 
396  // C++0x [class]p5:
397  // A trivially copyable class is a class that:
398  // -- has no non-trivial copy constructors,
399  if (hasNonTrivialCopyConstructor()) return false;
400  // -- has no non-trivial move constructors,
401  if (hasNonTrivialMoveConstructor()) return false;
402  // -- has no non-trivial copy assignment operators,
403  if (hasNonTrivialCopyAssignment()) return false;
404  // -- has no non-trivial move assignment operators, and
405  if (hasNonTrivialMoveAssignment()) return false;
406  // -- has a trivial destructor.
407  if (!hasTrivialDestructor()) return false;
408 
409  return true;
410 }
411 
412 void CXXRecordDecl::markedVirtualFunctionPure() {
413  // C++ [class.abstract]p2:
414  // A class is abstract if it has at least one pure virtual function.
415  data().Abstract = true;
416 }
417 
418 void CXXRecordDecl::addedMember(Decl *D) {
419  if (!D->isImplicit() &&
420  !isa<FieldDecl>(D) &&
421  !isa<IndirectFieldDecl>(D) &&
422  (!isa<TagDecl>(D) || cast<TagDecl>(D)->getTagKind() == TTK_Class ||
423  cast<TagDecl>(D)->getTagKind() == TTK_Interface))
424  data().HasOnlyCMembers = false;
425 
426  // Ignore friends and invalid declarations.
427  if (D->getFriendObjectKind() || D->isInvalidDecl())
428  return;
429 
430  FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(D);
431  if (FunTmpl)
432  D = FunTmpl->getTemplatedDecl();
433 
434  if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D)) {
435  if (Method->isVirtual()) {
436  // C++ [dcl.init.aggr]p1:
437  // An aggregate is an array or a class with [...] no virtual functions.
438  data().Aggregate = false;
439 
440  // C++ [class]p4:
441  // A POD-struct is an aggregate class...
442  data().PlainOldData = false;
443 
444  // Virtual functions make the class non-empty.
445  // FIXME: Standard ref?
446  data().Empty = false;
447 
448  // C++ [class.virtual]p1:
449  // A class that declares or inherits a virtual function is called a
450  // polymorphic class.
451  data().Polymorphic = true;
452 
453  // C++11 [class.ctor]p5, C++11 [class.copy]p12, C++11 [class.copy]p25:
454  // A [default constructor, copy/move constructor, or copy/move
455  // assignment operator for a class X] is trivial [...] if:
456  // -- class X has no virtual functions [...]
457  data().HasTrivialSpecialMembers &= SMF_Destructor;
458 
459  // C++0x [class]p7:
460  // A standard-layout class is a class that: [...]
461  // -- has no virtual functions
462  data().IsStandardLayout = false;
463  }
464  }
465 
466  // Notify the listener if an implicit member was added after the definition
467  // was completed.
468  if (!isBeingDefined() && D->isImplicit())
470  L->AddedCXXImplicitMember(data().Definition, D);
471 
472  // The kind of special member this declaration is, if any.
473  unsigned SMKind = 0;
474 
475  // Handle constructors.
476  if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(D)) {
477  if (!Constructor->isImplicit()) {
478  // Note that we have a user-declared constructor.
479  data().UserDeclaredConstructor = true;
480 
481  // C++ [class]p4:
482  // A POD-struct is an aggregate class [...]
483  // Since the POD bit is meant to be C++03 POD-ness, clear it even if the
484  // type is technically an aggregate in C++0x since it wouldn't be in 03.
485  data().PlainOldData = false;
486  }
487 
488  // Technically, "user-provided" is only defined for special member
489  // functions, but the intent of the standard is clearly that it should apply
490  // to all functions.
491  bool UserProvided = Constructor->isUserProvided();
492 
493  if (Constructor->isDefaultConstructor()) {
494  SMKind |= SMF_DefaultConstructor;
495 
496  if (UserProvided)
497  data().UserProvidedDefaultConstructor = true;
498  if (Constructor->isConstexpr())
499  data().HasConstexprDefaultConstructor = true;
500  }
501 
502  if (!FunTmpl) {
503  unsigned Quals;
504  if (Constructor->isCopyConstructor(Quals)) {
505  SMKind |= SMF_CopyConstructor;
506 
507  if (Quals & Qualifiers::Const)
508  data().HasDeclaredCopyConstructorWithConstParam = true;
509  } else if (Constructor->isMoveConstructor())
510  SMKind |= SMF_MoveConstructor;
511  }
512 
513  // Record if we see any constexpr constructors which are neither copy
514  // nor move constructors.
515  if (Constructor->isConstexpr() && !Constructor->isCopyOrMoveConstructor())
516  data().HasConstexprNonCopyMoveConstructor = true;
517 
518  // C++ [dcl.init.aggr]p1:
519  // An aggregate is an array or a class with no user-declared
520  // constructors [...].
521  // C++11 [dcl.init.aggr]p1:
522  // An aggregate is an array or a class with no user-provided
523  // constructors [...].
524  if (getASTContext().getLangOpts().CPlusPlus11
525  ? UserProvided : !Constructor->isImplicit())
526  data().Aggregate = false;
527  }
528 
529  // Handle destructors.
530  if (CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(D)) {
531  SMKind |= SMF_Destructor;
532 
533  if (DD->isUserProvided())
534  data().HasIrrelevantDestructor = false;
535  // If the destructor is explicitly defaulted and not trivial or not public
536  // or if the destructor is deleted, we clear HasIrrelevantDestructor in
537  // finishedDefaultedOrDeletedMember.
538 
539  // C++11 [class.dtor]p5:
540  // A destructor is trivial if [...] the destructor is not virtual.
541  if (DD->isVirtual())
542  data().HasTrivialSpecialMembers &= ~SMF_Destructor;
543  }
544 
545  // Handle member functions.
546  if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D)) {
547  if (Method->isCopyAssignmentOperator()) {
548  SMKind |= SMF_CopyAssignment;
549 
550  const ReferenceType *ParamTy =
551  Method->getParamDecl(0)->getType()->getAs<ReferenceType>();
552  if (!ParamTy || ParamTy->getPointeeType().isConstQualified())
553  data().HasDeclaredCopyAssignmentWithConstParam = true;
554  }
555 
556  if (Method->isMoveAssignmentOperator())
557  SMKind |= SMF_MoveAssignment;
558 
559  // Keep the list of conversion functions up-to-date.
560  if (CXXConversionDecl *Conversion = dyn_cast<CXXConversionDecl>(D)) {
561  // FIXME: We use the 'unsafe' accessor for the access specifier here,
562  // because Sema may not have set it yet. That's really just a misdesign
563  // in Sema. However, LLDB *will* have set the access specifier correctly,
564  // and adds declarations after the class is technically completed,
565  // so completeDefinition()'s overriding of the access specifiers doesn't
566  // work.
567  AccessSpecifier AS = Conversion->getAccessUnsafe();
568 
569  if (Conversion->getPrimaryTemplate()) {
570  // We don't record specializations.
571  } else {
572  ASTContext &Ctx = getASTContext();
573  ASTUnresolvedSet &Conversions = data().Conversions.get(Ctx);
574  NamedDecl *Primary =
575  FunTmpl ? cast<NamedDecl>(FunTmpl) : cast<NamedDecl>(Conversion);
576  if (Primary->getPreviousDecl())
577  Conversions.replace(cast<NamedDecl>(Primary->getPreviousDecl()),
578  Primary, AS);
579  else
580  Conversions.addDecl(Ctx, Primary, AS);
581  }
582  }
583 
584  if (SMKind) {
585  // If this is the first declaration of a special member, we no longer have
586  // an implicit trivial special member.
587  data().HasTrivialSpecialMembers &=
588  data().DeclaredSpecialMembers | ~SMKind;
589 
590  if (!Method->isImplicit() && !Method->isUserProvided()) {
591  // This method is user-declared but not user-provided. We can't work out
592  // whether it's trivial yet (not until we get to the end of the class).
593  // We'll handle this method in finishedDefaultedOrDeletedMember.
594  } else if (Method->isTrivial())
595  data().HasTrivialSpecialMembers |= SMKind;
596  else
597  data().DeclaredNonTrivialSpecialMembers |= SMKind;
598 
599  // Note when we have declared a declared special member, and suppress the
600  // implicit declaration of this special member.
601  data().DeclaredSpecialMembers |= SMKind;
602 
603  if (!Method->isImplicit()) {
604  data().UserDeclaredSpecialMembers |= SMKind;
605 
606  // C++03 [class]p4:
607  // A POD-struct is an aggregate class that has [...] no user-defined
608  // copy assignment operator and no user-defined destructor.
609  //
610  // Since the POD bit is meant to be C++03 POD-ness, and in C++03,
611  // aggregates could not have any constructors, clear it even for an
612  // explicitly defaulted or deleted constructor.
613  // type is technically an aggregate in C++0x since it wouldn't be in 03.
614  //
615  // Also, a user-declared move assignment operator makes a class non-POD.
616  // This is an extension in C++03.
617  data().PlainOldData = false;
618  }
619  }
620 
621  return;
622  }
623 
624  // Handle non-static data members.
625  if (FieldDecl *Field = dyn_cast<FieldDecl>(D)) {
626  // C++ [class.bit]p2:
627  // A declaration for a bit-field that omits the identifier declares an
628  // unnamed bit-field. Unnamed bit-fields are not members and cannot be
629  // initialized.
630  if (Field->isUnnamedBitfield())
631  return;
632 
633  // C++ [dcl.init.aggr]p1:
634  // An aggregate is an array or a class (clause 9) with [...] no
635  // private or protected non-static data members (clause 11).
636  //
637  // A POD must be an aggregate.
638  if (D->getAccess() == AS_private || D->getAccess() == AS_protected) {
639  data().Aggregate = false;
640  data().PlainOldData = false;
641  }
642 
643  // C++0x [class]p7:
644  // A standard-layout class is a class that:
645  // [...]
646  // -- has the same access control for all non-static data members,
647  switch (D->getAccess()) {
648  case AS_private: data().HasPrivateFields = true; break;
649  case AS_protected: data().HasProtectedFields = true; break;
650  case AS_public: data().HasPublicFields = true; break;
651  case AS_none: llvm_unreachable("Invalid access specifier");
652  };
653  if ((data().HasPrivateFields + data().HasProtectedFields +
654  data().HasPublicFields) > 1)
655  data().IsStandardLayout = false;
656 
657  // Keep track of the presence of mutable fields.
658  if (Field->isMutable())
659  data().HasMutableFields = true;
660 
661  // C++11 [class.union]p8, DR1460:
662  // If X is a union, a non-static data member of X that is not an anonymous
663  // union is a variant member of X.
664  if (isUnion() && !Field->isAnonymousStructOrUnion())
665  data().HasVariantMembers = true;
666 
667  // C++0x [class]p9:
668  // A POD struct is a class that is both a trivial class and a
669  // standard-layout class, and has no non-static data members of type
670  // non-POD struct, non-POD union (or array of such types).
671  //
672  // Automatic Reference Counting: the presence of a member of Objective-C pointer type
673  // that does not explicitly have no lifetime makes the class a non-POD.
675  QualType T = Context.getBaseElementType(Field->getType());
676  if (T->isObjCRetainableType() || T.isObjCGCStrong()) {
677  if (!Context.getLangOpts().ObjCAutoRefCount) {
678  setHasObjectMember(true);
679  } else if (T.getObjCLifetime() != Qualifiers::OCL_ExplicitNone) {
680  // Objective-C Automatic Reference Counting:
681  // If a class has a non-static data member of Objective-C pointer
682  // type (or array thereof), it is a non-POD type and its
683  // default constructor (if any), copy constructor, move constructor,
684  // copy assignment operator, move assignment operator, and destructor are
685  // non-trivial.
686  setHasObjectMember(true);
687  struct DefinitionData &Data = data();
688  Data.PlainOldData = false;
689  Data.HasTrivialSpecialMembers = 0;
690  Data.HasIrrelevantDestructor = false;
691  }
692  } else if (!T.isCXX98PODType(Context))
693  data().PlainOldData = false;
694 
695  if (T->isReferenceType()) {
696  if (!Field->hasInClassInitializer())
697  data().HasUninitializedReferenceMember = true;
698 
699  // C++0x [class]p7:
700  // A standard-layout class is a class that:
701  // -- has no non-static data members of type [...] reference,
702  data().IsStandardLayout = false;
703  }
704 
705  // Record if this field is the first non-literal or volatile field or base.
706  if (!T->isLiteralType(Context) || T.isVolatileQualified())
707  data().HasNonLiteralTypeFieldsOrBases = true;
708 
709  if (Field->hasInClassInitializer() ||
710  (Field->isAnonymousStructOrUnion() &&
711  Field->getType()->getAsCXXRecordDecl()->hasInClassInitializer())) {
712  data().HasInClassInitializer = true;
713 
714  // C++11 [class]p5:
715  // A default constructor is trivial if [...] no non-static data member
716  // of its class has a brace-or-equal-initializer.
717  data().HasTrivialSpecialMembers &= ~SMF_DefaultConstructor;
718 
719  // C++11 [dcl.init.aggr]p1:
720  // An aggregate is a [...] class with [...] no
721  // brace-or-equal-initializers for non-static data members.
722  //
723  // This rule was removed in C++1y.
724  if (!getASTContext().getLangOpts().CPlusPlus14)
725  data().Aggregate = false;
726 
727  // C++11 [class]p10:
728  // A POD struct is [...] a trivial class.
729  data().PlainOldData = false;
730  }
731 
732  // C++11 [class.copy]p23:
733  // A defaulted copy/move assignment operator for a class X is defined
734  // as deleted if X has:
735  // -- a non-static data member of reference type
736  if (T->isReferenceType())
737  data().DefaultedMoveAssignmentIsDeleted = true;
738 
739  if (const RecordType *RecordTy = T->getAs<RecordType>()) {
740  CXXRecordDecl* FieldRec = cast<CXXRecordDecl>(RecordTy->getDecl());
741  if (FieldRec->getDefinition()) {
742  addedClassSubobject(FieldRec);
743 
744  // We may need to perform overload resolution to determine whether a
745  // field can be moved if it's const or volatile qualified.
747  data().NeedOverloadResolutionForMoveConstructor = true;
748  data().NeedOverloadResolutionForMoveAssignment = true;
749  }
750 
751  // C++11 [class.ctor]p5, C++11 [class.copy]p11:
752  // A defaulted [special member] for a class X is defined as
753  // deleted if:
754  // -- X is a union-like class that has a variant member with a
755  // non-trivial [corresponding special member]
756  if (isUnion()) {
757  if (FieldRec->hasNonTrivialMoveConstructor())
758  data().DefaultedMoveConstructorIsDeleted = true;
759  if (FieldRec->hasNonTrivialMoveAssignment())
760  data().DefaultedMoveAssignmentIsDeleted = true;
761  if (FieldRec->hasNonTrivialDestructor())
762  data().DefaultedDestructorIsDeleted = true;
763  }
764 
765  // C++0x [class.ctor]p5:
766  // A default constructor is trivial [...] if:
767  // -- for all the non-static data members of its class that are of
768  // class type (or array thereof), each such class has a trivial
769  // default constructor.
770  if (!FieldRec->hasTrivialDefaultConstructor())
771  data().HasTrivialSpecialMembers &= ~SMF_DefaultConstructor;
772 
773  // C++0x [class.copy]p13:
774  // A copy/move constructor for class X is trivial if [...]
775  // [...]
776  // -- for each non-static data member of X that is of class type (or
777  // an array thereof), the constructor selected to copy/move that
778  // member is trivial;
779  if (!FieldRec->hasTrivialCopyConstructor())
780  data().HasTrivialSpecialMembers &= ~SMF_CopyConstructor;
781  // If the field doesn't have a simple move constructor, we'll eagerly
782  // declare the move constructor for this class and we'll decide whether
783  // it's trivial then.
784  if (!FieldRec->hasTrivialMoveConstructor())
785  data().HasTrivialSpecialMembers &= ~SMF_MoveConstructor;
786 
787  // C++0x [class.copy]p27:
788  // A copy/move assignment operator for class X is trivial if [...]
789  // [...]
790  // -- for each non-static data member of X that is of class type (or
791  // an array thereof), the assignment operator selected to
792  // copy/move that member is trivial;
793  if (!FieldRec->hasTrivialCopyAssignment())
794  data().HasTrivialSpecialMembers &= ~SMF_CopyAssignment;
795  // If the field doesn't have a simple move assignment, we'll eagerly
796  // declare the move assignment for this class and we'll decide whether
797  // it's trivial then.
798  if (!FieldRec->hasTrivialMoveAssignment())
799  data().HasTrivialSpecialMembers &= ~SMF_MoveAssignment;
800 
801  if (!FieldRec->hasTrivialDestructor())
802  data().HasTrivialSpecialMembers &= ~SMF_Destructor;
803  if (!FieldRec->hasIrrelevantDestructor())
804  data().HasIrrelevantDestructor = false;
805  if (FieldRec->hasObjectMember())
806  setHasObjectMember(true);
807  if (FieldRec->hasVolatileMember())
808  setHasVolatileMember(true);
809 
810  // C++0x [class]p7:
811  // A standard-layout class is a class that:
812  // -- has no non-static data members of type non-standard-layout
813  // class (or array of such types) [...]
814  if (!FieldRec->isStandardLayout())
815  data().IsStandardLayout = false;
816 
817  // C++0x [class]p7:
818  // A standard-layout class is a class that:
819  // [...]
820  // -- has no base classes of the same type as the first non-static
821  // data member.
822  // We don't want to expend bits in the state of the record decl
823  // tracking whether this is the first non-static data member so we
824  // cheat a bit and use some of the existing state: the empty bit.
825  // Virtual bases and virtual methods make a class non-empty, but they
826  // also make it non-standard-layout so we needn't check here.
827  // A non-empty base class may leave the class standard-layout, but not
828  // if we have arrived here, and have at least one non-static data
829  // member. If IsStandardLayout remains true, then the first non-static
830  // data member must come through here with Empty still true, and Empty
831  // will subsequently be set to false below.
832  if (data().IsStandardLayout && data().Empty) {
833  for (const auto &BI : bases()) {
834  if (Context.hasSameUnqualifiedType(BI.getType(), T)) {
835  data().IsStandardLayout = false;
836  break;
837  }
838  }
839  }
840 
841  // Keep track of the presence of mutable fields.
842  if (FieldRec->hasMutableFields())
843  data().HasMutableFields = true;
844 
845  // C++11 [class.copy]p13:
846  // If the implicitly-defined constructor would satisfy the
847  // requirements of a constexpr constructor, the implicitly-defined
848  // constructor is constexpr.
849  // C++11 [dcl.constexpr]p4:
850  // -- every constructor involved in initializing non-static data
851  // members [...] shall be a constexpr constructor
852  if (!Field->hasInClassInitializer() &&
853  !FieldRec->hasConstexprDefaultConstructor() && !isUnion())
854  // The standard requires any in-class initializer to be a constant
855  // expression. We consider this to be a defect.
856  data().DefaultedDefaultConstructorIsConstexpr = false;
857 
858  // C++11 [class.copy]p8:
859  // The implicitly-declared copy constructor for a class X will have
860  // the form 'X::X(const X&)' if [...] for all the non-static data
861  // members of X that are of a class type M (or array thereof), each
862  // such class type has a copy constructor whose first parameter is
863  // of type 'const M&' or 'const volatile M&'.
864  if (!FieldRec->hasCopyConstructorWithConstParam())
865  data().ImplicitCopyConstructorHasConstParam = false;
866 
867  // C++11 [class.copy]p18:
868  // The implicitly-declared copy assignment oeprator for a class X will
869  // have the form 'X& X::operator=(const X&)' if [...] for all the
870  // non-static data members of X that are of a class type M (or array
871  // thereof), each such class type has a copy assignment operator whose
872  // parameter is of type 'const M&', 'const volatile M&' or 'M'.
873  if (!FieldRec->hasCopyAssignmentWithConstParam())
874  data().ImplicitCopyAssignmentHasConstParam = false;
875 
876  if (FieldRec->hasUninitializedReferenceMember() &&
877  !Field->hasInClassInitializer())
878  data().HasUninitializedReferenceMember = true;
879 
880  // C++11 [class.union]p8, DR1460:
881  // a non-static data member of an anonymous union that is a member of
882  // X is also a variant member of X.
883  if (FieldRec->hasVariantMembers() &&
884  Field->isAnonymousStructOrUnion())
885  data().HasVariantMembers = true;
886  }
887  } else {
888  // Base element type of field is a non-class type.
889  if (!T->isLiteralType(Context) ||
890  (!Field->hasInClassInitializer() && !isUnion()))
891  data().DefaultedDefaultConstructorIsConstexpr = false;
892 
893  // C++11 [class.copy]p23:
894  // A defaulted copy/move assignment operator for a class X is defined
895  // as deleted if X has:
896  // -- a non-static data member of const non-class type (or array
897  // thereof)
898  if (T.isConstQualified())
899  data().DefaultedMoveAssignmentIsDeleted = true;
900  }
901 
902  // C++0x [class]p7:
903  // A standard-layout class is a class that:
904  // [...]
905  // -- either has no non-static data members in the most derived
906  // class and at most one base class with non-static data members,
907  // or has no base classes with non-static data members, and
908  // At this point we know that we have a non-static data member, so the last
909  // clause holds.
910  if (!data().HasNoNonEmptyBases)
911  data().IsStandardLayout = false;
912 
913  // If this is not a zero-length bit-field, then the class is not empty.
914  if (data().Empty) {
915  if (!Field->isBitField() ||
916  (!Field->getBitWidth()->isTypeDependent() &&
917  !Field->getBitWidth()->isValueDependent() &&
918  Field->getBitWidthValue(Context) != 0))
919  data().Empty = false;
920  }
921  }
922 
923  // Handle using declarations of conversion functions.
924  if (UsingShadowDecl *Shadow = dyn_cast<UsingShadowDecl>(D)) {
925  if (Shadow->getDeclName().getNameKind()
927  ASTContext &Ctx = getASTContext();
928  data().Conversions.get(Ctx).addDecl(Ctx, Shadow, Shadow->getAccess());
929  }
930  }
931 }
932 
934  assert(!D->isImplicit() && !D->isUserProvided());
935 
936  // The kind of special member this declaration is, if any.
937  unsigned SMKind = 0;
938 
939  if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(D)) {
940  if (Constructor->isDefaultConstructor()) {
941  SMKind |= SMF_DefaultConstructor;
942  if (Constructor->isConstexpr())
943  data().HasConstexprDefaultConstructor = true;
944  }
945  if (Constructor->isCopyConstructor())
946  SMKind |= SMF_CopyConstructor;
947  else if (Constructor->isMoveConstructor())
948  SMKind |= SMF_MoveConstructor;
949  else if (Constructor->isConstexpr())
950  // We may now know that the constructor is constexpr.
951  data().HasConstexprNonCopyMoveConstructor = true;
952  } else if (isa<CXXDestructorDecl>(D)) {
953  SMKind |= SMF_Destructor;
954  if (!D->isTrivial() || D->getAccess() != AS_public || D->isDeleted())
955  data().HasIrrelevantDestructor = false;
956  } else if (D->isCopyAssignmentOperator())
957  SMKind |= SMF_CopyAssignment;
958  else if (D->isMoveAssignmentOperator())
959  SMKind |= SMF_MoveAssignment;
960 
961  // Update which trivial / non-trivial special members we have.
962  // addedMember will have skipped this step for this member.
963  if (D->isTrivial())
964  data().HasTrivialSpecialMembers |= SMKind;
965  else
966  data().DeclaredNonTrivialSpecialMembers |= SMKind;
967 }
968 
970  if (getTagKind() == TTK_Class || getTagKind() == TTK_Interface ||
971  !TemplateOrInstantiation.isNull())
972  return false;
973  if (!hasDefinition())
974  return true;
975 
976  return isPOD() && data().HasOnlyCMembers;
977 }
978 
980  if (!isLambda()) return false;
981  return getLambdaData().IsGenericLambda;
982 }
983 
985  if (!isLambda()) return nullptr;
988  DeclContext::lookup_result Calls = lookup(Name);
989 
990  assert(!Calls.empty() && "Missing lambda call operator!");
991  assert(Calls.size() == 1 && "More than one lambda call operator!");
992 
993  NamedDecl *CallOp = Calls.front();
994  if (FunctionTemplateDecl *CallOpTmpl =
995  dyn_cast<FunctionTemplateDecl>(CallOp))
996  return cast<CXXMethodDecl>(CallOpTmpl->getTemplatedDecl());
997 
998  return cast<CXXMethodDecl>(CallOp);
999 }
1000 
1002  if (!isLambda()) return nullptr;
1005  DeclContext::lookup_result Invoker = lookup(Name);
1006  if (Invoker.empty()) return nullptr;
1007  assert(Invoker.size() == 1 && "More than one static invoker operator!");
1008  NamedDecl *InvokerFun = Invoker.front();
1009  if (FunctionTemplateDecl *InvokerTemplate =
1010  dyn_cast<FunctionTemplateDecl>(InvokerFun))
1011  return cast<CXXMethodDecl>(InvokerTemplate->getTemplatedDecl());
1012 
1013  return cast<CXXMethodDecl>(InvokerFun);
1014 }
1015 
1017  llvm::DenseMap<const VarDecl *, FieldDecl *> &Captures,
1018  FieldDecl *&ThisCapture) const {
1019  Captures.clear();
1020  ThisCapture = nullptr;
1021 
1022  LambdaDefinitionData &Lambda = getLambdaData();
1024  for (const LambdaCapture *C = Lambda.Captures, *CEnd = C + Lambda.NumCaptures;
1025  C != CEnd; ++C, ++Field) {
1026  if (C->capturesThis())
1027  ThisCapture = *Field;
1028  else if (C->capturesVariable())
1029  Captures[C->getCapturedVar()] = *Field;
1030  }
1031  assert(Field == field_end());
1032 }
1033 
1036  if (!isLambda()) return nullptr;
1037  CXXMethodDecl *CallOp = getLambdaCallOperator();
1038  if (FunctionTemplateDecl *Tmpl = CallOp->getDescribedFunctionTemplate())
1039  return Tmpl->getTemplateParameters();
1040  return nullptr;
1041 }
1042 
1044  QualType T =
1045  cast<CXXConversionDecl>(Conv->getUnderlyingDecl()->getAsFunction())
1046  ->getConversionType();
1047  return Context.getCanonicalType(T);
1048 }
1049 
1050 /// Collect the visible conversions of a base class.
1051 ///
1052 /// \param Record a base class of the class we're considering
1053 /// \param InVirtual whether this base class is a virtual base (or a base
1054 /// of a virtual base)
1055 /// \param Access the access along the inheritance path to this base
1056 /// \param ParentHiddenTypes the conversions provided by the inheritors
1057 /// of this base
1058 /// \param Output the set to which to add conversions from non-virtual bases
1059 /// \param VOutput the set to which to add conversions from virtual bases
1060 /// \param HiddenVBaseCs the set of conversions which were hidden in a
1061 /// virtual base along some inheritance path
1063  CXXRecordDecl *Record,
1064  bool InVirtual,
1065  AccessSpecifier Access,
1066  const llvm::SmallPtrSet<CanQualType, 8> &ParentHiddenTypes,
1067  ASTUnresolvedSet &Output,
1068  UnresolvedSetImpl &VOutput,
1069  llvm::SmallPtrSet<NamedDecl*, 8> &HiddenVBaseCs) {
1070  // The set of types which have conversions in this class or its
1071  // subclasses. As an optimization, we don't copy the derived set
1072  // unless it might change.
1073  const llvm::SmallPtrSet<CanQualType, 8> *HiddenTypes = &ParentHiddenTypes;
1074  llvm::SmallPtrSet<CanQualType, 8> HiddenTypesBuffer;
1075 
1076  // Collect the direct conversions and figure out which conversions
1077  // will be hidden in the subclasses.
1080  if (ConvI != ConvE) {
1081  HiddenTypesBuffer = ParentHiddenTypes;
1082  HiddenTypes = &HiddenTypesBuffer;
1083 
1084  for (CXXRecordDecl::conversion_iterator I = ConvI; I != ConvE; ++I) {
1085  CanQualType ConvType(GetConversionType(Context, I.getDecl()));
1086  bool Hidden = ParentHiddenTypes.count(ConvType);
1087  if (!Hidden)
1088  HiddenTypesBuffer.insert(ConvType);
1089 
1090  // If this conversion is hidden and we're in a virtual base,
1091  // remember that it's hidden along some inheritance path.
1092  if (Hidden && InVirtual)
1093  HiddenVBaseCs.insert(cast<NamedDecl>(I.getDecl()->getCanonicalDecl()));
1094 
1095  // If this conversion isn't hidden, add it to the appropriate output.
1096  else if (!Hidden) {
1097  AccessSpecifier IAccess
1098  = CXXRecordDecl::MergeAccess(Access, I.getAccess());
1099 
1100  if (InVirtual)
1101  VOutput.addDecl(I.getDecl(), IAccess);
1102  else
1103  Output.addDecl(Context, I.getDecl(), IAccess);
1104  }
1105  }
1106  }
1107 
1108  // Collect information recursively from any base classes.
1109  for (const auto &I : Record->bases()) {
1110  const RecordType *RT = I.getType()->getAs<RecordType>();
1111  if (!RT) continue;
1112 
1113  AccessSpecifier BaseAccess
1114  = CXXRecordDecl::MergeAccess(Access, I.getAccessSpecifier());
1115  bool BaseInVirtual = InVirtual || I.isVirtual();
1116 
1117  CXXRecordDecl *Base = cast<CXXRecordDecl>(RT->getDecl());
1118  CollectVisibleConversions(Context, Base, BaseInVirtual, BaseAccess,
1119  *HiddenTypes, Output, VOutput, HiddenVBaseCs);
1120  }
1121 }
1122 
1123 /// Collect the visible conversions of a class.
1124 ///
1125 /// This would be extremely straightforward if it weren't for virtual
1126 /// bases. It might be worth special-casing that, really.
1128  CXXRecordDecl *Record,
1129  ASTUnresolvedSet &Output) {
1130  // The collection of all conversions in virtual bases that we've
1131  // found. These will be added to the output as long as they don't
1132  // appear in the hidden-conversions set.
1133  UnresolvedSet<8> VBaseCs;
1134 
1135  // The set of conversions in virtual bases that we've determined to
1136  // be hidden.
1137  llvm::SmallPtrSet<NamedDecl*, 8> HiddenVBaseCs;
1138 
1139  // The set of types hidden by classes derived from this one.
1140  llvm::SmallPtrSet<CanQualType, 8> HiddenTypes;
1141 
1142  // Go ahead and collect the direct conversions and add them to the
1143  // hidden-types set.
1146  Output.append(Context, ConvI, ConvE);
1147  for (; ConvI != ConvE; ++ConvI)
1148  HiddenTypes.insert(GetConversionType(Context, ConvI.getDecl()));
1149 
1150  // Recursively collect conversions from base classes.
1151  for (const auto &I : Record->bases()) {
1152  const RecordType *RT = I.getType()->getAs<RecordType>();
1153  if (!RT) continue;
1154 
1155  CollectVisibleConversions(Context, cast<CXXRecordDecl>(RT->getDecl()),
1156  I.isVirtual(), I.getAccessSpecifier(),
1157  HiddenTypes, Output, VBaseCs, HiddenVBaseCs);
1158  }
1159 
1160  // Add any unhidden conversions provided by virtual bases.
1161  for (UnresolvedSetIterator I = VBaseCs.begin(), E = VBaseCs.end();
1162  I != E; ++I) {
1163  if (!HiddenVBaseCs.count(cast<NamedDecl>(I.getDecl()->getCanonicalDecl())))
1164  Output.addDecl(Context, I.getDecl(), I.getAccess());
1165  }
1166 }
1167 
1168 /// getVisibleConversionFunctions - get all conversion functions visible
1169 /// in current class; including conversion function templates.
1170 llvm::iterator_range<CXXRecordDecl::conversion_iterator>
1172  ASTContext &Ctx = getASTContext();
1173 
1174  ASTUnresolvedSet *Set;
1175  if (bases_begin() == bases_end()) {
1176  // If root class, all conversions are visible.
1177  Set = &data().Conversions.get(Ctx);
1178  } else {
1179  Set = &data().VisibleConversions.get(Ctx);
1180  // If visible conversion list is not evaluated, evaluate it.
1181  if (!data().ComputedVisibleConversions) {
1182  CollectVisibleConversions(Ctx, this, *Set);
1183  data().ComputedVisibleConversions = true;
1184  }
1185  }
1186  return llvm::make_range(Set->begin(), Set->end());
1187 }
1188 
1190  // This operation is O(N) but extremely rare. Sema only uses it to
1191  // remove UsingShadowDecls in a class that were followed by a direct
1192  // declaration, e.g.:
1193  // class A : B {
1194  // using B::operator int;
1195  // operator int();
1196  // };
1197  // This is uncommon by itself and even more uncommon in conjunction
1198  // with sufficiently large numbers of directly-declared conversions
1199  // that asymptotic behavior matters.
1200 
1201  ASTUnresolvedSet &Convs = data().Conversions.get(getASTContext());
1202  for (unsigned I = 0, E = Convs.size(); I != E; ++I) {
1203  if (Convs[I].getDecl() == ConvDecl) {
1204  Convs.erase(I);
1205  assert(std::find(Convs.begin(), Convs.end(), ConvDecl) == Convs.end()
1206  && "conversion was found multiple times in unresolved set");
1207  return;
1208  }
1209  }
1210 
1211  llvm_unreachable("conversion not found in set!");
1212 }
1213 
1216  return cast<CXXRecordDecl>(MSInfo->getInstantiatedFrom());
1217 
1218  return nullptr;
1219 }
1220 
1222  return TemplateOrInstantiation.dyn_cast<MemberSpecializationInfo *>();
1223 }
1224 
1225 void
1228  assert(TemplateOrInstantiation.isNull() &&
1229  "Previous template or instantiation?");
1230  assert(!isa<ClassTemplatePartialSpecializationDecl>(this));
1231  TemplateOrInstantiation
1232  = new (getASTContext()) MemberSpecializationInfo(RD, TSK);
1233 }
1234 
1236  return TemplateOrInstantiation.dyn_cast<ClassTemplateDecl *>();
1237 }
1238 
1240  TemplateOrInstantiation = Template;
1241 }
1242 
1244  if (const ClassTemplateSpecializationDecl *Spec
1245  = dyn_cast<ClassTemplateSpecializationDecl>(this))
1246  return Spec->getSpecializationKind();
1247 
1249  return MSInfo->getTemplateSpecializationKind();
1250 
1251  return TSK_Undeclared;
1252 }
1253 
1254 void
1257  = dyn_cast<ClassTemplateSpecializationDecl>(this)) {
1258  Spec->setSpecializationKind(TSK);
1259  return;
1260  }
1261 
1263  MSInfo->setTemplateSpecializationKind(TSK);
1264  return;
1265  }
1266 
1267  llvm_unreachable("Not a class template or member class specialization");
1268 }
1269 
1271  // If it's a class template specialization, find the template or partial
1272  // specialization from which it was instantiated.
1273  if (auto *TD = dyn_cast<ClassTemplateSpecializationDecl>(this)) {
1274  auto From = TD->getInstantiatedFrom();
1275  if (auto *CTD = From.dyn_cast<ClassTemplateDecl *>()) {
1276  while (auto *NewCTD = CTD->getInstantiatedFromMemberTemplate()) {
1277  if (NewCTD->isMemberSpecialization())
1278  break;
1279  CTD = NewCTD;
1280  }
1281  return CTD->getTemplatedDecl()->getDefinition();
1282  }
1283  if (auto *CTPSD =
1284  From.dyn_cast<ClassTemplatePartialSpecializationDecl *>()) {
1285  while (auto *NewCTPSD = CTPSD->getInstantiatedFromMember()) {
1286  if (NewCTPSD->isMemberSpecialization())
1287  break;
1288  CTPSD = NewCTPSD;
1289  }
1290  return CTPSD->getDefinition();
1291  }
1292  }
1293 
1295  if (isTemplateInstantiation(MSInfo->getTemplateSpecializationKind())) {
1296  const CXXRecordDecl *RD = this;
1297  while (auto *NewRD = RD->getInstantiatedFromMemberClass())
1298  RD = NewRD;
1299  return RD->getDefinition();
1300  }
1301  }
1302 
1304  "couldn't find pattern for class template instantiation");
1305  return nullptr;
1306 }
1307 
1309  ASTContext &Context = getASTContext();
1310  QualType ClassType = Context.getTypeDeclType(this);
1311 
1314  Context.getCanonicalType(ClassType));
1315 
1317  if (R.empty())
1318  return nullptr;
1319 
1320  CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(R.front());
1321  return Dtor;
1322 }
1323 
1325  // Destructor is noreturn.
1326  if (const CXXDestructorDecl *Destructor = getDestructor())
1327  if (Destructor->isNoReturn())
1328  return true;
1329 
1330  // Check base classes destructor for noreturn.
1331  for (const auto &Base : bases())
1332  if (Base.getType()->getAsCXXRecordDecl()->isAnyDestructorNoReturn())
1333  return true;
1334 
1335  // Check fields for noreturn.
1336  for (const auto *Field : fields())
1337  if (const CXXRecordDecl *RD =
1338  Field->getType()->getBaseElementTypeUnsafe()->getAsCXXRecordDecl())
1339  if (RD->isAnyDestructorNoReturn())
1340  return true;
1341 
1342  // All destructors are not noreturn.
1343  return false;
1344 }
1345 
1347  completeDefinition(nullptr);
1348 }
1349 
1352 
1353  // If the class may be abstract (but hasn't been marked as such), check for
1354  // any pure final overriders.
1355  if (mayBeAbstract()) {
1356  CXXFinalOverriderMap MyFinalOverriders;
1357  if (!FinalOverriders) {
1358  getFinalOverriders(MyFinalOverriders);
1359  FinalOverriders = &MyFinalOverriders;
1360  }
1361 
1362  bool Done = false;
1363  for (CXXFinalOverriderMap::iterator M = FinalOverriders->begin(),
1364  MEnd = FinalOverriders->end();
1365  M != MEnd && !Done; ++M) {
1366  for (OverridingMethods::iterator SO = M->second.begin(),
1367  SOEnd = M->second.end();
1368  SO != SOEnd && !Done; ++SO) {
1369  assert(SO->second.size() > 0 &&
1370  "All virtual functions have overridding virtual functions");
1371 
1372  // C++ [class.abstract]p4:
1373  // A class is abstract if it contains or inherits at least one
1374  // pure virtual function for which the final overrider is pure
1375  // virtual.
1376  if (SO->second.front().Method->isPure()) {
1377  data().Abstract = true;
1378  Done = true;
1379  break;
1380  }
1381  }
1382  }
1383  }
1384 
1385  // Set access bits correctly on the directly-declared conversions.
1387  I != E; ++I)
1388  I.setAccess((*I)->getAccess());
1389 }
1390 
1392  if (data().Abstract || isInvalidDecl() || !data().Polymorphic ||
1394  return false;
1395 
1396  for (const auto &B : bases()) {
1397  CXXRecordDecl *BaseDecl
1398  = cast<CXXRecordDecl>(B.getType()->getAs<RecordType>()->getDecl());
1399  if (BaseDecl->isAbstract())
1400  return true;
1401  }
1402 
1403  return false;
1404 }
1405 
1406 void CXXMethodDecl::anchor() { }
1407 
1409  const CXXMethodDecl *MD = getCanonicalDecl();
1410 
1411  if (MD->getStorageClass() == SC_Static)
1412  return true;
1413 
1415  return isStaticOverloadedOperator(OOK);
1416 }
1417 
1418 static bool recursivelyOverrides(const CXXMethodDecl *DerivedMD,
1419  const CXXMethodDecl *BaseMD) {
1421  E = DerivedMD->end_overridden_methods(); I != E; ++I) {
1422  const CXXMethodDecl *MD = *I;
1423  if (MD->getCanonicalDecl() == BaseMD->getCanonicalDecl())
1424  return true;
1425  if (recursivelyOverrides(MD, BaseMD))
1426  return true;
1427  }
1428  return false;
1429 }
1430 
1431 CXXMethodDecl *
1433  bool MayBeBase) {
1434  if (this->getParent()->getCanonicalDecl() == RD->getCanonicalDecl())
1435  return this;
1436 
1437  // Lookup doesn't work for destructors, so handle them separately.
1438  if (isa<CXXDestructorDecl>(this)) {
1439  CXXMethodDecl *MD = RD->getDestructor();
1440  if (MD) {
1441  if (recursivelyOverrides(MD, this))
1442  return MD;
1443  if (MayBeBase && recursivelyOverrides(this, MD))
1444  return MD;
1445  }
1446  return nullptr;
1447  }
1448 
1449  for (auto *ND : RD->lookup(getDeclName())) {
1450  CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(ND);
1451  if (!MD)
1452  continue;
1453  if (recursivelyOverrides(MD, this))
1454  return MD;
1455  if (MayBeBase && recursivelyOverrides(this, MD))
1456  return MD;
1457  }
1458 
1459  for (const auto &I : RD->bases()) {
1460  const RecordType *RT = I.getType()->getAs<RecordType>();
1461  if (!RT)
1462  continue;
1463  const CXXRecordDecl *Base = cast<CXXRecordDecl>(RT->getDecl());
1465  if (T)
1466  return T;
1467  }
1468 
1469  return nullptr;
1470 }
1471 
1472 CXXMethodDecl *
1474  SourceLocation StartLoc,
1475  const DeclarationNameInfo &NameInfo,
1476  QualType T, TypeSourceInfo *TInfo,
1477  StorageClass SC, bool isInline,
1478  bool isConstexpr, SourceLocation EndLocation) {
1479  return new (C, RD) CXXMethodDecl(CXXMethod, C, RD, StartLoc, NameInfo,
1480  T, TInfo, SC, isInline, isConstexpr,
1481  EndLocation);
1482 }
1483 
1485  return new (C, ID) CXXMethodDecl(CXXMethod, C, nullptr, SourceLocation(),
1486  DeclarationNameInfo(), QualType(), nullptr,
1487  SC_None, false, false, SourceLocation());
1488 }
1489 
1491  if (getOverloadedOperator() != OO_Delete &&
1492  getOverloadedOperator() != OO_Array_Delete)
1493  return false;
1494 
1495  // C++ [basic.stc.dynamic.deallocation]p2:
1496  // A template instance is never a usual deallocation function,
1497  // regardless of its signature.
1498  if (getPrimaryTemplate())
1499  return false;
1500 
1501  // C++ [basic.stc.dynamic.deallocation]p2:
1502  // If a class T has a member deallocation function named operator delete
1503  // with exactly one parameter, then that function is a usual (non-placement)
1504  // deallocation function. [...]
1505  if (getNumParams() == 1)
1506  return true;
1507 
1508  // C++ [basic.stc.dynamic.deallocation]p2:
1509  // [...] If class T does not declare such an operator delete but does
1510  // declare a member deallocation function named operator delete with
1511  // exactly two parameters, the second of which has type std::size_t (18.1),
1512  // then this function is a usual deallocation function.
1513  ASTContext &Context = getASTContext();
1514  if (getNumParams() != 2 ||
1516  Context.getSizeType()))
1517  return false;
1518 
1519  // This function is a usual deallocation function if there are no
1520  // single-parameter deallocation functions of the same kind.
1522  for (DeclContext::lookup_result::iterator I = R.begin(), E = R.end();
1523  I != E; ++I) {
1524  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(*I))
1525  if (FD->getNumParams() == 1)
1526  return false;
1527  }
1528 
1529  return true;
1530 }
1531 
1533  // C++0x [class.copy]p17:
1534  // A user-declared copy assignment operator X::operator= is a non-static
1535  // non-template member function of class X with exactly one parameter of
1536  // type X, X&, const X&, volatile X& or const volatile X&.
1537  if (/*operator=*/getOverloadedOperator() != OO_Equal ||
1538  /*non-static*/ isStatic() ||
1539  /*non-template*/getPrimaryTemplate() || getDescribedFunctionTemplate() ||
1540  getNumParams() != 1)
1541  return false;
1542 
1543  QualType ParamType = getParamDecl(0)->getType();
1544  if (const LValueReferenceType *Ref = ParamType->getAs<LValueReferenceType>())
1545  ParamType = Ref->getPointeeType();
1546 
1547  ASTContext &Context = getASTContext();
1548  QualType ClassType
1549  = Context.getCanonicalType(Context.getTypeDeclType(getParent()));
1550  return Context.hasSameUnqualifiedType(ClassType, ParamType);
1551 }
1552 
1554  // C++0x [class.copy]p19:
1555  // A user-declared move assignment operator X::operator= is a non-static
1556  // non-template member function of class X with exactly one parameter of type
1557  // X&&, const X&&, volatile X&&, or const volatile X&&.
1558  if (getOverloadedOperator() != OO_Equal || isStatic() ||
1560  getNumParams() != 1)
1561  return false;
1562 
1563  QualType ParamType = getParamDecl(0)->getType();
1564  if (!isa<RValueReferenceType>(ParamType))
1565  return false;
1566  ParamType = ParamType->getPointeeType();
1567 
1568  ASTContext &Context = getASTContext();
1569  QualType ClassType
1570  = Context.getCanonicalType(Context.getTypeDeclType(getParent()));
1571  return Context.hasSameUnqualifiedType(ClassType, ParamType);
1572 }
1573 
1575  assert(MD->isCanonicalDecl() && "Method is not canonical!");
1576  assert(!MD->getParent()->isDependentContext() &&
1577  "Can't add an overridden method to a class template!");
1578  assert(MD->isVirtual() && "Method is not virtual!");
1579 
1580  getASTContext().addOverriddenMethod(this, MD);
1581 }
1582 
1584  if (isa<CXXConstructorDecl>(this)) return nullptr;
1585  return getASTContext().overridden_methods_begin(this);
1586 }
1587 
1589  if (isa<CXXConstructorDecl>(this)) return nullptr;
1590  return getASTContext().overridden_methods_end(this);
1591 }
1592 
1594  if (isa<CXXConstructorDecl>(this)) return 0;
1595  return getASTContext().overridden_methods_size(this);
1596 }
1597 
1599  // C++ 9.3.2p1: The type of this in a member function of a class X is X*.
1600  // If the member function is declared const, the type of this is const X*,
1601  // if the member function is declared volatile, the type of this is
1602  // volatile X*, and if the member function is declared const volatile,
1603  // the type of this is const volatile X*.
1604 
1605  assert(isInstance() && "No 'this' for static methods!");
1606 
1607  QualType ClassTy = C.getTypeDeclType(getParent());
1608  ClassTy = C.getQualifiedType(ClassTy,
1610  return C.getPointerType(ClassTy);
1611 }
1612 
1614  // If this function is a template instantiation, look at the template from
1615  // which it was instantiated.
1616  const FunctionDecl *CheckFn = getTemplateInstantiationPattern();
1617  if (!CheckFn)
1618  CheckFn = this;
1619 
1620  const FunctionDecl *fn;
1621  return CheckFn->hasBody(fn) && !fn->isOutOfLine();
1622 }
1623 
1625  const CXXRecordDecl *P = getParent();
1626  if (P->isLambda()) {
1627  if (const CXXMethodDecl *StaticInvoker = P->getLambdaStaticInvoker()) {
1628  if (StaticInvoker == this) return true;
1630  return StaticInvoker == this->getPrimaryTemplate()->getTemplatedDecl();
1631  }
1632  }
1633  return false;
1634 }
1635 
1636 CXXCtorInitializer::CXXCtorInitializer(ASTContext &Context,
1637  TypeSourceInfo *TInfo, bool IsVirtual,
1638  SourceLocation L, Expr *Init,
1639  SourceLocation R,
1640  SourceLocation EllipsisLoc)
1641  : Initializee(TInfo), MemberOrEllipsisLocation(EllipsisLoc), Init(Init),
1642  LParenLoc(L), RParenLoc(R), IsDelegating(false), IsVirtual(IsVirtual),
1643  IsWritten(false), SourceOrderOrNumArrayIndices(0)
1644 {
1645 }
1646 
1647 CXXCtorInitializer::CXXCtorInitializer(ASTContext &Context,
1648  FieldDecl *Member,
1649  SourceLocation MemberLoc,
1650  SourceLocation L, Expr *Init,
1651  SourceLocation R)
1652  : Initializee(Member), MemberOrEllipsisLocation(MemberLoc), Init(Init),
1653  LParenLoc(L), RParenLoc(R), IsDelegating(false), IsVirtual(false),
1654  IsWritten(false), SourceOrderOrNumArrayIndices(0)
1655 {
1656 }
1657 
1658 CXXCtorInitializer::CXXCtorInitializer(ASTContext &Context,
1659  IndirectFieldDecl *Member,
1660  SourceLocation MemberLoc,
1661  SourceLocation L, Expr *Init,
1662  SourceLocation R)
1663  : Initializee(Member), MemberOrEllipsisLocation(MemberLoc), Init(Init),
1664  LParenLoc(L), RParenLoc(R), IsDelegating(false), IsVirtual(false),
1665  IsWritten(false), SourceOrderOrNumArrayIndices(0)
1666 {
1667 }
1668 
1669 CXXCtorInitializer::CXXCtorInitializer(ASTContext &Context,
1670  TypeSourceInfo *TInfo,
1671  SourceLocation L, Expr *Init,
1672  SourceLocation R)
1673  : Initializee(TInfo), MemberOrEllipsisLocation(), Init(Init),
1674  LParenLoc(L), RParenLoc(R), IsDelegating(true), IsVirtual(false),
1675  IsWritten(false), SourceOrderOrNumArrayIndices(0)
1676 {
1677 }
1678 
1679 CXXCtorInitializer::CXXCtorInitializer(ASTContext &Context,
1680  FieldDecl *Member,
1681  SourceLocation MemberLoc,
1682  SourceLocation L, Expr *Init,
1683  SourceLocation R,
1684  VarDecl **Indices,
1685  unsigned NumIndices)
1686  : Initializee(Member), MemberOrEllipsisLocation(MemberLoc), Init(Init),
1687  LParenLoc(L), RParenLoc(R), IsDelegating(false), IsVirtual(false),
1688  IsWritten(false), SourceOrderOrNumArrayIndices(NumIndices)
1689 {
1690  std::uninitialized_copy(Indices, Indices + NumIndices,
1691  getTrailingObjects<VarDecl *>());
1692 }
1693 
1695  FieldDecl *Member,
1696  SourceLocation MemberLoc,
1697  SourceLocation L, Expr *Init,
1698  SourceLocation R,
1699  VarDecl **Indices,
1700  unsigned NumIndices) {
1701  void *Mem = Context.Allocate(totalSizeToAlloc<VarDecl *>(NumIndices),
1702  llvm::alignOf<CXXCtorInitializer>());
1703  return new (Mem) CXXCtorInitializer(Context, Member, MemberLoc, L, Init, R,
1704  Indices, NumIndices);
1705 }
1706 
1708  if (isBaseInitializer())
1709  return Initializee.get<TypeSourceInfo*>()->getTypeLoc();
1710  else
1711  return TypeLoc();
1712 }
1713 
1715  if (isBaseInitializer())
1716  return Initializee.get<TypeSourceInfo*>()->getType().getTypePtr();
1717  else
1718  return nullptr;
1719 }
1720 
1723  return getAnyMember()->getLocation();
1724 
1725  if (isAnyMemberInitializer())
1726  return getMemberLocation();
1727 
1728  if (TypeSourceInfo *TSInfo = Initializee.get<TypeSourceInfo*>())
1729  return TSInfo->getTypeLoc().getLocalSourceRange().getBegin();
1730 
1731  return SourceLocation();
1732 }
1733 
1736  FieldDecl *D = getAnyMember();
1737  if (Expr *I = D->getInClassInitializer())
1738  return I->getSourceRange();
1739  return SourceRange();
1740  }
1741 
1743 }
1744 
1745 void CXXConstructorDecl::anchor() { }
1746 
1749  return new (C, ID) CXXConstructorDecl(C, nullptr, SourceLocation(),
1751  nullptr, false, false, false, false);
1752 }
1753 
1756  SourceLocation StartLoc,
1757  const DeclarationNameInfo &NameInfo,
1758  QualType T, TypeSourceInfo *TInfo,
1759  bool isExplicit, bool isInline,
1760  bool isImplicitlyDeclared, bool isConstexpr) {
1761  assert(NameInfo.getName().getNameKind()
1763  "Name must refer to a constructor");
1764  return new (C, RD) CXXConstructorDecl(C, RD, StartLoc, NameInfo, T, TInfo,
1765  isExplicit, isInline,
1766  isImplicitlyDeclared, isConstexpr);
1767 }
1768 
1770  return CtorInitializers.get(getASTContext().getExternalSource());
1771 }
1772 
1774  assert(isDelegatingConstructor() && "Not a delegating constructor!");
1775  Expr *E = (*init_begin())->getInit()->IgnoreImplicit();
1776  if (CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(E))
1777  return Construct->getConstructor();
1778 
1779  return nullptr;
1780 }
1781 
1783  // C++ [class.ctor]p5:
1784  // A default constructor for a class X is a constructor of class
1785  // X that can be called without an argument.
1786  return (getNumParams() == 0) ||
1787  (getNumParams() > 0 && getParamDecl(0)->hasDefaultArg());
1788 }
1789 
1790 bool
1791 CXXConstructorDecl::isCopyConstructor(unsigned &TypeQuals) const {
1792  return isCopyOrMoveConstructor(TypeQuals) &&
1794 }
1795 
1796 bool CXXConstructorDecl::isMoveConstructor(unsigned &TypeQuals) const {
1797  return isCopyOrMoveConstructor(TypeQuals) &&
1799 }
1800 
1801 /// \brief Determine whether this is a copy or move constructor.
1802 bool CXXConstructorDecl::isCopyOrMoveConstructor(unsigned &TypeQuals) const {
1803  // C++ [class.copy]p2:
1804  // A non-template constructor for class X is a copy constructor
1805  // if its first parameter is of type X&, const X&, volatile X& or
1806  // const volatile X&, and either there are no other parameters
1807  // or else all other parameters have default arguments (8.3.6).
1808  // C++0x [class.copy]p3:
1809  // A non-template constructor for class X is a move constructor if its
1810  // first parameter is of type X&&, const X&&, volatile X&&, or
1811  // const volatile X&&, and either there are no other parameters or else
1812  // all other parameters have default arguments.
1813  if ((getNumParams() < 1) ||
1814  (getNumParams() > 1 && !getParamDecl(1)->hasDefaultArg()) ||
1815  (getPrimaryTemplate() != nullptr) ||
1816  (getDescribedFunctionTemplate() != nullptr))
1817  return false;
1818 
1819  const ParmVarDecl *Param = getParamDecl(0);
1820 
1821  // Do we have a reference type?
1822  const ReferenceType *ParamRefType = Param->getType()->getAs<ReferenceType>();
1823  if (!ParamRefType)
1824  return false;
1825 
1826  // Is it a reference to our class type?
1827  ASTContext &Context = getASTContext();
1828 
1829  CanQualType PointeeType
1830  = Context.getCanonicalType(ParamRefType->getPointeeType());
1831  CanQualType ClassTy
1832  = Context.getCanonicalType(Context.getTagDeclType(getParent()));
1833  if (PointeeType.getUnqualifiedType() != ClassTy)
1834  return false;
1835 
1836  // FIXME: other qualifiers?
1837 
1838  // We have a copy or move constructor.
1839  TypeQuals = PointeeType.getCVRQualifiers();
1840  return true;
1841 }
1842 
1843 bool CXXConstructorDecl::isConvertingConstructor(bool AllowExplicit) const {
1844  // C++ [class.conv.ctor]p1:
1845  // A constructor declared without the function-specifier explicit
1846  // that can be called with a single parameter specifies a
1847  // conversion from the type of its first parameter to the type of
1848  // its class. Such a constructor is called a converting
1849  // constructor.
1850  if (isExplicit() && !AllowExplicit)
1851  return false;
1852 
1853  return (getNumParams() == 0 &&
1854  getType()->getAs<FunctionProtoType>()->isVariadic()) ||
1855  (getNumParams() == 1) ||
1856  (getNumParams() > 1 &&
1857  (getParamDecl(1)->hasDefaultArg() ||
1858  getParamDecl(1)->isParameterPack()));
1859 }
1860 
1862  if ((getNumParams() < 1) ||
1863  (getNumParams() > 1 && !getParamDecl(1)->hasDefaultArg()) ||
1864  (getDescribedFunctionTemplate() != nullptr))
1865  return false;
1866 
1867  const ParmVarDecl *Param = getParamDecl(0);
1868 
1869  ASTContext &Context = getASTContext();
1870  CanQualType ParamType = Context.getCanonicalType(Param->getType());
1871 
1872  // Is it the same as our our class type?
1873  CanQualType ClassTy
1874  = Context.getCanonicalType(Context.getTagDeclType(getParent()));
1875  if (ParamType.getUnqualifiedType() != ClassTy)
1876  return false;
1877 
1878  return true;
1879 }
1880 
1882  // Hack: we store the inherited constructor in the overridden method table
1884  if (It == getASTContext().overridden_methods_end(this))
1885  return nullptr;
1886 
1887  return cast<CXXConstructorDecl>(*It);
1888 }
1889 
1890 void
1892  // Hack: we store the inherited constructor in the overridden method table
1893  assert(getASTContext().overridden_methods_size(this) == 0 &&
1894  "Base ctor already set.");
1895  getASTContext().addOverriddenMethod(this, BaseCtor);
1896 }
1897 
1898 void CXXDestructorDecl::anchor() { }
1899 
1902  return new (C, ID)
1904  QualType(), nullptr, false, false);
1905 }
1906 
1909  SourceLocation StartLoc,
1910  const DeclarationNameInfo &NameInfo,
1911  QualType T, TypeSourceInfo *TInfo,
1912  bool isInline, bool isImplicitlyDeclared) {
1913  assert(NameInfo.getName().getNameKind()
1915  "Name must refer to a destructor");
1916  return new (C, RD) CXXDestructorDecl(C, RD, StartLoc, NameInfo, T, TInfo,
1917  isInline, isImplicitlyDeclared);
1918 }
1919 
1921  auto *First = cast<CXXDestructorDecl>(getFirstDecl());
1922  if (OD && !First->OperatorDelete) {
1923  First->OperatorDelete = OD;
1924  if (auto *L = getASTMutationListener())
1925  L->ResolvedOperatorDelete(First, OD);
1926  }
1927 }
1928 
1929 void CXXConversionDecl::anchor() { }
1930 
1933  return new (C, ID) CXXConversionDecl(C, nullptr, SourceLocation(),
1935  nullptr, false, false, false,
1936  SourceLocation());
1937 }
1938 
1941  SourceLocation StartLoc,
1942  const DeclarationNameInfo &NameInfo,
1943  QualType T, TypeSourceInfo *TInfo,
1944  bool isInline, bool isExplicit,
1945  bool isConstexpr, SourceLocation EndLocation) {
1946  assert(NameInfo.getName().getNameKind()
1948  "Name must refer to a conversion function");
1949  return new (C, RD) CXXConversionDecl(C, RD, StartLoc, NameInfo, T, TInfo,
1950  isInline, isExplicit, isConstexpr,
1951  EndLocation);
1952 }
1953 
1955  return isImplicit() && getParent()->isLambda() &&
1957 }
1958 
1959 void LinkageSpecDecl::anchor() { }
1960 
1962  DeclContext *DC,
1963  SourceLocation ExternLoc,
1964  SourceLocation LangLoc,
1965  LanguageIDs Lang,
1966  bool HasBraces) {
1967  return new (C, DC) LinkageSpecDecl(DC, ExternLoc, LangLoc, Lang, HasBraces);
1968 }
1969 
1971  unsigned ID) {
1972  return new (C, ID) LinkageSpecDecl(nullptr, SourceLocation(),
1973  SourceLocation(), lang_c, false);
1974 }
1975 
1976 void UsingDirectiveDecl::anchor() { }
1977 
1979  SourceLocation L,
1980  SourceLocation NamespaceLoc,
1981  NestedNameSpecifierLoc QualifierLoc,
1982  SourceLocation IdentLoc,
1983  NamedDecl *Used,
1984  DeclContext *CommonAncestor) {
1985  if (NamespaceDecl *NS = dyn_cast_or_null<NamespaceDecl>(Used))
1986  Used = NS->getOriginalNamespace();
1987  return new (C, DC) UsingDirectiveDecl(DC, L, NamespaceLoc, QualifierLoc,
1988  IdentLoc, Used, CommonAncestor);
1989 }
1990 
1992  unsigned ID) {
1993  return new (C, ID) UsingDirectiveDecl(nullptr, SourceLocation(),
1994  SourceLocation(),
1996  SourceLocation(), nullptr, nullptr);
1997 }
1998 
2000  if (NamespaceAliasDecl *NA =
2001  dyn_cast_or_null<NamespaceAliasDecl>(NominatedNamespace))
2002  return NA->getNamespace();
2003  return cast_or_null<NamespaceDecl>(NominatedNamespace);
2004 }
2005 
2006 NamespaceDecl::NamespaceDecl(ASTContext &C, DeclContext *DC, bool Inline,
2007  SourceLocation StartLoc, SourceLocation IdLoc,
2008  IdentifierInfo *Id, NamespaceDecl *PrevDecl)
2009  : NamedDecl(Namespace, DC, IdLoc, Id), DeclContext(Namespace),
2010  redeclarable_base(C), LocStart(StartLoc), RBraceLoc(),
2011  AnonOrFirstNamespaceAndInline(nullptr, Inline) {
2012  setPreviousDecl(PrevDecl);
2013 
2014  if (PrevDecl)
2015  AnonOrFirstNamespaceAndInline.setPointer(PrevDecl->getOriginalNamespace());
2016 }
2017 
2019  bool Inline, SourceLocation StartLoc,
2020  SourceLocation IdLoc, IdentifierInfo *Id,
2021  NamespaceDecl *PrevDecl) {
2022  return new (C, DC) NamespaceDecl(C, DC, Inline, StartLoc, IdLoc, Id,
2023  PrevDecl);
2024 }
2025 
2027  return new (C, ID) NamespaceDecl(C, nullptr, false, SourceLocation(),
2028  SourceLocation(), nullptr, nullptr);
2029 }
2030 
2032  if (isFirstDecl())
2033  return this;
2034 
2035  return AnonOrFirstNamespaceAndInline.getPointer();
2036 }
2037 
2039  if (isFirstDecl())
2040  return this;
2041 
2042  return AnonOrFirstNamespaceAndInline.getPointer();
2043 }
2044 
2046 
2047 NamespaceDecl *NamespaceDecl::getNextRedeclarationImpl() {
2048  return getNextRedeclaration();
2049 }
2050 NamespaceDecl *NamespaceDecl::getPreviousDeclImpl() {
2051  return getPreviousDecl();
2052 }
2053 NamespaceDecl *NamespaceDecl::getMostRecentDeclImpl() {
2054  return getMostRecentDecl();
2055 }
2056 
2057 void NamespaceAliasDecl::anchor() { }
2058 
2059 NamespaceAliasDecl *NamespaceAliasDecl::getNextRedeclarationImpl() {
2060  return getNextRedeclaration();
2061 }
2062 NamespaceAliasDecl *NamespaceAliasDecl::getPreviousDeclImpl() {
2063  return getPreviousDecl();
2064 }
2065 NamespaceAliasDecl *NamespaceAliasDecl::getMostRecentDeclImpl() {
2066  return getMostRecentDecl();
2067 }
2068 
2070  SourceLocation UsingLoc,
2071  SourceLocation AliasLoc,
2072  IdentifierInfo *Alias,
2073  NestedNameSpecifierLoc QualifierLoc,
2074  SourceLocation IdentLoc,
2075  NamedDecl *Namespace) {
2076  // FIXME: Preserve the aliased namespace as written.
2077  if (NamespaceDecl *NS = dyn_cast_or_null<NamespaceDecl>(Namespace))
2078  Namespace = NS->getOriginalNamespace();
2079  return new (C, DC) NamespaceAliasDecl(C, DC, UsingLoc, AliasLoc, Alias,
2080  QualifierLoc, IdentLoc, Namespace);
2081 }
2082 
2085  return new (C, ID) NamespaceAliasDecl(C, nullptr, SourceLocation(),
2086  SourceLocation(), nullptr,
2088  SourceLocation(), nullptr);
2089 }
2090 
2091 void UsingShadowDecl::anchor() { }
2092 
2095  return new (C, ID) UsingShadowDecl(C, nullptr, SourceLocation(),
2096  nullptr, nullptr);
2097 }
2098 
2100  const UsingShadowDecl *Shadow = this;
2101  while (const UsingShadowDecl *NextShadow =
2102  dyn_cast<UsingShadowDecl>(Shadow->UsingOrNextShadow))
2103  Shadow = NextShadow;
2104  return cast<UsingDecl>(Shadow->UsingOrNextShadow);
2105 }
2106 
2107 void UsingDecl::anchor() { }
2108 
2110  assert(std::find(shadow_begin(), shadow_end(), S) == shadow_end() &&
2111  "declaration already in set");
2112  assert(S->getUsingDecl() == this);
2113 
2114  if (FirstUsingShadow.getPointer())
2115  S->UsingOrNextShadow = FirstUsingShadow.getPointer();
2116  FirstUsingShadow.setPointer(S);
2117 }
2118 
2120  assert(std::find(shadow_begin(), shadow_end(), S) != shadow_end() &&
2121  "declaration not in set");
2122  assert(S->getUsingDecl() == this);
2123 
2124  // Remove S from the shadow decl chain. This is O(n) but hopefully rare.
2125 
2126  if (FirstUsingShadow.getPointer() == S) {
2127  FirstUsingShadow.setPointer(
2128  dyn_cast<UsingShadowDecl>(S->UsingOrNextShadow));
2129  S->UsingOrNextShadow = this;
2130  return;
2131  }
2132 
2133  UsingShadowDecl *Prev = FirstUsingShadow.getPointer();
2134  while (Prev->UsingOrNextShadow != S)
2135  Prev = cast<UsingShadowDecl>(Prev->UsingOrNextShadow);
2136  Prev->UsingOrNextShadow = S->UsingOrNextShadow;
2137  S->UsingOrNextShadow = this;
2138 }
2139 
2141  NestedNameSpecifierLoc QualifierLoc,
2142  const DeclarationNameInfo &NameInfo,
2143  bool HasTypename) {
2144  return new (C, DC) UsingDecl(DC, UL, QualifierLoc, NameInfo, HasTypename);
2145 }
2146 
2148  return new (C, ID) UsingDecl(nullptr, SourceLocation(),
2150  false);
2151 }
2152 
2155  ? getQualifierLoc().getBeginLoc() : UsingLocation;
2156  return SourceRange(Begin, getNameInfo().getEndLoc());
2157 }
2158 
2159 void UnresolvedUsingValueDecl::anchor() { }
2160 
2163  SourceLocation UsingLoc,
2164  NestedNameSpecifierLoc QualifierLoc,
2165  const DeclarationNameInfo &NameInfo) {
2166  return new (C, DC) UnresolvedUsingValueDecl(DC, C.DependentTy, UsingLoc,
2167  QualifierLoc, NameInfo);
2168 }
2169 
2172  return new (C, ID) UnresolvedUsingValueDecl(nullptr, QualType(),
2173  SourceLocation(),
2176 }
2177 
2180  ? getQualifierLoc().getBeginLoc() : UsingLocation;
2181  return SourceRange(Begin, getNameInfo().getEndLoc());
2182 }
2183 
2184 void UnresolvedUsingTypenameDecl::anchor() { }
2185 
2188  SourceLocation UsingLoc,
2189  SourceLocation TypenameLoc,
2190  NestedNameSpecifierLoc QualifierLoc,
2191  SourceLocation TargetNameLoc,
2192  DeclarationName TargetName) {
2193  return new (C, DC) UnresolvedUsingTypenameDecl(
2194  DC, UsingLoc, TypenameLoc, QualifierLoc, TargetNameLoc,
2195  TargetName.getAsIdentifierInfo());
2196 }
2197 
2200  return new (C, ID) UnresolvedUsingTypenameDecl(
2202  SourceLocation(), nullptr);
2203 }
2204 
2205 void StaticAssertDecl::anchor() { }
2206 
2208  SourceLocation StaticAssertLoc,
2209  Expr *AssertExpr,
2210  StringLiteral *Message,
2211  SourceLocation RParenLoc,
2212  bool Failed) {
2213  return new (C, DC) StaticAssertDecl(DC, StaticAssertLoc, AssertExpr, Message,
2214  RParenLoc, Failed);
2215 }
2216 
2218  unsigned ID) {
2219  return new (C, ID) StaticAssertDecl(nullptr, SourceLocation(), nullptr,
2220  nullptr, SourceLocation(), false);
2221 }
2222 
2225  QualType T, TypeSourceInfo *TInfo,
2226  SourceLocation StartL,
2227  IdentifierInfo *Getter,
2228  IdentifierInfo *Setter) {
2229  return new (C, DC) MSPropertyDecl(DC, L, N, T, TInfo, StartL, Getter, Setter);
2230 }
2231 
2233  unsigned ID) {
2234  return new (C, ID) MSPropertyDecl(nullptr, SourceLocation(),
2235  DeclarationName(), QualType(), nullptr,
2236  SourceLocation(), nullptr, nullptr);
2237 }
2238 
2239 static const char *getAccessName(AccessSpecifier AS) {
2240  switch (AS) {
2241  case AS_none:
2242  llvm_unreachable("Invalid access specifier!");
2243  case AS_public:
2244  return "public";
2245  case AS_private:
2246  return "private";
2247  case AS_protected:
2248  return "protected";
2249  }
2250  llvm_unreachable("Invalid access specifier!");
2251 }
2252 
2254  AccessSpecifier AS) {
2255  return DB << getAccessName(AS);
2256 }
2257 
2259  AccessSpecifier AS) {
2260  return DB << getAccessName(AS);
2261 }
static NamespaceDecl * Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl)
Definition: DeclCXX.cpp:2018
Defines the clang::ASTContext interface.
static const char * getAccessName(AccessSpecifier AS)
Definition: DeclCXX.cpp:2239
void setImplicit(bool I=true)
Definition: DeclBase.h:515
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1483
iterator begin() const
Definition: DeclBase.h:1090
bool isCXX98PODType(ASTContext &Context) const
Return true if this is a POD type according to the rules of the C++98 standard, regardless of the cur...
Definition: Type.cpp:1969
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization, retrieves the member specialization information.
Definition: DeclCXX.cpp:1221
A (possibly-)qualified type.
Definition: Type.h:575
unsigned overridden_methods_size(const CXXMethodDecl *Method) const
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
Definition: DeclCXX.h:206
virtual Decl * GetExternalDecl(uint32_t ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
base_class_range bases()
Definition: DeclCXX.h:713
bool replace(const NamedDecl *Old, NamedDecl *New, AccessSpecifier AS)
Replaces the given declaration with the new one, once.
void erase(unsigned I)
QualType getConversionType() const
Returns the type that this conversion function is converting to.
Definition: DeclCXX.h:2432
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
Definition: DeclCXX.h:1263
QualType getType() const
Retrieves the type of the base class.
Definition: DeclCXX.h:252
static UnresolvedUsingValueDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2171
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
Definition: ASTContext.h:1673
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration...
Definition: DeclCXX.h:1786
bool hasDefaultArg() const
hasDefaultArg - Determines whether this parameter has a default argument, either parsed or not...
Definition: Decl.cpp:2420
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a member function...
Definition: Decl.cpp:3318
bool IsBeingDefined
IsBeingDefined - True if this is currently being defined.
Definition: Decl.h:2662
static AccessSpecDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:33
bool isInClassMemberInitializer() const
Determine whether this initializer is an implicit initializer generated for a field with an initializ...
Definition: DeclCXX.h:1987
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:77
void setInheritedConstructor(const CXXConstructorDecl *BaseCtor)
Set the constructor that this inheriting constructor is based on.
Definition: DeclCXX.cpp:1891
bool isSpecializationCopyingObject() const
Determine whether this is a member template specialization that would copy the object to itself...
Definition: DeclCXX.cpp:1861
void append(ASTContext &C, iterator I, iterator E)
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
Definition: Lambda.h:23
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
Definition: Type.cpp:2149
Defines the C++ template declaration subclasses.
bool hasNonTrivialDestructor() const
Determine whether this class has a non-trivial destructor (C++ [class.dtor]p3)
Definition: DeclCXX.h:1269
unsigned getCVRQualifiers() const
Retrieve the const/volatile/restrict qualifiers.
llvm::iterator_range< conversion_iterator > getVisibleConversionFunctions()
Get all conversion functions visible in current class, including conversion function templates...
Definition: DeclCXX.cpp:1171
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
Definition: DeclBase.h:834
bool hasDefinition() const
Definition: DeclCXX.h:680
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
Definition: Attr.h:154
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
The base class of the type hierarchy.
Definition: Type.h:1249
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Definition: DeclBase.cpp:884
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
Definition: Type.h:5122
MapType::iterator iterator
bool forallBases(ForallBasesCallback BaseMatches, bool AllowShortCircuit=true) const
Determines if the given callback holds for all the direct or indirect base classes of this type...
SourceLocation getRParenLoc() const
Definition: DeclCXX.h:2090
NamespaceDecl - Represent a C++ namespace.
Definition: Decl.h:402
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1149
virtual void completeDefinition()
completeDefinition - Notes that the definition of this type is now complete.
Definition: Decl.cpp:3755
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition: Specifiers.h:90
A container of type source information.
Definition: Decl.h:61
bool isBlockPointerType() const
Definition: Type.h:5311
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:26
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2134
Expr * getInClassInitializer() const
getInClassInitializer - Get the C++11 in-class initializer for this member, or null if one has not be...
Definition: Decl.h:2332
bool isCopyAssignmentOperator() const
Determine whether this is a copy-assignment operator, regardless of whether it was declared implicitl...
Definition: DeclCXX.cpp:1532
This file provides some common utility functions for processing Lambda related AST Constructs...
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:699
static CXXConversionDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isExplicit, bool isConstexpr, SourceLocation EndLocation)
Definition: DeclCXX.cpp:1940
void finishedDefaultedOrDeletedMember(CXXMethodDecl *MD)
Indicates that the declaration of a defaulted or deleted special member function is now complete...
Definition: DeclCXX.cpp:933
AccessSpecifier getAccess() const
Definition: DeclBase.h:428
field_iterator field_begin() const
Definition: Decl.cpp:3746
bool isCLike() const
True if this class is C-like, without C++-specific features, e.g.
Definition: DeclCXX.cpp:969
static MSPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL, IdentifierInfo *Getter, IdentifierInfo *Setter)
Definition: DeclCXX.cpp:2223
The "__interface" keyword.
Definition: Type.h:4178
QualType getThisType(ASTContext &C) const
Returns the type of the this pointer.
Definition: DeclCXX.cpp:1598
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Definition: Decl.h:319
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:48
bool hasNonTrivialMoveAssignment() const
Determine whether this class has a non-trivial move assignment operator (C++11 [class.copy]p25)
Definition: DeclCXX.h:1255
bool MayHaveOutOfDateDef
Indicates whether it is possible for declarations of this kind to have an out-of-date definition...
Definition: Decl.h:2695
ParmVarDecl - Represents a parameter to a function.
Definition: Decl.h:1299
bool isObjCRetainableType() const
Definition: Type.cpp:3704
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
Definition: DeclCXX.cpp:1553
Defines the clang::Expr interface and subclasses for C++ expressions.
bool hasMutableFields() const
Determine whether this class, or any of its class subobjects, contains a mutable field.
Definition: DeclCXX.h:1163
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
Definition: DeclCXX.cpp:1270
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
Definition: DeclCXX.h:1965
bool isUsualDeallocationFunction() const
Determine whether this is a usual deallocation function (C++ [basic.stc.dynamic.deallocation]p2), which is an overloaded delete or delete[] operator with a particular signature.
Definition: DeclCXX.cpp:1490
bool hasTrivialCopyConstructor() const
Determine whether this class has a trivial copy constructor (C++ [class.copy]p6, C++11 [class...
Definition: DeclCXX.h:1207
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
Definition: DeclCXX.cpp:1255
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:40
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3166
ASTMutationListener * getASTMutationListener() const
Definition: DeclBase.cpp:315
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body (definition).
Definition: Decl.cpp:2460
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
Definition: Decl.h:2073
DeclarationName getName() const
getName - Returns the embedded declaration name.
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
Definition: DeclCXX.h:1144
method_iterator end_overridden_methods() const
Definition: DeclCXX.cpp:1588
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Definition: Type.h:4381
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:91
A C++ nested-name-specifier augmented with source location information.
The results of name lookup within a DeclContext.
Definition: DeclBase.h:1054
bool isDelegatingConstructor() const
Determine whether this constructor is a delegating constructor.
Definition: DeclCXX.h:2242
bool hasNonTrivialCopyConstructor() const
Determine whether this class has a non-trivial copy constructor (C++ [class.copy]p6, C++11 [class.copy]p12)
Definition: DeclCXX.h:1213
bool isAccessDeclaration() const
Return true if it is a C++03 access declaration (no 'using').
Definition: DeclCXX.h:2907
bool isReferenceType() const
Definition: Type.h:5314
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2209
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Definition: DeclTemplate.h:891
CXXConstructorDecl * getTargetConstructor() const
When this constructor delegates to another, retrieve the target.
Definition: DeclCXX.cpp:1773
static CXXRecordDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:129
void Deallocate(void *Ptr) const
Definition: ASTContext.h:566
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:1769
unsigned size() const
CXXRecordDecl * getDefinition() const
Definition: DeclCXX.h:675
static CXXCtorInitializer * Create(ASTContext &Context, FieldDecl *Member, SourceLocation MemberLoc, SourceLocation L, Expr *Init, SourceLocation R, VarDecl **Indices, unsigned NumIndices)
Creates a new member initializer that optionally contains array indices used to describe an elementwi...
Definition: DeclCXX.cpp:1694
TagKind getTagKind() const
Definition: Decl.h:2847
The iterator over UnresolvedSets.
Definition: UnresolvedSet.h:28
DeclarationName getCXXDestructorName(CanQualType Ty)
getCXXDestructorName - Returns the name of a C++ destructor for the given Type.
Represents an access specifier followed by colon ':'.
Definition: DeclCXX.h:101
void addShadowDecl(UsingShadowDecl *S)
Definition: DeclCXX.cpp:2109
static StaticAssertDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2217
static CXXRecordDecl * CreateLambda(const ASTContext &C, DeclContext *DC, TypeSourceInfo *Info, SourceLocation Loc, bool DependentLambda, bool IsGeneric, LambdaCaptureDefault CaptureDefault)
Definition: DeclCXX.cpp:111
bool isAnyDestructorNoReturn() const
Returns true if the class destructor, or any implicitly invoked destructors are marked noreturn...
Definition: DeclCXX.cpp:1324
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Definition: ASTContext.h:1191
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
Definition: ASTContext.h:1987
static NamespaceDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2026
IdentifierTable & Idents
Definition: ASTContext.h:451
Represents a C++ using-declaration.
Definition: DeclCXX.h:2858
NamespaceDecl * getNextRedeclaration() const
Definition: Redeclarable.h:134
void completeDefinition() override
Indicates that the definition of this class is now complete.
Definition: DeclCXX.cpp:1346
void addDecl(ASTContext &C, NamedDecl *D, AccessSpecifier AS)
const LangOptions & getLangOpts() const
Definition: ASTContext.h:596
CXXMethodDecl(Kind DK, ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInline, bool isConstexpr, SourceLocation EndLocation)
Definition: DeclCXX.h:1704
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:514
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
Definition: DeclCXX.h:1801
shadow_iterator shadow_begin() const
Definition: DeclCXX.h:2958
field_range fields() const
Definition: Decl.h:3295
static UnresolvedUsingTypenameDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2199
bool hasCopyAssignmentWithConstParam() const
Determine whether this class has a copy assignment operator with a parameter type which is a referenc...
Definition: DeclCXX.h:958
bool hasNonLiteralTypeFieldsOrBases() const
Determine whether this class has a non-literal or/ volatile type non-static data member or base class...
Definition: DeclCXX.h:1284
void setHasObjectMember(bool val)
Definition: Decl.h:3239
A set of unresolved declarations.
Definition: UnresolvedSet.h:55
RecordDecl * getDecl() const
Definition: Type.h:3553
FunctionDecl * getTemplateInstantiationPattern() const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
Definition: Decl.cpp:3123
bool isVariadic() const
Whether this function is variadic.
Definition: Decl.cpp:2454
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:651
const Type * getBaseClass() const
If this is a base class initializer, returns the type of the base class.
Definition: DeclCXX.cpp:1714
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclCXX.cpp:2153
base_class_iterator bases_begin()
Definition: DeclCXX.h:720
static UnresolvedUsingValueDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo)
Definition: DeclCXX.cpp:2162
static NamespaceAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Namespace)
Definition: DeclCXX.cpp:2069
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
Definition: Decl.cpp:3063
Represents a linkage specification.
Definition: DeclCXX.h:2454
StringRef getLambdaStaticInvokerName()
Definition: ASTLambda.h:23
detail::InMemoryDirectory::const_iterator I
NamedDecl * getDecl() const
Definition: UnresolvedSet.h:44
bool isLambdaToBlockPointerConversion() const
Determine whether this conversion function is a conversion from a lambda closure type to a block poin...
Definition: DeclCXX.cpp:1954
init_iterator init_begin()
Retrieve an iterator to the first initializer.
Definition: DeclCXX.h:2193
QualType getType() const
Definition: Decl.h:530
CXXMethodDecl * getCorrespondingMethodInClass(const CXXRecordDecl *RD, bool MayBeBase=false)
Find the method in RD that corresponds to this one.
Definition: DeclCXX.cpp:1432
shadow_iterator shadow_end() const
Definition: DeclCXX.h:2961
This object can be modified without requiring retains or releases.
Definition: Type.h:137
bool isAbstract() const
Determine whether this class has a pure virtual function.
Definition: DeclCXX.h:1155
field_iterator field_end() const
Definition: Decl.h:3298
CXXRecordDecl(Kind K, TagKind TK, const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl)
Definition: DeclCXX.cpp:86
AnnotatingParser & P
bool isStatic() const
Definition: DeclCXX.cpp:1408
bool isUnion() const
Definition: Decl.h:2856
void setBases(CXXBaseSpecifier const *const *Bases, unsigned NumBases)
Sets the base classes of this struct or class.
Definition: DeclCXX.cpp:138
TypeLoc getBaseClassLoc() const
If this is a base class initializer, returns the type of the base class with location information...
Definition: DeclCXX.cpp:1707
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
Definition: DeclBase.h:96
bool hasCopyConstructorWithConstParam() const
Determine whether this class has a copy constructor with a parameter type which is a reference to a c...
Definition: DeclCXX.h:876
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:866
bool hasIrrelevantDestructor() const
Determine whether this class has a destructor which has no semantic effect.
Definition: DeclCXX.h:1278
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
Definition: DeclCXX.cpp:1214
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
Definition: Type.h:980
bool isParameterPack() const
Determine whether this parameter is actually a function parameter pack.
Definition: Decl.cpp:2428
DeclarationNameTable DeclarationNames
Definition: ASTContext.h:454
bool isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e.
Definition: DeclCXX.cpp:979
overridden_cxx_method_iterator overridden_methods_end(const CXXMethodDecl *Method) const
ASTContext * Context
static StaticAssertDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *Message, SourceLocation RParenLoc, bool Failed)
Definition: DeclCXX.cpp:2207
ID
Defines the set of possible language-specific address spaces.
Definition: AddressSpaces.h:27
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:1979
const CXXMethodDecl *const * method_iterator
Definition: DeclCXX.h:1793
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Definition: Type.cpp:415
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isImplicitlyDeclared)
Definition: DeclCXX.cpp:1908
static bool recursivelyOverrides(const CXXMethodDecl *DerivedMD, const CXXMethodDecl *BaseMD)
Definition: DeclCXX.cpp:1418
bool isMoveConstructor() const
Determine whether this constructor is a move constructor (C++11 [class.copy]p3), which can be used to...
Definition: DeclCXX.h:2287
bool isDeleted() const
Whether this function has been deleted.
Definition: Decl.h:1820
unsigned getTypeQualifiers() const
Definition: DeclCXX.h:1817
Expr - This represents one expression.
Definition: Expr.h:104
bool isInstance() const
Definition: DeclCXX.h:1728
static LinkageSpecDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:1970
bool isVirtual() const
Definition: DeclCXX.h:1745
conversion_iterator conversion_end() const
Definition: DeclCXX.h:1085
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2345
const ParmVarDecl * getParamDecl(unsigned i) const
Definition: Decl.h:1927
overridden_cxx_method_iterator overridden_methods_begin(const CXXMethodDecl *Method) const
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Definition: Redeclarable.h:163
DeclContext * getDeclContext()
Definition: DeclBase.h:393
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Defines the clang::TypeLoc interface and its subclasses.
static CanQualType GetConversionType(ASTContext &Context, NamedDecl *Conv)
Definition: DeclCXX.cpp:1043
SourceLocation getMemberLocation() const
Definition: DeclCXX.h:2051
bool isExplicit() const
Determine whether this constructor was marked "explicit" or not.
Definition: DeclCXX.h:2174
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
static NamespaceAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2084
StorageClass
Storage classes.
Definition: Specifiers.h:198
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:1751
bool isCopyConstructor() const
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the cla...
Definition: DeclCXX.h:2273
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
Definition: DeclCXX.cpp:984
An lvalue reference type, per C++11 [dcl.ref].
Definition: Type.h:2334
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Definition: Decl.h:190
void setDescribedClassTemplate(ClassTemplateDecl *Template)
Definition: DeclCXX.cpp:1239
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2392
static UsingDirectiveDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:1991
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
Definition: Specifiers.h:162
bool hasNonTrivialCopyAssignment() const
Determine whether this class has a non-trivial copy assignment operator (C++ [class.copy]p11, C++11 [class.copy]p25)
Definition: DeclCXX.h:1241
bool hasUninitializedReferenceMember() const
Whether this class or any of its subobjects has any members of reference type which would make value-...
Definition: DeclCXX.h:1117
FunctionDecl * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Definition: Redeclarable.h:156
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
Definition: DeclCXX.cpp:95
DeclarationNameInfo getNameInfo() const
Definition: DeclCXX.h:2902
Abstract interface for external sources of AST nodes.
#define false
Definition: stdbool.h:33
The "struct" keyword.
Definition: Type.h:4176
static UsingShadowDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2094
NamespaceDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Definition: Redeclarable.h:144
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
Definition: DeclBase.cpp:187
SourceRange getSourceRange() const LLVM_READONLY
Determine the source range covering the entire initializer.
Definition: DeclCXX.cpp:1734
static CXXDestructorDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:1901
Encodes a location in the source.
void setOperatorDelete(FunctionDecl *OD)
Definition: DeclCXX.cpp:1920
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
Definition: ASTContext.h:932
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
Definition: Decl.cpp:2743
const TemplateArgument * iterator
Definition: Type.h:4070
method_iterator begin_overridden_methods() const
Definition: DeclCXX.cpp:1583
FieldDecl * getAnyMember() const
Definition: DeclCXX.h:2037
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isExplicit, bool isInline, bool isImplicitlyDeclared, bool isConstexpr)
Definition: DeclCXX.cpp:1755
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
reference front() const
Definition: DeclBase.h:1096
bool hasSimpleMoveConstructor() const
true if we know for sure that this class has a single, accessible, unambiguous move constructor that ...
Definition: DeclCXX.h:800
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:311
unsigned size_overridden_methods() const
Definition: DeclCXX.cpp:1593
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3004
bool mayBeAbstract() const
Determine whether this class may end up being abstract, even though it is not yet known to be abstrac...
Definition: DeclCXX.cpp:1391
void removeShadowDecl(UsingShadowDecl *S)
Definition: DeclCXX.cpp:2119
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1701
SourceLocation getSourceLocation() const
Determine the source location of the initializer.
Definition: DeclCXX.cpp:1721
void addOverriddenMethod(const CXXMethodDecl *MD)
Definition: DeclCXX.cpp:1574
bool isCopyOrMoveConstructor() const
Determine whether this a copy or move constructor.
Definition: DeclCXX.h:2299
bool hasInlineBody() const
Definition: DeclCXX.cpp:1613
void addDecl(NamedDecl *D)
Definition: UnresolvedSet.h:77
static MSPropertyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2232
bool hasVolatileMember() const
Definition: Decl.h:3241
T * get(ExternalASTSource *Source) const
Retrieve the pointer to the AST node that this lazy pointer.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Definition: DeclBase.cpp:1368
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
Definition: Specifiers.h:141
void getCaptureFields(llvm::DenseMap< const VarDecl *, FieldDecl * > &Captures, FieldDecl *&ThisCapture) const
For a closure type, retrieve the mapping from captured variables and this to the non-static data memb...
Definition: DeclCXX.cpp:1016
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3146
bool hasObjectMember() const
Definition: Decl.h:3238
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
Definition: Type.h:5159
CXXMethodDecl * getLambdaStaticInvoker() const
Retrieve the lambda static invoker, the address of which is returned by the conversion operator...
Definition: DeclCXX.cpp:1001
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
Definition: DeclCXX.cpp:1235
bool hasTrivialCopyAssignment() const
Determine whether this class has a trivial copy assignment operator (C++ [class.copy]p11, C++11 [class.copy]p25)
Definition: DeclCXX.h:1235
bool hasSimpleDestructor() const
true if we know for sure that this class has an accessible destructor that is not deleted...
Definition: DeclCXX.h:812
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
Definition: DeclCXX.cpp:1243
TagTypeKind
The kind of a tag type.
Definition: Type.h:4174
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
Definition: Decl.cpp:3164
static bool isStaticOverloadedOperator(OverloadedOperatorKind OOK)
Returns true if the given operator is implicitly static in a record context.
Definition: DeclCXX.h:1732
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
Definition: DeclCXX.cpp:1999
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces)
Definition: DeclCXX.cpp:1961
static CXXConversionDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:1932
void setHasVolatileMember(bool val)
Definition: Decl.h:3242
bool isAccessDeclaration() const
Return true if it is a C++03 access declaration (no 'using').
Definition: DeclCXX.h:3036
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1121
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:22
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
Definition: DeclCXX.cpp:1308
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Definition: DeclBase.h:759
bool hasSimpleMoveAssignment() const
true if we know for sure that this class has a single, accessible, unambiguous move assignment operat...
Definition: DeclCXX.h:806
bool hasVariantMembers() const
Determine whether this class has any variant members.
Definition: DeclCXX.h:1166
bool isInvalidDecl() const
Definition: DeclBase.h:509
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
Definition: Decl.h:2437
void removeConversion(const NamedDecl *Old)
Removes a conversion function from this class.
Definition: DeclCXX.cpp:1189
NamespaceDecl * getOriginalNamespace()
Get the original (first) namespace declaration.
Definition: DeclCXX.cpp:2031
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3087
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
static UsingDirectiveDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespaceLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor)
Definition: DeclCXX.cpp:1978
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
Definition: DeclCXX.h:1170
DeclarationName - The name of a declaration.
static UnresolvedUsingTypenameDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, DeclarationName TargetName)
Definition: DeclCXX.cpp:2187
A mapping from each virtual member function to its set of final overriders.
bool hasTrivialMoveConstructor() const
Determine whether this class has a trivial move constructor (C++11 [class.copy]p12) ...
Definition: DeclCXX.h:1220
detail::InMemoryDirectory::const_iterator E
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition: Specifiers.h:138
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:1946
bool isLValueReferenceType() const
Definition: Type.h:5317
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation...
Definition: DeclCXX.cpp:388
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
bool isLambda() const
Determine whether this class describes a lambda function object.
Definition: DeclCXX.h:1022
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
Definition: DeclBase.h:1459
bool isRValueReferenceType() const
Definition: Type.h:5320
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
Definition: DeclCXX.h:1582
bool hasTrivialMoveAssignment() const
Determine whether this class has a trivial move assignment operator (C++11 [class.copy]p25)
Definition: DeclCXX.h:1248
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:3544
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:5675
UsingDecl * getUsingDecl() const
Gets the using declaration to which this declaration is tied.
Definition: DeclCXX.cpp:2099
Represents a C++ base or member initializer.
Definition: DeclCXX.h:1885
LanguageIDs
Represents the language in a linkage specification.
Definition: DeclCXX.h:2463
bool isConvertingConstructor(bool AllowExplicit) const
Whether this constructor is a converting constructor (C++ [class.conv.ctor]), which can be used for u...
Definition: DeclCXX.cpp:1843
An UnresolvedSet-like class which uses the ASTContext's allocator.
CanQualType DependentTy
Definition: ASTContext.h:896
static CXXMethodDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:1484
bool isLambdaStaticInvoker() const
Determine whether this is a lambda closure type's static member function that is used for the result ...
Definition: DeclCXX.cpp:1624
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2287
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:2895
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition: Type.cpp:1522
bool isOriginalNamespace() const
Return true if this declaration is an original (first) declaration of the namespace.
Definition: DeclCXX.cpp:2045
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
Definition: Decl.h:1759
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
Definition: DeclBase.h:978
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInline, bool isConstexpr, SourceLocation EndLocation)
Definition: DeclCXX.cpp:1473
void setInstantiationOfMemberClass(CXXRecordDecl *RD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member class RD.
Definition: DeclCXX.cpp:1226
The "class" keyword.
Definition: Type.h:4182
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
Represents a base class of a C++ class.
Definition: DeclCXX.h:157
bool isAnyMemberInitializer() const
Definition: DeclCXX.h:1973
const CXXConstructorDecl * getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
Definition: DeclCXX.cpp:1881
QualType getPointeeType() const
Definition: Type.h:2308
TemplateParameterList * getGenericLambdaTemplateParameterList() const
Retrieve the generic lambda's template parameter list.
Definition: DeclCXX.cpp:1035
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
Definition: DeclCXX.cpp:1782
bool isObjCGCStrong() const
true when Type is objc's strong.
Definition: Type.h:975
bool hasNonTrivialMoveConstructor() const
Determine whether this class has a non-trivial move constructor (C++11 [class.copy]p12) ...
Definition: DeclCXX.h:1227
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
static CXXConstructorDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:1748
Represents a C++ struct/union/class.
Definition: DeclCXX.h:285
bool isTriviallyCopyable() const
Determine whether this class is considered trivially copyable per (C++11 [class]p6).
Definition: DeclCXX.cpp:395
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:560
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:492
base_class_iterator bases_end()
Definition: DeclCXX.h:722
static UsingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
Definition: DeclCXX.cpp:2140
Declaration of a class template.
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1452
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:83
static Qualifiers fromCVRMask(unsigned CVR)
Definition: Type.h:211
bool isStandardLayout() const
Determine whether this class has standard layout per (C++ [class]p7)
Definition: DeclCXX.h:1159
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclCXX.cpp:2178
conversion_iterator conversion_begin() const
Definition: DeclCXX.h:1082
NamedDecl * getMostRecentDecl()
Definition: Decl.h:332
CXXCtorInitializer *const * init_const_iterator
Iterates through the member/base initializer list.
Definition: DeclCXX.h:2182
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3040
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:3213
#define true
Definition: stdbool.h:32
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
Definition: DeclBase.h:384
NamedDecl - This represents a decl with a name.
Definition: Decl.h:145
Represents a C++ namespace alias.
Definition: DeclCXX.h:2649
void addOverriddenMethod(const CXXMethodDecl *Method, const CXXMethodDecl *Overridden)
Note that the given C++ Method overrides the given Overridden method.
static UsingDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2147
static void CollectVisibleConversions(ASTContext &Context, CXXRecordDecl *Record, bool InVirtual, AccessSpecifier Access, const llvm::SmallPtrSet< CanQualType, 8 > &ParentHiddenTypes, ASTUnresolvedSet &Output, UnresolvedSetImpl &VOutput, llvm::SmallPtrSet< NamedDecl *, 8 > &HiddenVBaseCs)
Collect the visible conversions of a base class.
Definition: DeclCXX.cpp:1062
void getFinalOverriders(CXXFinalOverriderMap &FinaOverriders) const
Retrieve the final overriders for each virtual member function in the class hierarchy where this clas...
bool isConstQualified() const
Determine whether this type is const-qualified.
Definition: Type.h:5148
Represents C++ using-directive.
Definition: DeclCXX.h:2546
bool hasConstexprDefaultConstructor() const
Determine whether this class has a constexpr default constructor.
Definition: DeclCXX.h:1199
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
Definition: DeclCXX.h:1148
bool isBeingDefined() const
isBeingDefined - Return true if this decl is currently being defined.
Definition: Decl.h:2799
base_class_range vbases()
Definition: DeclCXX.h:730
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
Declaration of a template function.
Definition: DeclTemplate.h:830
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:2766
DeclarationNameInfo getNameInfo() const
Definition: DeclCXX.h:3047
bool isPOD() const
Whether this class is a POD-type (C++ [class]p4)
Definition: DeclCXX.h:1130
DeclarationName getCXXOperatorName(OverloadedOperatorKind Op)
getCXXOperatorName - Get the name of the overloadable C++ operator corresponding to Op...
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
Definition: Decl.cpp:3009