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