clang  13.0.0git
DeclCXX.cpp
Go to the documentation of this file.
1 //===- DeclCXX.cpp - C++ Declaration AST Node Implementation --------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the C++ related Decl classes.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "clang/AST/DeclCXX.h"
14 #include "clang/AST/ASTContext.h"
15 #include "clang/AST/ASTLambda.h"
18 #include "clang/AST/Attr.h"
20 #include "clang/AST/DeclBase.h"
21 #include "clang/AST/DeclTemplate.h"
23 #include "clang/AST/Expr.h"
24 #include "clang/AST/ExprCXX.h"
27 #include "clang/AST/ODRHash.h"
28 #include "clang/AST/Type.h"
29 #include "clang/AST/TypeLoc.h"
31 #include "clang/Basic/Diagnostic.h"
33 #include "clang/Basic/LLVM.h"
38 #include "clang/Basic/Specifiers.h"
39 #include "llvm/ADT/None.h"
40 #include "llvm/ADT/SmallPtrSet.h"
41 #include "llvm/ADT/SmallVector.h"
42 #include "llvm/ADT/iterator_range.h"
43 #include "llvm/Support/Casting.h"
44 #include "llvm/Support/ErrorHandling.h"
45 #include "llvm/Support/Format.h"
46 #include "llvm/Support/raw_ostream.h"
47 #include <algorithm>
48 #include <cassert>
49 #include <cstddef>
50 #include <cstdint>
51 
52 using namespace clang;
53 
54 //===----------------------------------------------------------------------===//
55 // Decl Allocation/Deallocation Method Implementations
56 //===----------------------------------------------------------------------===//
57 
58 void AccessSpecDecl::anchor() {}
59 
61  return new (C, ID) AccessSpecDecl(EmptyShell());
62 }
63 
64 void LazyASTUnresolvedSet::getFromExternalSource(ASTContext &C) const {
65  ExternalASTSource *Source = C.getExternalSource();
66  assert(Impl.Decls.isLazy() && "getFromExternalSource for non-lazy set");
67  assert(Source && "getFromExternalSource with no external source");
68 
69  for (ASTUnresolvedSet::iterator I = Impl.begin(); I != Impl.end(); ++I)
70  I.setDecl(cast<NamedDecl>(Source->GetExternalDecl(
71  reinterpret_cast<uintptr_t>(I.getDecl()) >> 2)));
72  Impl.Decls.setLazy(false);
73 }
74 
75 CXXRecordDecl::DefinitionData::DefinitionData(CXXRecordDecl *D)
76  : UserDeclaredConstructor(false), UserDeclaredSpecialMembers(0),
77  Aggregate(true), PlainOldData(true), Empty(true), Polymorphic(false),
78  Abstract(false), IsStandardLayout(true), IsCXX11StandardLayout(true),
79  HasBasesWithFields(false), HasBasesWithNonStaticDataMembers(false),
80  HasPrivateFields(false), HasProtectedFields(false),
81  HasPublicFields(false), HasMutableFields(false), HasVariantMembers(false),
82  HasOnlyCMembers(true), HasInClassInitializer(false),
83  HasUninitializedReferenceMember(false), HasUninitializedFields(false),
84  HasInheritedConstructor(false),
85  HasInheritedDefaultConstructor(false),
86  HasInheritedAssignment(false),
87  NeedOverloadResolutionForCopyConstructor(false),
88  NeedOverloadResolutionForMoveConstructor(false),
89  NeedOverloadResolutionForCopyAssignment(false),
90  NeedOverloadResolutionForMoveAssignment(false),
91  NeedOverloadResolutionForDestructor(false),
92  DefaultedCopyConstructorIsDeleted(false),
93  DefaultedMoveConstructorIsDeleted(false),
94  DefaultedCopyAssignmentIsDeleted(false),
95  DefaultedMoveAssignmentIsDeleted(false),
96  DefaultedDestructorIsDeleted(false), HasTrivialSpecialMembers(SMF_All),
97  HasTrivialSpecialMembersForCall(SMF_All),
98  DeclaredNonTrivialSpecialMembers(0),
99  DeclaredNonTrivialSpecialMembersForCall(0), HasIrrelevantDestructor(true),
100  HasConstexprNonCopyMoveConstructor(false),
101  HasDefaultedDefaultConstructor(false),
102  DefaultedDefaultConstructorIsConstexpr(true),
103  HasConstexprDefaultConstructor(false),
104  DefaultedDestructorIsConstexpr(true),
105  HasNonLiteralTypeFieldsOrBases(false), StructuralIfLiteral(true),
106  UserProvidedDefaultConstructor(false), DeclaredSpecialMembers(0),
107  ImplicitCopyConstructorCanHaveConstParamForVBase(true),
108  ImplicitCopyConstructorCanHaveConstParamForNonVBase(true),
109  ImplicitCopyAssignmentHasConstParam(true),
110  HasDeclaredCopyConstructorWithConstParam(false),
111  HasDeclaredCopyAssignmentWithConstParam(false), IsLambda(false),
112  IsParsingBaseSpecifiers(false), ComputedVisibleConversions(false),
113  HasODRHash(false), Definition(D) {}
114 
115 CXXBaseSpecifier *CXXRecordDecl::DefinitionData::getBasesSlowCase() const {
116  return Bases.get(Definition->getASTContext().getExternalSource());
117 }
118 
119 CXXBaseSpecifier *CXXRecordDecl::DefinitionData::getVBasesSlowCase() const {
120  return VBases.get(Definition->getASTContext().getExternalSource());
121 }
122 
124  DeclContext *DC, SourceLocation StartLoc,
126  CXXRecordDecl *PrevDecl)
127  : RecordDecl(K, TK, C, DC, StartLoc, IdLoc, Id, PrevDecl),
128  DefinitionData(PrevDecl ? PrevDecl->DefinitionData
129  : nullptr) {}
130 
132  DeclContext *DC, SourceLocation StartLoc,
134  CXXRecordDecl *PrevDecl,
135  bool DelayTypeCreation) {
136  auto *R = new (C, DC) CXXRecordDecl(CXXRecord, TK, C, DC, StartLoc, IdLoc, Id,
137  PrevDecl);
138  R->setMayHaveOutOfDateDef(C.getLangOpts().Modules);
139 
140  // FIXME: DelayTypeCreation seems like such a hack
141  if (!DelayTypeCreation)
142  C.getTypeDeclType(R, PrevDecl);
143  return R;
144 }
145 
148  TypeSourceInfo *Info, SourceLocation Loc,
149  bool Dependent, bool IsGeneric,
150  LambdaCaptureDefault CaptureDefault) {
151  auto *R = new (C, DC) CXXRecordDecl(CXXRecord, TTK_Class, C, DC, Loc, Loc,
152  nullptr, nullptr);
153  R->setBeingDefined(true);
154  R->DefinitionData =
155  new (C) struct LambdaDefinitionData(R, Info, Dependent, IsGeneric,
156  CaptureDefault);
157  R->setMayHaveOutOfDateDef(false);
158  R->setImplicit(true);
159  C.getTypeDeclType(R, /*PrevDecl=*/nullptr);
160  return R;
161 }
162 
165  auto *R = new (C, ID) CXXRecordDecl(
166  CXXRecord, TTK_Struct, C, nullptr, SourceLocation(), SourceLocation(),
167  nullptr, nullptr);
168  R->setMayHaveOutOfDateDef(false);
169  return R;
170 }
171 
172 /// Determine whether a class has a repeated base class. This is intended for
173 /// use when determining if a class is standard-layout, so makes no attempt to
174 /// handle virtual bases.
175 static bool hasRepeatedBaseClass(const CXXRecordDecl *StartRD) {
177  SmallVector<const CXXRecordDecl*, 8> WorkList = {StartRD};
178  while (!WorkList.empty()) {
179  const CXXRecordDecl *RD = WorkList.pop_back_val();
180  for (const CXXBaseSpecifier &BaseSpec : RD->bases()) {
181  if (const CXXRecordDecl *B = BaseSpec.getType()->getAsCXXRecordDecl()) {
182  if (!SeenBaseTypes.insert(B).second)
183  return true;
184  WorkList.push_back(B);
185  }
186  }
187  }
188  return false;
189 }
190 
191 void
193  unsigned NumBases) {
194  ASTContext &C = getASTContext();
195 
196  if (!data().Bases.isOffset() && data().NumBases > 0)
197  C.Deallocate(data().getBases());
198 
199  if (NumBases) {
200  if (!C.getLangOpts().CPlusPlus17) {
201  // C++ [dcl.init.aggr]p1:
202  // An aggregate is [...] a class with [...] no base classes [...].
203  data().Aggregate = false;
204  }
205 
206  // C++ [class]p4:
207  // A POD-struct is an aggregate class...
208  data().PlainOldData = false;
209  }
210 
211  // The set of seen virtual base types.
212  llvm::SmallPtrSet<CanQualType, 8> SeenVBaseTypes;
213 
214  // The virtual bases of this class.
216 
217  data().Bases = new(C) CXXBaseSpecifier [NumBases];
218  data().NumBases = NumBases;
219  for (unsigned i = 0; i < NumBases; ++i) {
220  data().getBases()[i] = *Bases[i];
221  // Keep track of inherited vbases for this base class.
222  const CXXBaseSpecifier *Base = Bases[i];
223  QualType BaseType = Base->getType();
224  // Skip dependent types; we can't do any checking on them now.
225  if (BaseType->isDependentType())
226  continue;
227  auto *BaseClassDecl =
228  cast<CXXRecordDecl>(BaseType->castAs<RecordType>()->getDecl());
229 
230  // C++2a [class]p7:
231  // A standard-layout class is a class that:
232  // [...]
233  // -- has all non-static data members and bit-fields in the class and
234  // its base classes first declared in the same class
235  if (BaseClassDecl->data().HasBasesWithFields ||
236  !BaseClassDecl->field_empty()) {
237  if (data().HasBasesWithFields)
238  // Two bases have members or bit-fields: not standard-layout.
239  data().IsStandardLayout = false;
240  data().HasBasesWithFields = true;
241  }
242 
243  // C++11 [class]p7:
244  // A standard-layout class is a class that:
245  // -- [...] has [...] at most one base class with non-static data
246  // members
247  if (BaseClassDecl->data().HasBasesWithNonStaticDataMembers ||
248  BaseClassDecl->hasDirectFields()) {
249  if (data().HasBasesWithNonStaticDataMembers)
250  data().IsCXX11StandardLayout = false;
251  data().HasBasesWithNonStaticDataMembers = true;
252  }
253 
254  if (!BaseClassDecl->isEmpty()) {
255  // C++14 [meta.unary.prop]p4:
256  // T is a class type [...] with [...] no base class B for which
257  // is_empty<B>::value is false.
258  data().Empty = false;
259  }
260 
261  // C++1z [dcl.init.agg]p1:
262  // An aggregate is a class with [...] no private or protected base classes
263  if (Base->getAccessSpecifier() != AS_public) {
264  data().Aggregate = false;
265 
266  // C++20 [temp.param]p7:
267  // A structural type is [...] a literal class type with [...] all base
268  // classes [...] public
269  data().StructuralIfLiteral = false;
270  }
271 
272  // C++ [class.virtual]p1:
273  // A class that declares or inherits a virtual function is called a
274  // polymorphic class.
275  if (BaseClassDecl->isPolymorphic()) {
276  data().Polymorphic = true;
277 
278  // An aggregate is a class with [...] no virtual functions.
279  data().Aggregate = false;
280  }
281 
282  // C++0x [class]p7:
283  // A standard-layout class is a class that: [...]
284  // -- has no non-standard-layout base classes
285  if (!BaseClassDecl->isStandardLayout())
286  data().IsStandardLayout = false;
287  if (!BaseClassDecl->isCXX11StandardLayout())
288  data().IsCXX11StandardLayout = false;
289 
290  // Record if this base is the first non-literal field or base.
291  if (!hasNonLiteralTypeFieldsOrBases() && !BaseType->isLiteralType(C))
292  data().HasNonLiteralTypeFieldsOrBases = true;
293 
294  // Now go through all virtual bases of this base and add them.
295  for (const auto &VBase : BaseClassDecl->vbases()) {
296  // Add this base if it's not already in the list.
297  if (SeenVBaseTypes.insert(C.getCanonicalType(VBase.getType())).second) {
298  VBases.push_back(&VBase);
299 
300  // C++11 [class.copy]p8:
301  // The implicitly-declared copy constructor for a class X will have
302  // the form 'X::X(const X&)' if each [...] virtual base class B of X
303  // has a copy constructor whose first parameter is of type
304  // 'const B&' or 'const volatile B&' [...]
305  if (CXXRecordDecl *VBaseDecl = VBase.getType()->getAsCXXRecordDecl())
306  if (!VBaseDecl->hasCopyConstructorWithConstParam())
307  data().ImplicitCopyConstructorCanHaveConstParamForVBase = false;
308 
309  // C++1z [dcl.init.agg]p1:
310  // An aggregate is a class with [...] no virtual base classes
311  data().Aggregate = false;
312  }
313  }
314 
315  if (Base->isVirtual()) {
316  // Add this base if it's not already in the list.
317  if (SeenVBaseTypes.insert(C.getCanonicalType(BaseType)).second)
318  VBases.push_back(Base);
319 
320  // C++14 [meta.unary.prop] is_empty:
321  // T is a class type, but not a union type, with ... no virtual base
322  // classes
323  data().Empty = false;
324 
325  // C++1z [dcl.init.agg]p1:
326  // An aggregate is a class with [...] no virtual base classes
327  data().Aggregate = false;
328 
329  // C++11 [class.ctor]p5, C++11 [class.copy]p12, C++11 [class.copy]p25:
330  // A [default constructor, copy/move constructor, or copy/move assignment
331  // operator for a class X] is trivial [...] if:
332  // -- class X has [...] no virtual base classes
333  data().HasTrivialSpecialMembers &= SMF_Destructor;
334  data().HasTrivialSpecialMembersForCall &= SMF_Destructor;
335 
336  // C++0x [class]p7:
337  // A standard-layout class is a class that: [...]
338  // -- has [...] no virtual base classes
339  data().IsStandardLayout = false;
340  data().IsCXX11StandardLayout = false;
341 
342  // C++20 [dcl.constexpr]p3:
343  // In the definition of a constexpr function [...]
344  // -- if the function is a constructor or destructor,
345  // its class shall not have any virtual base classes
346  data().DefaultedDefaultConstructorIsConstexpr = false;
347  data().DefaultedDestructorIsConstexpr = false;
348 
349  // C++1z [class.copy]p8:
350  // The implicitly-declared copy constructor for a class X will have
351  // the form 'X::X(const X&)' if each potentially constructed subobject
352  // has a copy constructor whose first parameter is of type
353  // 'const B&' or 'const volatile B&' [...]
354  if (!BaseClassDecl->hasCopyConstructorWithConstParam())
355  data().ImplicitCopyConstructorCanHaveConstParamForVBase = false;
356  } else {
357  // C++ [class.ctor]p5:
358  // A default constructor is trivial [...] if:
359  // -- all the direct base classes of its class have trivial default
360  // constructors.
361  if (!BaseClassDecl->hasTrivialDefaultConstructor())
362  data().HasTrivialSpecialMembers &= ~SMF_DefaultConstructor;
363 
364  // C++0x [class.copy]p13:
365  // A copy/move constructor for class X is trivial if [...]
366  // [...]
367  // -- the constructor selected to copy/move each direct base class
368  // subobject is trivial, and
369  if (!BaseClassDecl->hasTrivialCopyConstructor())
370  data().HasTrivialSpecialMembers &= ~SMF_CopyConstructor;
371 
372  if (!BaseClassDecl->hasTrivialCopyConstructorForCall())
373  data().HasTrivialSpecialMembersForCall &= ~SMF_CopyConstructor;
374 
375  // If the base class doesn't have a simple move constructor, we'll eagerly
376  // declare it and perform overload resolution to determine which function
377  // it actually calls. If it does have a simple move constructor, this
378  // check is correct.
379  if (!BaseClassDecl->hasTrivialMoveConstructor())
380  data().HasTrivialSpecialMembers &= ~SMF_MoveConstructor;
381 
382  if (!BaseClassDecl->hasTrivialMoveConstructorForCall())
383  data().HasTrivialSpecialMembersForCall &= ~SMF_MoveConstructor;
384 
385  // C++0x [class.copy]p27:
386  // A copy/move assignment operator for class X is trivial if [...]
387  // [...]
388  // -- the assignment operator selected to copy/move each direct base
389  // class subobject is trivial, and
390  if (!BaseClassDecl->hasTrivialCopyAssignment())
391  data().HasTrivialSpecialMembers &= ~SMF_CopyAssignment;
392  // If the base class doesn't have a simple move assignment, we'll eagerly
393  // declare it and perform overload resolution to determine which function
394  // it actually calls. If it does have a simple move assignment, this
395  // check is correct.
396  if (!BaseClassDecl->hasTrivialMoveAssignment())
397  data().HasTrivialSpecialMembers &= ~SMF_MoveAssignment;
398 
399  // C++11 [class.ctor]p6:
400  // If that user-written default constructor would satisfy the
401  // requirements of a constexpr constructor, the implicitly-defined
402  // default constructor is constexpr.
403  if (!BaseClassDecl->hasConstexprDefaultConstructor())
404  data().DefaultedDefaultConstructorIsConstexpr = false;
405 
406  // C++1z [class.copy]p8:
407  // The implicitly-declared copy constructor for a class X will have
408  // the form 'X::X(const X&)' if each potentially constructed subobject
409  // has a copy constructor whose first parameter is of type
410  // 'const B&' or 'const volatile B&' [...]
411  if (!BaseClassDecl->hasCopyConstructorWithConstParam())
412  data().ImplicitCopyConstructorCanHaveConstParamForNonVBase = false;
413  }
414 
415  // C++ [class.ctor]p3:
416  // A destructor is trivial if all the direct base classes of its class
417  // have trivial destructors.
418  if (!BaseClassDecl->hasTrivialDestructor())
419  data().HasTrivialSpecialMembers &= ~SMF_Destructor;
420 
421  if (!BaseClassDecl->hasTrivialDestructorForCall())
422  data().HasTrivialSpecialMembersForCall &= ~SMF_Destructor;
423 
424  if (!BaseClassDecl->hasIrrelevantDestructor())
425  data().HasIrrelevantDestructor = false;
426 
427  // C++11 [class.copy]p18:
428  // The implicitly-declared copy assignment operator for a class X will
429  // have the form 'X& X::operator=(const X&)' if each direct base class B
430  // of X has a copy assignment operator whose parameter is of type 'const
431  // B&', 'const volatile B&', or 'B' [...]
432  if (!BaseClassDecl->hasCopyAssignmentWithConstParam())
433  data().ImplicitCopyAssignmentHasConstParam = false;
434 
435  // A class has an Objective-C object member if... or any of its bases
436  // has an Objective-C object member.
437  if (BaseClassDecl->hasObjectMember())
438  setHasObjectMember(true);
439 
440  if (BaseClassDecl->hasVolatileMember())
441  setHasVolatileMember(true);
442 
443  if (BaseClassDecl->getArgPassingRestrictions() ==
446 
447  // Keep track of the presence of mutable fields.
448  if (BaseClassDecl->hasMutableFields())
449  data().HasMutableFields = true;
450 
451  if (BaseClassDecl->hasUninitializedReferenceMember())
452  data().HasUninitializedReferenceMember = true;
453 
454  if (!BaseClassDecl->allowConstDefaultInit())
455  data().HasUninitializedFields = true;
456 
457  addedClassSubobject(BaseClassDecl);
458  }
459 
460  // C++2a [class]p7:
461  // A class S is a standard-layout class if it:
462  // -- has at most one base class subobject of any given type
463  //
464  // Note that we only need to check this for classes with more than one base
465  // class. If there's only one base class, and it's standard layout, then
466  // we know there are no repeated base classes.
467  if (data().IsStandardLayout && NumBases > 1 && hasRepeatedBaseClass(this))
468  data().IsStandardLayout = false;
469 
470  if (VBases.empty()) {
471  data().IsParsingBaseSpecifiers = false;
472  return;
473  }
474 
475  // Create base specifier for any direct or indirect virtual bases.
476  data().VBases = new (C) CXXBaseSpecifier[VBases.size()];
477  data().NumVBases = VBases.size();
478  for (int I = 0, E = VBases.size(); I != E; ++I) {
479  QualType Type = VBases[I]->getType();
480  if (!Type->isDependentType())
481  addedClassSubobject(Type->getAsCXXRecordDecl());
482  data().getVBases()[I] = *VBases[I];
483  }
484 
485  data().IsParsingBaseSpecifiers = false;
486 }
487 
488 unsigned CXXRecordDecl::getODRHash() const {
489  assert(hasDefinition() && "ODRHash only for records with definitions");
490 
491  // Previously calculated hash is stored in DefinitionData.
492  if (DefinitionData->HasODRHash)
493  return DefinitionData->ODRHash;
494 
495  // Only calculate hash on first call of getODRHash per record.
496  ODRHash Hash;
498  DefinitionData->HasODRHash = true;
499  DefinitionData->ODRHash = Hash.CalculateHash();
500 
501  return DefinitionData->ODRHash;
502 }
503 
504 void CXXRecordDecl::addedClassSubobject(CXXRecordDecl *Subobj) {
505  // C++11 [class.copy]p11:
506  // A defaulted copy/move constructor for a class X is defined as
507  // deleted if X has:
508  // -- a direct or virtual base class B that cannot be copied/moved [...]
509  // -- a non-static data member of class type M (or array thereof)
510  // that cannot be copied or moved [...]
511  if (!Subobj->hasSimpleCopyConstructor())
512  data().NeedOverloadResolutionForCopyConstructor = true;
513  if (!Subobj->hasSimpleMoveConstructor())
514  data().NeedOverloadResolutionForMoveConstructor = true;
515 
516  // C++11 [class.copy]p23:
517  // A defaulted copy/move assignment operator for a class X is defined as
518  // deleted if X has:
519  // -- a direct or virtual base class B that cannot be copied/moved [...]
520  // -- a non-static data member of class type M (or array thereof)
521  // that cannot be copied or moved [...]
522  if (!Subobj->hasSimpleCopyAssignment())
523  data().NeedOverloadResolutionForCopyAssignment = true;
524  if (!Subobj->hasSimpleMoveAssignment())
525  data().NeedOverloadResolutionForMoveAssignment = true;
526 
527  // C++11 [class.ctor]p5, C++11 [class.copy]p11, C++11 [class.dtor]p5:
528  // A defaulted [ctor or dtor] for a class X is defined as
529  // deleted if X has:
530  // -- any direct or virtual base class [...] has a type with a destructor
531  // that is deleted or inaccessible from the defaulted [ctor or dtor].
532  // -- any non-static data member has a type with a destructor
533  // that is deleted or inaccessible from the defaulted [ctor or dtor].
534  if (!Subobj->hasSimpleDestructor()) {
535  data().NeedOverloadResolutionForCopyConstructor = true;
536  data().NeedOverloadResolutionForMoveConstructor = true;
537  data().NeedOverloadResolutionForDestructor = true;
538  }
539 
540  // C++2a [dcl.constexpr]p4:
541  // The definition of a constexpr destructor [shall] satisfy the
542  // following requirement:
543  // -- for every subobject of class type or (possibly multi-dimensional)
544  // array thereof, that class type shall have a constexpr destructor
545  if (!Subobj->hasConstexprDestructor())
546  data().DefaultedDestructorIsConstexpr = false;
547 
548  // C++20 [temp.param]p7:
549  // A structural type is [...] a literal class type [for which] the types
550  // of all base classes and non-static data members are structural types or
551  // (possibly multi-dimensional) array thereof
552  if (!Subobj->data().StructuralIfLiteral)
553  data().StructuralIfLiteral = false;
554 }
555 
557  auto *Dtor = getDestructor();
558  return Dtor ? Dtor->isConstexpr() : defaultedDestructorIsConstexpr();
559 }
560 
562  if (!isDependentContext())
563  return false;
564 
565  return !forallBases([](const CXXRecordDecl *) { return true; });
566 }
567 
569  // C++0x [class]p5:
570  // A trivially copyable class is a class that:
571  // -- has no non-trivial copy constructors,
572  if (hasNonTrivialCopyConstructor()) return false;
573  // -- has no non-trivial move constructors,
574  if (hasNonTrivialMoveConstructor()) return false;
575  // -- has no non-trivial copy assignment operators,
576  if (hasNonTrivialCopyAssignment()) return false;
577  // -- has no non-trivial move assignment operators, and
578  if (hasNonTrivialMoveAssignment()) return false;
579  // -- has a trivial destructor.
580  if (!hasTrivialDestructor()) return false;
581 
582  return true;
583 }
584 
585 void CXXRecordDecl::markedVirtualFunctionPure() {
586  // C++ [class.abstract]p2:
587  // A class is abstract if it has at least one pure virtual function.
588  data().Abstract = true;
589 }
590 
591 bool CXXRecordDecl::hasSubobjectAtOffsetZeroOfEmptyBaseType(
592  ASTContext &Ctx, const CXXRecordDecl *XFirst) {
593  if (!getNumBases())
594  return false;
595 
599 
600  // Visit a type that we have determined is an element of M(S).
601  auto Visit = [&](const CXXRecordDecl *RD) -> bool {
602  RD = RD->getCanonicalDecl();
603 
604  // C++2a [class]p8:
605  // A class S is a standard-layout class if it [...] has no element of the
606  // set M(S) of types as a base class.
607  //
608  // If we find a subobject of an empty type, it might also be a base class,
609  // so we'll need to walk the base classes to check.
610  if (!RD->data().HasBasesWithFields) {
611  // Walk the bases the first time, stopping if we find the type. Build a
612  // set of them so we don't need to walk them again.
613  if (Bases.empty()) {
614  bool RDIsBase = !forallBases([&](const CXXRecordDecl *Base) -> bool {
615  Base = Base->getCanonicalDecl();
616  if (RD == Base)
617  return false;
618  Bases.insert(Base);
619  return true;
620  });
621  if (RDIsBase)
622  return true;
623  } else {
624  if (Bases.count(RD))
625  return true;
626  }
627  }
628 
629  if (M.insert(RD).second)
630  WorkList.push_back(RD);
631  return false;
632  };
633 
634  if (Visit(XFirst))
635  return true;
636 
637  while (!WorkList.empty()) {
638  const CXXRecordDecl *X = WorkList.pop_back_val();
639 
640  // FIXME: We don't check the bases of X. That matches the standard, but
641  // that sure looks like a wording bug.
642 
643  // -- If X is a non-union class type with a non-static data member
644  // [recurse to each field] that is either of zero size or is the
645  // first non-static data member of X
646  // -- If X is a union type, [recurse to union members]
647  bool IsFirstField = true;
648  for (auto *FD : X->fields()) {
649  // FIXME: Should we really care about the type of the first non-static
650  // data member of a non-union if there are preceding unnamed bit-fields?
651  if (FD->isUnnamedBitfield())
652  continue;
653 
654  if (!IsFirstField && !FD->isZeroSize(Ctx))
655  continue;
656 
657  // -- If X is n array type, [visit the element type]
658  QualType T = Ctx.getBaseElementType(FD->getType());
659  if (auto *RD = T->getAsCXXRecordDecl())
660  if (Visit(RD))
661  return true;
662 
663  if (!X->isUnion())
664  IsFirstField = false;
665  }
666  }
667 
668  return false;
669 }
670 
672  assert(isLambda() && "not a lambda");
673 
674  // C++2a [expr.prim.lambda.capture]p11:
675  // The closure type associated with a lambda-expression has no default
676  // constructor if the lambda-expression has a lambda-capture and a
677  // defaulted default constructor otherwise. It has a deleted copy
678  // assignment operator if the lambda-expression has a lambda-capture and
679  // defaulted copy and move assignment operators otherwise.
680  //
681  // C++17 [expr.prim.lambda]p21:
682  // The closure type associated with a lambda-expression has no default
683  // constructor and a deleted copy assignment operator.
684  if (getLambdaCaptureDefault() != LCD_None || capture_size() != 0)
685  return false;
686  return getASTContext().getLangOpts().CPlusPlus20;
687 }
688 
689 void CXXRecordDecl::addedMember(Decl *D) {
690  if (!D->isImplicit() &&
691  !isa<FieldDecl>(D) &&
692  !isa<IndirectFieldDecl>(D) &&
693  (!isa<TagDecl>(D) || cast<TagDecl>(D)->getTagKind() == TTK_Class ||
694  cast<TagDecl>(D)->getTagKind() == TTK_Interface))
695  data().HasOnlyCMembers = false;
696 
697  // Ignore friends and invalid declarations.
698  if (D->getFriendObjectKind() || D->isInvalidDecl())
699  return;
700 
701  auto *FunTmpl = dyn_cast<FunctionTemplateDecl>(D);
702  if (FunTmpl)
703  D = FunTmpl->getTemplatedDecl();
704 
705  // FIXME: Pass NamedDecl* to addedMember?
706  Decl *DUnderlying = D;
707  if (auto *ND = dyn_cast<NamedDecl>(DUnderlying)) {
708  DUnderlying = ND->getUnderlyingDecl();
709  if (auto *UnderlyingFunTmpl = dyn_cast<FunctionTemplateDecl>(DUnderlying))
710  DUnderlying = UnderlyingFunTmpl->getTemplatedDecl();
711  }
712 
713  if (const auto *Method = dyn_cast<CXXMethodDecl>(D)) {
714  if (Method->isVirtual()) {
715  // C++ [dcl.init.aggr]p1:
716  // An aggregate is an array or a class with [...] no virtual functions.
717  data().Aggregate = false;
718 
719  // C++ [class]p4:
720  // A POD-struct is an aggregate class...
721  data().PlainOldData = false;
722 
723  // C++14 [meta.unary.prop]p4:
724  // T is a class type [...] with [...] no virtual member functions...
725  data().Empty = false;
726 
727  // C++ [class.virtual]p1:
728  // A class that declares or inherits a virtual function is called a
729  // polymorphic class.
730  data().Polymorphic = true;
731 
732  // C++11 [class.ctor]p5, C++11 [class.copy]p12, C++11 [class.copy]p25:
733  // A [default constructor, copy/move constructor, or copy/move
734  // assignment operator for a class X] is trivial [...] if:
735  // -- class X has no virtual functions [...]
736  data().HasTrivialSpecialMembers &= SMF_Destructor;
737  data().HasTrivialSpecialMembersForCall &= SMF_Destructor;
738 
739  // C++0x [class]p7:
740  // A standard-layout class is a class that: [...]
741  // -- has no virtual functions
742  data().IsStandardLayout = false;
743  data().IsCXX11StandardLayout = false;
744  }
745  }
746 
747  // Notify the listener if an implicit member was added after the definition
748  // was completed.
749  if (!isBeingDefined() && D->isImplicit())
751  L->AddedCXXImplicitMember(data().Definition, D);
752 
753  // The kind of special member this declaration is, if any.
754  unsigned SMKind = 0;
755 
756  // Handle constructors.
757  if (const auto *Constructor = dyn_cast<CXXConstructorDecl>(D)) {
758  if (Constructor->isInheritingConstructor()) {
759  // Ignore constructor shadow declarations. They are lazily created and
760  // so shouldn't affect any properties of the class.
761  } else {
762  if (!Constructor->isImplicit()) {
763  // Note that we have a user-declared constructor.
764  data().UserDeclaredConstructor = true;
765 
766  // C++ [class]p4:
767  // A POD-struct is an aggregate class [...]
768  // Since the POD bit is meant to be C++03 POD-ness, clear it even if
769  // the type is technically an aggregate in C++0x since it wouldn't be
770  // in 03.
771  data().PlainOldData = false;
772  }
773 
774  if (Constructor->isDefaultConstructor()) {
775  SMKind |= SMF_DefaultConstructor;
776 
777  if (Constructor->isUserProvided())
778  data().UserProvidedDefaultConstructor = true;
779  if (Constructor->isConstexpr())
780  data().HasConstexprDefaultConstructor = true;
781  if (Constructor->isDefaulted())
782  data().HasDefaultedDefaultConstructor = true;
783  }
784 
785  if (!FunTmpl) {
786  unsigned Quals;
787  if (Constructor->isCopyConstructor(Quals)) {
788  SMKind |= SMF_CopyConstructor;
789 
790  if (Quals & Qualifiers::Const)
791  data().HasDeclaredCopyConstructorWithConstParam = true;
792  } else if (Constructor->isMoveConstructor())
793  SMKind |= SMF_MoveConstructor;
794  }
795 
796  // C++11 [dcl.init.aggr]p1: DR1518
797  // An aggregate is an array or a class with no user-provided [or]
798  // explicit [...] constructors
799  // C++20 [dcl.init.aggr]p1:
800  // An aggregate is an array or a class with no user-declared [...]
801  // constructors
803  ? !Constructor->isImplicit()
804  : (Constructor->isUserProvided() || Constructor->isExplicit()))
805  data().Aggregate = false;
806  }
807  }
808 
809  // Handle constructors, including those inherited from base classes.
810  if (const auto *Constructor = dyn_cast<CXXConstructorDecl>(DUnderlying)) {
811  // Record if we see any constexpr constructors which are neither copy
812  // nor move constructors.
813  // C++1z [basic.types]p10:
814  // [...] has at least one constexpr constructor or constructor template
815  // (possibly inherited from a base class) that is not a copy or move
816  // constructor [...]
817  if (Constructor->isConstexpr() && !Constructor->isCopyOrMoveConstructor())
818  data().HasConstexprNonCopyMoveConstructor = true;
819  if (!isa<CXXConstructorDecl>(D) && Constructor->isDefaultConstructor())
820  data().HasInheritedDefaultConstructor = true;
821  }
822 
823  // Handle destructors.
824  if (const auto *DD = dyn_cast<CXXDestructorDecl>(D)) {
825  SMKind |= SMF_Destructor;
826 
827  if (DD->isUserProvided())
828  data().HasIrrelevantDestructor = false;
829  // If the destructor is explicitly defaulted and not trivial or not public
830  // or if the destructor is deleted, we clear HasIrrelevantDestructor in
831  // finishedDefaultedOrDeletedMember.
832 
833  // C++11 [class.dtor]p5:
834  // A destructor is trivial if [...] the destructor is not virtual.
835  if (DD->isVirtual()) {
836  data().HasTrivialSpecialMembers &= ~SMF_Destructor;
837  data().HasTrivialSpecialMembersForCall &= ~SMF_Destructor;
838  }
839  }
840 
841  // Handle member functions.
842  if (const auto *Method = dyn_cast<CXXMethodDecl>(D)) {
843  if (Method->isCopyAssignmentOperator()) {
844  SMKind |= SMF_CopyAssignment;
845 
846  const auto *ParamTy =
847  Method->getParamDecl(0)->getType()->getAs<ReferenceType>();
848  if (!ParamTy || ParamTy->getPointeeType().isConstQualified())
849  data().HasDeclaredCopyAssignmentWithConstParam = true;
850  }
851 
852  if (Method->isMoveAssignmentOperator())
853  SMKind |= SMF_MoveAssignment;
854 
855  // Keep the list of conversion functions up-to-date.
856  if (auto *Conversion = dyn_cast<CXXConversionDecl>(D)) {
857  // FIXME: We use the 'unsafe' accessor for the access specifier here,
858  // because Sema may not have set it yet. That's really just a misdesign
859  // in Sema. However, LLDB *will* have set the access specifier correctly,
860  // and adds declarations after the class is technically completed,
861  // so completeDefinition()'s overriding of the access specifiers doesn't
862  // work.
863  AccessSpecifier AS = Conversion->getAccessUnsafe();
864 
865  if (Conversion->getPrimaryTemplate()) {
866  // We don't record specializations.
867  } else {
868  ASTContext &Ctx = getASTContext();
869  ASTUnresolvedSet &Conversions = data().Conversions.get(Ctx);
870  NamedDecl *Primary =
871  FunTmpl ? cast<NamedDecl>(FunTmpl) : cast<NamedDecl>(Conversion);
872  if (Primary->getPreviousDecl())
873  Conversions.replace(cast<NamedDecl>(Primary->getPreviousDecl()),
874  Primary, AS);
875  else
876  Conversions.addDecl(Ctx, Primary, AS);
877  }
878  }
879 
880  if (SMKind) {
881  // If this is the first declaration of a special member, we no longer have
882  // an implicit trivial special member.
883  data().HasTrivialSpecialMembers &=
884  data().DeclaredSpecialMembers | ~SMKind;
885  data().HasTrivialSpecialMembersForCall &=
886  data().DeclaredSpecialMembers | ~SMKind;
887 
888  if (!Method->isImplicit() && !Method->isUserProvided()) {
889  // This method is user-declared but not user-provided. We can't work out
890  // whether it's trivial yet (not until we get to the end of the class).
891  // We'll handle this method in finishedDefaultedOrDeletedMember.
892  } else if (Method->isTrivial()) {
893  data().HasTrivialSpecialMembers |= SMKind;
894  data().HasTrivialSpecialMembersForCall |= SMKind;
895  } else if (Method->isTrivialForCall()) {
896  data().HasTrivialSpecialMembersForCall |= SMKind;
897  data().DeclaredNonTrivialSpecialMembers |= SMKind;
898  } else {
899  data().DeclaredNonTrivialSpecialMembers |= SMKind;
900  // If this is a user-provided function, do not set
901  // DeclaredNonTrivialSpecialMembersForCall here since we don't know
902  // yet whether the method would be considered non-trivial for the
903  // purpose of calls (attribute "trivial_abi" can be dropped from the
904  // class later, which can change the special method's triviality).
905  if (!Method->isUserProvided())
906  data().DeclaredNonTrivialSpecialMembersForCall |= SMKind;
907  }
908 
909  // Note when we have declared a declared special member, and suppress the
910  // implicit declaration of this special member.
911  data().DeclaredSpecialMembers |= SMKind;
912 
913  if (!Method->isImplicit()) {
914  data().UserDeclaredSpecialMembers |= SMKind;
915 
916  // C++03 [class]p4:
917  // A POD-struct is an aggregate class that has [...] no user-defined
918  // copy assignment operator and no user-defined destructor.
919  //
920  // Since the POD bit is meant to be C++03 POD-ness, and in C++03,
921  // aggregates could not have any constructors, clear it even for an
922  // explicitly defaulted or deleted constructor.
923  // type is technically an aggregate in C++0x since it wouldn't be in 03.
924  //
925  // Also, a user-declared move assignment operator makes a class non-POD.
926  // This is an extension in C++03.
927  data().PlainOldData = false;
928  }
929  }
930 
931  return;
932  }
933 
934  // Handle non-static data members.
935  if (const auto *Field = dyn_cast<FieldDecl>(D)) {
936  ASTContext &Context = getASTContext();
937 
938  // C++2a [class]p7:
939  // A standard-layout class is a class that:
940  // [...]
941  // -- has all non-static data members and bit-fields in the class and
942  // its base classes first declared in the same class
943  if (data().HasBasesWithFields)
944  data().IsStandardLayout = false;
945 
946  // C++ [class.bit]p2:
947  // A declaration for a bit-field that omits the identifier declares an
948  // unnamed bit-field. Unnamed bit-fields are not members and cannot be
949  // initialized.
950  if (Field->isUnnamedBitfield()) {
951  // C++ [meta.unary.prop]p4: [LWG2358]
952  // T is a class type [...] with [...] no unnamed bit-fields of non-zero
953  // length
954  if (data().Empty && !Field->isZeroLengthBitField(Context) &&
955  Context.getLangOpts().getClangABICompat() >
957  data().Empty = false;
958  return;
959  }
960 
961  // C++11 [class]p7:
962  // A standard-layout class is a class that:
963  // -- either has no non-static data members in the most derived class
964  // [...] or has no base classes with non-static data members
965  if (data().HasBasesWithNonStaticDataMembers)
966  data().IsCXX11StandardLayout = false;
967 
968  // C++ [dcl.init.aggr]p1:
969  // An aggregate is an array or a class (clause 9) with [...] no
970  // private or protected non-static data members (clause 11).
971  //
972  // A POD must be an aggregate.
973  if (D->getAccess() == AS_private || D->getAccess() == AS_protected) {
974  data().Aggregate = false;
975  data().PlainOldData = false;
976 
977  // C++20 [temp.param]p7:
978  // A structural type is [...] a literal class type [for which] all
979  // non-static data members are public
980  data().StructuralIfLiteral = false;
981  }
982 
983  // Track whether this is the first field. We use this when checking
984  // whether the class is standard-layout below.
985  bool IsFirstField = !data().HasPrivateFields &&
986  !data().HasProtectedFields && !data().HasPublicFields;
987 
988  // C++0x [class]p7:
989  // A standard-layout class is a class that:
990  // [...]
991  // -- has the same access control for all non-static data members,
992  switch (D->getAccess()) {
993  case AS_private: data().HasPrivateFields = true; break;
994  case AS_protected: data().HasProtectedFields = true; break;
995  case AS_public: data().HasPublicFields = true; break;
996  case AS_none: llvm_unreachable("Invalid access specifier");
997  };
998  if ((data().HasPrivateFields + data().HasProtectedFields +
999  data().HasPublicFields) > 1) {
1000  data().IsStandardLayout = false;
1001  data().IsCXX11StandardLayout = false;
1002  }
1003 
1004  // Keep track of the presence of mutable fields.
1005  if (Field->isMutable()) {
1006  data().HasMutableFields = true;
1007 
1008  // C++20 [temp.param]p7:
1009  // A structural type is [...] a literal class type [for which] all
1010  // non-static data members are public
1011  data().StructuralIfLiteral = false;
1012  }
1013 
1014  // C++11 [class.union]p8, DR1460:
1015  // If X is a union, a non-static data member of X that is not an anonymous
1016  // union is a variant member of X.
1017  if (isUnion() && !Field->isAnonymousStructOrUnion())
1018  data().HasVariantMembers = true;
1019 
1020  // C++0x [class]p9:
1021  // A POD struct is a class that is both a trivial class and a
1022  // standard-layout class, and has no non-static data members of type
1023  // non-POD struct, non-POD union (or array of such types).
1024  //
1025  // Automatic Reference Counting: the presence of a member of Objective-C pointer type
1026  // that does not explicitly have no lifetime makes the class a non-POD.
1027  QualType T = Context.getBaseElementType(Field->getType());
1028  if (T->isObjCRetainableType() || T.isObjCGCStrong()) {
1029  if (T.hasNonTrivialObjCLifetime()) {
1030  // Objective-C Automatic Reference Counting:
1031  // If a class has a non-static data member of Objective-C pointer
1032  // type (or array thereof), it is a non-POD type and its
1033  // default constructor (if any), copy constructor, move constructor,
1034  // copy assignment operator, move assignment operator, and destructor are
1035  // non-trivial.
1036  setHasObjectMember(true);
1037  struct DefinitionData &Data = data();
1038  Data.PlainOldData = false;
1039  Data.HasTrivialSpecialMembers = 0;
1040 
1041  // __strong or __weak fields do not make special functions non-trivial
1042  // for the purpose of calls.
1045  data().HasTrivialSpecialMembersForCall = 0;
1046 
1047  // Structs with __weak fields should never be passed directly.
1048  if (LT == Qualifiers::OCL_Weak)
1050 
1051  Data.HasIrrelevantDestructor = false;
1052 
1053  if (isUnion()) {
1054  data().DefaultedCopyConstructorIsDeleted = true;
1055  data().DefaultedMoveConstructorIsDeleted = true;
1056  data().DefaultedCopyAssignmentIsDeleted = true;
1057  data().DefaultedMoveAssignmentIsDeleted = true;
1058  data().DefaultedDestructorIsDeleted = true;
1059  data().NeedOverloadResolutionForCopyConstructor = true;
1060  data().NeedOverloadResolutionForMoveConstructor = true;
1061  data().NeedOverloadResolutionForCopyAssignment = true;
1062  data().NeedOverloadResolutionForMoveAssignment = true;
1063  data().NeedOverloadResolutionForDestructor = true;
1064  }
1065  } else if (!Context.getLangOpts().ObjCAutoRefCount) {
1066  setHasObjectMember(true);
1067  }
1068  } else if (!T.isCXX98PODType(Context))
1069  data().PlainOldData = false;
1070 
1071  if (T->isReferenceType()) {
1072  if (!Field->hasInClassInitializer())
1073  data().HasUninitializedReferenceMember = true;
1074 
1075  // C++0x [class]p7:
1076  // A standard-layout class is a class that:
1077  // -- has no non-static data members of type [...] reference,
1078  data().IsStandardLayout = false;
1079  data().IsCXX11StandardLayout = false;
1080 
1081  // C++1z [class.copy.ctor]p10:
1082  // A defaulted copy constructor for a class X is defined as deleted if X has:
1083  // -- a non-static data member of rvalue reference type
1084  if (T->isRValueReferenceType())
1085  data().DefaultedCopyConstructorIsDeleted = true;
1086  }
1087 
1088  if (!Field->hasInClassInitializer() && !Field->isMutable()) {
1089  if (CXXRecordDecl *FieldType = T->getAsCXXRecordDecl()) {
1090  if (FieldType->hasDefinition() && !FieldType->allowConstDefaultInit())
1091  data().HasUninitializedFields = true;
1092  } else {
1093  data().HasUninitializedFields = true;
1094  }
1095  }
1096 
1097  // Record if this field is the first non-literal or volatile field or base.
1098  if (!T->isLiteralType(Context) || T.isVolatileQualified())
1099  data().HasNonLiteralTypeFieldsOrBases = true;
1100 
1101  if (Field->hasInClassInitializer() ||
1102  (Field->isAnonymousStructOrUnion() &&
1103  Field->getType()->getAsCXXRecordDecl()->hasInClassInitializer())) {
1104  data().HasInClassInitializer = true;
1105 
1106  // C++11 [class]p5:
1107  // A default constructor is trivial if [...] no non-static data member
1108  // of its class has a brace-or-equal-initializer.
1109  data().HasTrivialSpecialMembers &= ~SMF_DefaultConstructor;
1110 
1111  // C++11 [dcl.init.aggr]p1:
1112  // An aggregate is a [...] class with [...] no
1113  // brace-or-equal-initializers for non-static data members.
1114  //
1115  // This rule was removed in C++14.
1117  data().Aggregate = false;
1118 
1119  // C++11 [class]p10:
1120  // A POD struct is [...] a trivial class.
1121  data().PlainOldData = false;
1122  }
1123 
1124  // C++11 [class.copy]p23:
1125  // A defaulted copy/move assignment operator for a class X is defined
1126  // as deleted if X has:
1127  // -- a non-static data member of reference type
1128  if (T->isReferenceType()) {
1129  data().DefaultedCopyAssignmentIsDeleted = true;
1130  data().DefaultedMoveAssignmentIsDeleted = true;
1131  }
1132 
1133  // Bitfields of length 0 are also zero-sized, but we already bailed out for
1134  // those because they are always unnamed.
1135  bool IsZeroSize = Field->isZeroSize(Context);
1136 
1137  if (const auto *RecordTy = T->getAs<RecordType>()) {
1138  auto *FieldRec = cast<CXXRecordDecl>(RecordTy->getDecl());
1139  if (FieldRec->getDefinition()) {
1140  addedClassSubobject(FieldRec);
1141 
1142  // We may need to perform overload resolution to determine whether a
1143  // field can be moved if it's const or volatile qualified.
1145  // We need to care about 'const' for the copy constructor because an
1146  // implicit copy constructor might be declared with a non-const
1147  // parameter.
1148  data().NeedOverloadResolutionForCopyConstructor = true;
1149  data().NeedOverloadResolutionForMoveConstructor = true;
1150  data().NeedOverloadResolutionForCopyAssignment = true;
1151  data().NeedOverloadResolutionForMoveAssignment = true;
1152  }
1153 
1154  // C++11 [class.ctor]p5, C++11 [class.copy]p11:
1155  // A defaulted [special member] for a class X is defined as
1156  // deleted if:
1157  // -- X is a union-like class that has a variant member with a
1158  // non-trivial [corresponding special member]
1159  if (isUnion()) {
1160  if (FieldRec->hasNonTrivialCopyConstructor())
1161  data().DefaultedCopyConstructorIsDeleted = true;
1162  if (FieldRec->hasNonTrivialMoveConstructor())
1163  data().DefaultedMoveConstructorIsDeleted = true;
1164  if (FieldRec->hasNonTrivialCopyAssignment())
1165  data().DefaultedCopyAssignmentIsDeleted = true;
1166  if (FieldRec->hasNonTrivialMoveAssignment())
1167  data().DefaultedMoveAssignmentIsDeleted = true;
1168  if (FieldRec->hasNonTrivialDestructor())
1169  data().DefaultedDestructorIsDeleted = true;
1170  }
1171 
1172  // For an anonymous union member, our overload resolution will perform
1173  // overload resolution for its members.
1174  if (Field->isAnonymousStructOrUnion()) {
1175  data().NeedOverloadResolutionForCopyConstructor |=
1176  FieldRec->data().NeedOverloadResolutionForCopyConstructor;
1177  data().NeedOverloadResolutionForMoveConstructor |=
1178  FieldRec->data().NeedOverloadResolutionForMoveConstructor;
1179  data().NeedOverloadResolutionForCopyAssignment |=
1180  FieldRec->data().NeedOverloadResolutionForCopyAssignment;
1181  data().NeedOverloadResolutionForMoveAssignment |=
1182  FieldRec->data().NeedOverloadResolutionForMoveAssignment;
1183  data().NeedOverloadResolutionForDestructor |=
1184  FieldRec->data().NeedOverloadResolutionForDestructor;
1185  }
1186 
1187  // C++0x [class.ctor]p5:
1188  // A default constructor is trivial [...] if:
1189  // -- for all the non-static data members of its class that are of
1190  // class type (or array thereof), each such class has a trivial
1191  // default constructor.
1192  if (!FieldRec->hasTrivialDefaultConstructor())
1193  data().HasTrivialSpecialMembers &= ~SMF_DefaultConstructor;
1194 
1195  // C++0x [class.copy]p13:
1196  // A copy/move constructor for class X is trivial if [...]
1197  // [...]
1198  // -- for each non-static data member of X that is of class type (or
1199  // an array thereof), the constructor selected to copy/move that
1200  // member is trivial;
1201  if (!FieldRec->hasTrivialCopyConstructor())
1202  data().HasTrivialSpecialMembers &= ~SMF_CopyConstructor;
1203 
1204  if (!FieldRec->hasTrivialCopyConstructorForCall())
1205  data().HasTrivialSpecialMembersForCall &= ~SMF_CopyConstructor;
1206 
1207  // If the field doesn't have a simple move constructor, we'll eagerly
1208  // declare the move constructor for this class and we'll decide whether
1209  // it's trivial then.
1210  if (!FieldRec->hasTrivialMoveConstructor())
1211  data().HasTrivialSpecialMembers &= ~SMF_MoveConstructor;
1212 
1213  if (!FieldRec->hasTrivialMoveConstructorForCall())
1214  data().HasTrivialSpecialMembersForCall &= ~SMF_MoveConstructor;
1215 
1216  // C++0x [class.copy]p27:
1217  // A copy/move assignment operator for class X is trivial if [...]
1218  // [...]
1219  // -- for each non-static data member of X that is of class type (or
1220  // an array thereof), the assignment operator selected to
1221  // copy/move that member is trivial;
1222  if (!FieldRec->hasTrivialCopyAssignment())
1223  data().HasTrivialSpecialMembers &= ~SMF_CopyAssignment;
1224  // If the field doesn't have a simple move assignment, we'll eagerly
1225  // declare the move assignment for this class and we'll decide whether
1226  // it's trivial then.
1227  if (!FieldRec->hasTrivialMoveAssignment())
1228  data().HasTrivialSpecialMembers &= ~SMF_MoveAssignment;
1229 
1230  if (!FieldRec->hasTrivialDestructor())
1231  data().HasTrivialSpecialMembers &= ~SMF_Destructor;
1232  if (!FieldRec->hasTrivialDestructorForCall())
1233  data().HasTrivialSpecialMembersForCall &= ~SMF_Destructor;
1234  if (!FieldRec->hasIrrelevantDestructor())
1235  data().HasIrrelevantDestructor = false;
1236  if (FieldRec->hasObjectMember())
1237  setHasObjectMember(true);
1238  if (FieldRec->hasVolatileMember())
1239  setHasVolatileMember(true);
1240  if (FieldRec->getArgPassingRestrictions() ==
1243 
1244  // C++0x [class]p7:
1245  // A standard-layout class is a class that:
1246  // -- has no non-static data members of type non-standard-layout
1247  // class (or array of such types) [...]
1248  if (!FieldRec->isStandardLayout())
1249  data().IsStandardLayout = false;
1250  if (!FieldRec->isCXX11StandardLayout())
1251  data().IsCXX11StandardLayout = false;
1252 
1253  // C++2a [class]p7:
1254  // A standard-layout class is a class that:
1255  // [...]
1256  // -- has no element of the set M(S) of types as a base class.
1257  if (data().IsStandardLayout &&
1258  (isUnion() || IsFirstField || IsZeroSize) &&
1259  hasSubobjectAtOffsetZeroOfEmptyBaseType(Context, FieldRec))
1260  data().IsStandardLayout = false;
1261 
1262  // C++11 [class]p7:
1263  // A standard-layout class is a class that:
1264  // -- has no base classes of the same type as the first non-static
1265  // data member
1266  if (data().IsCXX11StandardLayout && IsFirstField) {
1267  // FIXME: We should check all base classes here, not just direct
1268  // base classes.
1269  for (const auto &BI : bases()) {
1270  if (Context.hasSameUnqualifiedType(BI.getType(), T)) {
1271  data().IsCXX11StandardLayout = false;
1272  break;
1273  }
1274  }
1275  }
1276 
1277  // Keep track of the presence of mutable fields.
1278  if (FieldRec->hasMutableFields())
1279  data().HasMutableFields = true;
1280 
1281  if (Field->isMutable()) {
1282  // Our copy constructor/assignment might call something other than
1283  // the subobject's copy constructor/assignment if it's mutable and of
1284  // class type.
1285  data().NeedOverloadResolutionForCopyConstructor = true;
1286  data().NeedOverloadResolutionForCopyAssignment = true;
1287  }
1288 
1289  // C++11 [class.copy]p13:
1290  // If the implicitly-defined constructor would satisfy the
1291  // requirements of a constexpr constructor, the implicitly-defined
1292  // constructor is constexpr.
1293  // C++11 [dcl.constexpr]p4:
1294  // -- every constructor involved in initializing non-static data
1295  // members [...] shall be a constexpr constructor
1296  if (!Field->hasInClassInitializer() &&
1297  !FieldRec->hasConstexprDefaultConstructor() && !isUnion())
1298  // The standard requires any in-class initializer to be a constant
1299  // expression. We consider this to be a defect.
1300  data().DefaultedDefaultConstructorIsConstexpr = false;
1301 
1302  // C++11 [class.copy]p8:
1303  // The implicitly-declared copy constructor for a class X will have
1304  // the form 'X::X(const X&)' if each potentially constructed subobject
1305  // of a class type M (or array thereof) has a copy constructor whose
1306  // first parameter is of type 'const M&' or 'const volatile M&'.
1307  if (!FieldRec->hasCopyConstructorWithConstParam())
1308  data().ImplicitCopyConstructorCanHaveConstParamForNonVBase = false;
1309 
1310  // C++11 [class.copy]p18:
1311  // The implicitly-declared copy assignment oeprator for a class X will
1312  // have the form 'X& X::operator=(const X&)' if [...] for all the
1313  // non-static data members of X that are of a class type M (or array
1314  // thereof), each such class type has a copy assignment operator whose
1315  // parameter is of type 'const M&', 'const volatile M&' or 'M'.
1316  if (!FieldRec->hasCopyAssignmentWithConstParam())
1317  data().ImplicitCopyAssignmentHasConstParam = false;
1318 
1319  if (FieldRec->hasUninitializedReferenceMember() &&
1320  !Field->hasInClassInitializer())
1321  data().HasUninitializedReferenceMember = true;
1322 
1323  // C++11 [class.union]p8, DR1460:
1324  // a non-static data member of an anonymous union that is a member of
1325  // X is also a variant member of X.
1326  if (FieldRec->hasVariantMembers() &&
1327  Field->isAnonymousStructOrUnion())
1328  data().HasVariantMembers = true;
1329  }
1330  } else {
1331  // Base element type of field is a non-class type.
1332  if (!T->isLiteralType(Context) ||
1333  (!Field->hasInClassInitializer() && !isUnion() &&
1334  !Context.getLangOpts().CPlusPlus20))
1335  data().DefaultedDefaultConstructorIsConstexpr = false;
1336 
1337  // C++11 [class.copy]p23:
1338  // A defaulted copy/move assignment operator for a class X is defined
1339  // as deleted if X has:
1340  // -- a non-static data member of const non-class type (or array
1341  // thereof)
1342  if (T.isConstQualified()) {
1343  data().DefaultedCopyAssignmentIsDeleted = true;
1344  data().DefaultedMoveAssignmentIsDeleted = true;
1345  }
1346 
1347  // C++20 [temp.param]p7:
1348  // A structural type is [...] a literal class type [for which] the
1349  // types of all non-static data members are structural types or
1350  // (possibly multidimensional) array thereof
1351  // We deal with class types elsewhere.
1352  if (!T->isStructuralType())
1353  data().StructuralIfLiteral = false;
1354  }
1355 
1356  // C++14 [meta.unary.prop]p4:
1357  // T is a class type [...] with [...] no non-static data members other
1358  // than subobjects of zero size
1359  if (data().Empty && !IsZeroSize)
1360  data().Empty = false;
1361  }
1362 
1363  // Handle using declarations of conversion functions.
1364  if (auto *Shadow = dyn_cast<UsingShadowDecl>(D)) {
1365  if (Shadow->getDeclName().getNameKind()
1367  ASTContext &Ctx = getASTContext();
1368  data().Conversions.get(Ctx).addDecl(Ctx, Shadow, Shadow->getAccess());
1369  }
1370  }
1371 
1372  if (const auto *Using = dyn_cast<UsingDecl>(D)) {
1373  if (Using->getDeclName().getNameKind() ==
1375  data().HasInheritedConstructor = true;
1376  // C++1z [dcl.init.aggr]p1:
1377  // An aggregate is [...] a class [...] with no inherited constructors
1378  data().Aggregate = false;
1379  }
1380 
1381  if (Using->getDeclName().getCXXOverloadedOperator() == OO_Equal)
1382  data().HasInheritedAssignment = true;
1383  }
1384 }
1385 
1387  assert(!D->isImplicit() && !D->isUserProvided());
1388 
1389  // The kind of special member this declaration is, if any.
1390  unsigned SMKind = 0;
1391 
1392  if (const auto *Constructor = dyn_cast<CXXConstructorDecl>(D)) {
1393  if (Constructor->isDefaultConstructor()) {
1394  SMKind |= SMF_DefaultConstructor;
1395  if (Constructor->isConstexpr())
1396  data().HasConstexprDefaultConstructor = true;
1397  }
1398  if (Constructor->isCopyConstructor())
1399  SMKind |= SMF_CopyConstructor;
1400  else if (Constructor->isMoveConstructor())
1401  SMKind |= SMF_MoveConstructor;
1402  else if (Constructor->isConstexpr())
1403  // We may now know that the constructor is constexpr.
1404  data().HasConstexprNonCopyMoveConstructor = true;
1405  } else if (isa<CXXDestructorDecl>(D)) {
1406  SMKind |= SMF_Destructor;
1407  if (!D->isTrivial() || D->getAccess() != AS_public || D->isDeleted())
1408  data().HasIrrelevantDestructor = false;
1409  } else if (D->isCopyAssignmentOperator())
1410  SMKind |= SMF_CopyAssignment;
1411  else if (D->isMoveAssignmentOperator())
1412  SMKind |= SMF_MoveAssignment;
1413 
1414  // Update which trivial / non-trivial special members we have.
1415  // addedMember will have skipped this step for this member.
1416  if (D->isTrivial())
1417  data().HasTrivialSpecialMembers |= SMKind;
1418  else
1419  data().DeclaredNonTrivialSpecialMembers |= SMKind;
1420 }
1421 
1423  ArrayRef<LambdaCapture> Captures) {
1424  CXXRecordDecl::LambdaDefinitionData &Data = getLambdaData();
1425 
1426  // Copy captures.
1427  Data.NumCaptures = Captures.size();
1428  Data.NumExplicitCaptures = 0;
1429  Data.Captures = (LambdaCapture *)Context.Allocate(sizeof(LambdaCapture) *
1430  Captures.size());
1431  LambdaCapture *ToCapture = Data.Captures;
1432  for (unsigned I = 0, N = Captures.size(); I != N; ++I) {
1433  if (Captures[I].isExplicit())
1434  ++Data.NumExplicitCaptures;
1435 
1436  *ToCapture++ = Captures[I];
1437  }
1438 
1440  Data.DefaultedCopyAssignmentIsDeleted = true;
1441 }
1442 
1444  unsigned SMKind = 0;
1445 
1446  if (const auto *Constructor = dyn_cast<CXXConstructorDecl>(D)) {
1447  if (Constructor->isCopyConstructor())
1448  SMKind = SMF_CopyConstructor;
1449  else if (Constructor->isMoveConstructor())
1450  SMKind = SMF_MoveConstructor;
1451  } else if (isa<CXXDestructorDecl>(D))
1452  SMKind = SMF_Destructor;
1453 
1454  if (D->isTrivialForCall())
1455  data().HasTrivialSpecialMembersForCall |= SMKind;
1456  else
1457  data().DeclaredNonTrivialSpecialMembersForCall |= SMKind;
1458 }
1459 
1461  if (getTagKind() == TTK_Class || getTagKind() == TTK_Interface ||
1462  !TemplateOrInstantiation.isNull())
1463  return false;
1464  if (!hasDefinition())
1465  return true;
1466 
1467  return isPOD() && data().HasOnlyCMembers;
1468 }
1469 
1471  if (!isLambda()) return false;
1472  return getLambdaData().IsGenericLambda;
1473 }
1474 
1475 #ifndef NDEBUG
1477  for (auto *D : R)
1478  if (!declaresSameEntity(D, R.front()))
1479  return false;
1480  return true;
1481 }
1482 #endif
1483 
1485  if (!RD.isLambda()) return nullptr;
1486  DeclarationName Name =
1488  DeclContext::lookup_result Calls = RD.lookup(Name);
1489 
1490  assert(!Calls.empty() && "Missing lambda call operator!");
1491  assert(allLookupResultsAreTheSame(Calls) &&
1492  "More than one lambda call operator!");
1493  return Calls.front();
1494 }
1495 
1497  NamedDecl *CallOp = getLambdaCallOperatorHelper(*this);
1498  return dyn_cast_or_null<FunctionTemplateDecl>(CallOp);
1499 }
1500 
1502  NamedDecl *CallOp = getLambdaCallOperatorHelper(*this);
1503 
1504  if (CallOp == nullptr)
1505  return nullptr;
1506 
1507  if (const auto *CallOpTmpl = dyn_cast<FunctionTemplateDecl>(CallOp))
1508  return cast<CXXMethodDecl>(CallOpTmpl->getTemplatedDecl());
1509 
1510  return cast<CXXMethodDecl>(CallOp);
1511 }
1512 
1515  CallingConv CC = CallOp->getType()->castAs<FunctionType>()->getCallConv();
1516  return getLambdaStaticInvoker(CC);
1517 }
1518 
1521  assert(RD.isLambda() && "Must be a lambda");
1522  DeclarationName Name =
1524  return RD.lookup(Name);
1525 }
1526 
1528  if (const auto *InvokerTemplate = dyn_cast<FunctionTemplateDecl>(ND))
1529  return cast<CXXMethodDecl>(InvokerTemplate->getTemplatedDecl());
1530  return cast<CXXMethodDecl>(ND);
1531 }
1532 
1534  if (!isLambda())
1535  return nullptr;
1537 
1538  for (NamedDecl *ND : Invoker) {
1539  const auto *FTy =
1540  cast<ValueDecl>(ND->getAsFunction())->getType()->castAs<FunctionType>();
1541  if (FTy->getCallConv() == CC)
1542  return getInvokerAsMethod(ND);
1543  }
1544 
1545  return nullptr;
1546 }
1547 
1549  llvm::DenseMap<const VarDecl *, FieldDecl *> &Captures,
1550  FieldDecl *&ThisCapture) const {
1551  Captures.clear();
1552  ThisCapture = nullptr;
1553 
1554  LambdaDefinitionData &Lambda = getLambdaData();
1556  for (const LambdaCapture *C = Lambda.Captures, *CEnd = C + Lambda.NumCaptures;
1557  C != CEnd; ++C, ++Field) {
1558  if (C->capturesThis())
1559  ThisCapture = *Field;
1560  else if (C->capturesVariable())
1561  Captures[C->getCapturedVar()] = *Field;
1562  }
1563  assert(Field == field_end());
1564 }
1565 
1568  if (!isGenericLambda()) return nullptr;
1570  if (FunctionTemplateDecl *Tmpl = CallOp->getDescribedFunctionTemplate())
1571  return Tmpl->getTemplateParameters();
1572  return nullptr;
1573 }
1574 
1578  if (!List)
1579  return {};
1580 
1581  assert(std::is_partitioned(List->begin(), List->end(),
1582  [](const NamedDecl *D) { return !D->isImplicit(); })
1583  && "Explicit template params should be ordered before implicit ones");
1584 
1585  const auto ExplicitEnd = llvm::partition_point(
1586  *List, [](const NamedDecl *D) { return !D->isImplicit(); });
1587  return llvm::makeArrayRef(List->begin(), ExplicitEnd);
1588 }
1589 
1591  assert(isLambda() && "Not a lambda closure type!");
1593  return getLambdaData().ContextDecl.get(Source);
1594 }
1595 
1597  assert(isLambda() && "Not a lambda closure type!");
1598  if (Num)
1599  getASTContext().DeviceLambdaManglingNumbers[this] = Num;
1600 }
1601 
1603  assert(isLambda() && "Not a lambda closure type!");
1604  auto I = getASTContext().DeviceLambdaManglingNumbers.find(this);
1605  if (I != getASTContext().DeviceLambdaManglingNumbers.end())
1606  return I->second;
1607  return 0;
1608 }
1609 
1611  QualType T =
1612  cast<CXXConversionDecl>(Conv->getUnderlyingDecl()->getAsFunction())
1613  ->getConversionType();
1614  return Context.getCanonicalType(T);
1615 }
1616 
1617 /// Collect the visible conversions of a base class.
1618 ///
1619 /// \param Record a base class of the class we're considering
1620 /// \param InVirtual whether this base class is a virtual base (or a base
1621 /// of a virtual base)
1622 /// \param Access the access along the inheritance path to this base
1623 /// \param ParentHiddenTypes the conversions provided by the inheritors
1624 /// of this base
1625 /// \param Output the set to which to add conversions from non-virtual bases
1626 /// \param VOutput the set to which to add conversions from virtual bases
1627 /// \param HiddenVBaseCs the set of conversions which were hidden in a
1628 /// virtual base along some inheritance path
1630  ASTContext &Context, const CXXRecordDecl *Record, bool InVirtual,
1631  AccessSpecifier Access,
1632  const llvm::SmallPtrSet<CanQualType, 8> &ParentHiddenTypes,
1633  ASTUnresolvedSet &Output, UnresolvedSetImpl &VOutput,
1634  llvm::SmallPtrSet<NamedDecl *, 8> &HiddenVBaseCs) {
1635  // The set of types which have conversions in this class or its
1636  // subclasses. As an optimization, we don't copy the derived set
1637  // unless it might change.
1638  const llvm::SmallPtrSet<CanQualType, 8> *HiddenTypes = &ParentHiddenTypes;
1639  llvm::SmallPtrSet<CanQualType, 8> HiddenTypesBuffer;
1640 
1641  // Collect the direct conversions and figure out which conversions
1642  // will be hidden in the subclasses.
1645  if (ConvI != ConvE) {
1646  HiddenTypesBuffer = ParentHiddenTypes;
1647  HiddenTypes = &HiddenTypesBuffer;
1648 
1649  for (CXXRecordDecl::conversion_iterator I = ConvI; I != ConvE; ++I) {
1650  CanQualType ConvType(GetConversionType(Context, I.getDecl()));
1651  bool Hidden = ParentHiddenTypes.count(ConvType);
1652  if (!Hidden)
1653  HiddenTypesBuffer.insert(ConvType);
1654 
1655  // If this conversion is hidden and we're in a virtual base,
1656  // remember that it's hidden along some inheritance path.
1657  if (Hidden && InVirtual)
1658  HiddenVBaseCs.insert(cast<NamedDecl>(I.getDecl()->getCanonicalDecl()));
1659 
1660  // If this conversion isn't hidden, add it to the appropriate output.
1661  else if (!Hidden) {
1662  AccessSpecifier IAccess
1663  = CXXRecordDecl::MergeAccess(Access, I.getAccess());
1664 
1665  if (InVirtual)
1666  VOutput.addDecl(I.getDecl(), IAccess);
1667  else
1668  Output.addDecl(Context, I.getDecl(), IAccess);
1669  }
1670  }
1671  }
1672 
1673  // Collect information recursively from any base classes.
1674  for (const auto &I : Record->bases()) {
1675  const auto *RT = I.getType()->getAs<RecordType>();
1676  if (!RT) continue;
1677 
1678  AccessSpecifier BaseAccess
1679  = CXXRecordDecl::MergeAccess(Access, I.getAccessSpecifier());
1680  bool BaseInVirtual = InVirtual || I.isVirtual();
1681 
1682  auto *Base = cast<CXXRecordDecl>(RT->getDecl());
1683  CollectVisibleConversions(Context, Base, BaseInVirtual, BaseAccess,
1684  *HiddenTypes, Output, VOutput, HiddenVBaseCs);
1685  }
1686 }
1687 
1688 /// Collect the visible conversions of a class.
1689 ///
1690 /// This would be extremely straightforward if it weren't for virtual
1691 /// bases. It might be worth special-casing that, really.
1693  const CXXRecordDecl *Record,
1694  ASTUnresolvedSet &Output) {
1695  // The collection of all conversions in virtual bases that we've
1696  // found. These will be added to the output as long as they don't
1697  // appear in the hidden-conversions set.
1698  UnresolvedSet<8> VBaseCs;
1699 
1700  // The set of conversions in virtual bases that we've determined to
1701  // be hidden.
1702  llvm::SmallPtrSet<NamedDecl*, 8> HiddenVBaseCs;
1703 
1704  // The set of types hidden by classes derived from this one.
1706 
1707  // Go ahead and collect the direct conversions and add them to the
1708  // hidden-types set.
1711  Output.append(Context, ConvI, ConvE);
1712  for (; ConvI != ConvE; ++ConvI)
1713  HiddenTypes.insert(GetConversionType(Context, ConvI.getDecl()));
1714 
1715  // Recursively collect conversions from base classes.
1716  for (const auto &I : Record->bases()) {
1717  const auto *RT = I.getType()->getAs<RecordType>();
1718  if (!RT) continue;
1719 
1720  CollectVisibleConversions(Context, cast<CXXRecordDecl>(RT->getDecl()),
1721  I.isVirtual(), I.getAccessSpecifier(),
1722  HiddenTypes, Output, VBaseCs, HiddenVBaseCs);
1723  }
1724 
1725  // Add any unhidden conversions provided by virtual bases.
1726  for (UnresolvedSetIterator I = VBaseCs.begin(), E = VBaseCs.end();
1727  I != E; ++I) {
1728  if (!HiddenVBaseCs.count(cast<NamedDecl>(I.getDecl()->getCanonicalDecl())))
1729  Output.addDecl(Context, I.getDecl(), I.getAccess());
1730  }
1731 }
1732 
1733 /// getVisibleConversionFunctions - get all conversion functions visible
1734 /// in current class; including conversion function templates.
1735 llvm::iterator_range<CXXRecordDecl::conversion_iterator>
1737  ASTContext &Ctx = getASTContext();
1738 
1739  ASTUnresolvedSet *Set;
1740  if (bases_begin() == bases_end()) {
1741  // If root class, all conversions are visible.
1742  Set = &data().Conversions.get(Ctx);
1743  } else {
1744  Set = &data().VisibleConversions.get(Ctx);
1745  // If visible conversion list is not evaluated, evaluate it.
1746  if (!data().ComputedVisibleConversions) {
1747  CollectVisibleConversions(Ctx, this, *Set);
1748  data().ComputedVisibleConversions = true;
1749  }
1750  }
1751  return llvm::make_range(Set->begin(), Set->end());
1752 }
1753 
1755  // This operation is O(N) but extremely rare. Sema only uses it to
1756  // remove UsingShadowDecls in a class that were followed by a direct
1757  // declaration, e.g.:
1758  // class A : B {
1759  // using B::operator int;
1760  // operator int();
1761  // };
1762  // This is uncommon by itself and even more uncommon in conjunction
1763  // with sufficiently large numbers of directly-declared conversions
1764  // that asymptotic behavior matters.
1765 
1766  ASTUnresolvedSet &Convs = data().Conversions.get(getASTContext());
1767  for (unsigned I = 0, E = Convs.size(); I != E; ++I) {
1768  if (Convs[I].getDecl() == ConvDecl) {
1769  Convs.erase(I);
1770  assert(llvm::find(Convs, ConvDecl) == Convs.end() &&
1771  "conversion was found multiple times in unresolved set");
1772  return;
1773  }
1774  }
1775 
1776  llvm_unreachable("conversion not found in set!");
1777 }
1778 
1781  return cast<CXXRecordDecl>(MSInfo->getInstantiatedFrom());
1782 
1783  return nullptr;
1784 }
1785 
1787  return TemplateOrInstantiation.dyn_cast<MemberSpecializationInfo *>();
1788 }
1789 
1790 void
1793  assert(TemplateOrInstantiation.isNull() &&
1794  "Previous template or instantiation?");
1795  assert(!isa<ClassTemplatePartialSpecializationDecl>(this));
1796  TemplateOrInstantiation
1797  = new (getASTContext()) MemberSpecializationInfo(RD, TSK);
1798 }
1799 
1801  return TemplateOrInstantiation.dyn_cast<ClassTemplateDecl *>();
1802 }
1803 
1805  TemplateOrInstantiation = Template;
1806 }
1807 
1809  if (const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(this))
1810  return Spec->getSpecializationKind();
1811 
1813  return MSInfo->getTemplateSpecializationKind();
1814 
1815  return TSK_Undeclared;
1816 }
1817 
1818 void
1820  if (auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(this)) {
1821  Spec->setSpecializationKind(TSK);
1822  return;
1823  }
1824 
1826  MSInfo->setTemplateSpecializationKind(TSK);
1827  return;
1828  }
1829 
1830  llvm_unreachable("Not a class template or member class specialization");
1831 }
1832 
1834  auto GetDefinitionOrSelf =
1835  [](const CXXRecordDecl *D) -> const CXXRecordDecl * {
1836  if (auto *Def = D->getDefinition())
1837  return Def;
1838  return D;
1839  };
1840 
1841  // If it's a class template specialization, find the template or partial
1842  // specialization from which it was instantiated.
1843  if (auto *TD = dyn_cast<ClassTemplateSpecializationDecl>(this)) {
1844  auto From = TD->getInstantiatedFrom();
1845  if (auto *CTD = From.dyn_cast<ClassTemplateDecl *>()) {
1846  while (auto *NewCTD = CTD->getInstantiatedFromMemberTemplate()) {
1847  if (NewCTD->isMemberSpecialization())
1848  break;
1849  CTD = NewCTD;
1850  }
1851  return GetDefinitionOrSelf(CTD->getTemplatedDecl());
1852  }
1853  if (auto *CTPSD =
1854  From.dyn_cast<ClassTemplatePartialSpecializationDecl *>()) {
1855  while (auto *NewCTPSD = CTPSD->getInstantiatedFromMember()) {
1856  if (NewCTPSD->isMemberSpecialization())
1857  break;
1858  CTPSD = NewCTPSD;
1859  }
1860  return GetDefinitionOrSelf(CTPSD);
1861  }
1862  }
1863 
1865  if (isTemplateInstantiation(MSInfo->getTemplateSpecializationKind())) {
1866  const CXXRecordDecl *RD = this;
1867  while (auto *NewRD = RD->getInstantiatedFromMemberClass())
1868  RD = NewRD;
1869  return GetDefinitionOrSelf(RD);
1870  }
1871  }
1872 
1874  "couldn't find pattern for class template instantiation");
1875  return nullptr;
1876 }
1877 
1879  ASTContext &Context = getASTContext();
1880  QualType ClassType = Context.getTypeDeclType(this);
1881 
1882  DeclarationName Name
1884  Context.getCanonicalType(ClassType));
1885 
1887 
1888  return R.empty() ? nullptr : dyn_cast<CXXDestructorDecl>(R.front());
1889 }
1890 
1892  // Destructor is noreturn.
1893  if (const CXXDestructorDecl *Destructor = getDestructor())
1894  if (Destructor->isNoReturn())
1895  return true;
1896 
1897  // Check base classes destructor for noreturn.
1898  for (const auto &Base : bases())
1899  if (const CXXRecordDecl *RD = Base.getType()->getAsCXXRecordDecl())
1900  if (RD->isAnyDestructorNoReturn())
1901  return true;
1902 
1903  // Check fields for noreturn.
1904  for (const auto *Field : fields())
1905  if (const CXXRecordDecl *RD =
1906  Field->getType()->getBaseElementTypeUnsafe()->getAsCXXRecordDecl())
1907  if (RD->isAnyDestructorNoReturn())
1908  return true;
1909 
1910  // All destructors are not noreturn.
1911  return false;
1912 }
1913 
1914 static bool isDeclContextInNamespace(const DeclContext *DC) {
1915  while (!DC->isTranslationUnit()) {
1916  if (DC->isNamespace())
1917  return true;
1918  DC = DC->getParent();
1919  }
1920  return false;
1921 }
1922 
1924  assert(hasDefinition() && "checking for interface-like without a definition");
1925  // All __interfaces are inheritently interface-like.
1926  if (isInterface())
1927  return true;
1928 
1929  // Interface-like types cannot have a user declared constructor, destructor,
1930  // friends, VBases, conversion functions, or fields. Additionally, lambdas
1931  // cannot be interface types.
1932  if (isLambda() || hasUserDeclaredConstructor() ||
1934  getNumVBases() > 0 || conversion_end() - conversion_begin() > 0)
1935  return false;
1936 
1937  // No interface-like type can have a method with a definition.
1938  for (const auto *const Method : methods())
1939  if (Method->isDefined() && !Method->isImplicit())
1940  return false;
1941 
1942  // Check "Special" types.
1943  const auto *Uuid = getAttr<UuidAttr>();
1944  // MS SDK declares IUnknown/IDispatch both in the root of a TU, or in an
1945  // extern C++ block directly in the TU. These are only valid if in one
1946  // of these two situations.
1947  if (Uuid && isStruct() && !getDeclContext()->isExternCContext() &&
1949  ((getName() == "IUnknown" &&
1950  Uuid->getGuid() == "00000000-0000-0000-C000-000000000046") ||
1951  (getName() == "IDispatch" &&
1952  Uuid->getGuid() == "00020400-0000-0000-C000-000000000046"))) {
1953  if (getNumBases() > 0)
1954  return false;
1955  return true;
1956  }
1957 
1958  // FIXME: Any access specifiers is supposed to make this no longer interface
1959  // like.
1960 
1961  // If this isn't a 'special' type, it must have a single interface-like base.
1962  if (getNumBases() != 1)
1963  return false;
1964 
1965  const auto BaseSpec = *bases_begin();
1966  if (BaseSpec.isVirtual() || BaseSpec.getAccessSpecifier() != AS_public)
1967  return false;
1968  const auto *Base = BaseSpec.getType()->getAsCXXRecordDecl();
1969  if (Base->isInterface() || !Base->isInterfaceLike())
1970  return false;
1971  return true;
1972 }
1973 
1975  completeDefinition(nullptr);
1976 }
1977 
1980 
1981  // If the class may be abstract (but hasn't been marked as such), check for
1982  // any pure final overriders.
1983  if (mayBeAbstract()) {
1984  CXXFinalOverriderMap MyFinalOverriders;
1985  if (!FinalOverriders) {
1986  getFinalOverriders(MyFinalOverriders);
1987  FinalOverriders = &MyFinalOverriders;
1988  }
1989 
1990  bool Done = false;
1991  for (CXXFinalOverriderMap::iterator M = FinalOverriders->begin(),
1992  MEnd = FinalOverriders->end();
1993  M != MEnd && !Done; ++M) {
1994  for (OverridingMethods::iterator SO = M->second.begin(),
1995  SOEnd = M->second.end();
1996  SO != SOEnd && !Done; ++SO) {
1997  assert(SO->second.size() > 0 &&
1998  "All virtual functions have overriding virtual functions");
1999 
2000  // C++ [class.abstract]p4:
2001  // A class is abstract if it contains or inherits at least one
2002  // pure virtual function for which the final overrider is pure
2003  // virtual.
2004  if (SO->second.front().Method->isPure()) {
2005  data().Abstract = true;
2006  Done = true;
2007  break;
2008  }
2009  }
2010  }
2011  }
2012 
2013  // Set access bits correctly on the directly-declared conversions.
2015  I != E; ++I)
2016  I.setAccess((*I)->getAccess());
2017 }
2018 
2020  if (data().Abstract || isInvalidDecl() || !data().Polymorphic ||
2022  return false;
2023 
2024  for (const auto &B : bases()) {
2025  const auto *BaseDecl =
2026  cast<CXXRecordDecl>(B.getType()->castAs<RecordType>()->getDecl());
2027  if (BaseDecl->isAbstract())
2028  return true;
2029  }
2030 
2031  return false;
2032 }
2033 
2035  auto *Def = getDefinition();
2036  if (!Def)
2037  return false;
2038  if (Def->hasAttr<FinalAttr>())
2039  return true;
2040  if (const auto *Dtor = Def->getDestructor())
2041  if (Dtor->hasAttr<FinalAttr>())
2042  return true;
2043  return false;
2044 }
2045 
2046 void CXXDeductionGuideDecl::anchor() {}
2047 
2049  if ((getKind() != Other.getKind() ||
2053  ODRHash SelfHash, OtherHash;
2054  SelfHash.AddStmt(getExpr());
2055  OtherHash.AddStmt(Other.getExpr());
2056  return SelfHash.CalculateHash() == OtherHash.CalculateHash();
2057  } else
2058  return false;
2059  }
2060  return true;
2061 }
2062 
2064  switch (Function->getDeclKind()) {
2065  case Decl::Kind::CXXConstructor:
2066  return cast<CXXConstructorDecl>(Function)->getExplicitSpecifier();
2067  case Decl::Kind::CXXConversion:
2068  return cast<CXXConversionDecl>(Function)->getExplicitSpecifier();
2069  case Decl::Kind::CXXDeductionGuide:
2070  return cast<CXXDeductionGuideDecl>(Function)->getExplicitSpecifier();
2071  default:
2072  return {};
2073  }
2074 }
2075 
2078  SourceLocation StartLoc, ExplicitSpecifier ES,
2079  const DeclarationNameInfo &NameInfo, QualType T,
2080  TypeSourceInfo *TInfo, SourceLocation EndLocation,
2081  CXXConstructorDecl *Ctor) {
2082  return new (C, DC) CXXDeductionGuideDecl(C, DC, StartLoc, ES, NameInfo, T,
2083  TInfo, EndLocation, Ctor);
2084 }
2085 
2087  unsigned ID) {
2088  return new (C, ID) CXXDeductionGuideDecl(
2090  QualType(), nullptr, SourceLocation(), nullptr);
2091 }
2092 
2094  ASTContext &C, DeclContext *DC, SourceLocation StartLoc) {
2095  return new (C, DC) RequiresExprBodyDecl(C, DC, StartLoc);
2096 }
2097 
2099  unsigned ID) {
2100  return new (C, ID) RequiresExprBodyDecl(C, nullptr, SourceLocation());
2101 }
2102 
2103 void CXXMethodDecl::anchor() {}
2104 
2106  const CXXMethodDecl *MD = getCanonicalDecl();
2107 
2108  if (MD->getStorageClass() == SC_Static)
2109  return true;
2110 
2112  return isStaticOverloadedOperator(OOK);
2113 }
2114 
2115 static bool recursivelyOverrides(const CXXMethodDecl *DerivedMD,
2116  const CXXMethodDecl *BaseMD) {
2117  for (const CXXMethodDecl *MD : DerivedMD->overridden_methods()) {
2118  if (MD->getCanonicalDecl() == BaseMD->getCanonicalDecl())
2119  return true;
2120  if (recursivelyOverrides(MD, BaseMD))
2121  return true;
2122  }
2123  return false;
2124 }
2125 
2126 CXXMethodDecl *
2128  bool MayBeBase) {
2129  if (this->getParent()->getCanonicalDecl() == RD->getCanonicalDecl())
2130  return this;
2131 
2132  // Lookup doesn't work for destructors, so handle them separately.
2133  if (isa<CXXDestructorDecl>(this)) {
2134  CXXMethodDecl *MD = RD->getDestructor();
2135  if (MD) {
2136  if (recursivelyOverrides(MD, this))
2137  return MD;
2138  if (MayBeBase && recursivelyOverrides(this, MD))
2139  return MD;
2140  }
2141  return nullptr;
2142  }
2143 
2144  for (auto *ND : RD->lookup(getDeclName())) {
2145  auto *MD = dyn_cast<CXXMethodDecl>(ND);
2146  if (!MD)
2147  continue;
2148  if (recursivelyOverrides(MD, this))
2149  return MD;
2150  if (MayBeBase && recursivelyOverrides(this, MD))
2151  return MD;
2152  }
2153 
2154  return nullptr;
2155 }
2156 
2157 CXXMethodDecl *
2159  bool MayBeBase) {
2160  if (auto *MD = getCorrespondingMethodDeclaredInClass(RD, MayBeBase))
2161  return MD;
2162 
2163  llvm::SmallVector<CXXMethodDecl*, 4> FinalOverriders;
2164  auto AddFinalOverrider = [&](CXXMethodDecl *D) {
2165  // If this function is overridden by a candidate final overrider, it is not
2166  // a final overrider.
2167  for (CXXMethodDecl *OtherD : FinalOverriders) {
2168  if (declaresSameEntity(D, OtherD) || recursivelyOverrides(OtherD, D))
2169  return;
2170  }
2171 
2172  // Other candidate final overriders might be overridden by this function.
2173  FinalOverriders.erase(
2174  std::remove_if(FinalOverriders.begin(), FinalOverriders.end(),
2175  [&](CXXMethodDecl *OtherD) {
2176  return recursivelyOverrides(D, OtherD);
2177  }),
2178  FinalOverriders.end());
2179 
2180  FinalOverriders.push_back(D);
2181  };
2182 
2183  for (const auto &I : RD->bases()) {
2184  const RecordType *RT = I.getType()->getAs<RecordType>();
2185  if (!RT)
2186  continue;
2187  const auto *Base = cast<CXXRecordDecl>(RT->getDecl());
2188  if (CXXMethodDecl *D = this->getCorrespondingMethodInClass(Base))
2189  AddFinalOverrider(D);
2190  }
2191 
2192  return FinalOverriders.size() == 1 ? FinalOverriders.front() : nullptr;
2193 }
2194 
2196  SourceLocation StartLoc,
2197  const DeclarationNameInfo &NameInfo,
2198  QualType T, TypeSourceInfo *TInfo,
2199  StorageClass SC, bool isInline,
2200  ConstexprSpecKind ConstexprKind,
2201  SourceLocation EndLocation,
2202  Expr *TrailingRequiresClause) {
2203  return new (C, RD)
2204  CXXMethodDecl(CXXMethod, C, RD, StartLoc, NameInfo, T, TInfo, SC,
2205  isInline, ConstexprKind, EndLocation,
2206  TrailingRequiresClause);
2207 }
2208 
2210  return new (C, ID)
2211  CXXMethodDecl(CXXMethod, C, nullptr, SourceLocation(),
2212  DeclarationNameInfo(), QualType(), nullptr, SC_None, false,
2214 }
2215 
2217  bool IsAppleKext) {
2218  assert(isVirtual() && "this method is expected to be virtual");
2219 
2220  // When building with -fapple-kext, all calls must go through the vtable since
2221  // the kernel linker can do runtime patching of vtables.
2222  if (IsAppleKext)
2223  return nullptr;
2224 
2225  // If the member function is marked 'final', we know that it can't be
2226  // overridden and can therefore devirtualize it unless it's pure virtual.
2227  if (hasAttr<FinalAttr>())
2228  return isPure() ? nullptr : this;
2229 
2230  // If Base is unknown, we cannot devirtualize.
2231  if (!Base)
2232  return nullptr;
2233 
2234  // If the base expression (after skipping derived-to-base conversions) is a
2235  // class prvalue, then we can devirtualize.
2236  Base = Base->getBestDynamicClassTypeExpr();
2237  if (Base->isRValue() && Base->getType()->isRecordType())
2238  return this;
2239 
2240  // If we don't even know what we would call, we can't devirtualize.
2241  const CXXRecordDecl *BestDynamicDecl = Base->getBestDynamicClassType();
2242  if (!BestDynamicDecl)
2243  return nullptr;
2244 
2245  // There may be a method corresponding to MD in a derived class.
2246  CXXMethodDecl *DevirtualizedMethod =
2247  getCorrespondingMethodInClass(BestDynamicDecl);
2248 
2249  // If there final overrider in the dynamic type is ambiguous, we can't
2250  // devirtualize this call.
2251  if (!DevirtualizedMethod)
2252  return nullptr;
2253 
2254  // If that method is pure virtual, we can't devirtualize. If this code is
2255  // reached, the result would be UB, not a direct call to the derived class
2256  // function, and we can't assume the derived class function is defined.
2257  if (DevirtualizedMethod->isPure())
2258  return nullptr;
2259 
2260  // If that method is marked final, we can devirtualize it.
2261  if (DevirtualizedMethod->hasAttr<FinalAttr>())
2262  return DevirtualizedMethod;
2263 
2264  // Similarly, if the class itself or its destructor is marked 'final',
2265  // the class can't be derived from and we can therefore devirtualize the
2266  // member function call.
2267  if (BestDynamicDecl->isEffectivelyFinal())
2268  return DevirtualizedMethod;
2269 
2270  if (const auto *DRE = dyn_cast<DeclRefExpr>(Base)) {
2271  if (const auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
2272  if (VD->getType()->isRecordType())
2273  // This is a record decl. We know the type and can devirtualize it.
2274  return DevirtualizedMethod;
2275 
2276  return nullptr;
2277  }
2278 
2279  // We can devirtualize calls on an object accessed by a class member access
2280  // expression, since by C++11 [basic.life]p6 we know that it can't refer to
2281  // a derived class object constructed in the same location.
2282  if (const auto *ME = dyn_cast<MemberExpr>(Base)) {
2283  const ValueDecl *VD = ME->getMemberDecl();
2284  return VD->getType()->isRecordType() ? DevirtualizedMethod : nullptr;
2285  }
2286 
2287  // Likewise for calls on an object accessed by a (non-reference) pointer to
2288  // member access.
2289  if (auto *BO = dyn_cast<BinaryOperator>(Base)) {
2290  if (BO->isPtrMemOp()) {
2291  auto *MPT = BO->getRHS()->getType()->castAs<MemberPointerType>();
2292  if (MPT->getPointeeType()->isRecordType())
2293  return DevirtualizedMethod;
2294  }
2295  }
2296 
2297  // We can't devirtualize the call.
2298  return nullptr;
2299 }
2300 
2302  SmallVectorImpl<const FunctionDecl *> &PreventedBy) const {
2303  assert(PreventedBy.empty() && "PreventedBy is expected to be empty");
2304  if (getOverloadedOperator() != OO_Delete &&
2305  getOverloadedOperator() != OO_Array_Delete)
2306  return false;
2307 
2308  // C++ [basic.stc.dynamic.deallocation]p2:
2309  // A template instance is never a usual deallocation function,
2310  // regardless of its signature.
2311  if (getPrimaryTemplate())
2312  return false;
2313 
2314  // C++ [basic.stc.dynamic.deallocation]p2:
2315  // If a class T has a member deallocation function named operator delete
2316  // with exactly one parameter, then that function is a usual (non-placement)
2317  // deallocation function. [...]
2318  if (getNumParams() == 1)
2319  return true;
2320  unsigned UsualParams = 1;
2321 
2322  // C++ P0722:
2323  // A destroying operator delete is a usual deallocation function if
2324  // removing the std::destroying_delete_t parameter and changing the
2325  // first parameter type from T* to void* results in the signature of
2326  // a usual deallocation function.
2328  ++UsualParams;
2329 
2330  // C++ <=14 [basic.stc.dynamic.deallocation]p2:
2331  // [...] If class T does not declare such an operator delete but does
2332  // declare a member deallocation function named operator delete with
2333  // exactly two parameters, the second of which has type std::size_t (18.1),
2334  // then this function is a usual deallocation function.
2335  //
2336  // C++17 says a usual deallocation function is one with the signature
2337  // (void* [, size_t] [, std::align_val_t] [, ...])
2338  // and all such functions are usual deallocation functions. It's not clear
2339  // that allowing varargs functions was intentional.
2340  ASTContext &Context = getASTContext();
2341  if (UsualParams < getNumParams() &&
2342  Context.hasSameUnqualifiedType(getParamDecl(UsualParams)->getType(),
2343  Context.getSizeType()))
2344  ++UsualParams;
2345 
2346  if (UsualParams < getNumParams() &&
2347  getParamDecl(UsualParams)->getType()->isAlignValT())
2348  ++UsualParams;
2349 
2350  if (UsualParams != getNumParams())
2351  return false;
2352 
2353  // In C++17 onwards, all potential usual deallocation functions are actual
2354  // usual deallocation functions. Honor this behavior when post-C++14
2355  // deallocation functions are offered as extensions too.
2356  // FIXME(EricWF): Destrying Delete should be a language option. How do we
2357  // handle when destroying delete is used prior to C++17?
2358  if (Context.getLangOpts().CPlusPlus17 ||
2359  Context.getLangOpts().AlignedAllocation ||
2361  return true;
2362 
2363  // This function is a usual deallocation function if there are no
2364  // single-parameter deallocation functions of the same kind.
2366  bool Result = true;
2367  for (const auto *D : R) {
2368  if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
2369  if (FD->getNumParams() == 1) {
2370  PreventedBy.push_back(FD);
2371  Result = false;
2372  }
2373  }
2374  }
2375  return Result;
2376 }
2377 
2379  // C++0x [class.copy]p17:
2380  // A user-declared copy assignment operator X::operator= is a non-static
2381  // non-template member function of class X with exactly one parameter of
2382  // type X, X&, const X&, volatile X& or const volatile X&.
2383  if (/*operator=*/getOverloadedOperator() != OO_Equal ||
2384  /*non-static*/ isStatic() ||
2385  /*non-template*/getPrimaryTemplate() || getDescribedFunctionTemplate() ||
2386  getNumParams() != 1)
2387  return false;
2388 
2389  QualType ParamType = getParamDecl(0)->getType();
2390  if (const auto *Ref = ParamType->getAs<LValueReferenceType>())
2391  ParamType = Ref->getPointeeType();
2392 
2393  ASTContext &Context = getASTContext();
2394  QualType ClassType
2395  = Context.getCanonicalType(Context.getTypeDeclType(getParent()));
2396  return Context.hasSameUnqualifiedType(ClassType, ParamType);
2397 }
2398 
2400  // C++0x [class.copy]p19:
2401  // A user-declared move assignment operator X::operator= is a non-static
2402  // non-template member function of class X with exactly one parameter of type
2403  // X&&, const X&&, volatile X&&, or const volatile X&&.
2404  if (getOverloadedOperator() != OO_Equal || isStatic() ||
2406  getNumParams() != 1)
2407  return false;
2408 
2409  QualType ParamType = getParamDecl(0)->getType();
2410  if (!isa<RValueReferenceType>(ParamType))
2411  return false;
2412  ParamType = ParamType->getPointeeType();
2413 
2414  ASTContext &Context = getASTContext();
2415  QualType ClassType
2416  = Context.getCanonicalType(Context.getTypeDeclType(getParent()));
2417  return Context.hasSameUnqualifiedType(ClassType, ParamType);
2418 }
2419 
2421  assert(MD->isCanonicalDecl() && "Method is not canonical!");
2422  assert(!MD->getParent()->isDependentContext() &&
2423  "Can't add an overridden method to a class template!");
2424  assert(MD->isVirtual() && "Method is not virtual!");
2425 
2426  getASTContext().addOverriddenMethod(this, MD);
2427 }
2428 
2430  if (isa<CXXConstructorDecl>(this)) return nullptr;
2431  return getASTContext().overridden_methods_begin(this);
2432 }
2433 
2435  if (isa<CXXConstructorDecl>(this)) return nullptr;
2436  return getASTContext().overridden_methods_end(this);
2437 }
2438 
2440  if (isa<CXXConstructorDecl>(this)) return 0;
2441  return getASTContext().overridden_methods_size(this);
2442 }
2443 
2446  if (isa<CXXConstructorDecl>(this))
2447  return overridden_method_range(nullptr, nullptr);
2448  return getASTContext().overridden_methods(this);
2449 }
2450 
2452  const CXXRecordDecl *Decl) {
2453  QualType ClassTy = C.getTypeDeclType(Decl);
2454  return C.getQualifiedType(ClassTy, FPT->getMethodQuals());
2455 }
2456 
2458  const CXXRecordDecl *Decl) {
2460  QualType ObjectTy = ::getThisObjectType(C, FPT, Decl);
2461  return C.getPointerType(ObjectTy);
2462 }
2463 
2465  const CXXRecordDecl *Decl) {
2468 }
2469 
2471  // C++ 9.3.2p1: The type of this in a member function of a class X is X*.
2472  // If the member function is declared const, the type of this is const X*,
2473  // if the member function is declared volatile, the type of this is
2474  // volatile X*, and if the member function is declared const volatile,
2475  // the type of this is const volatile X*.
2476  assert(isInstance() && "No 'this' for static methods!");
2477  return CXXMethodDecl::getThisType(getType()->castAs<FunctionProtoType>(),
2478  getParent());
2479 }
2480 
2482  // Ditto getThisType.
2483  assert(isInstance() && "No 'this' for static methods!");
2485  getType()->castAs<FunctionProtoType>(), getParent());
2486 }
2487 
2489  // If this function is a template instantiation, look at the template from
2490  // which it was instantiated.
2491  const FunctionDecl *CheckFn = getTemplateInstantiationPattern();
2492  if (!CheckFn)
2493  CheckFn = this;
2494 
2495  const FunctionDecl *fn;
2496  return CheckFn->isDefined(fn) && !fn->isOutOfLine() &&
2497  (fn->doesThisDeclarationHaveABody() || fn->willHaveBody());
2498 }
2499 
2501  const CXXRecordDecl *P = getParent();
2502  return P->isLambda() && getDeclName().isIdentifier() &&
2504 }
2505 
2507  TypeSourceInfo *TInfo, bool IsVirtual,
2508  SourceLocation L, Expr *Init,
2509  SourceLocation R,
2510  SourceLocation EllipsisLoc)
2511  : Initializee(TInfo), Init(Init), MemberOrEllipsisLocation(EllipsisLoc),
2512  LParenLoc(L), RParenLoc(R), IsDelegating(false), IsVirtual(IsVirtual),
2513  IsWritten(false), SourceOrder(0) {}
2514 
2516  SourceLocation MemberLoc,
2517  SourceLocation L, Expr *Init,
2518  SourceLocation R)
2519  : Initializee(Member), Init(Init), MemberOrEllipsisLocation(MemberLoc),
2520  LParenLoc(L), RParenLoc(R), IsDelegating(false), IsVirtual(false),
2521  IsWritten(false), SourceOrder(0) {}
2522 
2524  IndirectFieldDecl *Member,
2525  SourceLocation MemberLoc,
2526  SourceLocation L, Expr *Init,
2527  SourceLocation R)
2528  : Initializee(Member), Init(Init), MemberOrEllipsisLocation(MemberLoc),
2529  LParenLoc(L), RParenLoc(R), IsDelegating(false), IsVirtual(false),
2530  IsWritten(false), SourceOrder(0) {}
2531 
2533  TypeSourceInfo *TInfo,
2534  SourceLocation L, Expr *Init,
2535  SourceLocation R)
2536  : Initializee(TInfo), Init(Init), LParenLoc(L), RParenLoc(R),
2537  IsDelegating(true), IsVirtual(false), IsWritten(false), SourceOrder(0) {}
2538 
2539 int64_t CXXCtorInitializer::getID(const ASTContext &Context) const {
2540  return Context.getAllocator()
2541  .identifyKnownAlignedObject<CXXCtorInitializer>(this);
2542 }
2543 
2545  if (isBaseInitializer())
2546  return Initializee.get<TypeSourceInfo*>()->getTypeLoc();
2547  else
2548  return {};
2549 }
2550 
2552  if (isBaseInitializer())
2553  return Initializee.get<TypeSourceInfo*>()->getType().getTypePtr();
2554  else
2555  return nullptr;
2556 }
2557 
2560  return getAnyMember()->getLocation();
2561 
2562  if (isAnyMemberInitializer())
2563  return getMemberLocation();
2564 
2565  if (const auto *TSInfo = Initializee.get<TypeSourceInfo *>())
2566  return TSInfo->getTypeLoc().getLocalSourceRange().getBegin();
2567 
2568  return {};
2569 }
2570 
2573  FieldDecl *D = getAnyMember();
2574  if (Expr *I = D->getInClassInitializer())
2575  return I->getSourceRange();
2576  return {};
2577  }
2578 
2580 }
2581 
2582 CXXConstructorDecl::CXXConstructorDecl(
2583  ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
2584  const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo,
2585  ExplicitSpecifier ES, bool isInline, bool isImplicitlyDeclared,
2586  ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited,
2587  Expr *TrailingRequiresClause)
2588  : CXXMethodDecl(CXXConstructor, C, RD, StartLoc, NameInfo, T, TInfo,
2589  SC_None, isInline, ConstexprKind, SourceLocation(),
2590  TrailingRequiresClause) {
2591  setNumCtorInitializers(0);
2592  setInheritingConstructor(static_cast<bool>(Inherited));
2593  setImplicit(isImplicitlyDeclared);
2594  CXXConstructorDeclBits.HasTrailingExplicitSpecifier = ES.getExpr() ? 1 : 0;
2595  if (Inherited)
2596  *getTrailingObjects<InheritedConstructor>() = Inherited;
2597  setExplicitSpecifier(ES);
2598 }
2599 
2600 void CXXConstructorDecl::anchor() {}
2601 
2603  unsigned ID,
2604  uint64_t AllocKind) {
2605  bool hasTrailingExplicit = static_cast<bool>(AllocKind & TAKHasTailExplicit);
2607  static_cast<bool>(AllocKind & TAKInheritsConstructor);
2608  unsigned Extra =
2609  additionalSizeToAlloc<InheritedConstructor, ExplicitSpecifier>(
2610  isInheritingConstructor, hasTrailingExplicit);
2611  auto *Result = new (C, ID, Extra) CXXConstructorDecl(
2612  C, nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), nullptr,
2614  InheritedConstructor(), nullptr);
2615  Result->setInheritingConstructor(isInheritingConstructor);
2616  Result->CXXConstructorDeclBits.HasTrailingExplicitSpecifier =
2617  hasTrailingExplicit;
2618  Result->setExplicitSpecifier(ExplicitSpecifier());
2619  return Result;
2620 }
2621 
2623  ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
2624  const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo,
2625  ExplicitSpecifier ES, bool isInline, bool isImplicitlyDeclared,
2626  ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited,
2627  Expr *TrailingRequiresClause) {
2628  assert(NameInfo.getName().getNameKind()
2630  "Name must refer to a constructor");
2631  unsigned Extra =
2632  additionalSizeToAlloc<InheritedConstructor, ExplicitSpecifier>(
2633  Inherited ? 1 : 0, ES.getExpr() ? 1 : 0);
2634  return new (C, RD, Extra)
2635  CXXConstructorDecl(C, RD, StartLoc, NameInfo, T, TInfo, ES, isInline,
2636  isImplicitlyDeclared, ConstexprKind, Inherited,
2637  TrailingRequiresClause);
2638 }
2639 
2641  return CtorInitializers.get(getASTContext().getExternalSource());
2642 }
2643 
2645  assert(isDelegatingConstructor() && "Not a delegating constructor!");
2646  Expr *E = (*init_begin())->getInit()->IgnoreImplicit();
2647  if (const auto *Construct = dyn_cast<CXXConstructExpr>(E))
2648  return Construct->getConstructor();
2649 
2650  return nullptr;
2651 }
2652 
2654  // C++ [class.default.ctor]p1:
2655  // A default constructor for a class X is a constructor of class X for
2656  // which each parameter that is not a function parameter pack has a default
2657  // argument (including the case of a constructor with no parameters)
2658  return getMinRequiredArguments() == 0;
2659 }
2660 
2661 bool
2662 CXXConstructorDecl::isCopyConstructor(unsigned &TypeQuals) const {
2663  return isCopyOrMoveConstructor(TypeQuals) &&
2665 }
2666 
2667 bool CXXConstructorDecl::isMoveConstructor(unsigned &TypeQuals) const {
2668  return isCopyOrMoveConstructor(TypeQuals) &&
2670 }
2671 
2672 /// Determine whether this is a copy or move constructor.
2673 bool CXXConstructorDecl::isCopyOrMoveConstructor(unsigned &TypeQuals) const {
2674  // C++ [class.copy]p2:
2675  // A non-template constructor for class X is a copy constructor
2676  // if its first parameter is of type X&, const X&, volatile X& or
2677  // const volatile X&, and either there are no other parameters
2678  // or else all other parameters have default arguments (8.3.6).
2679  // C++0x [class.copy]p3:
2680  // A non-template constructor for class X is a move constructor if its
2681  // first parameter is of type X&&, const X&&, volatile X&&, or
2682  // const volatile X&&, and either there are no other parameters or else
2683  // all other parameters have default arguments.
2684  if (!hasOneParamOrDefaultArgs() || getPrimaryTemplate() != nullptr ||
2685  getDescribedFunctionTemplate() != nullptr)
2686  return false;
2687 
2688  const ParmVarDecl *Param = getParamDecl(0);
2689 
2690  // Do we have a reference type?
2691  const auto *ParamRefType = Param->getType()->getAs<ReferenceType>();
2692  if (!ParamRefType)
2693  return false;
2694 
2695  // Is it a reference to our class type?
2696  ASTContext &Context = getASTContext();
2697 
2698  CanQualType PointeeType
2699  = Context.getCanonicalType(ParamRefType->getPointeeType());
2700  CanQualType ClassTy
2701  = Context.getCanonicalType(Context.getTagDeclType(getParent()));
2702  if (PointeeType.getUnqualifiedType() != ClassTy)
2703  return false;
2704 
2705  // FIXME: other qualifiers?
2706 
2707  // We have a copy or move constructor.
2708  TypeQuals = PointeeType.getCVRQualifiers();
2709  return true;
2710 }
2711 
2712 bool CXXConstructorDecl::isConvertingConstructor(bool AllowExplicit) const {
2713  // C++ [class.conv.ctor]p1:
2714  // A constructor declared without the function-specifier explicit
2715  // that can be called with a single parameter specifies a
2716  // conversion from the type of its first parameter to the type of
2717  // its class. Such a constructor is called a converting
2718  // constructor.
2719  if (isExplicit() && !AllowExplicit)
2720  return false;
2721 
2722  // FIXME: This has nothing to do with the definition of converting
2723  // constructor, but is convenient for how we use this function in overload
2724  // resolution.
2725  return getNumParams() == 0
2727  : getMinRequiredArguments() <= 1;
2728 }
2729 
2732  return false;
2733 
2734  const ParmVarDecl *Param = getParamDecl(0);
2735 
2736  ASTContext &Context = getASTContext();
2737  CanQualType ParamType = Context.getCanonicalType(Param->getType());
2738 
2739  // Is it the same as our class type?
2740  CanQualType ClassTy
2741  = Context.getCanonicalType(Context.getTagDeclType(getParent()));
2742  if (ParamType.getUnqualifiedType() != ClassTy)
2743  return false;
2744 
2745  return true;
2746 }
2747 
2748 void CXXDestructorDecl::anchor() {}
2749 
2752  return new (C, ID) CXXDestructorDecl(
2753  C, nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), nullptr,
2754  false, false, ConstexprSpecKind::Unspecified, nullptr);
2755 }
2756 
2758  ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
2759  const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo,
2760  bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind,
2761  Expr *TrailingRequiresClause) {
2762  assert(NameInfo.getName().getNameKind()
2764  "Name must refer to a destructor");
2765  return new (C, RD)
2766  CXXDestructorDecl(C, RD, StartLoc, NameInfo, T, TInfo, isInline,
2767  isImplicitlyDeclared, ConstexprKind,
2768  TrailingRequiresClause);
2769 }
2770 
2772  auto *First = cast<CXXDestructorDecl>(getFirstDecl());
2773  if (OD && !First->OperatorDelete) {
2774  First->OperatorDelete = OD;
2775  First->OperatorDeleteThisArg = ThisArg;
2776  if (auto *L = getASTMutationListener())
2777  L->ResolvedOperatorDelete(First, OD, ThisArg);
2778  }
2779 }
2780 
2781 void CXXConversionDecl::anchor() {}
2782 
2785  return new (C, ID) CXXConversionDecl(
2786  C, nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), nullptr,
2788  SourceLocation(), nullptr);
2789 }
2790 
2792  ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
2793  const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo,
2794  bool isInline, ExplicitSpecifier ES, ConstexprSpecKind ConstexprKind,
2795  SourceLocation EndLocation, Expr *TrailingRequiresClause) {
2796  assert(NameInfo.getName().getNameKind()
2798  "Name must refer to a conversion function");
2799  return new (C, RD)
2800  CXXConversionDecl(C, RD, StartLoc, NameInfo, T, TInfo, isInline, ES,
2801  ConstexprKind, EndLocation, TrailingRequiresClause);
2802 }
2803 
2805  return isImplicit() && getParent()->isLambda() &&
2807 }
2808 
2809 LinkageSpecDecl::LinkageSpecDecl(DeclContext *DC, SourceLocation ExternLoc,
2810  SourceLocation LangLoc, LanguageIDs lang,
2811  bool HasBraces)
2812  : Decl(LinkageSpec, DC, LangLoc), DeclContext(LinkageSpec),
2813  ExternLoc(ExternLoc), RBraceLoc(SourceLocation()) {
2814  setLanguage(lang);
2815  LinkageSpecDeclBits.HasBraces = HasBraces;
2816 }
2817 
2818 void LinkageSpecDecl::anchor() {}
2819 
2821  DeclContext *DC,
2822  SourceLocation ExternLoc,
2823  SourceLocation LangLoc,
2824  LanguageIDs Lang,
2825  bool HasBraces) {
2826  return new (C, DC) LinkageSpecDecl(DC, ExternLoc, LangLoc, Lang, HasBraces);
2827 }
2828 
2830  unsigned ID) {
2831  return new (C, ID) LinkageSpecDecl(nullptr, SourceLocation(),
2832  SourceLocation(), lang_c, false);
2833 }
2834 
2835 void UsingDirectiveDecl::anchor() {}
2836 
2838  SourceLocation L,
2839  SourceLocation NamespaceLoc,
2840  NestedNameSpecifierLoc QualifierLoc,
2841  SourceLocation IdentLoc,
2842  NamedDecl *Used,
2843  DeclContext *CommonAncestor) {
2844  if (auto *NS = dyn_cast_or_null<NamespaceDecl>(Used))
2845  Used = NS->getOriginalNamespace();
2846  return new (C, DC) UsingDirectiveDecl(DC, L, NamespaceLoc, QualifierLoc,
2847  IdentLoc, Used, CommonAncestor);
2848 }
2849 
2851  unsigned ID) {
2852  return new (C, ID) UsingDirectiveDecl(nullptr, SourceLocation(),
2853  SourceLocation(),
2855  SourceLocation(), nullptr, nullptr);
2856 }
2857 
2859  if (auto *NA = dyn_cast_or_null<NamespaceAliasDecl>(NominatedNamespace))
2860  return NA->getNamespace();
2861  return cast_or_null<NamespaceDecl>(NominatedNamespace);
2862 }
2863 
2864 NamespaceDecl::NamespaceDecl(ASTContext &C, DeclContext *DC, bool Inline,
2865  SourceLocation StartLoc, SourceLocation IdLoc,
2866  IdentifierInfo *Id, NamespaceDecl *PrevDecl)
2867  : NamedDecl(Namespace, DC, IdLoc, Id), DeclContext(Namespace),
2868  redeclarable_base(C), LocStart(StartLoc),
2869  AnonOrFirstNamespaceAndInline(nullptr, Inline) {
2870  setPreviousDecl(PrevDecl);
2871 
2872  if (PrevDecl)
2873  AnonOrFirstNamespaceAndInline.setPointer(PrevDecl->getOriginalNamespace());
2874 }
2875 
2877  bool Inline, SourceLocation StartLoc,
2879  NamespaceDecl *PrevDecl) {
2880  return new (C, DC) NamespaceDecl(C, DC, Inline, StartLoc, IdLoc, Id,
2881  PrevDecl);
2882 }
2883 
2885  return new (C, ID) NamespaceDecl(C, nullptr, false, SourceLocation(),
2886  SourceLocation(), nullptr, nullptr);
2887 }
2888 
2890  if (isFirstDecl())
2891  return this;
2892 
2893  return AnonOrFirstNamespaceAndInline.getPointer();
2894 }
2895 
2897  if (isFirstDecl())
2898  return this;
2899 
2900  return AnonOrFirstNamespaceAndInline.getPointer();
2901 }
2902 
2904 
2905 NamespaceDecl *NamespaceDecl::getNextRedeclarationImpl() {
2906  return getNextRedeclaration();
2907 }
2908 
2909 NamespaceDecl *NamespaceDecl::getPreviousDeclImpl() {
2910  return getPreviousDecl();
2911 }
2912 
2913 NamespaceDecl *NamespaceDecl::getMostRecentDeclImpl() {
2914  return getMostRecentDecl();
2915 }
2916 
2917 void NamespaceAliasDecl::anchor() {}
2918 
2919 NamespaceAliasDecl *NamespaceAliasDecl::getNextRedeclarationImpl() {
2920  return getNextRedeclaration();
2921 }
2922 
2923 NamespaceAliasDecl *NamespaceAliasDecl::getPreviousDeclImpl() {
2924  return getPreviousDecl();
2925 }
2926 
2927 NamespaceAliasDecl *NamespaceAliasDecl::getMostRecentDeclImpl() {
2928  return getMostRecentDecl();
2929 }
2930 
2932  SourceLocation UsingLoc,
2933  SourceLocation AliasLoc,
2934  IdentifierInfo *Alias,
2935  NestedNameSpecifierLoc QualifierLoc,
2936  SourceLocation IdentLoc,
2937  NamedDecl *Namespace) {
2938  // FIXME: Preserve the aliased namespace as written.
2939  if (auto *NS = dyn_cast_or_null<NamespaceDecl>(Namespace))
2940  Namespace = NS->getOriginalNamespace();
2941  return new (C, DC) NamespaceAliasDecl(C, DC, UsingLoc, AliasLoc, Alias,
2942  QualifierLoc, IdentLoc, Namespace);
2943 }
2944 
2947  return new (C, ID) NamespaceAliasDecl(C, nullptr, SourceLocation(),
2948  SourceLocation(), nullptr,
2950  SourceLocation(), nullptr);
2951 }
2952 
2953 void LifetimeExtendedTemporaryDecl::anchor() {}
2954 
2955 /// Retrieve the storage duration for the materialized temporary.
2957  const ValueDecl *ExtendingDecl = getExtendingDecl();
2958  if (!ExtendingDecl)
2959  return SD_FullExpression;
2960  // FIXME: This is not necessarily correct for a temporary materialized
2961  // within a default initializer.
2962  if (isa<FieldDecl>(ExtendingDecl))
2963  return SD_Automatic;
2964  // FIXME: This only works because storage class specifiers are not allowed
2965  // on decomposition declarations.
2966  if (isa<BindingDecl>(ExtendingDecl))
2967  return ExtendingDecl->getDeclContext()->isFunctionOrMethod() ? SD_Automatic
2968  : SD_Static;
2969  return cast<VarDecl>(ExtendingDecl)->getStorageDuration();
2970 }
2971 
2973  assert(getStorageDuration() == SD_Static &&
2974  "don't need to cache the computed value for this temporary");
2975  if (MayCreate && !Value) {
2976  Value = (new (getASTContext()) APValue);
2978  }
2979  assert(Value && "may not be null");
2980  return Value;
2981 }
2982 
2983 void UsingShadowDecl::anchor() {}
2984 
2986  SourceLocation Loc, DeclarationName Name,
2987  BaseUsingDecl *Introducer, NamedDecl *Target)
2988  : NamedDecl(K, DC, Loc, Name), redeclarable_base(C),
2989  UsingOrNextShadow(Introducer) {
2990  if (Target)
2992  setImplicit();
2993 }
2994 
2996  : NamedDecl(K, nullptr, SourceLocation(), DeclarationName()),
2997  redeclarable_base(C) {}
2998 
3001  return new (C, ID) UsingShadowDecl(UsingShadow, C, EmptyShell());
3002 }
3003 
3005  const UsingShadowDecl *Shadow = this;
3006  while (const auto *NextShadow =
3007  dyn_cast<UsingShadowDecl>(Shadow->UsingOrNextShadow))
3008  Shadow = NextShadow;
3009  return cast<BaseUsingDecl>(Shadow->UsingOrNextShadow);
3010 }
3011 
3012 void ConstructorUsingShadowDecl::anchor() {}
3013 
3016  SourceLocation Loc, UsingDecl *Using,
3017  NamedDecl *Target, bool IsVirtual) {
3018  return new (C, DC) ConstructorUsingShadowDecl(C, DC, Loc, Using, Target,
3019  IsVirtual);
3020 }
3021 
3024  return new (C, ID) ConstructorUsingShadowDecl(C, EmptyShell());
3025 }
3026 
3029 }
3030 
3031 void BaseUsingDecl::anchor() {}
3032 
3034  assert(std::find(shadow_begin(), shadow_end(), S) == shadow_end() &&
3035  "declaration already in set");
3036  assert(S->getIntroducer() == this);
3037 
3038  if (FirstUsingShadow.getPointer())
3039  S->UsingOrNextShadow = FirstUsingShadow.getPointer();
3040  FirstUsingShadow.setPointer(S);
3041 }
3042 
3044  assert(std::find(shadow_begin(), shadow_end(), S) != shadow_end() &&
3045  "declaration not in set");
3046  assert(S->getIntroducer() == this);
3047 
3048  // Remove S from the shadow decl chain. This is O(n) but hopefully rare.
3049 
3050  if (FirstUsingShadow.getPointer() == S) {
3051  FirstUsingShadow.setPointer(
3052  dyn_cast<UsingShadowDecl>(S->UsingOrNextShadow));
3053  S->UsingOrNextShadow = this;
3054  return;
3055  }
3056 
3057  UsingShadowDecl *Prev = FirstUsingShadow.getPointer();
3058  while (Prev->UsingOrNextShadow != S)
3059  Prev = cast<UsingShadowDecl>(Prev->UsingOrNextShadow);
3060  Prev->UsingOrNextShadow = S->UsingOrNextShadow;
3061  S->UsingOrNextShadow = this;
3062 }
3063 
3064 void UsingDecl::anchor() {}
3065 
3067  NestedNameSpecifierLoc QualifierLoc,
3068  const DeclarationNameInfo &NameInfo,
3069  bool HasTypename) {
3070  return new (C, DC) UsingDecl(DC, UL, QualifierLoc, NameInfo, HasTypename);
3071 }
3072 
3074  return new (C, ID) UsingDecl(nullptr, SourceLocation(),
3076  false);
3077 }
3078 
3081  ? getQualifierLoc().getBeginLoc() : UsingLocation;
3082  return SourceRange(Begin, getNameInfo().getEndLoc());
3083 }
3084 
3085 void UsingPackDecl::anchor() {}
3086 
3088  NamedDecl *InstantiatedFrom,
3089  ArrayRef<NamedDecl *> UsingDecls) {
3090  size_t Extra = additionalSizeToAlloc<NamedDecl *>(UsingDecls.size());
3091  return new (C, DC, Extra) UsingPackDecl(DC, InstantiatedFrom, UsingDecls);
3092 }
3093 
3095  unsigned NumExpansions) {
3096  size_t Extra = additionalSizeToAlloc<NamedDecl *>(NumExpansions);
3097  auto *Result = new (C, ID, Extra) UsingPackDecl(nullptr, nullptr, None);
3098  Result->NumExpansions = NumExpansions;
3099  auto *Trail = Result->getTrailingObjects<NamedDecl *>();
3100  for (unsigned I = 0; I != NumExpansions; ++I)
3101  new (Trail + I) NamedDecl*(nullptr);
3102  return Result;
3103 }
3104 
3105 void UnresolvedUsingValueDecl::anchor() {}
3106 
3109  SourceLocation UsingLoc,
3110  NestedNameSpecifierLoc QualifierLoc,
3111  const DeclarationNameInfo &NameInfo,
3112  SourceLocation EllipsisLoc) {
3113  return new (C, DC) UnresolvedUsingValueDecl(DC, C.DependentTy, UsingLoc,
3114  QualifierLoc, NameInfo,
3115  EllipsisLoc);
3116 }
3117 
3120  return new (C, ID) UnresolvedUsingValueDecl(nullptr, QualType(),
3121  SourceLocation(),
3124  SourceLocation());
3125 }
3126 
3129  ? getQualifierLoc().getBeginLoc() : UsingLocation;
3130  return SourceRange(Begin, getNameInfo().getEndLoc());
3131 }
3132 
3133 void UnresolvedUsingTypenameDecl::anchor() {}
3134 
3137  SourceLocation UsingLoc,
3138  SourceLocation TypenameLoc,
3139  NestedNameSpecifierLoc QualifierLoc,
3140  SourceLocation TargetNameLoc,
3141  DeclarationName TargetName,
3142  SourceLocation EllipsisLoc) {
3143  return new (C, DC) UnresolvedUsingTypenameDecl(
3144  DC, UsingLoc, TypenameLoc, QualifierLoc, TargetNameLoc,
3145  TargetName.getAsIdentifierInfo(), EllipsisLoc);
3146 }
3147 
3150  return new (C, ID) UnresolvedUsingTypenameDecl(
3152  SourceLocation(), nullptr, SourceLocation());
3153 }
3154 
3157  SourceLocation Loc, DeclarationName Name) {
3158  return new (Ctx, DC) UnresolvedUsingIfExistsDecl(DC, Loc, Name);
3159 }
3160 
3163  return new (Ctx, ID)
3165 }
3166 
3167 UnresolvedUsingIfExistsDecl::UnresolvedUsingIfExistsDecl(DeclContext *DC,
3168  SourceLocation Loc,
3169  DeclarationName Name)
3170  : NamedDecl(Decl::UnresolvedUsingIfExists, DC, Loc, Name) {}
3171 
3172 void UnresolvedUsingIfExistsDecl::anchor() {}
3173 
3174 void StaticAssertDecl::anchor() {}
3175 
3177  SourceLocation StaticAssertLoc,
3178  Expr *AssertExpr,
3179  StringLiteral *Message,
3180  SourceLocation RParenLoc,
3181  bool Failed) {
3182  return new (C, DC) StaticAssertDecl(DC, StaticAssertLoc, AssertExpr, Message,
3183  RParenLoc, Failed);
3184 }
3185 
3187  unsigned ID) {
3188  return new (C, ID) StaticAssertDecl(nullptr, SourceLocation(), nullptr,
3189  nullptr, SourceLocation(), false);
3190 }
3191 
3192 void BindingDecl::anchor() {}
3193 
3195  SourceLocation IdLoc, IdentifierInfo *Id) {
3196  return new (C, DC) BindingDecl(DC, IdLoc, Id);
3197 }
3198 
3200  return new (C, ID) BindingDecl(nullptr, SourceLocation(), nullptr);
3201 }
3202 
3204  Expr *B = getBinding();
3205  if (!B)
3206  return nullptr;
3207  auto *DRE = dyn_cast<DeclRefExpr>(B->IgnoreImplicit());
3208  if (!DRE)
3209  return nullptr;
3210 
3211  auto *VD = cast<VarDecl>(DRE->getDecl());
3212  assert(VD->isImplicit() && "holding var for binding decl not implicit");
3213  return VD;
3214 }
3215 
3216 void DecompositionDecl::anchor() {}
3217 
3219  SourceLocation StartLoc,
3220  SourceLocation LSquareLoc,
3221  QualType T, TypeSourceInfo *TInfo,
3222  StorageClass SC,
3224  size_t Extra = additionalSizeToAlloc<BindingDecl *>(Bindings.size());
3225  return new (C, DC, Extra)
3226  DecompositionDecl(C, DC, StartLoc, LSquareLoc, T, TInfo, SC, Bindings);
3227 }
3228 
3230  unsigned ID,
3231  unsigned NumBindings) {
3232  size_t Extra = additionalSizeToAlloc<BindingDecl *>(NumBindings);
3233  auto *Result = new (C, ID, Extra)
3235  QualType(), nullptr, StorageClass(), None);
3236  // Set up and clean out the bindings array.
3237  Result->NumBindings = NumBindings;
3238  auto *Trail = Result->getTrailingObjects<BindingDecl *>();
3239  for (unsigned I = 0; I != NumBindings; ++I)
3240  new (Trail + I) BindingDecl*(nullptr);
3241  return Result;
3242 }
3243 
3244 void DecompositionDecl::printName(llvm::raw_ostream &os) const {
3245  os << '[';
3246  bool Comma = false;
3247  for (const auto *B : bindings()) {
3248  if (Comma)
3249  os << ", ";
3250  B->printName(os);
3251  Comma = true;
3252  }
3253  os << ']';
3254 }
3255 
3256 void MSPropertyDecl::anchor() {}
3257 
3260  QualType T, TypeSourceInfo *TInfo,
3261  SourceLocation StartL,
3262  IdentifierInfo *Getter,
3263  IdentifierInfo *Setter) {
3264  return new (C, DC) MSPropertyDecl(DC, L, N, T, TInfo, StartL, Getter, Setter);
3265 }
3266 
3268  unsigned ID) {
3269  return new (C, ID) MSPropertyDecl(nullptr, SourceLocation(),
3270  DeclarationName(), QualType(), nullptr,
3271  SourceLocation(), nullptr, nullptr);
3272 }
3273 
3274 void MSGuidDecl::anchor() {}
3275 
3276 MSGuidDecl::MSGuidDecl(DeclContext *DC, QualType T, Parts P)
3277  : ValueDecl(Decl::MSGuid, DC, SourceLocation(), DeclarationName(), T),
3278  PartVal(P), APVal() {}
3279 
3280 MSGuidDecl *MSGuidDecl::Create(const ASTContext &C, QualType T, Parts P) {
3281  DeclContext *DC = C.getTranslationUnitDecl();
3282  return new (C, DC) MSGuidDecl(DC, T, P);
3283 }
3284 
3285 MSGuidDecl *MSGuidDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
3286  return new (C, ID) MSGuidDecl(nullptr, QualType(), Parts());
3287 }
3288 
3289 void MSGuidDecl::printName(llvm::raw_ostream &OS) const {
3290  OS << llvm::format("GUID{%08" PRIx32 "-%04" PRIx16 "-%04" PRIx16 "-",
3291  PartVal.Part1, PartVal.Part2, PartVal.Part3);
3292  unsigned I = 0;
3293  for (uint8_t Byte : PartVal.Part4And5) {
3294  OS << llvm::format("%02" PRIx8, Byte);
3295  if (++I == 2)
3296  OS << '-';
3297  }
3298  OS << '}';
3299 }
3300 
3301 /// Determine if T is a valid 'struct _GUID' of the shape that we expect.
3302 static bool isValidStructGUID(ASTContext &Ctx, QualType T) {
3303  // FIXME: We only need to check this once, not once each time we compute a
3304  // GUID APValue.
3305  using MatcherRef = llvm::function_ref<bool(QualType)>;
3306 
3307  auto IsInt = [&Ctx](unsigned N) {
3308  return [&Ctx, N](QualType T) {
3309  return T->isUnsignedIntegerOrEnumerationType() &&
3310  Ctx.getIntWidth(T) == N;
3311  };
3312  };
3313 
3314  auto IsArray = [&Ctx](MatcherRef Elem, unsigned N) {
3315  return [&Ctx, Elem, N](QualType T) {
3316  const ConstantArrayType *CAT = Ctx.getAsConstantArrayType(T);
3317  return CAT && CAT->getSize() == N && Elem(CAT->getElementType());
3318  };
3319  };
3320 
3321  auto IsStruct = [](std::initializer_list<MatcherRef> Fields) {
3322  return [Fields](QualType T) {
3323  const RecordDecl *RD = T->getAsRecordDecl();
3324  if (!RD || RD->isUnion())
3325  return false;
3326  RD = RD->getDefinition();
3327  if (!RD)
3328  return false;
3329  if (auto *CXXRD = dyn_cast<CXXRecordDecl>(RD))
3330  if (CXXRD->getNumBases())
3331  return false;
3332  auto MatcherIt = Fields.begin();
3333  for (const FieldDecl *FD : RD->fields()) {
3334  if (FD->isUnnamedBitfield()) continue;
3335  if (FD->isBitField() || MatcherIt == Fields.end() ||
3336  !(*MatcherIt)(FD->getType()))
3337  return false;
3338  ++MatcherIt;
3339  }
3340  return MatcherIt == Fields.end();
3341  };
3342  };
3343 
3344  // We expect an {i32, i16, i16, [8 x i8]}.
3345  return IsStruct({IsInt(32), IsInt(16), IsInt(16), IsArray(IsInt(8), 8)})(T);
3346 }
3347 
3349  if (APVal.isAbsent() && isValidStructGUID(getASTContext(), getType())) {
3350  using llvm::APInt;
3351  using llvm::APSInt;
3352  APVal = APValue(APValue::UninitStruct(), 0, 4);
3353  APVal.getStructField(0) = APValue(APSInt(APInt(32, PartVal.Part1), true));
3354  APVal.getStructField(1) = APValue(APSInt(APInt(16, PartVal.Part2), true));
3355  APVal.getStructField(2) = APValue(APSInt(APInt(16, PartVal.Part3), true));
3356  APValue &Arr = APVal.getStructField(3) =
3357  APValue(APValue::UninitArray(), 8, 8);
3358  for (unsigned I = 0; I != 8; ++I) {
3359  Arr.getArrayInitializedElt(I) =
3360  APValue(APSInt(APInt(8, PartVal.Part4And5[I]), true));
3361  }
3362  // Register this APValue to be destroyed if necessary. (Note that the
3363  // MSGuidDecl destructor is never run.)
3364  getASTContext().addDestruction(&APVal);
3365  }
3366 
3367  return APVal;
3368 }
3369 
3370 static const char *getAccessName(AccessSpecifier AS) {
3371  switch (AS) {
3372  case AS_none:
3373  llvm_unreachable("Invalid access specifier!");
3374  case AS_public:
3375  return "public";
3376  case AS_private:
3377  return "private";
3378  case AS_protected:
3379  return "protected";
3380  }
3381  llvm_unreachable("Invalid access specifier!");
3382 }
3383 
3385  AccessSpecifier AS) {
3386  return DB << getAccessName(AS);
3387 }
clang::DecompositionDecl::printName
void printName(raw_ostream &os) const override
Pretty-print the unqualified name of this declaration.
Definition: DeclCXX.cpp:3244
clang::ExplicitSpecifier
Store information needed for an explicit specifier.
Definition: DeclCXX.h:1795
clang::CXXMethodDecl::getThisType
QualType getThisType() const
Return the type of the this pointer.
Definition: DeclCXX.cpp:2470
clang::CXXRecordDecl::hasSimpleCopyConstructor
bool hasSimpleCopyConstructor() const
true if we know for sure that this class has a single, accessible, unambiguous copy constructor that ...
Definition: DeclCXX.h:704
clang::prec::Comma
@ Comma
Definition: OperatorPrecedence.h:28
clang::CXXCtorInitializer::getMemberLocation
SourceLocation getMemberLocation() const
Definition: DeclCXX.h:2330
clang::FunctionDecl::doesThisDeclarationHaveABody
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
Definition: Decl.h:2132
clang::CXXCtorInitializer::getAnyMember
FieldDecl * getAnyMember() const
Definition: DeclCXX.h:2316
clang::Type::isRecordType
bool isRecordType() const
Definition: Type.h:6765
clang::NamespaceDecl::Create
static NamespaceDecl * Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl)
Definition: DeclCXX.cpp:2876
clang::RequiresExprBodyDecl::Create
static RequiresExprBodyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc)
Definition: DeclCXX.cpp:2093
clang::Decl::getASTContext
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:414
clang::AccessSpecDecl
Represents an access specifier followed by colon ':'.
Definition: DeclCXX.h:87
clang::UnresolvedSetIterator::getDecl
NamedDecl * getDecl() const
Definition: UnresolvedSet.h:50
clang::QualType::getCVRQualifiers
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
Definition: Type.h:6460
clang::RecordDecl::field_begin
field_iterator field_begin() const
Definition: Decl.cpp:4571
clang::CXXRecordDecl::getDeviceLambdaManglingNumber
unsigned getDeviceLambdaManglingNumber() const
Retrieve the device side mangling number.
Definition: DeclCXX.cpp:1602
clang::CXXMethodDecl::CXXMethodDecl
CXXMethodDecl(Kind DK, ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInline, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, Expr *TrailingRequiresClause=nullptr)
Definition: DeclCXX.h:1952
clang::CXXMethodDecl::getThisObjectType
QualType getThisObjectType() const
Return the type of the object pointed by this.
Definition: DeclCXX.cpp:2481
clang::CXXConstructorDecl
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2402
clang::NestedNameSpecifier::getAsRecordDecl
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
Definition: NestedNameSpecifier.cpp:185
clang::CXXMethodDecl::isLambdaStaticInvoker
bool isLambdaStaticInvoker() const
Determine whether this is a lambda closure type's static member function that is used for the result ...
Definition: DeclCXX.cpp:2500
clang::ASTContext::getTypeDeclType
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:1460
clang::CXXMethodDecl::isCopyAssignmentOperator
bool isCopyAssignmentOperator() const
Determine whether this is a copy-assignment operator, regardless of whether it was declared implicitl...
Definition: DeclCXX.cpp:2378
clang::DeclContext::getParentASTContext
ASTContext & getParentASTContext() const
Definition: DeclBase.h:1889
clang::CXXConversionDecl::isLambdaToBlockPointerConversion
bool isLambdaToBlockPointerConversion() const
Determine whether this conversion function is a conversion from a lambda closure type to a block poin...
Definition: DeclCXX.cpp:2804
clang::FunctionDecl::getNumParams
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
Definition: Decl.cpp:3346
clang::Type::isBlockPointerType
bool isBlockPointerType() const
Definition: Type.h:6683
clang::CXXRecordDecl::getDependentLambdaCallOperator
FunctionTemplateDecl * getDependentLambdaCallOperator() const
Retrieve the dependent lambda call operator of the closure type if this is a templated closure type.
Definition: DeclCXX.cpp:1496
clang::RecordDecl::setArgPassingRestrictions
void setArgPassingRestrictions(ArgPassingKind Kind)
Definition: Decl.h:3978
Specifiers.h
clang::CXXRecordDecl::hasAnyDependentBases
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation.
Definition: DeclCXX.cpp:561
clang::CXXRecordDecl::isTriviallyCopyable
bool isTriviallyCopyable() const
Determine whether this class is considered trivially copyable per (C++11 [class]p6).
Definition: DeclCXX.cpp:568
clang::interp::APInt
llvm::APInt APInt
Definition: Integral.h:27
clang::UsingDirectiveDecl::Create
static UsingDirectiveDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespaceLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor)
Definition: DeclCXX.cpp:2837
LT
ASTImporterLookupTable & LT
Definition: ASTImporterLookupTable.cpp:23
clang::CXXRecordDecl::hasSimpleDestructor
bool hasSimpleDestructor() const
true if we know for sure that this class has an accessible destructor that is not deleted.
Definition: DeclCXX.h:732
clang::DeclContext::specific_decl_iterator
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
Definition: DeclBase.h:2129
clang::CXXCtorInitializer::getBaseClass
const Type * getBaseClass() const
If this is a base class initializer, returns the type of the base class.
Definition: DeclCXX.cpp:2551
clang::CXXRecordDecl::isEffectivelyFinal
bool isEffectivelyFinal() const
Determine whether it's impossible for a class to be derived from this class.
Definition: DeclCXX.cpp:2034
clang::UsingPackDecl::CreateDeserialized
static UsingPackDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumExpansions)
Definition: DeclCXX.cpp:3094
clang::CXXMethodDecl::isStatic
bool isStatic() const
Definition: DeclCXX.cpp:2105
clang::CXXFinalOverriderMap
A mapping from each virtual member function to its set of final overriders.
Definition: CXXInheritance.h:357
clang::MemberSpecializationInfo
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:619
clang::UnresolvedSetImpl
A set of unresolved declarations.
Definition: UnresolvedSet.h:61
clang::ASTUnresolvedSet::size
unsigned size() const
Definition: ASTUnresolvedSet.h:77
clang::Decl::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclBase.h:426
clang::Type::isObjCRetainableType
bool isObjCRetainableType() const
Definition: Type.cpp:4271
clang::LinkageSpecDecl
Represents a linkage specification.
Definition: DeclCXX.h:2796
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:212
clang::DecompositionDecl::bindings
ArrayRef< BindingDecl * > bindings() const
Definition: DeclCXX.h:3990
clang::CXXRecordDecl::isCLike
bool isCLike() const
True if this class is C-like, without C++-specific features, e.g.
Definition: DeclCXX.cpp:1460
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1347
clang::ASTUnresolvedSet::erase
void erase(unsigned I)
Definition: ASTUnresolvedSet.h:72
clang::BindingDecl::Create
static BindingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id)
Definition: DeclCXX.cpp:3194
clang::StaticAssertDecl::Create
static StaticAssertDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *Message, SourceLocation RParenLoc, bool Failed)
Definition: DeclCXX.cpp:3176
clang::ExplicitSpecKind::Unresolved
@ Unresolved
clang::LambdaCapture
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:25
clang::CXXConversionDecl
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2732
clang::Decl::hasAttr
bool hasAttr() const
Definition: DeclBase.h:547
clang::Redeclarable< UsingShadowDecl >
clang::CXXRecordDecl::getMemberSpecializationInfo
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization,...
Definition: DeclCXX.cpp:1786
clang::NamespaceAliasDecl
Represents a C++ namespace alias.
Definition: DeclCXX.h:2985
clang::LifetimeExtendedTemporaryDecl::getOrCreateValue
APValue * getOrCreateValue(bool MayCreate) const
Get the storage for the constant value of a materialized temporary of static storage duration.
Definition: DeclCXX.cpp:2972
clang::DecompositionDecl::Create
static DecompositionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation LSquareLoc, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< BindingDecl * > Bindings)
Definition: DeclCXX.cpp:3218
clang::QualType::isConstQualified
bool isConstQualified() const
Determine whether this type is const-qualified.
Definition: Type.h:6486
clang::CXXRecordDecl::hasNonTrivialMoveConstructor
bool hasNonTrivialMoveConstructor() const
Determine whether this class has a non-trivial move constructor (C++11 [class.copy]p12)
Definition: DeclCXX.h:1258
clang::ConstantArrayType
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:2923
clang::Decl::getAsFunction
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
Definition: DeclBase.cpp:218
Used
@ Used
Definition: ObjCUnusedIVarsChecker.cpp:29
clang::CXXRecordDecl::hasNonTrivialMoveAssignment
bool hasNonTrivialMoveAssignment() const
Determine whether this class has a non-trivial move assignment operator (C++11 [class....
Definition: DeclCXX.h:1293
clang::FunctionDecl::isDeleted
bool isDeleted() const
Whether this function has been deleted.
Definition: Decl.h:2307
clang::UsingDecl::getQualifier
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Definition: DeclCXX.h:3415
clang::Qualifiers::OCL_Weak
@ OCL_Weak
Reading or writing from this object requires a barrier call.
Definition: Type.h:176
clang::UsingDirectiveDecl
Represents C++ using-directive.
Definition: DeclCXX.h:2881
clang::ConstantArrayType::getSize
const llvm::APInt & getSize() const
Definition: Type.h:2946
clang::CXXDestructorDecl::setOperatorDelete
void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg)
Definition: DeclCXX.cpp:2771
clang::CXXRecordDecl::isAnyDestructorNoReturn
bool isAnyDestructorNoReturn() const
Returns true if the class destructor, or any implicitly invoked destructors are marked noreturn.
Definition: DeclCXX.cpp:1891
clang::Decl::getASTMutationListener
ASTMutationListener * getASTMutationListener() const
Definition: DeclBase.cpp:424
clang::BindingDecl
A binding in a decomposition declaration.
Definition: DeclCXX.h:3899
clang::Expr::IgnoreImplicit
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Definition: Expr.cpp:2908
clang::DeclarationName::CXXConstructorName
@ CXXConstructorName
Definition: DeclarationName.h:206
clang::CXXRecordDecl::removeConversion
void removeConversion(const NamedDecl *Old)
Removes a conversion function from this class.
Definition: DeclCXX.cpp:1754
llvm::SmallVector
Definition: LLVM.h:38
clang::UsingDirectiveDecl::CreateDeserialized
static UsingDirectiveDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2850
clang::IdentifierTable::get
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
Definition: IdentifierTable.h:529
clang::RecordDecl::field_empty
bool field_empty() const
Definition: Decl.h:4048
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:89
clang::CXXRecordDecl::conversion_begin
conversion_iterator conversion_begin() const
Definition: DeclCXX.h:1076
clang::QualType::getQualifiers
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Definition: Type.h:6454
clang::ASTContext::getIntWidth
unsigned getIntWidth(QualType T) const
Definition: ASTContext.cpp:10090
clang::TTK_Struct
@ TTK_Struct
The "struct" keyword.
Definition: Type.h:5312
clang::FunctionDecl::hasOneParamOrDefaultArgs
bool hasOneParamOrDefaultArgs() const
Determine whether this function has a single parameter, or multiple parameters where all but the firs...
Definition: Decl.cpp:3385
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:223
clang::AS_private
@ AS_private
Definition: Specifiers.h:101
clang::CXXConstructorDecl::isExplicit
bool isExplicit() const
Return true if the declartion is already resolved to be explicit.
Definition: DeclCXX.h:2483
clang::NamedDecl::getUnderlyingDecl
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Definition: Decl.h:433
clang::MultiVersionKind::Target
@ Target
CXXInheritance.h
clang::ASTContext::DeclarationNames
DeclarationNameTable DeclarationNames
Definition: ASTContext.h:616
clang::RecordDecl::setHasVolatileMember
void setHasVolatileMember(bool val)
Definition: Decl.h:3906
clang::CXXConstructorDecl::isDelegatingConstructor
bool isDelegatingConstructor() const
Determine whether this constructor is a delegating constructor.
Definition: DeclCXX.h:2556
clang::TSK_Undeclared
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
Definition: Specifiers.h:166
clang::CXXRecordDecl::getDefinition
CXXRecordDecl * getDefinition() const
Definition: DeclCXX.h:535
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:668
Attr.h
clang::CXXRecordDecl::hasNonTrivialCopyAssignment
bool hasNonTrivialCopyAssignment() const
Determine whether this class has a non-trivial copy assignment operator (C++ [class....
Definition: DeclCXX.h:1279
recursivelyOverrides
static bool recursivelyOverrides(const CXXMethodDecl *DerivedMD, const CXXMethodDecl *BaseMD)
Definition: DeclCXX.cpp:2115
clang::FunctionDecl::getParamDecl
const ParmVarDecl * getParamDecl(unsigned i) const
Definition: Decl.h:2475
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:53
isValidStructGUID
static bool isValidStructGUID(ASTContext &Ctx, QualType T)
Determine if T is a valid 'struct _GUID' of the shape that we expect.
Definition: DeclCXX.cpp:3302
clang::CXXRecordDecl::setCaptures
void setCaptures(ASTContext &Context, ArrayRef< LambdaCapture > Captures)
Set the captures for this lambda closure type.
Definition: DeclCXX.cpp:1422
clang::cast
U cast(CodeGen::Address addr)
Definition: Address.h:108
clang::FunctionDecl::willHaveBody
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
Definition: Decl.h:2400
clang::UnresolvedSetIterator
The iterator over UnresolvedSets.
Definition: UnresolvedSet.h:32
clang::CXXRecordDecl::MergeAccess
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
Definition: DeclCXX.h:1662
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2796
clang::ASTContext::getBaseElementType
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
Definition: ASTContext.cpp:6196
clang::FieldDecl::getInClassInitializer
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set.
Definition: Decl.h:2943
clang::UnresolvedUsingValueDecl::isAccessDeclaration
bool isAccessDeclaration() const
Return true if it is a C++03 access declaration (no 'using').
Definition: DeclCXX.h:3691
isDeclContextInNamespace
static bool isDeclContextInNamespace(const DeclContext *DC)
Definition: DeclCXX.cpp:1914
clang::index::SymbolRole::Definition
@ Definition
clang::ParmVarDecl
Represents a parameter to a function.
Definition: Decl.h:1634
clang::NamespaceAliasDecl::CreateDeserialized
static NamespaceAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2946
clang::Redeclarable< FunctionDecl >::getFirstDecl
FunctionDecl * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Definition: Redeclarable.h:215
DeclCXX.h
clang::CXXMethodDecl::getCanonicalDecl
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:2034
clang::MSPropertyDecl::Create
static MSPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL, IdentifierInfo *Getter, IdentifierInfo *Setter)
Definition: DeclCXX.cpp:3258
clang::UnresolvedUsingValueDecl::getNameInfo
DeclarationNameInfo getNameInfo() const
Definition: DeclCXX.h:3702
clang::CXXCtorInitializer::isBaseInitializer
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
Definition: DeclCXX.h:2242
clang::UsingShadowDecl
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3186
clang::DeclarationNameTable::getCXXDestructorName
DeclarationName getCXXDestructorName(CanQualType Ty)
Returns the name of a C++ destructor for the given Type.
Definition: DeclarationName.cpp:326
clang::FunctionDecl::getPrimaryTemplate
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
Definition: Decl.cpp:3778
clang::index::SymbolKind::Using
@ Using
clang::CXXRecordDecl::Create
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:131
clang::UnresolvedUsingValueDecl::CreateDeserialized
static UnresolvedUsingValueDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:3119
clang::RecordDecl::getDefinition
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
Definition: Decl.h:4025
llvm::SmallPtrSet
Definition: ASTContext.h:82
hasRepeatedBaseClass
static bool hasRepeatedBaseClass(const CXXRecordDecl *StartRD)
Determine whether a class has a repeated base class.
Definition: DeclCXX.cpp:175
clang::CXXRecordDecl::isGenericLambda
bool isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e.
Definition: DeclCXX.cpp:1470
clang::FunctionDecl::isUserProvided
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration.
Definition: Decl.h:2199
clang::QualType::isVolatileQualified
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
Definition: Type.h:6497
clang::CXXRecordDecl::hasUserDeclaredConstructor
bool hasUserDeclaredConstructor() const
Determine whether this class has any user-declared constructors.
Definition: DeclCXX.h:761
clang::Decl::getLangOpts
const LangOptions & getLangOpts() const LLVM_READONLY
Helper to get the language options from the ASTContext.
Definition: DeclBase.cpp:420
clang::CPlusPlus14
@ CPlusPlus14
Definition: LangStandard.h:50
clang::tooling::X
static ToolExecutorPluginRegistry::Add< AllTUsToolExecutorPlugin > X("all-TUs", "Runs FrontendActions on all TUs in the compilation database. " "Tool results are stored in memory.")
clang::CXXCtorInitializer::isAnyMemberInitializer
bool isAnyMemberInitializer() const
Definition: DeclCXX.h:2250
clang::ClassTemplatePartialSpecializationDecl
Definition: DeclTemplate.h:2071
clang::UsingPackDecl
Represents a pack of using declarations that a single using-declarator pack-expanded into.
Definition: DeclCXX.h:3584
clang::RecordDecl::APK_CanNeverPassInRegs
@ APK_CanNeverPassInRegs
The argument of this type cannot be passed directly in registers.
Definition: Decl.h:3845
ASTLambda.h
clang::DeclarationName::getAsIdentifierInfo
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
Definition: DeclarationName.h:410
clang::MSGuidDeclParts::Part1
uint32_t Part1
{01234567-...
Definition: DeclCXX.h:4058
clang::Type::isRValueReferenceType
bool isRValueReferenceType() const
Definition: Type.h:6695
clang::CXXMethodDecl::Create
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInline, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, Expr *TrailingRequiresClause=nullptr)
Definition: DeclCXX.cpp:2195
clang::FunctionType
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3548
clang::SD_Automatic
@ SD_Automatic
Automatic storage duration (most local variables).
Definition: Specifiers.h:296
clang::TTK_Interface
@ TTK_Interface
The "__interface" keyword.
Definition: Type.h:5315
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:145
clang::CXXRecordDecl::bases_end
base_class_iterator bases_end()
Definition: DeclCXX.h:598
clang::index::SymbolKind::Constructor
@ Constructor
clang::BindingDecl::getHoldingVar
VarDecl * getHoldingVar() const
Get the variable (if any) that holds the value of evaluating the binding.
Definition: DeclCXX.cpp:3203
clang::CXXRecordDecl::lambdaIsDefaultConstructibleAndAssignable
bool lambdaIsDefaultConstructibleAndAssignable() const
Determine whether this lambda should have an implicit default constructor and copy and move assignmen...
Definition: DeclCXX.cpp:671
clang::CXXRecordDecl::getLambdaContextDecl
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
Definition: DeclCXX.cpp:1590
clang::CXXMethodDecl::getCorrespondingMethodInClass
CXXMethodDecl * getCorrespondingMethodInClass(const CXXRecordDecl *RD, bool MayBeBase=false)
Find the method in RD that corresponds to this one.
Definition: DeclCXX.cpp:2158
clang::CXXRecordDecl::getLambdaCallOperator
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
Definition: DeclCXX.cpp:1501
clang::CXXMethodDecl::isMoveAssignmentOperator
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
Definition: DeclCXX.cpp:2399
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1485
getLambdaStaticInvokers
static DeclContext::lookup_result getLambdaStaticInvokers(const CXXRecordDecl &RD)
Definition: DeclCXX.cpp:1520
clang::CXXCtorInitializer::getSourceLocation
SourceLocation getSourceLocation() const
Determine the source location of the initializer.
Definition: DeclCXX.cpp:2558
clang::StorageDuration
StorageDuration
The storage duration for an object (per C++ [basic.stc]).
Definition: Specifiers.h:294
clang::AS_none
@ AS_none
Definition: Specifiers.h:102
clang::NamespaceDecl::getOriginalNamespace
NamespaceDecl * getOriginalNamespace()
Get the original (first) namespace declaration.
Definition: DeclCXX.cpp:2889
clang::LinkageSpecDecl::lang_c
@ lang_c
Definition: DeclCXX.h:2805
clang::RecordDecl::setHasObjectMember
void setHasObjectMember(bool val)
Definition: Decl.h:3902
clang::CXXRecordDecl::getDescribedClassTemplate
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
Definition: DeclCXX.cpp:1800
clang::CXXConstructorDecl::CreateDeserialized
static CXXConstructorDecl * CreateDeserialized(ASTContext &C, unsigned ID, uint64_t AllocKind)
Definition: DeclCXX.cpp:2602
APSInt
llvm::APSInt APSInt
Definition: ByteCodeEmitter.cpp:18
clang::UsingDecl::isAccessDeclaration
bool isAccessDeclaration() const
Return true if it is a C++03 access declaration (no 'using').
Definition: DeclCXX.h:3424
clang::ASTContext::Allocate
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:655
clang::UnresolvedUsingTypenameDecl
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3749
clang::CXXCtorInitializer::isInClassMemberInitializer
bool isInClassMemberInitializer() const
Determine whether this initializer is an implicit initializer generated for a field with an initializ...
Definition: DeclCXX.h:2264
clang::Type::isLiteralType
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
Definition: Type.cpp:2538
clang::UnresolvedUsingValueDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclCXX.cpp:3127
clang::FunctionTemplateDecl
Declaration of a template function.
Definition: DeclTemplate.h:974
clang::Type::isStructuralType
bool isStructuralType() const
Determine if this type is a structural type, per C++20 [temp.param]p7.
Definition: Type.cpp:2603
clang::CXXRecordDecl::getInstantiatedFromMemberClass
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:1779
clang::Type::isReferenceType
bool isReferenceType() const
Definition: Type.h:6687
clang::UnresolvedUsingTypenameDecl::CreateDeserialized
static UnresolvedUsingTypenameDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:3149
clang::ASTContext::getExternalSource
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
Definition: ASTContext.h:1086
clang::QualType::hasNonTrivialObjCLifetime
bool hasNonTrivialObjCLifetime() const
Definition: Type.h:1119
clang::Decl::Kind
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:92
clang::CXXRecordDecl::getLambdaCaptureDefault
LambdaCaptureDefault getLambdaCaptureDefault() const
Definition: DeclCXX.h:1033
clang::RecordType
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4615
clang::CXXMethodDecl::overridden_methods
overridden_method_range overridden_methods() const
Definition: DeclCXX.cpp:2445
clang::CXXCtorInitializer::getBaseClassLoc
TypeLoc getBaseClassLoc() const
If this is a base class initializer, returns the type of the base class with location information.
Definition: DeclCXX.cpp:2544
getAccessName
static const char * getAccessName(AccessSpecifier AS)
Definition: DeclCXX.cpp:3370
DeclTemplate.h
clang::DeclarationName::getCXXOverloadedOperator
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
Definition: DeclarationName.h:462
clang::NamespaceDecl::CreateDeserialized
static NamespaceDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2884
clang::ASTUnresolvedSet
An UnresolvedSet-like class which uses the ASTContext's allocator.
Definition: ASTUnresolvedSet.h:29
clang::OverridingMethods::iterator
MapType::iterator iterator
Definition: CXXInheritance.h:277
clang::UsingShadowDecl::getIntroducer
BaseUsingDecl * getIntroducer() const
Gets the (written or instantiated) using declaration that introduced this declaration.
Definition: DeclCXX.cpp:3004
clang::RequiresExprBodyDecl
Represents the body of a requires-expression.
Definition: DeclCXX.h:1926
clang::CXXMethodDecl::isInstance
bool isInstance() const
Definition: DeclCXX.h:1976
clang::ASTContext::getAsConstantArrayType
const ConstantArrayType * getAsConstantArrayType(QualType T) const
Definition: ASTContext.h:2547
clang::Decl::getAccess
AccessSpecifier getAccess() const
Definition: DeclBase.h:478
clang::CXXRecordDecl::methods
method_range methods() const
Definition: DeclCXX.h:631
clang::FunctionDecl::isTrivial
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
Definition: Decl.h:2176
clang::ASTUnresolvedSet::append
void append(ASTContext &C, iterator I, iterator E)
Definition: ASTUnresolvedSet.h:83
clang::TagTypeKind
TagTypeKind
The kind of a tag type.
Definition: Type.h:5310
clang::QualType::isObjCGCStrong
bool isObjCGCStrong() const
true when Type is objc's strong.
Definition: Type.h:1110
Id
int Id
Definition: ASTDiff.cpp:191
DeclBase.h
clang::Qualifiers::OCL_Strong
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
Definition: Type.h:173
clang::FunctionDecl::getTemplateInstantiationPattern
FunctionDecl * getTemplateInstantiationPattern(bool ForDefinition=true) const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
Definition: Decl.cpp:3729
OperatorKinds.h
clang::DeclarationName::CXXDestructorName
@ CXXDestructorName
Definition: DeclarationName.h:207
clang::UsingDecl::CreateDeserialized
static UsingDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:3073
clang::AS_public
@ AS_public
Definition: Specifiers.h:99
clang::CXXCtorInitializer::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
Determine the source range covering the entire initializer.
Definition: DeclCXX.cpp:2571
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:189
clang::ASTContext::getSizeType
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Definition: ASTContext.cpp:5629
clang::ASTContext::addOverriddenMethod
void addOverriddenMethod(const CXXMethodDecl *Method, const CXXMethodDecl *Overridden)
Note that the given C++ Method overrides the given Overridden method.
Definition: ASTContext.cpp:1635
clang::StreamingDiagnostic
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
Definition: Diagnostic.h:1105
clang::DeclContextLookupResult::front
reference front() const
Definition: DeclBase.h:1315
clang::DeclarationNameTable::getCXXOperatorName
DeclarationName getCXXOperatorName(OverloadedOperatorKind Op)
Get the name of the overloadable C++ operator corresponding to Op.
Definition: DeclarationName.h:639
clang::ConstructorUsingShadowDecl::CreateDeserialized
static ConstructorUsingShadowDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:3023
NestedNameSpecifier.h
clang::DeclaratorContext::Member
@ Member
LangOptions.h
Diagnostic.h
clang::CXXRecordDecl::getLambdaStaticInvoker
CXXMethodDecl * getLambdaStaticInvoker() const
Retrieve the lambda static invoker, the address of which is returned by the conversion operator,...
Definition: DeclCXX.cpp:1513
clang::DecompositionDecl
A decomposition declaration.
Definition: DeclCXX.h:3956
clang::QualType::isCXX98PODType
bool isCXX98PODType(const ASTContext &Context) const
Return true if this is a POD type according to the rules of the C++98 standard, regardless of the cur...
Definition: Type.cpp:2341
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7160
clang::CXXRecordDecl::getNumBases
unsigned getNumBases() const
Retrieves the number of base classes of this class.
Definition: DeclCXX.h:583
clang::CXXConversionDecl::CreateDeserialized
static CXXConversionDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2784
clang::Decl::isInvalidDecl
bool isInvalidDecl() const
Definition: DeclBase.h:558
clang::ASTMutationListener
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Definition: ASTMutationListener.h:46
clang::ConstructorUsingShadowDecl::getIntroducer
UsingDecl * getIntroducer() const
Override the UsingShadowDecl's getIntroducer, returning the UsingDecl that introduced this.
Definition: DeclCXX.h:3520
clang::LambdaCaptureDefault
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
Definition: Lambda.h:22
clang::Qualifiers::Volatile
@ Volatile
Definition: Type.h:150
clang::Type::isLValueReferenceType
bool isLValueReferenceType() const
Definition: Type.h:6691
clang::index::SymbolKind::Field
@ Field
clang::MSGuidDecl
A global _GUID constant.
Definition: DeclCXX.h:4079
uintptr_t
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Definition: opencl-c-base.h:100
clang::CXXDestructorDecl
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2668
IdentifierTable.h
clang::DeclContext::isTranslationUnit
bool isTranslationUnit() const
Definition: DeclBase.h:1935
Type.h
clang::UsingDecl::Create
static UsingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
Definition: DeclCXX.cpp:3066
clang::CXXRecordDecl::isPOD
bool isPOD() const
Whether this class is a POD-type (C++ [class]p4)
Definition: DeclCXX.h:1126
clang::CPlusPlus20
@ CPlusPlus20
Definition: LangStandard.h:52
Expr.h
clang::CanQual::getCVRQualifiers
unsigned getCVRQualifiers() const
Retrieve the const/volatile/restrict qualifiers.
Definition: CanonicalType.h:132
bool
#define bool
Definition: stdbool.h:15
clang::BaseUsingDecl::removeShadowDecl
void removeShadowDecl(UsingShadowDecl *S)
Definition: DeclCXX.cpp:3043
clang::MSGuidDecl::getAsAPValue
APValue & getAsAPValue() const
Get the value of this MSGuidDecl as an APValue.
Definition: DeclCXX.cpp:3348
ASTContext.h
clang::UnresolvedSet< 8 >
clang::CallingConv
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:253
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:848
clang::UnresolvedUsingIfExistsDecl::CreateDeserialized
static UnresolvedUsingIfExistsDecl * CreateDeserialized(ASTContext &Ctx, unsigned ID)
Definition: DeclCXX.cpp:3162
clang::MSPropertyDecl::CreateDeserialized
static MSPropertyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:3267
clang::Type::getPointeeType
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
Definition: Type.cpp:625
clang::TemplateParameterList
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:69
clang::ASTUnresolvedSet::replace
bool replace(const NamedDecl *Old, NamedDecl *New, AccessSpecifier AS)
Replaces the given declaration with the new one, once.
Definition: ASTUnresolvedSet.h:62
clang::CXXRecordDecl::hasConstexprDestructor
bool hasConstexprDestructor() const
Determine whether this class has a constexpr destructor.
Definition: DeclCXX.cpp:556
clang::StringLiteral
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1757
clang::SD_FullExpression
@ SD_FullExpression
Full-expression storage duration (for temporaries).
Definition: Specifiers.h:295
getLambdaCallOperatorHelper
static NamedDecl * getLambdaCallOperatorHelper(const CXXRecordDecl &RD)
Definition: DeclCXX.cpp:1484
clang::TTK_Class
@ TTK_Class
The "class" keyword.
Definition: Type.h:5321
clang::UsingShadowDecl::UsingShadowDecl
UsingShadowDecl(Kind K, ASTContext &C, DeclContext *DC, SourceLocation Loc, DeclarationName Name, BaseUsingDecl *Introducer, NamedDecl *Target)
Definition: DeclCXX.cpp:2985
clang::ASTContext::getCanonicalType
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:2388
clang::Type::getAsCXXRecordDecl
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition: Type.cpp:1753
clang::TagDecl::isUnion
bool isUnion() const
Definition: Decl.h:3477
clang::LinkageSpecDecl::LanguageIDs
LanguageIDs
Represents the language in a linkage specification.
Definition: DeclCXX.h:2805
clang::DeclContext::isNamespace
bool isNamespace() const
Definition: DeclBase.h:1944
clang::CXXRecordDecl::bases
base_class_range bases()
Definition: DeclCXX.h:589
clang::CXXRecordDecl::hasFriends
bool hasFriends() const
Determines whether this record has any friends.
Definition: DeclCXX.h:672
clang::ASTContext::addDestruction
void addDestruction(T *Ptr) const
If T isn't trivially destructible, calls AddDeallocation to register it for destruction.
Definition: ASTContext.h:2874
clang::CXXRecordDecl::setInstantiationOfMemberClass
void setInstantiationOfMemberClass(CXXRecordDecl *RD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member class RD.
Definition: DeclCXX.cpp:1791
clang::MSGuidDecl::printName
void printName(llvm::raw_ostream &OS) const override
Print this UUID in a human-readable format.
Definition: DeclCXX.cpp:3289
clang::CXXDeductionGuideDecl::Create
static CXXDeductionGuideDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation, CXXConstructorDecl *Ctor=nullptr)
Definition: DeclCXX.cpp:2077
clang::CXXRecordDecl::forallBases
bool forallBases(ForallBasesCallback BaseMatches) const
Determines if the given callback holds for all the direct or indirect base classes of this type.
Definition: CXXInheritance.cpp:127
clang::NestedNameSpecifierLoc
A C++ nested-name-specifier augmented with source location information.
Definition: NestedNameSpecifier.h:243
clang::Redeclarable< NamespaceDecl >::getPreviousDecl
NamespaceDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Definition: Redeclarable.h:203
clang::FunctionDecl::getMinRequiredArguments
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
Definition: Decl.cpp:3367
clang::CanQual< Type >
ExprCXX.h
clang::ExplicitSpecifier::getFromDecl
static ExplicitSpecifier getFromDecl(FunctionDecl *Function)
Definition: DeclCXX.cpp:2063
clang::MSGuidDecl::Parts
MSGuidDeclParts Parts
Definition: DeclCXX.h:4083
Base
clang::Type::isUnsignedIntegerOrEnumerationType
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
Definition: Type.cpp:2069
clang::LCD_None
@ LCD_None
Definition: Lambda.h:23
clang::FunctionDecl::getOverloadedOperator
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
Definition: Decl.cpp:3619
clang::UnresolvedUsingValueDecl
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3653
clang::Redeclarable< NamespaceDecl >::isFirstDecl
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Definition: Redeclarable.h:222
clang::CXXConstructorDecl::isConvertingConstructor
bool isConvertingConstructor(bool AllowExplicit) const
Whether this constructor is a converting constructor (C++ [class.conv.ctor]), which can be used for u...
Definition: DeclCXX.cpp:2712
clang::CXXRecordDecl::hasSimpleMoveAssignment
bool hasSimpleMoveAssignment() const
true if we know for sure that this class has a single, accessible, unambiguous move assignment operat...
Definition: DeclCXX.h:725
clang::APValue::getArrayInitializedElt
APValue & getArrayInitializedElt(unsigned I)
Definition: APValue.h:502
clang::operator<<
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
Definition: ASTContext.cpp:11644
clang::Decl::setImplicit
void setImplicit(bool I=true)
Definition: DeclBase.h:564
clang::NamespaceDecl::isOriginalNamespace
bool isOriginalNamespace() const
Return true if this declaration is an original (first) declaration of the namespace.
Definition: DeclCXX.cpp:2903
clang::CXXConversionDecl::Create
static CXXConversionDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, ExplicitSpecifier ES, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, Expr *TrailingRequiresClause=nullptr)
Definition: DeclCXX.cpp:2791
clang::ConstructorUsingShadowDecl::Create
static ConstructorUsingShadowDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, UsingDecl *Using, NamedDecl *Target, bool IsVirtual)
Definition: DeclCXX.cpp:3015
clang::Decl::isImplicit
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:563
clang::OverloadedOperatorKind
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
clang::Qualifiers::ObjCLifetime
ObjCLifetime
Definition: Type.h:160
clang::ODRHash
Definition: ODRHash.h:41
clang::SC_Static
@ SC_Static
Definition: Specifiers.h:227
clang::ExplicitSpecifier::isEquivalent
bool isEquivalent(const ExplicitSpecifier Other) const
Check for equivalence of explicit specifiers.
Definition: DeclCXX.cpp:2048
clang::CXXRecordDecl::getODRHash
unsigned getODRHash() const
Definition: DeclCXX.cpp:488
clang::UsingDecl
Represents a C++ using-declaration.
Definition: DeclCXX.h:3378
clang::DeclarationNameInfo::getName
DeclarationName getName() const
getName - Returns the embedded declaration name.
Definition: DeclarationName.h:781
clang::NamedDecl::getMostRecentDecl
NamedDecl * getMostRecentDecl()
Definition: Decl.h:447
clang::ASTUnresolvedSet::addDecl
void addDecl(ASTContext &C, NamedDecl *D, AccessSpecifier AS)
Definition: ASTUnresolvedSet.h:55
clang::CXXConstructorDecl::isDefaultConstructor
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
Definition: DeclCXX.cpp:2653
clang::DeclarationName::CXXConversionFunctionName
@ CXXConversionFunctionName
Definition: DeclarationName.h:208
clang::ExplicitSpecifier::getExpr
const Expr * getExpr() const
Definition: DeclCXX.h:1804
clang::FunctionDecl::isDestroyingOperatorDelete
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
Definition: Decl.cpp:3170
clang::LinkageSpecDecl::CreateDeserialized
static LinkageSpecDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2829
clang::Type::castAs
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:7225
clang::ConstexprSpecKind
ConstexprSpecKind
Define the kind of constexpr specifier.
Definition: Specifiers.h:32
clang::AccessSpecifier
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition: Specifiers.h:98
clang::CXXMethodDecl::end_overridden_methods
method_iterator end_overridden_methods() const
Definition: DeclCXX.cpp:2434
clang::LifetimeExtendedTemporaryDecl::getStorageDuration
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
Definition: DeclCXX.cpp:2956
clang::ASTContext::overridden_methods_end
overridden_cxx_method_iterator overridden_methods_end(const CXXMethodDecl *Method) const
Definition: ASTContext.cpp:1616
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:255
clang::ASTUnresolvedSet::begin
iterator begin()
Definition: ASTUnresolvedSet.h:49
clang::CXXMethodDecl::begin_overridden_methods
method_iterator begin_overridden_methods() const
Definition: DeclCXX.cpp:2429
clang::Redeclarable< FunctionDecl >::First
FunctionDecl * First
Definition: Redeclarable.h:187
SourceLocation.h
P
StringRef P
Definition: ASTMatchersInternal.cpp:563
clang::Type::isDependentType
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2168
clang::TemplateSpecializationKind
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition: Specifiers.h:163
clang::CXXConstructorDecl::init_const_iterator
CXXCtorInitializer *const * init_const_iterator
Iterates through the member/base initializer list.
Definition: DeclCXX.h:2489
clang::CXXRecordDecl::conversion_end
conversion_iterator conversion_end() const
Definition: DeclCXX.h:1080
clang::CXXDeductionGuideDecl::CreateDeserialized
static CXXDeductionGuideDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2086
clang::Decl::getPreviousDecl
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
Definition: DeclBase.h:984
clang::Decl::getFriendObjectKind
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
Definition: DeclBase.h:1143
clang::CXXCtorInitializer::getRParenLoc
SourceLocation getRParenLoc() const
Definition: DeclCXX.h:2369
clang::DecompositionDecl::CreateDeserialized
static DecompositionDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumBindings)
Definition: DeclCXX.cpp:3229
clang::UsingPackDecl::Create
static UsingPackDecl * Create(ASTContext &C, DeclContext *DC, NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl * > UsingDecls)
Definition: DeclCXX.cpp:3087
clang::CXXMethodDecl::size_overridden_methods
unsigned size_overridden_methods() const
Definition: DeclCXX.cpp:2439
clang::DeclContext::LinkageSpecDeclBits
LinkageSpecDeclBitfields LinkageSpecDeclBits
Definition: DeclBase.h:1805
clang::BindingDecl::CreateDeserialized
static BindingDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:3199
false
#define false
Definition: stdbool.h:17
clang::StaticAssertDecl
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3850
clang::CXXRecordDecl::hasSimpleCopyAssignment
bool hasSimpleCopyAssignment() const
true if we know for sure that this class has a single, accessible, unambiguous copy assignment operat...
Definition: DeclCXX.h:718
clang::CXXRecordDecl::getNumVBases
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
Definition: DeclCXX.h:604
clang::CXXRecordDecl::setDeviceLambdaManglingNumber
void setDeviceLambdaManglingNumber(unsigned Num) const
Set the device side mangling number.
Definition: DeclCXX.cpp:1596
clang::TagDecl::isBeingDefined
bool isBeingDefined() const
Return true if this decl is currently being defined.
Definition: Decl.h:3414
clang::CXXRecordDecl::hasNonTrivialCopyConstructor
bool hasNonTrivialCopyConstructor() const
Determine whether this class has a non-trivial copy constructor (C++ [class.copy]p6,...
Definition: DeclCXX.h:1233
clang::ASTContext::overridden_methods
overridden_method_range overridden_methods(const CXXMethodDecl *Method) const
Definition: ASTContext.cpp:1627
clang::ClassTemplateDecl
Declaration of a class template.
Definition: DeclTemplate.h:2243
clang::ValueDecl
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:648
clang::AS_protected
@ AS_protected
Definition: Specifiers.h:100
clang::RecordDecl::completeDefinition
virtual void completeDefinition()
Note that the definition of this type is now complete.
Definition: Decl.cpp:4580
clang::ASTUnresolvedSet::end
iterator end()
Definition: ASTUnresolvedSet.h:50
clang::ASTContext::getTagDeclType
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
Definition: ASTContext.cpp:5619
clang::FunctionProtoType
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3887
clang::ASTContext::Idents
IdentifierTable & Idents
Definition: ASTContext.h:613
clang::UnresolvedUsingIfExistsDecl::Create
static UnresolvedUsingIfExistsDecl * Create(ASTContext &Ctx, DeclContext *DC, SourceLocation Loc, DeclarationName Name)
Definition: DeclCXX.cpp:3156
clang::DeclContext::getParent
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1860
clang::Redeclarable< NamespaceDecl >::getNextRedeclaration
NamespaceDecl * getNextRedeclaration() const
Definition: Redeclarable.h:189
clang::RecordDecl::fields
field_range fields() const
Definition: Decl.h:4040
clang::CXXConversionDecl::getConversionType
QualType getConversionType() const
Returns the type that this conversion function is converting to.
Definition: DeclCXX.h:2770
clang::DeclarationName::isIdentifier
bool isIdentifier() const
Predicate functions for querying what type of name this is.
Definition: DeclarationName.h:375
clang::CXXConstructorDecl::getTargetConstructor
CXXConstructorDecl * getTargetConstructor() const
When this constructor delegates to another, retrieve the target.
Definition: DeclCXX.cpp:2644
Begin
SourceLocation Begin
Definition: USRLocFinder.cpp:165
llvm::ArrayRef
Definition: LLVM.h:34
clang::ASTContext::overridden_methods_size
unsigned overridden_methods_size(const CXXMethodDecl *Method) const
Definition: ASTContext.cpp:1621
Value
Value
Definition: UninitializedValues.cpp:102
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
clang::MSGuidDeclParts::Part2
uint16_t Part2
...-89ab-...
Definition: DeclCXX.h:4060
clang::FunctionDecl::isPure
bool isPure() const
Whether this virtual function is pure, i.e.
Definition: Decl.h:2159
clang::TypeLoc
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:58
clang::CXXConstructorDecl::isCopyOrMoveConstructor
bool isCopyOrMoveConstructor() const
Determine whether this a copy or move constructor.
Definition: DeclCXX.h:2613
clang::UsingDecl::getQualifierLoc
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3412
clang::UsingDecl::getNameInfo
DeclarationNameInfo getNameInfo() const
Definition: DeclCXX.h:3419
clang::CXXRecordDecl::getLambdaExplicitTemplateParameters
ArrayRef< NamedDecl * > getLambdaExplicitTemplateParameters() const
Retrieve the lambda template parameters that were specified explicitly.
Definition: DeclCXX.cpp:1576
clang::TagDecl::isStruct
bool isStruct() const
Definition: Decl.h:3474
clang::APValue::isAbsent
bool isAbsent() const
Definition: APValue.h:389
clang::FunctionDecl::isTrivialForCall
bool isTrivialForCall() const
Definition: Decl.h:2179
ASTMutationListener.h
clang::CXXMethodDecl::method_iterator
const CXXMethodDecl *const * method_iterator
Definition: DeclCXX.h:2051
clang::SD_Static
@ SD_Static
Static storage duration.
Definition: Specifiers.h:298
clang::UnresolvedUsingValueDecl::getQualifierLoc
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3695
LLVM.h
clang::CXXCtorInitializer::CXXCtorInitializer
CXXCtorInitializer(ASTContext &Context, TypeSourceInfo *TInfo, bool IsVirtual, SourceLocation L, Expr *Init, SourceLocation R, SourceLocation EllipsisLoc)
Creates a new base-class initializer.
Definition: DeclCXX.cpp:2506
clang::CXXMethodDecl::isStaticOverloadedOperator
static bool isStaticOverloadedOperator(OverloadedOperatorKind OOK)
Returns true if the given operator is implicitly static in a record context.
Definition: DeclCXX.h:1980
clang::NamespaceAliasDecl::Create
static NamespaceAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Namespace)
Definition: DeclCXX.cpp:2931
clang::Type::getAsRecordDecl
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Definition: Type.cpp:1757
clang::APValue::getStructField
APValue & getStructField(unsigned i)
Definition: APValue.h:543
clang::CXXConstructorDecl::init_begin
init_iterator init_begin()
Retrieve an iterator to the first initializer.
Definition: DeclCXX.h:2500
clang::CXXRecordDecl::capture_size
unsigned capture_size() const
Definition: DeclCXX.h:1072
clang::ODRHash::AddCXXRecordDecl
void AddCXXRecordDecl(const CXXRecordDecl *Record)
Definition: ODRHash.cpp:472
clang::CXXRecordDecl::mayBeAbstract
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:2019
clang::TagDecl::isInterface
bool isInterface() const
Definition: Decl.h:3475
clang::CXXMethodDecl::overridden_method_range
llvm::iterator_range< llvm::TinyPtrVector< const CXXMethodDecl * >::const_iterator > overridden_method_range
Definition: DeclCXX.h:2058
clang::CXXRecordDecl::hasTrivialDestructor
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
Definition: DeclCXX.h:1311
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:67
clang::CXXRecordDecl::finishedDefaultedOrDeletedMember
void finishedDefaultedOrDeletedMember(CXXMethodDecl *MD)
Indicates that the declaration of a defaulted or deleted special member function is now complete.
Definition: DeclCXX.cpp:1386
clang::RecordDecl::field_end
field_iterator field_end() const
Definition: Decl.h:4043
clang::BaseUsingDecl::shadow_begin
shadow_iterator shadow_begin() const
Definition: DeclCXX.h:3353
clang::CXXMethodDecl::getCorrespondingMethodDeclaredInClass
CXXMethodDecl * getCorrespondingMethodDeclaredInClass(const CXXRecordDecl *RD, bool MayBeBase=false)
Find if RD declares a function that overrides this function, and if so, return it.
Definition: DeclCXX.cpp:2127
ODRHash.h
clang::FunctionProtoType::getMethodQuals
Qualifiers getMethodQuals() const
Definition: Type.h:4237
clang::CXXRecordDecl::getDestructor
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
Definition: DeclCXX.cpp:1878
clang::CXXRecordDecl::CreateLambda
static CXXRecordDecl * CreateLambda(const ASTContext &C, DeclContext *DC, TypeSourceInfo *Info, SourceLocation Loc, bool DependentLambda, bool IsGeneric, LambdaCaptureDefault CaptureDefault)
Definition: DeclCXX.cpp:147
clang::CXXRecordDecl::getGenericLambdaTemplateParameterList
TemplateParameterList * getGenericLambdaTemplateParameterList() const
Retrieve the generic lambda's template parameter list.
Definition: DeclCXX.cpp:1567
clang::MemberPointerType
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2825
clang::CXXRecordDecl::setTemplateSpecializationKind
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
Definition: DeclCXX.cpp:1819
clang::BaseUsingDecl::addShadowDecl
void addShadowDecl(UsingShadowDecl *S)
Definition: DeclCXX.cpp:3033
clang::UnresolvedSetImpl::end
iterator end()
Definition: UnresolvedSet.h:84
clang::LazyOffsetPtr::get
T * get(ExternalASTSource *Source) const
Retrieve the pointer to the AST node that this lazy pointer points to.
Definition: ExternalASTSource.h:374
DeclarationName.h
clang::ODRHash::AddStmt
void AddStmt(const Stmt *S)
Definition: ODRHash.cpp:24
clang::CXXDeductionGuideDecl
Represents a C++ deduction guide declaration.
Definition: DeclCXX.h:1850
clang::CXXRecordDecl::hasNonLiteralTypeFieldsOrBases
bool hasNonLiteralTypeFieldsOrBases() const
Determine whether this class has a non-literal or/ volatile type non-static data member or base class...
Definition: DeclCXX.h:1353
clang::CXXRecordDecl::setBases
void setBases(CXXBaseSpecifier const *const *Bases, unsigned NumBases)
Sets the base classes of this struct or class.
Definition: DeclCXX.cpp:192
clang::UnresolvedUsingTypenameDecl::Create
static UnresolvedUsingTypenameDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, DeclarationName TargetName, SourceLocation EllipsisLoc)
Definition: DeclCXX.cpp:3136
clang::CanQual::getUnqualifiedType
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
Definition: CanonicalType.h:620
clang::DeclarationName::getNameKind
NameKind getNameKind() const
Determine what kind of name this is.
Definition: DeclarationName.h:384
clang::CXXMethodDecl::addOverriddenMethod
void addOverriddenMethod(const CXXMethodDecl *MD)
Definition: DeclCXX.cpp:2420
clang::Builtin::ID
ID
Definition: Builtins.h:48
clang::LinkageSpecDecl::Create
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces)
Definition: DeclCXX.cpp:2820
PartialDiagnostic.h
clang::CXXRecordDecl::getTemplateSpecializationKind
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
Definition: DeclCXX.cpp:1808
clang
Definition: CalledOnceCheck.h:17
clang::IndirectFieldDecl
Represents a field injected from an anonymous union/struct into the parent scope.
Definition: Decl.h:3050
clang::DeclContext::lookup
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Definition: DeclBase.cpp:1630
clang::CXXConstructorDecl::isSpecializationCopyingObject
bool isSpecializationCopyingObject() const
Determine whether this is a member template specialization that would copy the object to itself.
Definition: DeclCXX.cpp:2730
clang::MSGuidDeclParts::Part4And5
uint8_t Part4And5[8]
...-0123-456789abcdef}
Definition: DeclCXX.h:4064
UnresolvedSet.h
clang::UnresolvedSetImpl::addDecl
void addDecl(NamedDecl *D)
Definition: UnresolvedSet.h:91
clang::Qualifiers::getObjCLifetime
ObjCLifetime getObjCLifetime() const
Definition: Type.h:335
clang::RequiresExprBodyDecl::CreateDeserialized
static RequiresExprBodyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2098
clang::CXXRecordDecl::CreateDeserialized
static CXXRecordDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:164
clang::MSPropertyDecl
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:4027
clang::CXXRecordDecl::getCanonicalDecl
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:494
clang::CXXCtorInitializer::getID
int64_t getID(const ASTContext &Context) const
Definition: DeclCXX.cpp:2539
clang::ConstructorUsingShadowDecl::getNominatedBaseClass
CXXRecordDecl * getNominatedBaseClass() const
Get the base class that was named in the using declaration.
Definition: DeclCXX.cpp:3027
clang::CXXMethodDecl::hasInlineBody
bool hasInlineBody() const
Definition: DeclCXX.cpp:2488
clang::CXXRecordDecl::getCaptureFields
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:1548
clang::BaseUsingDecl::shadow_end
shadow_iterator shadow_end() const
Definition: DeclCXX.h:3357
clang::UnresolvedUsingValueDecl::Create
static UnresolvedUsingValueDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, SourceLocation EllipsisLoc)
Definition: DeclCXX.cpp:3108
clang::CXXRecordDecl::bases_begin
base_class_iterator bases_begin()
Definition: DeclCXX.h:596
clang::ASTContext::overridden_methods_begin
overridden_cxx_method_iterator overridden_methods_begin(const CXXMethodDecl *Method) const
Definition: ASTContext.cpp:1611
clang::CXXRecordDecl::isInterfaceLike
bool isInterfaceLike() const
Definition: DeclCXX.cpp:1923
clang::MSGuidDeclParts::Part3
uint16_t Part3
...-cdef-...
Definition: DeclCXX.h:4062
clang::CXXBaseSpecifier
Represents a base class of a C++ class.
Definition: DeclCXX.h:147
clang::CXXRecordDecl::hasDefinition
bool hasDefinition() const
Definition: DeclCXX.h:542
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6398
clang::NamedDecl::getDeclName
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:287
getInvokerAsMethod
static CXXMethodDecl * getInvokerAsMethod(NamedDecl *ND)
Definition: DeclCXX.cpp:1527
clang::Qualifiers::Const
@ Const
Definition: Type.h:148
clang::DeclContext::isDependentContext
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Definition: DeclBase.cpp:1141
clang::CXXDestructorDecl::Create
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, Expr *TrailingRequiresClause=nullptr)
Definition: DeclCXX.cpp:2757
getThisObjectType
static QualType getThisObjectType(ASTContext &C, const FunctionProtoType *FPT, const CXXRecordDecl *Decl)
Definition: DeclCXX.cpp:2451
clang::CXXRecordDecl::getFinalOverriders
void getFinalOverriders(CXXFinalOverriderMap &FinaOverriders) const
Retrieve the final overriders for each virtual member function in the class hierarchy where this clas...
Definition: CXXInheritance.cpp:642
clang::CXXMethodDecl::getDevirtualizedMethod
CXXMethodDecl * getDevirtualizedMethod(const Expr *Base, bool IsAppleKext)
If it's possible to devirtualize a call to this method, return the called function.
Definition: DeclCXX.cpp:2216
clang::FunctionDecl::isVariadic
bool isVariadic() const
Whether this function is variadic.
Definition: Decl.cpp:2891
clang::UnresolvedUsingIfExistsDecl
This node is generated when a using-declaration that was annotated with attribute((using_if_exists)) ...
Definition: DeclCXX.h:3832
clang::LifetimeExtendedTemporaryDecl::getExtendingDecl
ValueDecl * getExtendingDecl()
Definition: DeclCXX.h:3130
clang::TagDecl::getTagKind
TagKind getTagKind() const
Definition: Decl.h:3468
clang::CXXConstructorDecl::Create
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, ExplicitSpecifier ES, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited=InheritedConstructor(), Expr *TrailingRequiresClause=nullptr)
Definition: DeclCXX.cpp:2622
allLookupResultsAreTheSame
static bool allLookupResultsAreTheSame(const DeclContext::lookup_result &R)
Definition: DeclCXX.cpp:1476
clang::CXXRecordDecl::completeDefinition
void completeDefinition() override
Indicates that the definition of this class is now complete.
Definition: DeclCXX.cpp:1974
clang::ExplicitSpecifier::getKind
ExplicitSpecKind getKind() const
Definition: DeclCXX.h:1803
clang::DeclContextLookupResult
The results of name lookup within a DeclContext.
Definition: DeclBase.h:1292
LambdaCapture.h
clang::CXXMethodDecl::isUsualDeallocationFunction
bool isUsualDeallocationFunction(SmallVectorImpl< const FunctionDecl * > &PreventedBy) const
Determine whether this is a usual deallocation function (C++ [basic.stc.dynamic.deallocation]p2),...
Definition: DeclCXX.cpp:2301
clang::RecordType::getDecl
RecordDecl * getDecl() const
Definition: Type.h:4625
clang::BindingDecl::getBinding
Expr * getBinding() const
Get the expression to which this declaration is bound.
Definition: DeclCXX.h:3923
clang::Decl::EmptyShell
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
Definition: DeclBase.h:105
clang::ReferenceType
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2745
clang::DeclContext::isExternCContext
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
Definition: DeclBase.cpp:1190
clang::InheritedConstructor
Description of a constructor that was inherited from a base class.
Definition: DeclCXX.h:2376
clang::ExternalASTSource::GetExternalDecl
virtual Decl * GetExternalDecl(uint32_t ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
Definition: ExternalASTSource.cpp:71
clang::CXXRecordDecl::isLambda
bool isLambda() const
Determine whether this class describes a lambda function object.
Definition: DeclCXX.h:992
clang::CXXConstructorDecl::isCopyConstructor
bool isCopyConstructor() const
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the cla...
Definition: DeclCXX.h:2587
clang::APValue
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition: APValue.h:122
clang::isTemplateInstantiation
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
Definition: Specifiers.h:187
clang::CXXRecordDecl::hasSimpleMoveConstructor
bool hasSimpleMoveConstructor() const
true if we know for sure that this class has a single, accessible, unambiguous move constructor that ...
Definition: DeclCXX.h:711
clang::APValue::UninitArray
Definition: APValue.h:250
clang::ODRHash::CalculateHash
unsigned CalculateHash()
Definition: ODRHash.cpp:204
llvm::SmallVectorImpl
Definition: LLVM.h:39
clang::CXXRecordDecl::hasUserDeclaredDestructor
bool hasUserDeclaredDestructor() const
Determine whether this class has a user-declared destructor.
Definition: DeclCXX.h:975
clang::SC_None
@ SC_None
Definition: Specifiers.h:225
clang::ValueDecl::getType
QualType getType() const
Definition: Decl.h:659
true
#define true
Definition: stdbool.h:16
clang::NestedNameSpecifierLoc::getBeginLoc
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
Definition: NestedNameSpecifier.h:299
clang::ASTContext::hasSameUnqualifiedType
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
Definition: ASTContext.h:2428
clang::ArrayType::getElementType
QualType getElementType() const
Definition: Type.h:2898
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::BaseUsingDecl
Represents a C++ declaration that introduces decls from somewhere else.
Definition: DeclCXX.h:3283
clang::UsingDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclCXX.cpp:3079
clang::FunctionDecl::getDescribedFunctionTemplate
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
Definition: Decl.cpp:3677
clang::ConstructorUsingShadowDecl
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition: DeclCXX.h:3464
clang::UsingShadowDecl::CreateDeserialized
static UsingShadowDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:3000
clang::CXXRecordDecl::defaultedDestructorIsConstexpr
bool defaultedDestructorIsConstexpr() const
Determine whether a defaulted default constructor for this class would be constexpr.
Definition: DeclCXX.h:1301
clang::CXXCtorInitializer
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2173
clang::ExternalASTSource
Abstract interface for external sources of AST nodes.
Definition: ExternalASTSource.h:60
clang::StaticAssertDecl::CreateDeserialized
static StaticAssertDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:3186
clang::DeclContext::isFunctionOrMethod
bool isFunctionOrMethod() const
Definition: DeclBase.h:1912
clang::DeclarationNameInfo
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Definition: DeclarationName.h:758
clang::CXXDestructorDecl::CreateDeserialized
static CXXDestructorDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2751
clang::Decl::getLocation
SourceLocation getLocation() const
Definition: DeclBase.h:430
clang::CXXRecordDecl::getTemplateInstantiationPattern
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
Definition: DeclCXX.cpp:1833
clang::Decl::isCanonicalDecl
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Definition: DeclBase.h:907
GCCTypeClass::None
@ None
clang::NamespaceDecl
Represent a C++ namespace.
Definition: Decl.h:516
clang::DeclContextLookupResult::empty
bool empty() const
Definition: DeclBase.h:1313
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1825
ASTUnresolvedSet.h
clang::CXXMethodDecl::CreateDeserialized
static CXXMethodDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2209
clang::CXXRecordDecl::CXXRecordDecl
CXXRecordDecl(Kind K, TagKind TK, const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl)
Definition: DeclCXX.cpp:123
clang::RecordDecl
Represents a struct/union/class.
Definition: Decl.h:3820
clang::CXXConstructorDecl::isMoveConstructor
bool isMoveConstructor() const
Determine whether this constructor is a move constructor (C++11 [class.copy]p3), which can be used to...
Definition: DeclCXX.h:2601
clang::FunctionDecl::getStorageClass
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:2549
clang::AccessSpecDecl::CreateDeserialized
static AccessSpecDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:60
CollectVisibleConversions
static void CollectVisibleConversions(ASTContext &Context, const CXXRecordDecl *Record, bool InVirtual, AccessSpecifier Access, const llvm::SmallPtrSet< CanQualType, 8 > &ParentHiddenTypes, ASTUnresolvedSet &Output, UnresolvedSetImpl &VOutput, llvm::SmallPtrSet< NamedDecl *, 8 > &HiddenVBaseCs)
Collect the visible conversions of a base class.
Definition: DeclCXX.cpp:1629
clang::LangOptions::ClangABI::Ver6
@ Ver6
Attempt to be ABI-compatible with code generated by Clang 6.0.x (SVN r321711).
clang::getLambdaStaticInvokerName
StringRef getLambdaStaticInvokerName()
Definition: ASTLambda.h:22
clang::FunctionDecl::isDefined
bool isDefined(const FunctionDecl *&Definition, bool CheckForPendingFriendDefinition=false) const
Returns true if the function has a definition that does not need to be instantiated.
Definition: Decl.cpp:2970
clang::ASTContext::getLangOpts
const LangOptions & getLangOpts() const
Definition: ASTContext.h:711
clang::APValue::UninitStruct
Definition: APValue.h:251
clang::ASTContext::getAllocator
llvm::BumpPtrAllocator & getAllocator() const
Definition: ASTContext.h:651
clang::UsingDirectiveDecl::getNominatedNamespace
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
Definition: DeclCXX.cpp:2858
clang::UsingShadowDecl::setTargetDecl
void setTargetDecl(NamedDecl *ND)
Sets the underlying declaration which has been brought into the local scope.
Definition: DeclCXX.h:3254
clang::CXXConstructorDecl::isInheritingConstructor
bool isInheritingConstructor() const
Determine whether this is an implicit constructor synthesized to model a call to a constructor inheri...
Definition: DeclCXX.h:2630
clang::CXXRecordDecl::setTrivialForCallFlags
void setTrivialForCallFlags(CXXMethodDecl *MD)
Definition: DeclCXX.cpp:1443
clang::CXXMethodDecl::isVirtual
bool isVirtual() const
Definition: DeclCXX.h:1993
TypeLoc.h
clang::declaresSameEntity
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
Definition: DeclBase.h:1198
clang::UnresolvedSetImpl::begin
iterator begin()
Definition: UnresolvedSet.h:83
GetConversionType
static CanQualType GetConversionType(ASTContext &Context, NamedDecl *Conv)
Definition: DeclCXX.cpp:1610
clang::CXXRecordDecl::setDescribedClassTemplate
void setDescribedClassTemplate(ClassTemplateDecl *Template)
Definition: DeclCXX.cpp:1804
clang::LValueReferenceType
An lvalue reference type, per C++11 [dcl.ref].
Definition: Type.h:2789
clang::CXXMethodDecl::getParent
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Definition: DeclCXX.h:2064
clang::CXXMethodDecl
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1948
clang::CXXRecordDecl::getVisibleConversionFunctions
llvm::iterator_range< conversion_iterator > getVisibleConversionFunctions() const
Get all conversion functions visible in current class, including conversion function templates.
Definition: DeclCXX.cpp:1736
clang::ConstexprSpecKind::Unspecified
@ Unspecified
clang::Decl::getDeclContext
DeclContext * getDeclContext()
Definition: DeclBase.h:439
clang::FunctionDecl::isOutOfLine
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a member function.
Definition: Decl.cpp:3970
clang::StorageClass
StorageClass
Storage classes.
Definition: Specifiers.h:223
clang::NamedDecl::getName
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:250