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