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