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