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