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