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