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