clang 24.0.0git
DeclCXX.h
Go to the documentation of this file.
1//===- DeclCXX.h - Classes for representing C++ declarations --*- C++ -*-=====//
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/// \file
10/// Defines the C++ Decl subclasses, other than those for templates
11/// (found in DeclTemplate.h) and friends (in DeclFriend.h).
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CLANG_AST_DECLCXX_H
16#define LLVM_CLANG_AST_DECLCXX_H
17
19#include "clang/AST/Decl.h"
20#include "clang/AST/DeclBase.h"
22#include "clang/AST/Expr.h"
27#include "clang/AST/Stmt.h"
28#include "clang/AST/TypeBase.h"
29#include "clang/AST/TypeLoc.h"
31#include "clang/Basic/LLVM.h"
32#include "clang/Basic/Lambda.h"
37#include "llvm/ADT/ArrayRef.h"
38#include "llvm/ADT/DenseMap.h"
39#include "llvm/ADT/PointerIntPair.h"
40#include "llvm/ADT/PointerUnion.h"
41#include "llvm/ADT/STLExtras.h"
42#include "llvm/ADT/TinyPtrVector.h"
43#include "llvm/ADT/iterator_range.h"
44#include "llvm/Support/Casting.h"
45#include "llvm/Support/Compiler.h"
46#include "llvm/Support/PointerLikeTypeTraits.h"
47#include "llvm/Support/TrailingObjects.h"
48#include <cassert>
49#include <cstddef>
50#include <iterator>
51#include <memory>
52#include <vector>
53
54namespace clang {
55
56class ASTContext;
59class CXXBasePath;
60class CXXBasePaths;
65class CXXMethodDecl;
67class FriendDecl;
69class IdentifierInfo;
71class BaseUsingDecl;
72class TemplateDecl;
74class UsingDecl;
75
76/// Represents an access specifier followed by colon ':'.
77///
78/// An objects of this class represents sugar for the syntactic occurrence
79/// of an access specifier followed by a colon in the list of member
80/// specifiers of a C++ class definition.
81///
82/// Note that they do not represent other uses of access specifiers,
83/// such as those occurring in a list of base specifiers.
84/// Also note that this class has nothing to do with so-called
85/// "access declarations" (C++98 11.3 [class.access.dcl]).
86class AccessSpecDecl : public Decl {
87 /// The location of the ':'.
88 SourceLocation ColonLoc;
89
90 AccessSpecDecl(AccessSpecifier AS, DeclContext *DC,
91 SourceLocation ASLoc, SourceLocation ColonLoc)
92 : Decl(AccessSpec, DC, ASLoc), ColonLoc(ColonLoc) {
93 setAccess(AS);
94 }
95
96 AccessSpecDecl(EmptyShell Empty) : Decl(AccessSpec, Empty) {}
97
98 virtual void anchor();
99
100public:
101 /// The location of the access specifier.
103
104 /// Sets the location of the access specifier.
106
107 /// The location of the colon following the access specifier.
108 SourceLocation getColonLoc() const { return ColonLoc; }
109
110 /// Sets the location of the colon.
111 void setColonLoc(SourceLocation CLoc) { ColonLoc = CLoc; }
112
113 SourceRange getSourceRange() const override LLVM_READONLY {
115 }
116
117 static AccessSpecDecl *Create(ASTContext &C, AccessSpecifier AS,
118 DeclContext *DC, SourceLocation ASLoc,
119 SourceLocation ColonLoc) {
120 return new (C, DC) AccessSpecDecl(AS, DC, ASLoc, ColonLoc);
121 }
122
124
125 // Implement isa/cast/dyncast/etc.
126 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
127 static bool classofKind(Kind K) { return K == AccessSpec; }
128};
129
130/// Represents a base class of a C++ class.
131///
132/// Each CXXBaseSpecifier represents a single, direct base class (or
133/// struct) of a C++ class (or struct). It specifies the type of that
134/// base class, whether it is a virtual or non-virtual base, and what
135/// level of access (public, protected, private) is used for the
136/// derivation. For example:
137///
138/// \code
139/// class A { };
140/// class B { };
141/// class C : public virtual A, protected B { };
142/// \endcode
143///
144/// In this code, C will have two CXXBaseSpecifiers, one for "public
145/// virtual A" and the other for "protected B".
147 /// The source code range that covers the full base
148 /// specifier, including the "virtual" (if present) and access
149 /// specifier (if present).
150 SourceRange Range;
151
152 /// The source location of the ellipsis, if this is a pack
153 /// expansion.
154 SourceLocation EllipsisLoc;
155
156 /// Whether this is a virtual base class or not.
157 LLVM_PREFERRED_TYPE(bool)
158 unsigned Virtual : 1;
159
160 /// Whether this is the base of a class (true) or of a struct (false).
161 ///
162 /// This determines the mapping from the access specifier as written in the
163 /// source code to the access specifier used for semantic analysis.
164 LLVM_PREFERRED_TYPE(bool)
165 unsigned BaseOfClass : 1;
166
167 /// Access specifier as written in the source code (may be AS_none).
168 ///
169 /// The actual type of data stored here is an AccessSpecifier, but we use
170 /// "unsigned" here to work around Microsoft ABI.
171 LLVM_PREFERRED_TYPE(AccessSpecifier)
172 unsigned Access : 2;
173
174 /// Whether the class contains a using declaration
175 /// to inherit the named class's constructors.
176 LLVM_PREFERRED_TYPE(bool)
177 unsigned InheritConstructors : 1;
178
179 /// The type of the base class.
180 ///
181 /// This will be a class or struct (or a typedef of such). The source code
182 /// range does not include the \c virtual or the access specifier.
183 TypeSourceInfo *BaseTypeInfo;
184
185public:
186 CXXBaseSpecifier() = default;
188 TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
189 : Range(R), EllipsisLoc(EllipsisLoc), Virtual(V), BaseOfClass(BC),
190 Access(A), InheritConstructors(false), BaseTypeInfo(TInfo) {}
191
192 /// Retrieves the source range that contains the entire base specifier.
193 SourceRange getSourceRange() const LLVM_READONLY { return Range; }
194 SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
195 SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
196
197 /// Get the location at which the base class type was written.
198 SourceLocation getBaseTypeLoc() const LLVM_READONLY {
199 return BaseTypeInfo->getTypeLoc().getBeginLoc();
200 }
201
202 /// Determines whether the base class is a virtual base class (or not).
203 bool isVirtual() const { return Virtual; }
204
205 /// Determine whether this base class is a base of a class declared
206 /// with the 'class' keyword (vs. one declared with the 'struct' keyword).
207 bool isBaseOfClass() const { return BaseOfClass; }
208
209 /// Determine whether this base specifier is a pack expansion.
210 bool isPackExpansion() const { return EllipsisLoc.isValid(); }
211
212 /// Determine whether this base class's constructors get inherited.
213 bool getInheritConstructors() const { return InheritConstructors; }
214
215 /// Set that this base class's constructors should be inherited.
216 void setInheritConstructors(bool Inherit = true) {
217 InheritConstructors = Inherit;
218 }
219
220 /// For a pack expansion, determine the location of the ellipsis.
222 return EllipsisLoc;
223 }
224
225 /// Returns the access specifier for this base specifier.
226 ///
227 /// This is the actual base specifier as used for semantic analysis, so
228 /// the result can never be AS_none. To retrieve the access specifier as
229 /// written in the source code, use getAccessSpecifierAsWritten().
231 if ((AccessSpecifier)Access == AS_none)
232 return BaseOfClass? AS_private : AS_public;
233 else
234 return (AccessSpecifier)Access;
235 }
236
237 /// Retrieves the access specifier as written in the source code
238 /// (which may mean that no access specifier was explicitly written).
239 ///
240 /// Use getAccessSpecifier() to retrieve the access specifier for use in
241 /// semantic analysis.
245
246 /// Retrieves the type of the base class.
247 ///
248 /// This type will always be an unqualified class type.
250 return BaseTypeInfo->getType().getUnqualifiedType();
251 }
252
253 /// Retrieves the type and source location of the base class.
254 TypeSourceInfo *getTypeSourceInfo() const { return BaseTypeInfo; }
255};
256
257/// Represents a C++ struct/union/class.
258class CXXRecordDecl : public RecordDecl {
259 friend class ASTDeclMerger;
260 friend class ASTDeclReader;
261 friend class ASTDeclWriter;
262 friend class ASTNodeImporter;
263 friend class ASTReader;
264 friend class ASTRecordWriter;
265 friend class ASTWriter;
266 friend class DeclContext;
267 friend class LambdaExpr;
268 friend class ODRDiagsEmitter;
269
272
273 /// Values used in DefinitionData fields to represent special members.
274 enum SpecialMemberFlags {
275 SMF_DefaultConstructor = 0x1,
276 SMF_CopyConstructor = 0x2,
277 SMF_MoveConstructor = 0x4,
278 SMF_CopyAssignment = 0x8,
279 SMF_MoveAssignment = 0x10,
280 SMF_Destructor = 0x20,
281 SMF_All = 0x3f
282 };
283
284public:
290
291private:
292 struct DefinitionData {
293 #define FIELD(Name, Width, Merge) \
294 unsigned Name : Width;
295 #include "CXXRecordDeclDefinitionBits.def"
296
297 /// Whether this class describes a C++ lambda.
298 LLVM_PREFERRED_TYPE(bool)
299 unsigned IsLambda : 1;
300
301 /// Whether we are currently parsing base specifiers.
302 LLVM_PREFERRED_TYPE(bool)
303 unsigned IsParsingBaseSpecifiers : 1;
304
305 /// True when visible conversion functions are already computed
306 /// and are available.
307 LLVM_PREFERRED_TYPE(bool)
308 unsigned ComputedVisibleConversions : 1;
309
310 LLVM_PREFERRED_TYPE(bool)
311 unsigned HasODRHash : 1;
312
313 /// A hash of parts of the class to help in ODR checking.
314 unsigned ODRHash = 0;
315
316 /// The number of base class specifiers in Bases.
317 unsigned NumBases = 0;
318
319 /// The number of virtual base class specifiers in VBases.
320 unsigned NumVBases = 0;
321
322 /// Base classes of this class.
323 ///
324 /// FIXME: This is wasted space for a union.
326
327 /// direct and indirect virtual base classes of this class.
329
330 /// The conversion functions of this C++ class (but not its
331 /// inherited conversion functions).
332 ///
333 /// Each of the entries in this overload set is a CXXConversionDecl.
334 LazyASTUnresolvedSet Conversions;
335
336 /// The conversion functions of this C++ class and all those
337 /// inherited conversion functions that are visible in this class.
338 ///
339 /// Each of the entries in this overload set is a CXXConversionDecl or a
340 /// FunctionTemplateDecl.
341 LazyASTUnresolvedSet VisibleConversions;
342
343 /// The declaration which defines this record.
344 CXXRecordDecl *Definition;
345
346 /// The first friend declaration in this class, or null if there
347 /// aren't any.
348 ///
349 /// This is actually currently stored in reverse order.
350 LazyDeclPtr FirstFriend;
351
352 DefinitionData(CXXRecordDecl *D);
353
354 /// Retrieve the set of direct base classes.
355 CXXBaseSpecifier *getBases() const {
356 if (!Bases.isOffset())
357 return Bases.get(nullptr);
358 return getBasesSlowCase();
359 }
360
361 /// Retrieve the set of virtual base classes.
362 CXXBaseSpecifier *getVBases() const {
363 if (!VBases.isOffset())
364 return VBases.get(nullptr);
365 return getVBasesSlowCase();
366 }
367
368 ArrayRef<CXXBaseSpecifier> bases() const { return {getBases(), NumBases}; }
369
370 ArrayRef<CXXBaseSpecifier> vbases() const {
371 return {getVBases(), NumVBases};
372 }
373
374 private:
375 CXXBaseSpecifier *getBasesSlowCase() const;
376 CXXBaseSpecifier *getVBasesSlowCase() const;
377 };
378
379 struct DefinitionData *DefinitionData;
380
381 /// Describes a C++ closure type (generated by a lambda expression).
382 struct LambdaDefinitionData : public DefinitionData {
383 using Capture = LambdaCapture;
384
385 /// Whether this lambda is known to be dependent, even if its
386 /// context isn't dependent.
387 ///
388 /// A lambda with a non-dependent context can be dependent if it occurs
389 /// within the default argument of a function template, because the
390 /// lambda will have been created with the enclosing context as its
391 /// declaration context, rather than function. This is an unfortunate
392 /// artifact of having to parse the default arguments before.
393 LLVM_PREFERRED_TYPE(LambdaDependencyKind)
394 unsigned DependencyKind : 2;
395
396 /// Whether this lambda is a generic lambda.
397 LLVM_PREFERRED_TYPE(bool)
398 unsigned IsGenericLambda : 1;
399
400 /// The Default Capture.
401 LLVM_PREFERRED_TYPE(LambdaCaptureDefault)
402 unsigned CaptureDefault : 2;
403
404 /// The number of captures in this lambda is limited 2^NumCaptures.
405 unsigned NumCaptures : 15;
406
407 /// The number of explicit captures in this lambda.
408 unsigned NumExplicitCaptures : 12;
409
410 /// Has known `internal` linkage.
411 LLVM_PREFERRED_TYPE(bool)
412 unsigned HasKnownInternalLinkage : 1;
413
414 /// The number used to indicate this lambda expression for name
415 /// mangling in the Itanium C++ ABI.
416 unsigned ManglingNumber : 31;
417
418 /// The index of this lambda within its context declaration. This is not in
419 /// general the same as the mangling number.
420 unsigned IndexInContext;
421
422 /// The declaration that provides context for this lambda, if the
423 /// actual DeclContext does not suffice. This is used for lambdas that
424 /// occur within default arguments of function parameters within the class
425 /// or within a data member initializer.
426 LazyDeclPtr ContextDecl;
427
428 /// The lists of captures, both explicit and implicit, for this
429 /// lambda. One list is provided for each merged copy of the lambda.
430 /// The first list corresponds to the canonical definition.
431 /// The destructor is registered by AddCaptureList when necessary.
432 llvm::TinyPtrVector<Capture*> Captures;
433
434 /// The type of the call method.
435 TypeSourceInfo *MethodTyInfo;
436
437 LambdaDefinitionData(CXXRecordDecl *D, TypeSourceInfo *Info, unsigned DK,
438 bool IsGeneric, LambdaCaptureDefault CaptureDefault)
439 : DefinitionData(D), DependencyKind(DK), IsGenericLambda(IsGeneric),
440 CaptureDefault(CaptureDefault), NumCaptures(0),
441 NumExplicitCaptures(0), HasKnownInternalLinkage(0), ManglingNumber(0),
442 IndexInContext(0), MethodTyInfo(Info) {
443 IsLambda = true;
444
445 // C++1z [expr.prim.lambda]p4:
446 // This class type is not an aggregate type.
447 Aggregate = false;
448 PlainOldData = false;
449 }
450
451 // Add a list of captures.
452 void AddCaptureList(ASTContext &Ctx, Capture *CaptureList);
453 };
454
455 struct DefinitionData *dataPtr() const {
456 // Complete the redecl chain (if necessary).
458 return DefinitionData;
459 }
460
461 struct DefinitionData &data() const {
462 auto *DD = dataPtr();
463 assert(DD && "queried property of class with no definition");
464 return *DD;
465 }
466
467 struct LambdaDefinitionData &getLambdaData() const {
468 // No update required: a merged definition cannot change any lambda
469 // properties.
470 auto *DD = DefinitionData;
471 assert(DD && DD->IsLambda && "queried lambda property of non-lambda class");
472 return static_cast<LambdaDefinitionData&>(*DD);
473 }
474
475 /// The template or declaration that this declaration
476 /// describes or was instantiated from, respectively.
477 ///
478 /// For non-templates, this value will be null. For record
479 /// declarations that describe a class template, this will be a
480 /// pointer to a ClassTemplateDecl. For member
481 /// classes of class template specializations, this will be the
482 /// MemberSpecializationInfo referring to the member class that was
483 /// instantiated or specialized.
484 llvm::PointerUnion<ClassTemplateDecl *, MemberSpecializationInfo *>
485 TemplateOrInstantiation;
486
487 /// Called from setBases and addedMember to notify the class that a
488 /// direct or virtual base class or a member of class type has been added.
489 void addedClassSubobject(CXXRecordDecl *Base);
490
491 /// Notify the class that member has been added.
492 ///
493 /// This routine helps maintain information about the class based on which
494 /// members have been added. It will be invoked by DeclContext::addDecl()
495 /// whenever a member is added to this record.
496 void addedMember(Decl *D);
497
498 void markedVirtualFunctionPure();
499
500 /// Get the head of our list of friend declarations, possibly
501 /// deserializing the friends from an external AST source.
502 FriendDecl *getFirstFriend() const;
503
504 /// Determine whether this class has an empty base class subobject of type X
505 /// or of one of the types that might be at offset 0 within X (per the C++
506 /// "standard layout" rules).
507 bool hasSubobjectAtOffsetZeroOfEmptyBaseType(ASTContext &Ctx,
508 const CXXRecordDecl *X);
509
510protected:
512 SourceLocation StartLoc, SourceLocation IdLoc,
513 IdentifierInfo *Id, CXXRecordDecl *PrevDecl);
514
515public:
516 /// Iterator that traverses the base classes of a class.
518
519 /// Iterator that traverses the base classes of a class.
521
525
527 return const_cast<CXXRecordDecl*>(this)->getCanonicalDecl();
528 }
529
531 return cast_or_null<CXXRecordDecl>(
532 static_cast<RecordDecl *>(this)->getPreviousDecl());
533 }
534
536 return const_cast<CXXRecordDecl*>(this)->getPreviousDecl();
537 }
538
540 return cast<CXXRecordDecl>(
541 static_cast<RecordDecl *>(this)->getMostRecentDecl());
542 }
543
545 return const_cast<CXXRecordDecl*>(this)->getMostRecentDecl();
546 }
547
549 // We only need an update if we don't already know which
550 // declaration is the definition.
551 auto *DD = DefinitionData ? DefinitionData : dataPtr();
552 return DD ? DD->Definition : nullptr;
553 }
554
556 if (auto *Def = getDefinition())
557 return Def;
558 return const_cast<CXXRecordDecl *>(this);
559 }
560
561 bool hasDefinition() const { return DefinitionData || dataPtr(); }
562
563 static CXXRecordDecl *Create(const ASTContext &C, TagKind TK, DeclContext *DC,
564 SourceLocation StartLoc, SourceLocation IdLoc,
565 IdentifierInfo *Id,
566 CXXRecordDecl *PrevDecl = nullptr);
569 unsigned DependencyKind, bool IsGeneric,
570 LambdaCaptureDefault CaptureDefault);
572 GlobalDeclID ID);
573
574 bool isDynamicClass() const {
575 return data().Polymorphic || data().NumVBases != 0;
576 }
577
578 /// @returns true if class is dynamic or might be dynamic because the
579 /// definition is incomplete of dependent.
580 bool mayBeDynamicClass() const {
582 }
583
584 /// @returns true if class is non dynamic or might be non dynamic because the
585 /// definition is incomplete of dependent.
586 bool mayBeNonDynamicClass() const {
588 }
589
590 void setIsParsingBaseSpecifiers() { data().IsParsingBaseSpecifiers = true; }
591
593 return data().IsParsingBaseSpecifiers;
594 }
595
596 unsigned getODRHash() const;
597
598 /// Sets the base classes of this struct or class.
599 void setBases(CXXBaseSpecifier const * const *Bases, unsigned NumBases);
600
601 /// Retrieves the number of base classes of this class.
602 unsigned getNumBases() const { return data().NumBases; }
603
604 using base_class_range = llvm::iterator_range<base_class_iterator>;
606 llvm::iterator_range<base_class_const_iterator>;
607
614
615 base_class_iterator bases_begin() { return data().getBases(); }
616 base_class_const_iterator bases_begin() const { return data().getBases(); }
617 base_class_iterator bases_end() { return bases_begin() + data().NumBases; }
619 return bases_begin() + data().NumBases;
620 }
621
622 /// Retrieves the number of virtual base classes of this class.
623 unsigned getNumVBases() const { return data().NumVBases; }
624
631
632 base_class_iterator vbases_begin() { return data().getVBases(); }
633 base_class_const_iterator vbases_begin() const { return data().getVBases(); }
634 base_class_iterator vbases_end() { return vbases_begin() + data().NumVBases; }
636 return vbases_begin() + data().NumVBases;
637 }
638
639 /// Determine whether this class has any dependent base classes which
640 /// are not the current instantiation.
641 bool hasAnyDependentBases() const;
642
643 /// Iterator access to method members. The method iterator visits
644 /// all method members of the class, including non-instance methods,
645 /// special methods, etc.
648 llvm::iterator_range<specific_decl_iterator<CXXMethodDecl>>;
649
652 }
653
654 /// Method begin iterator. Iterates in the order the methods
655 /// were declared.
659
660 /// Method past-the-end iterator.
662 return method_iterator(decls_end());
663 }
664
665 /// Iterator access to constructor members.
668 llvm::iterator_range<specific_decl_iterator<CXXConstructorDecl>>;
669
671
673 return ctor_iterator(decls_begin());
674 }
675
677 return ctor_iterator(decls_end());
678 }
679
680 /// An iterator over friend declarations. All of these are defined
681 /// in DeclFriend.h.
682 class friend_iterator;
683 using friend_range = llvm::iterator_range<friend_iterator>;
684
685 friend_range friends() const;
688 void pushFriendDecl(FriendDecl *FD);
689
690 /// Determines whether this record has any friends.
691 bool hasFriends() const {
692 return data().FirstFriend.isValid();
693 }
694
695 bool hasLazyFriends() const { return data().FirstFriend.isOffset(); }
696
697 void loadLazyFriends();
698
699 /// \c true if a defaulted copy constructor for this class would be
700 /// deleted.
703 (data().DeclaredSpecialMembers & SMF_CopyConstructor)) &&
704 "this property has not yet been computed by Sema");
705 return data().DefaultedCopyConstructorIsDeleted;
706 }
707
708 /// \c true if a defaulted move constructor for this class would be
709 /// deleted.
712 (data().DeclaredSpecialMembers & SMF_MoveConstructor)) &&
713 "this property has not yet been computed by Sema");
714 return data().DefaultedMoveConstructorIsDeleted;
715 }
716
717 /// \c true if a defaulted destructor for this class would be deleted.
720 (data().DeclaredSpecialMembers & SMF_Destructor)) &&
721 "this property has not yet been computed by Sema");
722 return data().DefaultedDestructorIsDeleted;
723 }
724
725 /// \c true if we know for sure that this class has a single,
726 /// accessible, unambiguous copy constructor that is not deleted.
729 !data().DefaultedCopyConstructorIsDeleted;
730 }
731
732 /// \c true if we know for sure that this class has a single,
733 /// accessible, unambiguous move constructor that is not deleted.
736 !data().DefaultedMoveConstructorIsDeleted;
737 }
738
739 /// \c true if we know for sure that this class has a single,
740 /// accessible, unambiguous copy assignment operator that is not deleted.
743 !data().DefaultedCopyAssignmentIsDeleted;
744 }
745
746 /// \c true if we know for sure that this class has a single,
747 /// accessible, unambiguous move assignment operator that is not deleted.
750 !data().DefaultedMoveAssignmentIsDeleted;
751 }
752
753 /// \c true if we know for sure that this class has an accessible
754 /// destructor that is not deleted.
755 bool hasSimpleDestructor() const {
756 return !hasUserDeclaredDestructor() &&
757 !data().DefaultedDestructorIsDeleted;
758 }
759
760 /// Determine whether this class has any default constructors.
762 return (data().DeclaredSpecialMembers & SMF_DefaultConstructor) ||
764 }
765
766 /// Determine if we need to declare a default constructor for
767 /// this class.
768 ///
769 /// This value is used for lazy creation of default constructors.
771 return (!getLangOpts().HLSL || isHLSLBuiltinRecord()) &&
772 ((!data().UserDeclaredConstructor &&
773 !(data().DeclaredSpecialMembers & SMF_DefaultConstructor) &&
775 // FIXME: Proposed fix to core wording issue: if a class inherits
776 // a default constructor and doesn't explicitly declare one, one
777 // is declared implicitly.
778 (data().HasInheritedDefaultConstructor &&
779 !(data().DeclaredSpecialMembers & SMF_DefaultConstructor)));
780 }
781
782 /// Determine whether this class has any user-declared constructors.
783 ///
784 /// When true, a default constructor will not be implicitly declared.
786 return data().UserDeclaredConstructor;
787 }
788
789 /// Whether this class has a user-provided default constructor
790 /// per C++11.
792 return data().UserProvidedDefaultConstructor;
793 }
794
795 /// Determine whether this class has a user-declared copy constructor.
796 ///
797 /// When false, a copy constructor will be implicitly declared.
799 return data().UserDeclaredSpecialMembers & SMF_CopyConstructor;
800 }
801
802 /// Determine whether this class needs an implicit copy
803 /// constructor to be lazily declared.
805 return !(data().DeclaredSpecialMembers & SMF_CopyConstructor) &&
807 }
808
809 /// Determine whether we need to eagerly declare a defaulted copy
810 /// constructor for this class.
812 // C++17 [class.copy.ctor]p6:
813 // If the class definition declares a move constructor or move assignment
814 // operator, the implicitly declared copy constructor is defined as
815 // deleted.
816 // In MSVC mode, sometimes a declared move assignment does not delete an
817 // implicit copy constructor, so defer this choice to Sema.
818 if (data().UserDeclaredSpecialMembers &
819 (SMF_MoveConstructor | SMF_MoveAssignment))
820 return true;
821 return data().NeedOverloadResolutionForCopyConstructor;
822 }
823
824 /// Determine whether an implicit copy constructor for this type
825 /// would have a parameter with a const-qualified reference type.
827 return data().ImplicitCopyConstructorCanHaveConstParamForNonVBase &&
828 (isAbstract() ||
829 data().ImplicitCopyConstructorCanHaveConstParamForVBase);
830 }
831
832 /// Determine whether this class has a copy constructor with
833 /// a parameter type which is a reference to a const-qualified type.
835 return data().HasDeclaredCopyConstructorWithConstParam ||
838 }
839
840 /// Whether this class has a user-declared move constructor or
841 /// assignment operator.
842 ///
843 /// When false, a move constructor and assignment operator may be
844 /// implicitly declared.
846 return data().UserDeclaredSpecialMembers &
847 (SMF_MoveConstructor | SMF_MoveAssignment);
848 }
849
850 /// Determine whether this class has had a move constructor
851 /// declared by the user.
853 return data().UserDeclaredSpecialMembers & SMF_MoveConstructor;
854 }
855
856 /// Determine whether this class has a move constructor.
857 bool hasMoveConstructor() const {
858 return (data().DeclaredSpecialMembers & SMF_MoveConstructor) ||
860 }
861
862 /// Set that we attempted to declare an implicit copy
863 /// constructor, but overload resolution failed so we deleted it.
865 assert((data().DefaultedCopyConstructorIsDeleted ||
867 "Copy constructor should not be deleted");
868 data().DefaultedCopyConstructorIsDeleted = true;
869 }
870
871 /// Set that we attempted to declare an implicit move
872 /// constructor, but overload resolution failed so we deleted it.
874 assert((data().DefaultedMoveConstructorIsDeleted ||
876 "move constructor should not be deleted");
877 data().DefaultedMoveConstructorIsDeleted = true;
878 }
879
880 /// Set that we attempted to declare an implicit destructor,
881 /// but overload resolution failed so we deleted it.
883 assert((data().DefaultedDestructorIsDeleted ||
885 "destructor should not be deleted");
886 data().DefaultedDestructorIsDeleted = true;
887 // C++23 [dcl.constexpr]p3.2:
888 // if the function is a constructor or destructor, its class does not have
889 // any virtual base classes.
890 // C++20 [dcl.constexpr]p5:
891 // The definition of a constexpr destructor whose function-body is
892 // not = delete shall additionally satisfy...
893 data().DefaultedDestructorIsConstexpr = data().NumVBases == 0;
894 }
895
896 /// Determine whether this class should get an implicit move
897 /// constructor or if any existing special member function inhibits this.
899 return !(data().DeclaredSpecialMembers & SMF_MoveConstructor) &&
905 }
906
907 /// Determine whether we need to eagerly declare a defaulted move
908 /// constructor for this class.
910 return data().NeedOverloadResolutionForMoveConstructor;
911 }
912
913 /// Determine whether this class has a user-declared copy assignment
914 /// operator.
915 ///
916 /// When false, a copy assignment operator will be implicitly declared.
918 return data().UserDeclaredSpecialMembers & SMF_CopyAssignment;
919 }
920
921 /// Set that we attempted to declare an implicit copy assignment
922 /// operator, but overload resolution failed so we deleted it.
924 assert((data().DefaultedCopyAssignmentIsDeleted ||
926 "copy assignment should not be deleted");
927 data().DefaultedCopyAssignmentIsDeleted = true;
928 }
929
930 /// Determine whether this class needs an implicit copy
931 /// assignment operator to be lazily declared.
933 return !(data().DeclaredSpecialMembers & SMF_CopyAssignment) &&
935 }
936
937 /// Determine whether we need to eagerly declare a defaulted copy
938 /// assignment operator for this class.
940 // C++20 [class.copy.assign]p2:
941 // If the class definition declares a move constructor or move assignment
942 // operator, the implicitly declared copy assignment operator is defined
943 // as deleted.
944 // In MSVC mode, sometimes a declared move constructor does not delete an
945 // implicit copy assignment, so defer this choice to Sema.
946 if (data().UserDeclaredSpecialMembers &
947 (SMF_MoveConstructor | SMF_MoveAssignment))
948 return true;
949 return data().NeedOverloadResolutionForCopyAssignment;
950 }
951
952 /// Determine whether an implicit copy assignment operator for this
953 /// type would have a parameter with a const-qualified reference type.
955 return data().ImplicitCopyAssignmentHasConstParam;
956 }
957
958 /// Determine whether this class has a copy assignment operator with
959 /// a parameter type which is a reference to a const-qualified type or is not
960 /// a reference.
962 return data().HasDeclaredCopyAssignmentWithConstParam ||
965 }
966
967 /// Determine whether this class has had a move assignment
968 /// declared by the user.
970 return data().UserDeclaredSpecialMembers & SMF_MoveAssignment;
971 }
972
973 /// Determine whether this class has a move assignment operator.
974 bool hasMoveAssignment() const {
975 return (data().DeclaredSpecialMembers & SMF_MoveAssignment) ||
977 }
978
979 /// Set that we attempted to declare an implicit move assignment
980 /// operator, but overload resolution failed so we deleted it.
982 assert((data().DefaultedMoveAssignmentIsDeleted ||
984 "move assignment should not be deleted");
985 data().DefaultedMoveAssignmentIsDeleted = true;
986 }
987
988 /// Determine whether this class should get an implicit move
989 /// assignment operator or if any existing special member function inhibits
990 /// this.
992 return !(data().DeclaredSpecialMembers & SMF_MoveAssignment) &&
999 }
1000
1001 /// Determine whether we need to eagerly declare a move assignment
1002 /// operator for this class.
1004 return data().NeedOverloadResolutionForMoveAssignment;
1005 }
1006
1007 /// Determine whether this class has a user-declared destructor.
1008 ///
1009 /// When false, a destructor will be implicitly declared.
1011 return data().UserDeclaredSpecialMembers & SMF_Destructor;
1012 }
1013
1014 /// Determine whether this class needs an implicit destructor to
1015 /// be lazily declared.
1017 return !(data().DeclaredSpecialMembers & SMF_Destructor);
1018 }
1019
1020 /// Determine whether we need to eagerly declare a destructor for this
1021 /// class.
1023 return data().NeedOverloadResolutionForDestructor;
1024 }
1025
1026 /// Determine whether this class describes a lambda function object.
1027 bool isLambda() const {
1028 // An update record can't turn a non-lambda into a lambda.
1029 auto *DD = DefinitionData;
1030 return DD && DD->IsLambda;
1031 }
1032
1033 /// Determine whether this class describes a generic
1034 /// lambda function object (i.e. function call operator is
1035 /// a template).
1036 bool isGenericLambda() const;
1037
1038 /// Determine whether this lambda should have an implicit default constructor
1039 /// and copy and move assignment operators.
1041
1042 /// Retrieve the lambda call operator of the closure type
1043 /// if this is a closure type.
1045
1046 /// Retrieve the dependent lambda call operator of the closure type
1047 /// if this is a templated closure type.
1049
1050 /// Retrieve the lambda static invoker, the address of which
1051 /// is returned by the conversion operator, and the body of which
1052 /// is forwarded to the lambda call operator. The version that does not
1053 /// take a calling convention uses the 'default' calling convention for free
1054 /// functions if the Lambda's calling convention was not modified via
1055 /// attribute. Otherwise, it will return the calling convention specified for
1056 /// the lambda.
1059
1060 /// Retrieve the generic lambda's template parameter list.
1061 /// Returns null if the class does not represent a lambda or a generic
1062 /// lambda.
1064
1065 /// Retrieve the lambda template parameters that were specified explicitly.
1067
1069 assert(isLambda());
1070 return static_cast<LambdaCaptureDefault>(getLambdaData().CaptureDefault);
1071 }
1072
1073 bool isCapturelessLambda() const {
1074 if (!isLambda())
1075 return false;
1076 return getLambdaCaptureDefault() == LCD_None && capture_size() == 0;
1077 }
1078
1079 /// Set the captures for this lambda closure type.
1080 void setCaptures(ASTContext &Context, ArrayRef<LambdaCapture> Captures);
1081
1082 /// For a closure type, retrieve the mapping from captured
1083 /// variables and \c this to the non-static data members that store the
1084 /// values or references of the captures.
1085 ///
1086 /// \param Captures Will be populated with the mapping from captured
1087 /// variables to the corresponding fields.
1088 ///
1089 /// \param ThisCapture Will be set to the field declaration for the
1090 /// \c this capture.
1091 ///
1092 /// \note No entries will be added for init-captures, as they do not capture
1093 /// variables.
1094 ///
1095 /// \note If multiple versions of the lambda are merged together, they may
1096 /// have different variable declarations corresponding to the same capture.
1097 /// In that case, all of those variable declarations will be added to the
1098 /// Captures list, so it may have more than one variable listed per field.
1099 void
1100 getCaptureFields(llvm::DenseMap<const ValueDecl *, FieldDecl *> &Captures,
1101 FieldDecl *&ThisCapture) const;
1102
1104 using capture_const_range = llvm::iterator_range<capture_const_iterator>;
1105
1109
1111 if (!isLambda()) return nullptr;
1112 LambdaDefinitionData &LambdaData = getLambdaData();
1113 return LambdaData.Captures.empty() ? nullptr : LambdaData.Captures.front();
1114 }
1115
1117 return isLambda() ? captures_begin() + getLambdaData().NumCaptures
1118 : nullptr;
1119 }
1120
1121 unsigned capture_size() const { return getLambdaData().NumCaptures; }
1122
1123 const LambdaCapture *getCapture(unsigned I) const {
1124 assert(isLambda() && I < capture_size() && "invalid index for capture");
1125 return captures_begin() + I;
1126 }
1127
1129
1131 return data().Conversions.get(getASTContext()).begin();
1132 }
1133
1135 return data().Conversions.get(getASTContext()).end();
1136 }
1137
1138 /// Removes a conversion function from this class. The conversion
1139 /// function must currently be a member of this class. Furthermore,
1140 /// this class must currently be in the process of being defined.
1141 void removeConversion(const NamedDecl *Old);
1142
1143 /// Get all conversion functions visible in current class,
1144 /// including conversion function templates.
1145 llvm::iterator_range<conversion_iterator>
1147
1148 /// Determine whether this class is an aggregate (C++ [dcl.init.aggr]),
1149 /// which is a class with no user-declared constructors, no private
1150 /// or protected non-static data members, no base classes, and no virtual
1151 /// functions (C++ [dcl.init.aggr]p1).
1152 bool isAggregate() const { return data().Aggregate; }
1153
1154 /// Whether this class has any in-class initializers
1155 /// for non-static data members (including those in anonymous unions or
1156 /// structs).
1157 bool hasInClassInitializer() const { return data().HasInClassInitializer; }
1158
1159 /// Whether this class or any of its subobjects has any members of
1160 /// reference type which would make value-initialization ill-formed.
1161 ///
1162 /// Per C++03 [dcl.init]p5:
1163 /// - if T is a non-union class type without a user-declared constructor,
1164 /// then every non-static data member and base-class component of T is
1165 /// value-initialized [...] A program that calls for [...]
1166 /// value-initialization of an entity of reference type is ill-formed.
1168 return !isUnion() && !hasUserDeclaredConstructor() &&
1169 data().HasUninitializedReferenceMember;
1170 }
1171
1172 /// Whether this class is a POD-type (C++ [class]p4)
1173 ///
1174 /// For purposes of this function a class is POD if it is an aggregate
1175 /// that has no non-static non-POD data members, no reference data
1176 /// members, no user-defined copy assignment operator and no
1177 /// user-defined destructor.
1178 ///
1179 /// Note that this is the C++ TR1 definition of POD.
1180 bool isPOD() const { return data().PlainOldData; }
1181
1182 /// True if this class is C-like, without C++-specific features, e.g.
1183 /// it contains only public fields, no bases, tag kind is not 'class', etc.
1184 bool isCLike() const;
1185
1186 /// Determine whether this is an empty class in the sense of
1187 /// (C++11 [meta.unary.prop]).
1188 ///
1189 /// The CXXRecordDecl is a class type, but not a union type,
1190 /// with no non-static data members other than bit-fields of length 0,
1191 /// no virtual member functions, no virtual base classes,
1192 /// and no base class B for which is_empty<B>::value is false.
1193 ///
1194 /// \note This does NOT include a check for union-ness.
1195 bool isEmpty() const { return data().Empty; }
1196
1197 void setInitMethod(bool Val) { data().HasInitMethod = Val; }
1198 bool hasInitMethod() const { return data().HasInitMethod; }
1199
1200 bool hasPrivateFields() const {
1201 return data().HasPrivateFields;
1202 }
1203
1204 bool hasProtectedFields() const {
1205 return data().HasProtectedFields;
1206 }
1207
1208 /// Determine whether this class has direct non-static data members.
1209 bool hasDirectFields() const {
1210 auto &D = data();
1211 return D.HasPublicFields || D.HasProtectedFields || D.HasPrivateFields;
1212 }
1213
1214 /// If this is a standard-layout class or union, any and all data members will
1215 /// be declared in the same type.
1216 ///
1217 /// This retrieves the type where any fields are declared,
1218 /// or the current class if there is no class with fields.
1220
1221 /// Whether this class is polymorphic (C++ [class.virtual]),
1222 /// which means that the class contains or inherits a virtual function.
1223 bool isPolymorphic() const { return data().Polymorphic; }
1224
1225 /// Determine whether this class has a pure virtual function.
1226 ///
1227 /// The class is abstract per (C++ [class.abstract]p2) if it declares
1228 /// a pure virtual function or inherits a pure virtual function that is
1229 /// not overridden.
1230 bool isAbstract() const { return data().Abstract; }
1231
1232 /// Determine whether this class is standard-layout per
1233 /// C++ [class]p7.
1234 bool isStandardLayout() const { return data().IsStandardLayout; }
1235
1236 /// Determine whether this class was standard-layout per
1237 /// C++11 [class]p7, specifically using the C++11 rules without any DRs.
1238 bool isCXX11StandardLayout() const { return data().IsCXX11StandardLayout; }
1239
1240 /// Determine whether this class, or any of its class subobjects,
1241 /// contains a mutable field.
1242 bool hasMutableFields() const { return data().HasMutableFields; }
1243
1244 /// Determine whether this class has any variant members.
1245 bool hasVariantMembers() const { return data().HasVariantMembers; }
1246
1247 /// Returns whether the pointer fields in this class should have pointer field
1248 /// protection (PFP) by default, either because of an attribute, the
1249 /// -fexperimental-pointer-field-protection-abi compiler flag or inheritance
1250 /// from a base or member with PFP.
1251 bool isPFPType() const { return data().IsPFPType; }
1252
1253 /// Determine whether this class has a trivial default constructor
1254 /// (C++11 [class.ctor]p5).
1256 return hasDefaultConstructor() &&
1257 (data().HasTrivialSpecialMembers & SMF_DefaultConstructor);
1258 }
1259
1260 /// Determine whether this class has a non-trivial default constructor
1261 /// (C++11 [class.ctor]p5).
1263 return (data().DeclaredNonTrivialSpecialMembers & SMF_DefaultConstructor) ||
1265 !(data().HasTrivialSpecialMembers & SMF_DefaultConstructor));
1266 }
1267
1268 /// Determine whether this class has at least one constexpr constructor
1269 /// other than the copy or move constructors.
1271 return data().HasConstexprNonCopyMoveConstructor ||
1274 }
1275
1276 /// Determine whether a defaulted default constructor for this class
1277 /// would be constexpr.
1279 return data().DefaultedDefaultConstructorIsConstexpr &&
1281 getLangOpts().CPlusPlus20);
1282 }
1283
1284 /// Determine whether this class has a constexpr default constructor.
1286 return data().HasConstexprDefaultConstructor ||
1289 }
1290
1291 /// Determine whether this class has a trivial copy constructor
1292 /// (C++ [class.copy]p6, C++11 [class.copy]p12)
1294 return data().HasTrivialSpecialMembers & SMF_CopyConstructor;
1295 }
1296
1298 return data().HasTrivialSpecialMembersForCall & SMF_CopyConstructor;
1299 }
1300
1301 /// Determine whether this class has a non-trivial copy constructor
1302 /// (C++ [class.copy]p6, C++11 [class.copy]p12)
1304 return data().DeclaredNonTrivialSpecialMembers & SMF_CopyConstructor ||
1306 }
1307
1309 return (data().DeclaredNonTrivialSpecialMembersForCall &
1310 SMF_CopyConstructor) ||
1312 }
1313
1314 /// Determine whether this class has a trivial move constructor
1315 /// (C++11 [class.copy]p12)
1317 return hasMoveConstructor() &&
1318 (data().HasTrivialSpecialMembers & SMF_MoveConstructor);
1319 }
1320
1322 return hasMoveConstructor() &&
1323 (data().HasTrivialSpecialMembersForCall & SMF_MoveConstructor);
1324 }
1325
1326 /// Determine whether this class has a non-trivial move constructor
1327 /// (C++11 [class.copy]p12)
1329 return (data().DeclaredNonTrivialSpecialMembers & SMF_MoveConstructor) ||
1331 !(data().HasTrivialSpecialMembers & SMF_MoveConstructor));
1332 }
1333
1335 return (data().DeclaredNonTrivialSpecialMembersForCall &
1336 SMF_MoveConstructor) ||
1338 !(data().HasTrivialSpecialMembersForCall & SMF_MoveConstructor));
1339 }
1340
1341 /// Determine whether this class has a trivial copy assignment operator
1342 /// (C++ [class.copy]p11, C++11 [class.copy]p25)
1344 return data().HasTrivialSpecialMembers & SMF_CopyAssignment;
1345 }
1346
1347 /// Determine whether this class has a non-trivial copy assignment
1348 /// operator (C++ [class.copy]p11, C++11 [class.copy]p25)
1350 return data().DeclaredNonTrivialSpecialMembers & SMF_CopyAssignment ||
1352 }
1353
1354 /// Determine whether this class has a trivial move assignment operator
1355 /// (C++11 [class.copy]p25)
1357 return hasMoveAssignment() &&
1358 (data().HasTrivialSpecialMembers & SMF_MoveAssignment);
1359 }
1360
1361 /// Determine whether this class has a non-trivial move assignment
1362 /// operator (C++11 [class.copy]p25)
1364 return (data().DeclaredNonTrivialSpecialMembers & SMF_MoveAssignment) ||
1366 !(data().HasTrivialSpecialMembers & SMF_MoveAssignment));
1367 }
1368
1369 /// Determine whether a defaulted default constructor for this class
1370 /// would be constexpr.
1372 return data().DefaultedDestructorIsConstexpr &&
1373 getLangOpts().CPlusPlus20;
1374 }
1375
1376 /// Determine whether this class has a constexpr destructor.
1377 bool hasConstexprDestructor() const;
1378
1379 /// Determine whether this class has a trivial destructor
1380 /// (C++ [class.dtor]p3)
1382 return data().HasTrivialSpecialMembers & SMF_Destructor;
1383 }
1384
1386 return data().HasTrivialSpecialMembersForCall & SMF_Destructor;
1387 }
1388
1389 /// Determine whether this class has a non-trivial destructor
1390 /// (C++ [class.dtor]p3)
1392 return !(data().HasTrivialSpecialMembers & SMF_Destructor);
1393 }
1394
1396 return !(data().HasTrivialSpecialMembersForCall & SMF_Destructor);
1397 }
1398
1400 data().HasTrivialSpecialMembersForCall =
1401 (SMF_CopyConstructor | SMF_MoveConstructor | SMF_Destructor);
1402 }
1403
1404 /// Determine whether declaring a const variable with this type is ok
1405 /// per core issue 253.
1407 return !data().HasUninitializedFields ||
1408 !(data().HasDefaultedDefaultConstructor ||
1410 }
1411
1412 /// Determine whether this class has a destructor which has no
1413 /// semantic effect.
1414 ///
1415 /// Any such destructor will be trivial, public, defaulted and not deleted,
1416 /// and will call only irrelevant destructors.
1418 return data().HasIrrelevantDestructor;
1419 }
1420
1421 /// Determine whether this class has a non-literal or/ volatile type
1422 /// non-static data member or base class.
1424 return data().HasNonLiteralTypeFieldsOrBases;
1425 }
1426
1427 /// Determine whether this class has a using-declaration that names
1428 /// a user-declared base class constructor.
1430 return data().HasInheritedConstructor;
1431 }
1432
1433 /// Determine whether this class has a using-declaration that names
1434 /// a base class assignment operator.
1436 return data().HasInheritedAssignment;
1437 }
1438
1439 /// Determine whether this class is considered trivially copyable per
1440 /// (C++11 [class]p6).
1441 bool isTriviallyCopyable() const;
1442
1443 /// Determine whether this class is considered trivially copyable per
1444 bool isTriviallyCopyConstructible() const;
1445
1446 /// Determine whether this class is considered trivial.
1447 ///
1448 /// C++11 [class]p6:
1449 /// "A trivial class is a class that has a trivial default constructor and
1450 /// is trivially copyable."
1451 bool isTrivial() const {
1453 }
1454
1455 /// Determine whether this class is a literal type.
1456 ///
1457 /// C++20 [basic.types]p10:
1458 /// A class type that has all the following properties:
1459 /// - it has a constexpr destructor
1460 /// - all of its non-static non-variant data members and base classes
1461 /// are of non-volatile literal types, and it:
1462 /// - is a closure type
1463 /// - is an aggregate union type that has either no variant members
1464 /// or at least one variant member of non-volatile literal type
1465 /// - is a non-union aggregate type for which each of its anonymous
1466 /// union members satisfies the above requirements for an aggregate
1467 /// union type, or
1468 /// - has at least one constexpr constructor or constructor template
1469 /// that is not a copy or move constructor.
1470 bool isLiteral() const;
1471
1472 /// Determine whether this is a structural type.
1473 bool isStructural() const {
1474 return isLiteral() && data().StructuralIfLiteral;
1475 }
1476
1477 /// Notify the class that this destructor is now selected.
1478 ///
1479 /// Important properties of the class depend on destructor properties. Since
1480 /// C++20, it is possible to have multiple destructor declarations in a class
1481 /// out of which one will be selected at the end.
1482 /// This is called separately from addedMember because it has to be deferred
1483 /// to the completion of the class.
1485
1486 /// Notify the class that an eligible SMF has been added.
1487 /// This updates triviality and destructor based properties of the class accordingly.
1488 void addedEligibleSpecialMemberFunction(const CXXMethodDecl *MD, unsigned SMKind);
1489
1490 /// If this record is an instantiation of a member class,
1491 /// retrieves the member class from which it was instantiated.
1492 ///
1493 /// This routine will return non-null for (non-templated) member
1494 /// classes of class templates. For example, given:
1495 ///
1496 /// \code
1497 /// template<typename T>
1498 /// struct X {
1499 /// struct A { };
1500 /// };
1501 /// \endcode
1502 ///
1503 /// The declaration for X<int>::A is a (non-templated) CXXRecordDecl
1504 /// whose parent is the class template specialization X<int>. For
1505 /// this declaration, getInstantiatedFromMemberClass() will return
1506 /// the CXXRecordDecl X<T>::A. When a complete definition of
1507 /// X<int>::A is required, it will be instantiated from the
1508 /// declaration returned by getInstantiatedFromMemberClass().
1510
1511 /// If this class is an instantiation of a member class of a
1512 /// class template specialization, retrieves the member specialization
1513 /// information.
1515
1516 /// Specify that this record is an instantiation of the
1517 /// member class \p RD.
1520
1521 /// Retrieves the class template that is described by this
1522 /// class declaration.
1523 ///
1524 /// Every class template is represented as a ClassTemplateDecl and a
1525 /// CXXRecordDecl. The former contains template properties (such as
1526 /// the template parameter lists) while the latter contains the
1527 /// actual description of the template's
1528 /// contents. ClassTemplateDecl::getTemplatedDecl() retrieves the
1529 /// CXXRecordDecl that from a ClassTemplateDecl, while
1530 /// getDescribedClassTemplate() retrieves the ClassTemplateDecl from
1531 /// a CXXRecordDecl.
1533
1535
1536 /// Determine whether this particular class is a specialization or
1537 /// instantiation of a class template or member class of a class template,
1538 /// and how it was instantiated or specialized.
1540
1541 /// Set the kind of specialization or template instantiation this is.
1543
1544 /// Retrieve the record declaration from which this record could be
1545 /// instantiated. Returns null if this class is not a template instantiation.
1547
1549 return const_cast<CXXRecordDecl *>(const_cast<const CXXRecordDecl *>(this)
1550 ->getTemplateInstantiationPattern());
1551 }
1552
1553 /// Returns the destructor decl for this class.
1555
1556 /// Returns the destructor decl for this class.
1557 bool hasDeletedDestructor() const;
1558
1559 /// Returns true if the class destructor, or any implicitly invoked
1560 /// destructors are marked noreturn.
1561 bool isAnyDestructorNoReturn() const { return data().IsAnyDestructorNoReturn; }
1562
1563 /// Returns true if the class contains HLSL intangible type, either as
1564 /// a field or in base class.
1565 bool isHLSLIntangible() const { return data().IsHLSLIntangible; }
1566
1567 /// Returns true if the class is a built-in HLSL record.
1568 bool isHLSLBuiltinRecord() const { return data().IsHLSLBuiltinRecord; }
1569
1570 /// Sets the flag that the class is a built-in HLSL record.
1572 data().IsHLSLBuiltinRecord = Value;
1573 }
1574
1575 /// If the class is a local class [class.local], returns
1576 /// the enclosing function declaration.
1578 if (const auto *RD = dyn_cast<CXXRecordDecl>(getDeclContext()))
1579 return RD->isLocalClass();
1580
1581 return dyn_cast<FunctionDecl>(getDeclContext());
1582 }
1583
1585 return const_cast<FunctionDecl*>(
1586 const_cast<const CXXRecordDecl*>(this)->isLocalClass());
1587 }
1588
1589 /// Determine whether this dependent class is a current instantiation,
1590 /// when viewed from within the given context.
1591 bool isCurrentInstantiation(const DeclContext *CurContext) const;
1592
1593 /// Determine whether this class is derived from the class \p Base.
1594 ///
1595 /// This routine only determines whether this class is derived from \p Base,
1596 /// but does not account for factors that may make a Derived -> Base class
1597 /// ill-formed, such as private/protected inheritance or multiple, ambiguous
1598 /// base class subobjects.
1599 ///
1600 /// \param Base the base class we are searching for.
1601 ///
1602 /// \returns true if this class is derived from Base, false otherwise.
1603 bool isDerivedFrom(const CXXRecordDecl *Base) const;
1604
1605 /// Determine whether this class is derived from the type \p Base.
1606 ///
1607 /// This routine only determines whether this class is derived from \p Base,
1608 /// but does not account for factors that may make a Derived -> Base class
1609 /// ill-formed, such as private/protected inheritance or multiple, ambiguous
1610 /// base class subobjects.
1611 ///
1612 /// \param Base the base class we are searching for.
1613 ///
1614 /// \param Paths will contain the paths taken from the current class to the
1615 /// given \p Base class.
1616 ///
1617 /// \returns true if this class is derived from \p Base, false otherwise.
1618 ///
1619 /// \todo add a separate parameter to configure IsDerivedFrom, rather than
1620 /// tangling input and output in \p Paths
1621 bool isDerivedFrom(const CXXRecordDecl *Base, CXXBasePaths &Paths) const;
1622
1623 /// Determine whether this class is virtually derived from
1624 /// the class \p Base.
1625 ///
1626 /// This routine only determines whether this class is virtually
1627 /// derived from \p Base, but does not account for factors that may
1628 /// make a Derived -> Base class ill-formed, such as
1629 /// private/protected inheritance or multiple, ambiguous base class
1630 /// subobjects.
1631 ///
1632 /// \param Base the base class we are searching for.
1633 ///
1634 /// \returns true if this class is virtually derived from Base,
1635 /// false otherwise.
1636 bool isVirtuallyDerivedFrom(const CXXRecordDecl *Base) const;
1637
1638 /// Determine whether this class is provably not derived from
1639 /// the type \p Base.
1640 bool isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const;
1641
1642 /// Function type used by forallBases() as a callback.
1643 ///
1644 /// \param BaseDefinition the definition of the base class
1645 ///
1646 /// \returns true if this base matched the search criteria
1648 llvm::function_ref<bool(const CXXRecordDecl *BaseDefinition)>;
1649
1650 /// Determines if the given callback holds for all the direct
1651 /// or indirect base classes of this type.
1652 ///
1653 /// The class itself does not count as a base class. This routine
1654 /// returns false if the class has non-computable base classes.
1655 ///
1656 /// \param BaseMatches Callback invoked for each (direct or indirect) base
1657 /// class of this type until a call returns false.
1658 bool forallBases(ForallBasesCallback BaseMatches) const;
1659
1660 /// Function type used by lookupInBases() to determine whether a
1661 /// specific base class subobject matches the lookup criteria.
1662 ///
1663 /// \param Specifier the base-class specifier that describes the inheritance
1664 /// from the base class we are trying to match.
1665 ///
1666 /// \param Path the current path, from the most-derived class down to the
1667 /// base named by the \p Specifier.
1668 ///
1669 /// \returns true if this base matched the search criteria, false otherwise.
1671 llvm::function_ref<bool(const CXXBaseSpecifier *Specifier,
1672 CXXBasePath &Path)>;
1673
1674 /// Look for entities within the base classes of this C++ class,
1675 /// transitively searching all base class subobjects.
1676 ///
1677 /// This routine uses the callback function \p BaseMatches to find base
1678 /// classes meeting some search criteria, walking all base class subobjects
1679 /// and populating the given \p Paths structure with the paths through the
1680 /// inheritance hierarchy that resulted in a match. On a successful search,
1681 /// the \p Paths structure can be queried to retrieve the matching paths and
1682 /// to determine if there were any ambiguities.
1683 ///
1684 /// \param BaseMatches callback function used to determine whether a given
1685 /// base matches the user-defined search criteria.
1686 ///
1687 /// \param Paths used to record the paths from this class to its base class
1688 /// subobjects that match the search criteria.
1689 ///
1690 /// \param LookupInDependent can be set to true to extend the search to
1691 /// dependent base classes.
1692 ///
1693 /// \returns true if there exists any path from this class to a base class
1694 /// subobject that matches the search criteria.
1695 bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths,
1696 bool LookupInDependent = false) const;
1697
1698 /// Base-class lookup callback that determines whether the given
1699 /// base class specifier refers to a specific class declaration.
1700 ///
1701 /// This callback can be used with \c lookupInBases() to determine whether
1702 /// a given derived class has is a base class subobject of a particular type.
1703 /// The base record pointer should refer to the canonical CXXRecordDecl of the
1704 /// base class that we are searching for.
1705 static bool FindBaseClass(const CXXBaseSpecifier *Specifier,
1706 CXXBasePath &Path, const CXXRecordDecl *BaseRecord);
1707
1708 /// Base-class lookup callback that determines whether the
1709 /// given base class specifier refers to a specific class
1710 /// declaration and describes virtual derivation.
1711 ///
1712 /// This callback can be used with \c lookupInBases() to determine
1713 /// whether a given derived class has is a virtual base class
1714 /// subobject of a particular type. The base record pointer should
1715 /// refer to the canonical CXXRecordDecl of the base class that we
1716 /// are searching for.
1717 static bool FindVirtualBaseClass(const CXXBaseSpecifier *Specifier,
1718 CXXBasePath &Path,
1719 const CXXRecordDecl *BaseRecord);
1720
1721 /// Retrieve the final overriders for each virtual member
1722 /// function in the class hierarchy where this class is the
1723 /// most-derived class in the class hierarchy.
1724 void getFinalOverriders(CXXFinalOverriderMap &FinaOverriders) const;
1725
1726 /// Get the indirect primary bases for this class.
1728
1729 /// Determine whether this class has a member with the given name, possibly
1730 /// in a non-dependent base class.
1731 ///
1732 /// No check for ambiguity is performed, so this should never be used when
1733 /// implementing language semantics, but it may be appropriate for warnings,
1734 /// static analysis, or similar.
1735 bool hasMemberName(DeclarationName N) const;
1736
1737 /// Renders and displays an inheritance diagram
1738 /// for this C++ class and all of its base classes (transitively) using
1739 /// GraphViz.
1740 void viewInheritance(ASTContext& Context) const;
1741
1742 /// Calculates the access of a decl that is reached
1743 /// along a path.
1745 AccessSpecifier DeclAccess) {
1746 assert(DeclAccess != AS_none);
1747 if (DeclAccess == AS_private) return AS_none;
1748 return (PathAccess > DeclAccess ? PathAccess : DeclAccess);
1749 }
1750
1751 /// Indicates that the declaration of a defaulted or deleted special
1752 /// member function is now complete.
1754
1756
1757 /// Indicates that the definition of this class is now complete.
1758 void completeDefinition() override;
1759
1760 /// Indicates that the definition of this class is now complete,
1761 /// and provides a final overrider map to help determine
1762 ///
1763 /// \param FinalOverriders The final overrider map for this class, which can
1764 /// be provided as an optimization for abstract-class checking. If NULL,
1765 /// final overriders will be computed if they are needed to complete the
1766 /// definition.
1767 void completeDefinition(CXXFinalOverriderMap *FinalOverriders);
1768
1769 /// Determine whether this class may end up being abstract, even though
1770 /// it is not yet known to be abstract.
1771 ///
1772 /// \returns true if this class is not known to be abstract but has any
1773 /// base classes that are abstract. In this case, \c completeDefinition()
1774 /// will need to compute final overriders to determine whether the class is
1775 /// actually abstract.
1776 bool mayBeAbstract() const;
1777
1778 /// Determine whether it's impossible for a class to be derived from this
1779 /// class. This is best-effort, and may conservatively return false.
1780 bool isEffectivelyFinal() const;
1781
1782 /// If this is the closure type of a lambda expression, retrieve the
1783 /// number to be used for name mangling in the Itanium C++ ABI.
1784 ///
1785 /// Zero indicates that this closure type has internal linkage, so the
1786 /// mangling number does not matter, while a non-zero value indicates which
1787 /// lambda expression this is in this particular context.
1788 unsigned getLambdaManglingNumber() const {
1789 assert(isLambda() && "Not a lambda closure type!");
1790 return getLambdaData().ManglingNumber;
1791 }
1792
1793 /// The lambda is known to has internal linkage no matter whether it has name
1794 /// mangling number.
1796 assert(isLambda() && "Not a lambda closure type!");
1797 return getLambdaData().HasKnownInternalLinkage;
1798 }
1799
1800 /// Retrieve the declaration that provides additional context for a
1801 /// lambda, when the normal declaration context is not specific enough.
1802 ///
1803 /// Certain contexts (default arguments of in-class function parameters and
1804 /// the initializers of data members) have separate name mangling rules for
1805 /// lambdas within the Itanium C++ ABI. For these cases, this routine provides
1806 /// the declaration in which the lambda occurs, e.g., the function parameter
1807 /// or the non-static data member. Otherwise, it returns NULL to imply that
1808 /// the declaration context suffices.
1809 Decl *getLambdaContextDecl() const;
1810
1811 /// Set the context declaration for a lambda class.
1812 void setLambdaContextDecl(Decl *ContextDecl);
1813
1814 /// Retrieve the index of this lambda within the context declaration returned
1815 /// by getLambdaContextDecl().
1816 unsigned getLambdaIndexInContext() const {
1817 assert(isLambda() && "Not a lambda closure type!");
1818 return getLambdaData().IndexInContext;
1819 }
1820
1821 /// Information about how a lambda is numbered within its context.
1823 unsigned IndexInContext = 0;
1824 unsigned ManglingNumber = 0;
1827 };
1828
1829 /// Set the mangling numbers for a lambda class.
1830 void setLambdaNumbering(LambdaNumbering Numbering);
1831
1832 // Get the mangling numbers for a lambda class.
1837
1838 /// Retrieve the device side mangling number.
1839 unsigned getDeviceLambdaManglingNumber() const;
1840
1841 /// Returns the inheritance model used for this record.
1843
1844 /// Calculate what the inheritance model would be for this class.
1846
1847 /// In the Microsoft C++ ABI, use zero for the field offset of a null data
1848 /// member pointer if we can guarantee that zero is not a valid field offset,
1849 /// or if the member pointer has multiple fields. Polymorphic classes have a
1850 /// vfptr at offset zero, so we can use zero for null. If there are multiple
1851 /// fields, we can use zero even if it is a valid field offset because
1852 /// null-ness testing will check the other fields.
1853 bool nullFieldOffsetIsZero() const;
1854
1855 /// Controls when vtordisps will be emitted if this record is used as a
1856 /// virtual base.
1858
1859 /// Determine whether this lambda expression was known to be dependent
1860 /// at the time it was created, even if its context does not appear to be
1861 /// dependent.
1862 ///
1863 /// This flag is a workaround for an issue with parsing, where default
1864 /// arguments are parsed before their enclosing function declarations have
1865 /// been created. This means that any lambda expressions within those
1866 /// default arguments will have as their DeclContext the context enclosing
1867 /// the function declaration, which may be non-dependent even when the
1868 /// function declaration itself is dependent. This flag indicates when we
1869 /// know that the lambda is dependent despite that.
1870 bool isDependentLambda() const {
1871 return isLambda() && getLambdaData().DependencyKind == LDK_AlwaysDependent;
1872 }
1873
1875 return isLambda() && getLambdaData().DependencyKind == LDK_NeverDependent;
1876 }
1877
1878 unsigned getLambdaDependencyKind() const {
1879 if (!isLambda())
1880 return LDK_Unknown;
1881 return getLambdaData().DependencyKind;
1882 }
1883
1885 return getLambdaData().MethodTyInfo;
1886 }
1887
1889 assert(DefinitionData && DefinitionData->IsLambda &&
1890 "setting lambda property of non-lambda class");
1891 auto &DL = static_cast<LambdaDefinitionData &>(*DefinitionData);
1892 DL.MethodTyInfo = TS;
1893 }
1894
1895 void setLambdaDependencyKind(unsigned Kind) {
1896 getLambdaData().DependencyKind = Kind;
1897 }
1898
1899 void setLambdaIsGeneric(bool IsGeneric) {
1900 assert(DefinitionData && DefinitionData->IsLambda &&
1901 "setting lambda property of non-lambda class");
1902 auto &DL = static_cast<LambdaDefinitionData &>(*DefinitionData);
1903 DL.IsGenericLambda = IsGeneric;
1904 }
1905
1906 /// Determines whether this declaration represents the
1907 /// injected class name.
1908 ///
1909 /// The injected class name in C++ is the name of the class that
1910 /// appears inside the class itself. For example:
1911 ///
1912 /// \code
1913 /// struct C {
1914 /// // C is implicitly declared here as a synonym for the class name.
1915 /// };
1916 ///
1917 /// C::C c; // same as "C c;"
1918 /// \endcode
1919 bool isInjectedClassName() const;
1920
1921 /// Determines whether this declaration has is canonically of an injected
1922 /// class type. These are non-instantiated class template patterns, which can
1923 /// be used from within the class template itself. For example:
1924 ///
1925 /// \code
1926 /// template<class T> struct C {
1927 /// C *t; // Here `C *` is a pointer to an injected class type.
1928 /// };
1929 /// \endcode
1930 bool hasInjectedClassType() const;
1931
1934
1935 // Determine whether this type is an Interface Like type for
1936 // __interface inheritance purposes.
1937 bool isInterfaceLike() const;
1938
1939 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1940 static bool classofKind(Kind K) {
1941 return K >= firstCXXRecord && K <= lastCXXRecord;
1942 }
1943 void markAbstract() { data().Abstract = true; }
1944};
1945
1946/// Store information needed for an explicit specifier.
1947/// Used by CXXDeductionGuideDecl, CXXConstructorDecl and CXXConversionDecl.
1949 llvm::PointerIntPair<Expr *, 2, ExplicitSpecKind> ExplicitSpec{
1951
1952public:
1955 : ExplicitSpec(Expression, Kind) {}
1956 ExplicitSpecKind getKind() const { return ExplicitSpec.getInt(); }
1957 const Expr *getExpr() const { return ExplicitSpec.getPointer(); }
1958 Expr *getExpr() { return ExplicitSpec.getPointer(); }
1959
1960 /// Determine if the declaration had an explicit specifier of any kind.
1961 bool isSpecified() const {
1962 return ExplicitSpec.getInt() != ExplicitSpecKind::ResolvedFalse ||
1963 ExplicitSpec.getPointer();
1964 }
1965
1966 /// Check for equivalence of explicit specifiers.
1967 /// \return true if the explicit specifier are equivalent, false otherwise.
1969 /// Determine whether this specifier is known to correspond to an explicit
1970 /// declaration. Returns false if the specifier is absent or has an
1971 /// expression that is value-dependent or evaluates to false.
1972 bool isExplicit() const {
1973 return ExplicitSpec.getInt() == ExplicitSpecKind::ResolvedTrue;
1974 }
1975 /// Determine if the explicit specifier is invalid.
1976 /// This state occurs after a substitution failures.
1977 bool isInvalid() const {
1978 return ExplicitSpec.getInt() == ExplicitSpecKind::Unresolved &&
1979 !ExplicitSpec.getPointer();
1980 }
1981 void setKind(ExplicitSpecKind Kind) { ExplicitSpec.setInt(Kind); }
1982 void setExpr(Expr *E) { ExplicitSpec.setPointer(E); }
1983 // Retrieve the explicit specifier in the given declaration, if any.
1988};
1989
1990/// Represents a C++ deduction guide declaration.
1991///
1992/// \code
1993/// template<typename T> struct A { A(); A(T); };
1994/// A() -> A<int>;
1995/// \endcode
1996///
1997/// In this example, there will be an explicit deduction guide from the
1998/// second line, and implicit deduction guide templates synthesized from
1999/// the constructors of \c A.
2000class CXXDeductionGuideDecl : public FunctionDecl {
2001 void anchor() override;
2002
2003public:
2004 // Represents the relationship between this deduction guide and the
2005 // deduction guide that it was generated from (or lack thereof).
2006 // See the SourceDeductionGuide member for more details.
2011
2012private:
2015 const DeclarationNameInfo &NameInfo, QualType T,
2016 TypeSourceInfo *TInfo, SourceLocation EndLocation,
2018 const AssociatedConstraint &TrailingRequiresClause,
2019 const CXXDeductionGuideDecl *GeneratedFrom,
2020 SourceDeductionGuideKind SourceKind)
2021 : FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo,
2023 TrailingRequiresClause),
2024 Ctor(Ctor), ExplicitSpec(ES),
2025 SourceDeductionGuide(GeneratedFrom, SourceKind) {
2026 if (EndLocation.isValid())
2027 setRangeEnd(EndLocation);
2029 }
2030
2031 CXXConstructorDecl *Ctor;
2032 ExplicitSpecifier ExplicitSpec;
2033 // The deduction guide, if any, that this deduction guide was generated from,
2034 // in the case of alias template deduction. The SourceDeductionGuideKind
2035 // member indicates which of these sources applies, or is None otherwise.
2036 llvm::PointerIntPair<const CXXDeductionGuideDecl *, 2,
2038 SourceDeductionGuide;
2039 void setExplicitSpecifier(ExplicitSpecifier ES) { ExplicitSpec = ES; }
2040
2041public:
2042 friend class ASTDeclReader;
2043 friend class ASTDeclWriter;
2044
2045 static CXXDeductionGuideDecl *
2047 ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T,
2048 TypeSourceInfo *TInfo, SourceLocation EndLocation,
2049 CXXConstructorDecl *Ctor = nullptr,
2051 const AssociatedConstraint &TrailingRequiresClause = {},
2052 const CXXDeductionGuideDecl *SourceDG = nullptr,
2054
2056 GlobalDeclID ID);
2057
2058 ExplicitSpecifier getExplicitSpecifier() const { return ExplicitSpec; }
2059
2060 /// Return true if the declaration is already resolved to be explicit.
2061 bool isExplicit() const { return ExplicitSpec.isExplicit(); }
2062
2063 /// Get the template for which this guide performs deduction.
2067
2068 /// Get the constructor from which this deduction guide was generated, if
2069 /// this is an implicit deduction guide.
2071
2072 /// Get the deduction guide from which this deduction guide was generated,
2073 /// if it was generated as part of alias template deduction or from an
2074 /// inherited constructor.
2075 const CXXDeductionGuideDecl *getSourceDeductionGuide() const {
2076 return SourceDeductionGuide.getPointer();
2077 }
2078
2079 void setSourceDeductionGuide(CXXDeductionGuideDecl *DG) {
2080 SourceDeductionGuide.setPointer(DG);
2081 }
2082
2084 return SourceDeductionGuide.getInt();
2085 }
2086
2088 SourceDeductionGuide.setInt(SK);
2089 }
2090
2092 FunctionDeclBits.DeductionCandidateKind = static_cast<unsigned char>(K);
2093 }
2094
2096 return static_cast<DeductionCandidate>(
2097 FunctionDeclBits.DeductionCandidateKind);
2098 }
2099
2100 // Implement isa/cast/dyncast/etc.
2101 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2102 static bool classofKind(Kind K) { return K == CXXDeductionGuide; }
2103};
2104
2105/// \brief Represents the body of a requires-expression.
2106///
2107/// This decl exists merely to serve as the DeclContext for the local
2108/// parameters of the requires expression as well as other declarations inside
2109/// it.
2110///
2111/// \code
2112/// template<typename T> requires requires (T t) { {t++} -> regular; }
2113/// \endcode
2114///
2115/// In this example, a RequiresExpr object will be generated for the expression,
2116/// and a RequiresExprBodyDecl will be created to hold the parameter t and the
2117/// template argument list imposed by the compound requirement.
2118class RequiresExprBodyDecl : public Decl, public DeclContext {
2119 RequiresExprBodyDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc)
2120 : Decl(RequiresExprBody, DC, StartLoc), DeclContext(RequiresExprBody) {}
2121
2122public:
2123 friend class ASTDeclReader;
2124 friend class ASTDeclWriter;
2125
2126 static RequiresExprBodyDecl *Create(ASTContext &C, DeclContext *DC,
2127 SourceLocation StartLoc);
2128
2129 static RequiresExprBodyDecl *CreateDeserialized(ASTContext &C,
2130 GlobalDeclID ID);
2131
2132 // Implement isa/cast/dyncast/etc.
2133 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2134 static bool classofKind(Kind K) { return K == RequiresExprBody; }
2135
2136 static DeclContext *castToDeclContext(const RequiresExprBodyDecl *D) {
2137 return static_cast<DeclContext *>(const_cast<RequiresExprBodyDecl *>(D));
2138 }
2139
2140 static RequiresExprBodyDecl *castFromDeclContext(const DeclContext *DC) {
2141 return static_cast<RequiresExprBodyDecl *>(const_cast<DeclContext *>(DC));
2142 }
2143};
2144
2145/// Represents a static or instance method of a struct/union/class.
2146///
2147/// In the terminology of the C++ Standard, these are the (static and
2148/// non-static) member functions, whether virtual or not.
2150 void anchor() override;
2151
2152protected:
2154 SourceLocation StartLoc, const DeclarationNameInfo &NameInfo,
2156 bool UsesFPIntrin, bool isInline,
2157 ConstexprSpecKind ConstexprKind, SourceLocation EndLocation,
2158 const AssociatedConstraint &TrailingRequiresClause = {})
2159 : FunctionDecl(DK, C, RD, StartLoc, NameInfo, T, TInfo, SC, UsesFPIntrin,
2160 isInline, ConstexprKind, TrailingRequiresClause) {
2161 if (EndLocation.isValid())
2162 setRangeEnd(EndLocation);
2163 }
2164
2165public:
2166 static CXXMethodDecl *
2167 Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
2168 const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo,
2169 StorageClass SC, bool UsesFPIntrin, bool isInline,
2170 ConstexprSpecKind ConstexprKind, SourceLocation EndLocation,
2171 const AssociatedConstraint &TrailingRequiresClause = {});
2172
2173 static CXXMethodDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
2174
2175 bool isStatic() const;
2176 bool isInstance() const { return !isStatic(); }
2177
2178 /// [C++2b][dcl.fct]/p7
2179 /// An explicit object member function is a non-static
2180 /// member function with an explicit object parameter. e.g.,
2181 /// void func(this SomeType);
2182 bool isExplicitObjectMemberFunction() const;
2183
2184 /// [C++2b][dcl.fct]/p7
2185 /// An implicit object member function is a non-static
2186 /// member function without an explicit object parameter.
2187 bool isImplicitObjectMemberFunction() const;
2188
2189 /// Returns true if the given operator is implicitly static in a record
2190 /// context.
2192 // [class.free]p1:
2193 // Any allocation function for a class T is a static member
2194 // (even if not explicitly declared static).
2195 // [class.free]p6 Any deallocation function for a class X is a static member
2196 // (even if not explicitly declared static).
2197 return OOK == OO_New || OOK == OO_Array_New || OOK == OO_Delete ||
2198 OOK == OO_Array_Delete;
2199 }
2200
2201 bool isConst() const { return getType()->castAs<FunctionType>()->isConst(); }
2202 bool isVolatile() const { return getType()->castAs<FunctionType>()->isVolatile(); }
2203
2204 bool isVirtual() const {
2205 CXXMethodDecl *CD = const_cast<CXXMethodDecl*>(this)->getCanonicalDecl();
2206
2207 // Member function is virtual if it is marked explicitly so, or if it is
2208 // declared in __interface -- then it is automatically pure virtual.
2209 if (CD->isVirtualAsWritten() || CD->isPureVirtual())
2210 return true;
2211
2212 return CD->size_overridden_methods() != 0;
2213 }
2214
2215 /// If it's possible to devirtualize a call to this method, return the called
2216 /// function. Otherwise, return null.
2217
2218 /// \param Base The object on which this virtual function is called.
2219 /// \param IsAppleKext True if we are compiling for Apple kext.
2220 CXXMethodDecl *getDevirtualizedMethod(const Expr *Base, bool IsAppleKext);
2221
2223 bool IsAppleKext) const {
2224 return const_cast<CXXMethodDecl *>(this)->getDevirtualizedMethod(
2225 Base, IsAppleKext);
2226 }
2227
2231
2232 /// Determine whether this is a usual deallocation function (C++
2233 /// [basic.stc.dynamic.deallocation]p2), which is an overloaded delete or
2234 /// delete[] operator with a particular signature. Populates \p PreventedBy
2235 /// with the declarations of the functions of the same kind if they were the
2236 /// reason for this function returning false. This is used by
2237 /// Sema::isUsualDeallocationFunction to reconsider the answer based on the
2238 /// context.
2240 SmallVectorImpl<const FunctionDecl *> &PreventedBy) const;
2241
2242 /// Determine whether this is a copy-assignment operator, regardless
2243 /// of whether it was declared implicitly or explicitly.
2244 bool isCopyAssignmentOperator() const;
2245
2246 /// Determine whether this is a move assignment operator.
2247 bool isMoveAssignmentOperator() const;
2248
2249 /// Determine whether this is a copy or move constructor or a copy or move
2250 /// assignment operator.
2252
2253 /// Determine whether this is a copy or move constructor. Always returns
2254 /// false for non-constructor methods; see also
2255 /// CXXConstructorDecl::isCopyOrMoveConstructor().
2256 bool isCopyOrMoveConstructor() const;
2257
2258 /// Returns whether this is a copy/move constructor or assignment operator
2259 /// that can be implemented as a memcpy of the object representation.
2260 bool isMemcpyEquivalentSpecialMember(const ASTContext &Ctx) const;
2261
2266 return const_cast<CXXMethodDecl*>(this)->getCanonicalDecl();
2267 }
2268
2270 return cast<CXXMethodDecl>(
2271 static_cast<FunctionDecl *>(this)->getMostRecentDecl());
2272 }
2274 return const_cast<CXXMethodDecl*>(this)->getMostRecentDecl();
2275 }
2276
2277 void addOverriddenMethod(const CXXMethodDecl *MD);
2278
2279 using method_iterator = const CXXMethodDecl *const *;
2280
2283 unsigned size_overridden_methods() const;
2284
2285 using overridden_method_range = llvm::iterator_range<
2286 llvm::TinyPtrVector<const CXXMethodDecl *>::const_iterator>;
2287
2289
2290 /// Return the parent of this method declaration, which
2291 /// is the class in which this method is defined.
2295
2296 /// Return the parent of this method declaration, which
2297 /// is the class in which this method is defined.
2299 return const_cast<CXXRecordDecl *>(
2301 }
2302
2303 /// Return the type of the \c this pointer.
2304 ///
2305 /// Should only be called for instance (i.e., non-static) methods. Note
2306 /// that for the call operator of a lambda closure type, this returns the
2307 /// desugared 'this' type (a pointer to the closure type), not the captured
2308 /// 'this' type.
2309 QualType getThisType() const;
2310
2311 /// Return the type of the object pointed by \c this.
2312 ///
2313 /// See getThisType() for usage restriction.
2314
2319
2320 unsigned getNumExplicitParams() const {
2321 return getNumParams() - (isExplicitObjectMemberFunction() ? 1 : 0);
2322 }
2323
2324 static QualType getThisType(const FunctionProtoType *FPT,
2325 const CXXRecordDecl *Decl);
2326
2328 return getType()->castAs<FunctionProtoType>()->getMethodQuals();
2329 }
2330
2331 /// Retrieve the ref-qualifier associated with this method.
2332 ///
2333 /// In the following example, \c f() has an lvalue ref-qualifier, \c g()
2334 /// has an rvalue ref-qualifier, and \c h() has no ref-qualifier.
2335 /// @code
2336 /// struct X {
2337 /// void f() &;
2338 /// void g() &&;
2339 /// void h();
2340 /// };
2341 /// @endcode
2345
2346 bool hasInlineBody() const;
2347
2348 /// Determine whether this is a lambda closure type's static member
2349 /// function that is used for the result of the lambda's conversion to
2350 /// function pointer (for a lambda with no captures).
2351 ///
2352 /// The function itself, if used, will have a placeholder body that will be
2353 /// supplied by IR generation to either forward to the function call operator
2354 /// or clone the function call operator.
2355 bool isLambdaStaticInvoker() const;
2356
2357 /// Find the method in \p RD that corresponds to this one.
2358 ///
2359 /// Find if \p RD or one of the classes it inherits from override this method.
2360 /// If so, return it. \p RD is assumed to be a subclass of the class defining
2361 /// this method (or be the class itself), unless \p MayBeBase is set to true.
2364 bool MayBeBase = false);
2365
2366 const CXXMethodDecl *
2368 bool MayBeBase = false) const {
2369 return const_cast<CXXMethodDecl *>(this)
2370 ->getCorrespondingMethodInClass(RD, MayBeBase);
2371 }
2372
2373 /// Find if \p RD declares a function that overrides this function, and if so,
2374 /// return it. Does not search base classes.
2376 bool MayBeBase = false);
2377 const CXXMethodDecl *
2379 bool MayBeBase = false) const {
2380 return const_cast<CXXMethodDecl *>(this)
2382 }
2383
2384 // Implement isa/cast/dyncast/etc.
2385 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2386 static bool classofKind(Kind K) {
2387 return K >= firstCXXMethod && K <= lastCXXMethod;
2388 }
2389};
2390
2391/// Represents a C++ base or member initializer.
2392///
2393/// This is part of a constructor initializer that
2394/// initializes one non-static member variable or one base class. For
2395/// example, in the following, both 'A(a)' and 'f(3.14159)' are member
2396/// initializers:
2397///
2398/// \code
2399/// class A { };
2400/// class B : public A {
2401/// float f;
2402/// public:
2403/// B(A& a) : A(a), f(3.14159) { }
2404/// };
2405/// \endcode
2407 /// Either the base class name/delegating constructor type (stored as
2408 /// a TypeSourceInfo*), an normal field (FieldDecl), or an anonymous field
2409 /// (IndirectFieldDecl*) being initialized.
2410 llvm::PointerUnion<TypeSourceInfo *, FieldDecl *, IndirectFieldDecl *>
2411 Initializee;
2412
2413 /// The argument used to initialize the base or member, which may
2414 /// end up constructing an object (when multiple arguments are involved).
2415 Stmt *Init;
2416
2417 /// The source location for the field name or, for a base initializer
2418 /// pack expansion, the location of the ellipsis.
2419 ///
2420 /// In the case of a delegating
2421 /// constructor, it will still include the type's source location as the
2422 /// Initializee points to the CXXConstructorDecl (to allow loop detection).
2423 SourceLocation MemberOrEllipsisLocation;
2424
2425 /// Location of the left paren of the ctor-initializer.
2426 SourceLocation LParenLoc;
2427
2428 /// Location of the right paren of the ctor-initializer.
2429 SourceLocation RParenLoc;
2430
2431 /// If the initializee is a type, whether that type makes this
2432 /// a delegating initialization.
2433 LLVM_PREFERRED_TYPE(bool)
2434 unsigned IsDelegating : 1;
2435
2436 /// If the initializer is a base initializer, this keeps track
2437 /// of whether the base is virtual or not.
2438 LLVM_PREFERRED_TYPE(bool)
2439 unsigned IsVirtual : 1;
2440
2441 /// Whether or not the initializer is explicitly written
2442 /// in the sources.
2443 LLVM_PREFERRED_TYPE(bool)
2444 unsigned IsWritten : 1;
2445
2446 /// If IsWritten is true, then this number keeps track of the textual order
2447 /// of this initializer in the original sources, counting from 0.
2448 unsigned SourceOrder : 13;
2449
2450public:
2451 /// Creates a new base-class initializer.
2452 explicit
2453 CXXCtorInitializer(ASTContext &Context, TypeSourceInfo *TInfo, bool IsVirtual,
2455 SourceLocation EllipsisLoc);
2456
2457 /// Creates a new member initializer.
2458 explicit
2460 SourceLocation MemberLoc, SourceLocation L, Expr *Init,
2461 SourceLocation R);
2462
2463 /// Creates a new anonymous field initializer.
2464 explicit
2466 SourceLocation MemberLoc, SourceLocation L, Expr *Init,
2467 SourceLocation R);
2468
2469 /// Creates a new delegating initializer.
2470 explicit
2472 SourceLocation L, Expr *Init, SourceLocation R);
2473
2474 /// \return Unique reproducible object identifier.
2475 int64_t getID(const ASTContext &Context) const;
2476
2477 /// Determine whether this initializer is initializing a base class.
2478 bool isBaseInitializer() const {
2479 return isa<TypeSourceInfo *>(Initializee) && !IsDelegating;
2480 }
2481
2482 /// Determine whether this initializer is initializing a non-static
2483 /// data member.
2484 bool isMemberInitializer() const { return isa<FieldDecl *>(Initializee); }
2485
2489
2491 return isa<IndirectFieldDecl *>(Initializee);
2492 }
2493
2494 /// Determine whether this initializer is an implicit initializer
2495 /// generated for a field with an initializer defined on the member
2496 /// declaration.
2497 ///
2498 /// In-class member initializers (also known as "non-static data member
2499 /// initializations", NSDMIs) were introduced in C++11.
2501 return Init->getStmtClass() == Stmt::CXXDefaultInitExprClass;
2502 }
2503
2504 /// Determine whether this initializer is creating a delegating
2505 /// constructor.
2507 return isa<TypeSourceInfo *>(Initializee) && IsDelegating;
2508 }
2509
2510 /// Determine whether this initializer is a pack expansion.
2511 bool isPackExpansion() const {
2512 return isBaseInitializer() && MemberOrEllipsisLocation.isValid();
2513 }
2514
2515 // For a pack expansion, returns the location of the ellipsis.
2517 if (!isPackExpansion())
2518 return {};
2519 return MemberOrEllipsisLocation;
2520 }
2521
2522 /// If this is a base class initializer, returns the type of the
2523 /// base class with location information. Otherwise, returns an NULL
2524 /// type location.
2525 TypeLoc getBaseClassLoc() const;
2526
2527 /// If this is a base class initializer, returns the type of the base class.
2528 /// Otherwise, returns null.
2529 const Type *getBaseClass() const;
2530
2531 /// Returns whether the base is virtual or not.
2532 bool isBaseVirtual() const {
2533 assert(isBaseInitializer() && "Must call this on base initializer!");
2534
2535 return IsVirtual;
2536 }
2537
2538 /// Returns the declarator information for a base class or delegating
2539 /// initializer.
2541 return Initializee.dyn_cast<TypeSourceInfo *>();
2542 }
2543
2544 /// If this is a member initializer, returns the declaration of the
2545 /// non-static data member being initialized. Otherwise, returns null.
2547 if (isMemberInitializer())
2548 return cast<FieldDecl *>(Initializee);
2549 return nullptr;
2550 }
2551
2553 if (isMemberInitializer())
2554 return cast<FieldDecl *>(Initializee);
2556 return cast<IndirectFieldDecl *>(Initializee)->getAnonField();
2557 return nullptr;
2558 }
2559
2562 return cast<IndirectFieldDecl *>(Initializee);
2563 return nullptr;
2564 }
2565
2567 return MemberOrEllipsisLocation;
2568 }
2569
2570 /// Determine the source location of the initializer.
2572
2573 /// Determine the source range covering the entire initializer.
2574 SourceRange getSourceRange() const LLVM_READONLY;
2575
2576 /// Determine whether this initializer is explicitly written
2577 /// in the source code.
2578 bool isWritten() const { return IsWritten; }
2579
2580 /// Return the source position of the initializer, counting from 0.
2581 /// If the initializer was implicit, -1 is returned.
2582 int getSourceOrder() const {
2583 return IsWritten ? static_cast<int>(SourceOrder) : -1;
2584 }
2585
2586 /// Set the source order of this initializer.
2587 ///
2588 /// This can only be called once for each initializer; it cannot be called
2589 /// on an initializer having a positive number of (implicit) array indices.
2590 ///
2591 /// This assumes that the initializer was written in the source code, and
2592 /// ensures that isWritten() returns true.
2593 void setSourceOrder(int Pos) {
2594 assert(!IsWritten &&
2595 "setSourceOrder() used on implicit initializer");
2596 assert(SourceOrder == 0 &&
2597 "calling twice setSourceOrder() on the same initializer");
2598 assert(Pos >= 0 &&
2599 "setSourceOrder() used to make an initializer implicit");
2600 IsWritten = true;
2601 SourceOrder = static_cast<unsigned>(Pos);
2602 }
2603
2604 SourceLocation getLParenLoc() const { return LParenLoc; }
2605 SourceLocation getRParenLoc() const { return RParenLoc; }
2606
2607 /// Get the initializer.
2608 Expr *getInit() const { return static_cast<Expr *>(Init); }
2609};
2610
2611/// Description of a constructor that was inherited from a base class.
2613 ConstructorUsingShadowDecl *Shadow = nullptr;
2614 CXXConstructorDecl *BaseCtor = nullptr;
2615
2616public:
2619 CXXConstructorDecl *BaseCtor)
2620 : Shadow(Shadow), BaseCtor(BaseCtor) {}
2621
2622 explicit operator bool() const { return Shadow; }
2623
2624 ConstructorUsingShadowDecl *getShadowDecl() const { return Shadow; }
2625 CXXConstructorDecl *getConstructor() const { return BaseCtor; }
2626};
2627
2628/// Represents a C++ constructor within a class.
2629///
2630/// For example:
2631///
2632/// \code
2633/// class X {
2634/// public:
2635/// explicit X(int); // represented by a CXXConstructorDecl.
2636/// };
2637/// \endcode
2638class CXXConstructorDecl final
2639 : public CXXMethodDecl,
2640 private llvm::TrailingObjects<CXXConstructorDecl, InheritedConstructor,
2641 ExplicitSpecifier> {
2642 // This class stores some data in DeclContext::CXXConstructorDeclBits
2643 // to save some space. Use the provided accessors to access it.
2644
2645 /// \name Support for base and member initializers.
2646 /// \{
2647 /// The arguments used to initialize the base or member.
2648 LazyCXXCtorInitializersPtr CtorInitializers;
2649
2650 CXXConstructorDecl(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
2651 const DeclarationNameInfo &NameInfo, QualType T,
2653 bool UsesFPIntrin, bool isInline,
2654 bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind,
2655 InheritedConstructor Inherited,
2656 const AssociatedConstraint &TrailingRequiresClause);
2657
2658 void anchor() override;
2659
2660 size_t numTrailingObjects(OverloadToken<InheritedConstructor>) const {
2661 return CXXConstructorDeclBits.IsInheritingConstructor;
2662 }
2663
2664 ExplicitSpecifier getExplicitSpecifierInternal() const {
2665 if (CXXConstructorDeclBits.HasTrailingExplicitSpecifier)
2666 return *getTrailingObjects<ExplicitSpecifier>();
2667 return ExplicitSpecifier(
2668 nullptr, CXXConstructorDeclBits.IsSimpleExplicit
2671 }
2672
2673 enum TrailingAllocKind {
2674 TAKInheritsConstructor = 1,
2675 TAKHasTailExplicit = 1 << 1,
2676 };
2677
2678 uint64_t getTrailingAllocKind() const {
2679 uint64_t Kind = 0;
2680 if (CXXConstructorDeclBits.IsInheritingConstructor)
2681 Kind |= TAKInheritsConstructor;
2682 if (CXXConstructorDeclBits.HasTrailingExplicitSpecifier)
2683 Kind |= TAKHasTailExplicit;
2684 return Kind;
2685 }
2686
2687public:
2688 friend class ASTDeclReader;
2689 friend class ASTDeclWriter;
2691
2692 static CXXConstructorDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID,
2693 uint64_t AllocKind);
2694 static CXXConstructorDecl *
2696 const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo,
2697 ExplicitSpecifier ES, bool UsesFPIntrin, bool isInline,
2698 bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind,
2700 const AssociatedConstraint &TrailingRequiresClause = {});
2701
2703 assert((!ES.getExpr() ||
2704 CXXConstructorDeclBits.HasTrailingExplicitSpecifier) &&
2705 "cannot set this explicit specifier. no trail-allocated space for "
2706 "explicit");
2707 if (ES.getExpr())
2708 *getCanonicalDecl()->getTrailingObjects<ExplicitSpecifier>() = ES;
2709 else
2710 CXXConstructorDeclBits.IsSimpleExplicit = ES.isExplicit();
2711 }
2712
2714 return getCanonicalDecl()->getExplicitSpecifierInternal();
2715 }
2716
2717 /// Return true if the declaration is already resolved to be explicit.
2718 bool isExplicit() const { return getExplicitSpecifier().isExplicit(); }
2719
2720 /// Iterates through the member/base initializer list.
2722
2723 /// Iterates through the member/base initializer list.
2725
2726 using init_range = llvm::iterator_range<init_iterator>;
2727 using init_const_range = llvm::iterator_range<init_const_iterator>;
2728
2732 }
2733
2734 /// Retrieve an iterator to the first initializer.
2736 const auto *ConstThis = this;
2737 return const_cast<init_iterator>(ConstThis->init_begin());
2738 }
2739
2740 /// Retrieve an iterator to the first initializer.
2742
2743 /// Retrieve an iterator past the last initializer.
2747
2748 /// Retrieve an iterator past the last initializer.
2752
2753 using init_reverse_iterator = std::reverse_iterator<init_iterator>;
2755 std::reverse_iterator<init_const_iterator>;
2756
2763
2770
2771 /// Determine the number of arguments used to initialize the member
2772 /// or base.
2773 unsigned getNumCtorInitializers() const {
2774 return CXXConstructorDeclBits.NumCtorInitializers;
2775 }
2776
2777 void setNumCtorInitializers(unsigned numCtorInitializers) {
2778 CXXConstructorDeclBits.NumCtorInitializers = numCtorInitializers;
2779 // This assert added because NumCtorInitializers is stored
2780 // in CXXConstructorDeclBits as a bitfield and its width has
2781 // been shrunk from 32 bits to fit into CXXConstructorDeclBitfields.
2782 assert(CXXConstructorDeclBits.NumCtorInitializers ==
2783 numCtorInitializers && "NumCtorInitializers overflow!");
2784 }
2785
2787 CtorInitializers = Initializers;
2788 }
2789
2790 /// Determine whether this constructor is a delegating constructor.
2792 return (getNumCtorInitializers() == 1) &&
2794 }
2795
2796 /// When this constructor delegates to another, retrieve the target.
2798
2799 /// Whether this constructor is a default
2800 /// constructor (C++ [class.ctor]p5), which can be used to
2801 /// default-initialize a class of this type.
2802 bool isDefaultConstructor() const;
2803
2804 /// Whether this constructor is a copy constructor (C++ [class.copy]p2,
2805 /// which can be used to copy the class.
2806 ///
2807 /// \p TypeQuals will be set to the qualifiers on the
2808 /// argument type. For example, \p TypeQuals would be set to \c
2809 /// Qualifiers::Const for the following copy constructor:
2810 ///
2811 /// \code
2812 /// class X {
2813 /// public:
2814 /// X(const X&);
2815 /// };
2816 /// \endcode
2817 bool isCopyConstructor(unsigned &TypeQuals) const;
2818
2819 /// Whether this constructor is a copy
2820 /// constructor (C++ [class.copy]p2, which can be used to copy the
2821 /// class.
2822 bool isCopyConstructor() const {
2823 unsigned TypeQuals = 0;
2824 return isCopyConstructor(TypeQuals);
2825 }
2826
2827 /// Determine whether this constructor is a move constructor
2828 /// (C++11 [class.copy]p3), which can be used to move values of the class.
2829 ///
2830 /// \param TypeQuals If this constructor is a move constructor, will be set
2831 /// to the type qualifiers on the referent of the first parameter's type.
2832 bool isMoveConstructor(unsigned &TypeQuals) const;
2833
2834 /// Determine whether this constructor is a move constructor
2835 /// (C++11 [class.copy]p3), which can be used to move values of the class.
2836 bool isMoveConstructor() const {
2837 unsigned TypeQuals = 0;
2838 return isMoveConstructor(TypeQuals);
2839 }
2840
2841 /// Determine whether this is a copy or move constructor.
2842 ///
2843 /// \param TypeQuals Will be set to the type qualifiers on the reference
2844 /// parameter, if in fact this is a copy or move constructor.
2845 bool isCopyOrMoveConstructor(unsigned &TypeQuals) const;
2846
2847 /// Determine whether this a copy or move constructor.
2849 unsigned Quals;
2850 return isCopyOrMoveConstructor(Quals);
2851 }
2852
2853 /// Whether this constructor is a
2854 /// converting constructor (C++ [class.conv.ctor]), which can be
2855 /// used for user-defined conversions.
2856 bool isConvertingConstructor(bool AllowExplicit) const;
2857
2858 /// Determine whether this is a member template specialization that
2859 /// would copy the object to itself. Such constructors are never used to copy
2860 /// an object.
2861 bool isSpecializationCopyingObject() const;
2862
2863 /// Determine whether this is an implicit constructor synthesized to
2864 /// model a call to a constructor inherited from a base class.
2866 return CXXConstructorDeclBits.IsInheritingConstructor;
2867 }
2868
2869 /// State that this is an implicit constructor synthesized to
2870 /// model a call to a constructor inherited from a base class.
2871 void setInheritingConstructor(bool isIC = true) {
2872 CXXConstructorDeclBits.IsInheritingConstructor = isIC;
2873 }
2874
2875 /// Get the constructor that this inheriting constructor is based on.
2877 return isInheritingConstructor() ?
2878 *getTrailingObjects<InheritedConstructor>() : InheritedConstructor();
2879 }
2880
2881 CXXConstructorDecl *getCanonicalDecl() override {
2883 }
2884 const CXXConstructorDecl *getCanonicalDecl() const {
2885 return const_cast<CXXConstructorDecl*>(this)->getCanonicalDecl();
2886 }
2887
2890
2891 // Implement isa/cast/dyncast/etc.
2892 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2893 static bool classofKind(Kind K) { return K == CXXConstructor; }
2894};
2895
2896/// Represents a C++ destructor within a class.
2897///
2898/// For example:
2899///
2900/// \code
2901/// class X {
2902/// public:
2903/// ~X(); // represented by a CXXDestructorDecl.
2904/// };
2905/// \endcode
2906class CXXDestructorDecl : public CXXMethodDecl {
2907 friend class ASTDeclReader;
2908 friend class ASTDeclWriter;
2909
2910 // FIXME: Don't allocate storage for these except in the first declaration
2911 // of a virtual destructor.
2912 Expr *OperatorDeleteThisArg = nullptr;
2913
2914 CXXDestructorDecl(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
2915 const DeclarationNameInfo &NameInfo, QualType T,
2916 TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline,
2917 bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind,
2918 const AssociatedConstraint &TrailingRequiresClause = {})
2919 : CXXMethodDecl(CXXDestructor, C, RD, StartLoc, NameInfo, T, TInfo,
2920 SC_None, UsesFPIntrin, isInline, ConstexprKind,
2921 SourceLocation(), TrailingRequiresClause) {
2922 setImplicit(isImplicitlyDeclared);
2923 }
2924
2925 void anchor() override;
2926
2927public:
2928 static CXXDestructorDecl *
2929 Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
2930 const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo,
2931 bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared,
2932 ConstexprSpecKind ConstexprKind,
2933 const AssociatedConstraint &TrailingRequiresClause = {});
2934 static CXXDestructorDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
2935
2936 void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg);
2940 const FunctionDecl *getOperatorDelete() const;
2942 const FunctionDecl *getArrayOperatorDelete() const;
2944
2946 return getCanonicalDecl()->OperatorDeleteThisArg;
2947 }
2948
2949 /// Will this destructor ever be called when considering which deallocation
2950 /// function is associated with the destructor? Can optionally be passed an
2951 /// 'operator delete' function declaration to test against specifically.
2952 bool isCalledByDelete(const FunctionDecl *OpDel = nullptr) const;
2953
2954 CXXDestructorDecl *getCanonicalDecl() override {
2956 }
2957 const CXXDestructorDecl *getCanonicalDecl() const {
2958 return const_cast<CXXDestructorDecl*>(this)->getCanonicalDecl();
2959 }
2960
2961 // Implement isa/cast/dyncast/etc.
2962 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2963 static bool classofKind(Kind K) { return K == CXXDestructor; }
2964};
2965
2966/// Represents a C++ conversion function within a class.
2967///
2968/// For example:
2969///
2970/// \code
2971/// class X {
2972/// public:
2973/// operator bool();
2974/// };
2975/// \endcode
2976class CXXConversionDecl : public CXXMethodDecl {
2977 CXXConversionDecl(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
2978 const DeclarationNameInfo &NameInfo, QualType T,
2979 TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline,
2980 ExplicitSpecifier ES, ConstexprSpecKind ConstexprKind,
2981 SourceLocation EndLocation,
2982 const AssociatedConstraint &TrailingRequiresClause = {})
2983 : CXXMethodDecl(CXXConversion, C, RD, StartLoc, NameInfo, T, TInfo,
2984 SC_None, UsesFPIntrin, isInline, ConstexprKind,
2985 EndLocation, TrailingRequiresClause),
2986 ExplicitSpec(ES) {}
2987 void anchor() override;
2988
2989 ExplicitSpecifier ExplicitSpec;
2990
2991public:
2992 friend class ASTDeclReader;
2993 friend class ASTDeclWriter;
2994
2995 static CXXConversionDecl *
2997 const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo,
2998 bool UsesFPIntrin, bool isInline, ExplicitSpecifier ES,
2999 ConstexprSpecKind ConstexprKind, SourceLocation EndLocation,
3000 const AssociatedConstraint &TrailingRequiresClause = {});
3002
3004 return getCanonicalDecl()->ExplicitSpec;
3005 }
3006
3007 /// Return true if the declaration is already resolved to be explicit.
3008 bool isExplicit() const { return getExplicitSpecifier().isExplicit(); }
3009 void setExplicitSpecifier(ExplicitSpecifier ES) { ExplicitSpec = ES; }
3010
3011 /// Returns the type that this conversion function is converting to.
3013 return getType()->castAs<FunctionType>()->getReturnType();
3014 }
3015
3016 /// Determine whether this conversion function is a conversion from
3017 /// a lambda closure type to a block pointer.
3019
3020 CXXConversionDecl *getCanonicalDecl() override {
3022 }
3023 const CXXConversionDecl *getCanonicalDecl() const {
3024 return const_cast<CXXConversionDecl*>(this)->getCanonicalDecl();
3025 }
3026
3027 // Implement isa/cast/dyncast/etc.
3028 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3029 static bool classofKind(Kind K) { return K == CXXConversion; }
3030};
3031
3032/// Represents the language in a linkage specification.
3033///
3034/// The values are part of the serialization ABI for
3035/// ASTs and cannot be changed without altering that ABI.
3036enum class LinkageSpecLanguageIDs { C = 1, CXX = 2 };
3037
3038/// Represents a linkage specification.
3039///
3040/// For example:
3041/// \code
3042/// extern "C" void foo();
3043/// \endcode
3044class LinkageSpecDecl : public Decl, public DeclContext {
3045 virtual void anchor();
3046 // This class stores some data in DeclContext::LinkageSpecDeclBits to save
3047 // some space. Use the provided accessors to access it.
3048
3049 /// The source location for the extern keyword.
3050 SourceLocation ExternLoc;
3051
3052 /// The source location for the right brace (if valid).
3053 SourceLocation RBraceLoc;
3054
3055 LinkageSpecDecl(DeclContext *DC, SourceLocation ExternLoc,
3057 bool HasBraces);
3058
3059public:
3060 static LinkageSpecDecl *Create(ASTContext &C, DeclContext *DC,
3061 SourceLocation ExternLoc,
3062 SourceLocation LangLoc,
3063 LinkageSpecLanguageIDs Lang, bool HasBraces);
3064 static LinkageSpecDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
3065
3066 /// Return the language specified by this linkage specification.
3068 return static_cast<LinkageSpecLanguageIDs>(LinkageSpecDeclBits.Language);
3069 }
3070
3071 /// Set the language specified by this linkage specification.
3073 LinkageSpecDeclBits.Language = llvm::to_underlying(L);
3074 }
3075
3076 /// Determines whether this linkage specification had braces in
3077 /// its syntactic form.
3078 bool hasBraces() const {
3079 assert(!RBraceLoc.isValid() || LinkageSpecDeclBits.HasBraces);
3080 return LinkageSpecDeclBits.HasBraces;
3081 }
3082
3083 SourceLocation getExternLoc() const { return ExternLoc; }
3084 SourceLocation getRBraceLoc() const { return RBraceLoc; }
3085 void setExternLoc(SourceLocation L) { ExternLoc = L; }
3087 RBraceLoc = L;
3088 LinkageSpecDeclBits.HasBraces = RBraceLoc.isValid();
3089 }
3090
3091 SourceLocation getEndLoc() const LLVM_READONLY {
3092 if (hasBraces())
3093 return getRBraceLoc();
3094 // No braces: get the end location of the (only) declaration in context
3095 // (if present).
3096 return decls_empty() ? getLocation() : decls_begin()->getEndLoc();
3097 }
3098
3099 SourceRange getSourceRange() const override LLVM_READONLY {
3100 return SourceRange(ExternLoc, getEndLoc());
3101 }
3102
3103 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3104 static bool classofKind(Kind K) { return K == LinkageSpec; }
3105
3106 static DeclContext *castToDeclContext(const LinkageSpecDecl *D) {
3107 return static_cast<DeclContext *>(const_cast<LinkageSpecDecl*>(D));
3108 }
3109
3110 static LinkageSpecDecl *castFromDeclContext(const DeclContext *DC) {
3111 return static_cast<LinkageSpecDecl *>(const_cast<DeclContext*>(DC));
3112 }
3113};
3114
3115/// Represents C++ using-directive.
3116///
3117/// For example:
3118/// \code
3119/// using namespace std;
3120/// \endcode
3121///
3122/// \note UsingDirectiveDecl should be Decl not NamedDecl, but we provide
3123/// artificial names for all using-directives in order to store
3124/// them in DeclContext effectively.
3125class UsingDirectiveDecl : public NamedDecl {
3126 /// The location of the \c using keyword.
3127 SourceLocation UsingLoc;
3128
3129 /// The location of the \c namespace keyword.
3130 SourceLocation NamespaceLoc;
3131
3132 /// The nested-name-specifier that precedes the namespace.
3133 NestedNameSpecifierLoc QualifierLoc;
3134
3135 /// The namespace nominated by this using-directive.
3136 NamedDecl *NominatedNamespace;
3137
3138 /// Enclosing context containing both using-directive and nominated
3139 /// namespace.
3140 DeclContext *CommonAncestor;
3141
3142 UsingDirectiveDecl(DeclContext *DC, SourceLocation UsingLoc,
3143 SourceLocation NamespcLoc,
3144 NestedNameSpecifierLoc QualifierLoc,
3145 SourceLocation IdentLoc,
3146 NamedDecl *Nominated,
3147 DeclContext *CommonAncestor)
3148 : NamedDecl(UsingDirective, DC, IdentLoc, getName()), UsingLoc(UsingLoc),
3149 NamespaceLoc(NamespcLoc), QualifierLoc(QualifierLoc),
3150 NominatedNamespace(Nominated), CommonAncestor(CommonAncestor) {}
3151
3152 /// Returns special DeclarationName used by using-directives.
3153 ///
3154 /// This is only used by DeclContext for storing UsingDirectiveDecls in
3155 /// its lookup structure.
3156 static DeclarationName getName() {
3158 }
3159
3160 void anchor() override;
3161
3162public:
3163 friend class ASTDeclReader;
3164
3165 // Friend for getUsingDirectiveName.
3166 friend class DeclContext;
3167
3168 /// Retrieve the nested-name-specifier that qualifies the
3169 /// name of the namespace, with source-location information.
3170 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3171
3172 /// Retrieve the nested-name-specifier that qualifies the
3173 /// name of the namespace.
3175 return QualifierLoc.getNestedNameSpecifier();
3176 }
3177
3178 NamedDecl *getNominatedNamespaceAsWritten() { return NominatedNamespace; }
3180 return NominatedNamespace;
3181 }
3182
3183 /// Returns the namespace nominated by this using-directive.
3185
3187 return const_cast<UsingDirectiveDecl*>(this)->getNominatedNamespace();
3188 }
3189
3190 /// Returns the common ancestor context of this using-directive and
3191 /// its nominated namespace.
3192 DeclContext *getCommonAncestor() { return CommonAncestor; }
3193 const DeclContext *getCommonAncestor() const { return CommonAncestor; }
3194
3195 /// Return the location of the \c using keyword.
3196 SourceLocation getUsingLoc() const { return UsingLoc; }
3197
3198 // FIXME: Could omit 'Key' in name.
3199 /// Returns the location of the \c namespace keyword.
3200 SourceLocation getNamespaceKeyLocation() const { return NamespaceLoc; }
3201
3202 /// Returns the location of this using declaration's identifier.
3204
3206 SourceLocation UsingLoc,
3207 SourceLocation NamespaceLoc,
3208 NestedNameSpecifierLoc QualifierLoc,
3209 SourceLocation IdentLoc,
3210 NamedDecl *Nominated,
3211 DeclContext *CommonAncestor);
3213
3214 SourceRange getSourceRange() const override LLVM_READONLY {
3215 return SourceRange(UsingLoc, getLocation());
3216 }
3217
3218 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3219 static bool classofKind(Kind K) { return K == UsingDirective; }
3220};
3221
3222/// Represents a C++ namespace alias.
3223///
3224/// For example:
3225///
3226/// \code
3227/// namespace Foo = Bar;
3228/// \endcode
3229class NamespaceAliasDecl : public NamespaceBaseDecl,
3230 public Redeclarable<NamespaceAliasDecl> {
3231 friend class ASTDeclReader;
3232
3233 /// The location of the \c namespace keyword.
3234 SourceLocation NamespaceLoc;
3235
3236 /// The location of the namespace's identifier.
3237 ///
3238 /// This is accessed by TargetNameLoc.
3239 SourceLocation IdentLoc;
3240
3241 /// The nested-name-specifier that precedes the namespace.
3242 NestedNameSpecifierLoc QualifierLoc;
3243
3244 /// The Decl that this alias points to, either a NamespaceDecl or
3245 /// a NamespaceAliasDecl.
3246 NamespaceBaseDecl *Namespace;
3247
3248 NamespaceAliasDecl(ASTContext &C, DeclContext *DC,
3249 SourceLocation NamespaceLoc, SourceLocation AliasLoc,
3250 IdentifierInfo *Alias, NestedNameSpecifierLoc QualifierLoc,
3251 SourceLocation IdentLoc, NamespaceBaseDecl *Namespace)
3252 : NamespaceBaseDecl(NamespaceAlias, DC, AliasLoc, Alias),
3253 redeclarable_base(C), NamespaceLoc(NamespaceLoc), IdentLoc(IdentLoc),
3254 QualifierLoc(QualifierLoc), Namespace(Namespace) {}
3255
3256 void anchor() override;
3257
3258 using redeclarable_base = Redeclarable<NamespaceAliasDecl>;
3259
3263
3264public:
3265 static NamespaceAliasDecl *
3266 Create(ASTContext &C, DeclContext *DC, SourceLocation NamespaceLoc,
3267 SourceLocation AliasLoc, IdentifierInfo *Alias,
3268 NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc,
3269 NamespaceBaseDecl *Namespace);
3270
3272
3274 using redecl_iterator = redeclarable_base::redecl_iterator;
3275
3281
3282 NamespaceAliasDecl *getCanonicalDecl() override {
3283 return getFirstDecl();
3284 }
3285 const NamespaceAliasDecl *getCanonicalDecl() const {
3286 return getFirstDecl();
3287 }
3288
3289 /// Retrieve the nested-name-specifier that qualifies the
3290 /// name of the namespace, with source-location information.
3291 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3292
3293 /// Retrieve the nested-name-specifier that qualifies the
3294 /// name of the namespace.
3296 return QualifierLoc.getNestedNameSpecifier();
3297 }
3298
3299 /// Retrieve the namespace declaration aliased by this directive.
3301 if (auto *AD = dyn_cast<NamespaceAliasDecl>(Namespace))
3302 return AD->getNamespace();
3303
3304 return cast<NamespaceDecl>(Namespace);
3305 }
3306
3308 return const_cast<NamespaceAliasDecl *>(this)->getNamespace();
3309 }
3310
3311 /// Returns the location of the alias name, i.e. 'foo' in
3312 /// "namespace foo = ns::bar;".
3314
3315 /// Returns the location of the \c namespace keyword.
3316 SourceLocation getNamespaceLoc() const { return NamespaceLoc; }
3317
3318 /// Returns the location of the identifier in the named namespace.
3319 SourceLocation getTargetNameLoc() const { return IdentLoc; }
3320
3321 /// Retrieve the namespace that this alias refers to, which
3322 /// may either be a NamespaceDecl or a NamespaceAliasDecl.
3323 NamespaceBaseDecl *getAliasedNamespace() const { return Namespace; }
3324
3325 SourceRange getSourceRange() const override LLVM_READONLY {
3326 return SourceRange(NamespaceLoc, IdentLoc);
3327 }
3328
3329 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3330 static bool classofKind(Kind K) { return K == NamespaceAlias; }
3331};
3332
3333/// Implicit declaration of a temporary that was materialized by
3334/// a MaterializeTemporaryExpr and lifetime-extended by a declaration
3335class LifetimeExtendedTemporaryDecl final
3336 : public Decl,
3337 public Mergeable<LifetimeExtendedTemporaryDecl> {
3339 friend class ASTDeclReader;
3340
3341 Stmt *ExprWithTemporary = nullptr;
3342
3343 /// The declaration which lifetime-extended this reference, if any.
3344 /// Either a VarDecl, or (for a ctor-initializer) a FieldDecl.
3345 ValueDecl *ExtendingDecl = nullptr;
3346 unsigned ManglingNumber;
3347
3348 mutable APValue *Value = nullptr;
3349
3350 LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
3351
3352 LifetimeExtendedTemporaryDecl(Expr *Temp, ValueDecl *EDecl, unsigned Mangling)
3353 : Decl(Decl::LifetimeExtendedTemporary, EDecl->getDeclContext(),
3354 EDecl->getLocation()),
3355 ExprWithTemporary(Temp), ExtendingDecl(EDecl),
3356 ManglingNumber(Mangling) {}
3357
3359 : Decl(Decl::LifetimeExtendedTemporary, EmptyShell{}) {}
3360
3361public:
3362 static LifetimeExtendedTemporaryDecl *Create(Expr *Temp, ValueDecl *EDec,
3363 unsigned Mangling) {
3364 return new (EDec->getASTContext(), EDec->getDeclContext())
3365 LifetimeExtendedTemporaryDecl(Temp, EDec, Mangling);
3366 }
3367 static LifetimeExtendedTemporaryDecl *CreateDeserialized(ASTContext &C,
3368 GlobalDeclID ID) {
3369 return new (C, ID) LifetimeExtendedTemporaryDecl(EmptyShell{});
3370 }
3371
3372 ValueDecl *getExtendingDecl() { return ExtendingDecl; }
3373 const ValueDecl *getExtendingDecl() const { return ExtendingDecl; }
3374
3375 /// Retrieve the storage duration for the materialized temporary.
3377
3378 /// Retrieve the expression to which the temporary materialization conversion
3379 /// was applied. This isn't necessarily the initializer of the temporary due
3380 /// to the C++98 delayed materialization rules, but
3381 /// skipRValueSubobjectAdjustments can be used to find said initializer within
3382 /// the subexpression.
3383 Expr *getTemporaryExpr() { return cast<Expr>(ExprWithTemporary); }
3384 const Expr *getTemporaryExpr() const { return cast<Expr>(ExprWithTemporary); }
3385
3386 unsigned getManglingNumber() const { return ManglingNumber; }
3387
3388 /// Get the storage for the constant value of a materialized temporary
3389 /// of static storage duration.
3390 APValue *getOrCreateValue(bool MayCreate) const;
3391
3392 APValue *getValue() const { return Value; }
3393
3394 // Iterators
3396 return Stmt::child_range(&ExprWithTemporary, &ExprWithTemporary + 1);
3397 }
3398
3400 return Stmt::const_child_range(&ExprWithTemporary, &ExprWithTemporary + 1);
3401 }
3402
3403 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3404 static bool classofKind(Kind K) {
3405 return K == Decl::LifetimeExtendedTemporary;
3406 }
3407};
3408
3409/// Represents a shadow declaration implicitly introduced into a scope by a
3410/// (resolved) using-declaration or using-enum-declaration to achieve
3411/// the desired lookup semantics.
3412///
3413/// For example:
3414/// \code
3415/// namespace A {
3416/// void foo();
3417/// void foo(int);
3418/// struct foo {};
3419/// enum bar { bar1, bar2 };
3420/// }
3421/// namespace B {
3422/// // add a UsingDecl and three UsingShadowDecls (named foo) to B.
3423/// using A::foo;
3424/// // adds UsingEnumDecl and two UsingShadowDecls (named bar1 and bar2) to B.
3425/// using enum A::bar;
3426/// }
3427/// \endcode
3428class UsingShadowDecl : public NamedDecl, public Redeclarable<UsingShadowDecl> {
3429 friend class BaseUsingDecl;
3430
3431 /// The referenced declaration.
3432 NamedDecl *Underlying = nullptr;
3433
3434 /// The using declaration which introduced this decl or the next using
3435 /// shadow declaration contained in the aforementioned using declaration.
3436 NamedDecl *UsingOrNextShadow = nullptr;
3437
3438 void anchor() override;
3439
3440 using redeclarable_base = Redeclarable<UsingShadowDecl>;
3441
3443 return getNextRedeclaration();
3444 }
3445
3447 return getPreviousDecl();
3448 }
3449
3451 return getMostRecentDecl();
3452 }
3453
3454protected:
3455 UsingShadowDecl(Kind K, ASTContext &C, DeclContext *DC, SourceLocation Loc,
3456 DeclarationName Name, BaseUsingDecl *Introducer,
3457 NamedDecl *Target);
3458 UsingShadowDecl(Kind K, ASTContext &C, EmptyShell);
3459
3460public:
3461 friend class ASTDeclReader;
3462 friend class ASTDeclWriter;
3463
3466 BaseUsingDecl *Introducer, NamedDecl *Target) {
3467 return new (C, DC)
3468 UsingShadowDecl(UsingShadow, C, DC, Loc, Name, Introducer, Target);
3469 }
3470
3472
3474 using redecl_iterator = redeclarable_base::redecl_iterator;
3475
3482
3484 return getFirstDecl();
3485 }
3487 return getFirstDecl();
3488 }
3489
3490 /// Gets the underlying declaration which has been brought into the
3491 /// local scope.
3492 NamedDecl *getTargetDecl() const { return Underlying; }
3493
3494 /// Sets the underlying declaration which has been brought into the
3495 /// local scope.
3497 assert(ND && "Target decl is null!");
3498 Underlying = ND;
3499 // A UsingShadowDecl is never a friend or local extern declaration, even
3500 // if it is a shadow declaration for one.
3504 }
3505
3506 /// Gets the (written or instantiated) using declaration that introduced this
3507 /// declaration.
3509
3510 /// The next using shadow declaration contained in the shadow decl
3511 /// chain of the using declaration which introduced this decl.
3513 return dyn_cast_or_null<UsingShadowDecl>(UsingOrNextShadow);
3514 }
3515
3516 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3517 static bool classofKind(Kind K) {
3518 return K == Decl::UsingShadow || K == Decl::ConstructorUsingShadow;
3519 }
3520};
3521
3522/// Represents a C++ declaration that introduces decls from somewhere else. It
3523/// provides a set of the shadow decls so introduced.
3524
3525class BaseUsingDecl : public NamedDecl {
3526 /// The first shadow declaration of the shadow decl chain associated
3527 /// with this using declaration.
3528 ///
3529 /// The bool member of the pair is a bool flag a derived type may use
3530 /// (UsingDecl makes use of it).
3531 llvm::PointerIntPair<UsingShadowDecl *, 1, bool> FirstUsingShadow;
3532
3533protected:
3535 : NamedDecl(DK, DC, L, N), FirstUsingShadow(nullptr, false) {}
3536
3537private:
3538 void anchor() override;
3539
3540protected:
3541 /// A bool flag for use by a derived type
3542 bool getShadowFlag() const { return FirstUsingShadow.getInt(); }
3543
3544 /// A bool flag a derived type may set
3545 void setShadowFlag(bool V) { FirstUsingShadow.setInt(V); }
3546
3547public:
3548 friend class ASTDeclReader;
3549 friend class ASTDeclWriter;
3550
3551 /// Iterates through the using shadow declarations associated with
3552 /// this using declaration.
3554 /// The current using shadow declaration.
3555 UsingShadowDecl *Current = nullptr;
3556
3557 public:
3561 using iterator_category = std::forward_iterator_tag;
3562 using difference_type = std::ptrdiff_t;
3563
3564 shadow_iterator() = default;
3565 explicit shadow_iterator(UsingShadowDecl *C) : Current(C) {}
3566
3567 reference operator*() const { return Current; }
3568 pointer operator->() const { return Current; }
3569
3571 Current = Current->getNextUsingShadowDecl();
3572 return *this;
3573 }
3574
3576 shadow_iterator tmp(*this);
3577 ++(*this);
3578 return tmp;
3579 }
3580
3582 return x.Current == y.Current;
3583 }
3585 return x.Current != y.Current;
3586 }
3587 };
3588
3589 using shadow_range = llvm::iterator_range<shadow_iterator>;
3590
3593 }
3594
3596 return shadow_iterator(FirstUsingShadow.getPointer());
3597 }
3598
3600
3601 /// Return the number of shadowed declarations associated with this
3602 /// using declaration.
3603 unsigned shadow_size() const {
3604 return std::distance(shadow_begin(), shadow_end());
3605 }
3606
3609
3610 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3611 static bool classofKind(Kind K) { return K == Using || K == UsingEnum; }
3612};
3613
3614/// Represents a C++ using-declaration.
3615///
3616/// For example:
3617/// \code
3618/// using someNameSpace::someIdentifier;
3619/// \endcode
3620class UsingDecl : public BaseUsingDecl, public Mergeable<UsingDecl> {
3621 /// The source location of the 'using' keyword itself.
3622 SourceLocation UsingLocation;
3623
3624 /// The nested-name-specifier that precedes the name.
3625 NestedNameSpecifierLoc QualifierLoc;
3626
3627 /// Provides source/type location info for the declaration name
3628 /// embedded in the ValueDecl base class.
3629 DeclarationNameLoc DNLoc;
3630
3631 UsingDecl(DeclContext *DC, SourceLocation UL,
3632 NestedNameSpecifierLoc QualifierLoc,
3633 const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
3634 : BaseUsingDecl(Using, DC, NameInfo.getLoc(), NameInfo.getName()),
3635 UsingLocation(UL), QualifierLoc(QualifierLoc),
3636 DNLoc(NameInfo.getInfo()) {
3637 setShadowFlag(HasTypenameKeyword);
3638 }
3639
3640 void anchor() override;
3641
3642public:
3643 friend class ASTDeclReader;
3644 friend class ASTDeclWriter;
3645
3646 /// Return the source location of the 'using' keyword.
3647 SourceLocation getUsingLoc() const { return UsingLocation; }
3648
3649 /// Set the source location of the 'using' keyword.
3650 void setUsingLoc(SourceLocation L) { UsingLocation = L; }
3651
3652 /// Retrieve the nested-name-specifier that qualifies the name,
3653 /// with source-location information.
3654 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3655
3656 /// Retrieve the nested-name-specifier that qualifies the name.
3658 return QualifierLoc.getNestedNameSpecifier();
3659 }
3660
3664
3665 /// Return true if it is a C++03 access declaration (no 'using').
3666 bool isAccessDeclaration() const { return UsingLocation.isInvalid(); }
3667
3668 /// Return true if the using declaration has 'typename'.
3669 bool hasTypename() const { return getShadowFlag(); }
3670
3671 /// Sets whether the using declaration has 'typename'.
3672 void setTypename(bool TN) { setShadowFlag(TN); }
3673
3674 static UsingDecl *Create(ASTContext &C, DeclContext *DC,
3675 SourceLocation UsingL,
3676 NestedNameSpecifierLoc QualifierLoc,
3677 const DeclarationNameInfo &NameInfo,
3678 bool HasTypenameKeyword);
3679
3681
3682 SourceRange getSourceRange() const override LLVM_READONLY;
3683
3684 /// Retrieves the canonical declaration of this declaration.
3685 UsingDecl *getCanonicalDecl() override {
3686 return cast<UsingDecl>(getFirstDecl());
3687 }
3688 const UsingDecl *getCanonicalDecl() const {
3689 return cast<UsingDecl>(getFirstDecl());
3690 }
3691
3692 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3693 static bool classofKind(Kind K) { return K == Using; }
3694};
3695
3696/// Represents a shadow constructor declaration introduced into a
3697/// class by a C++11 using-declaration that names a constructor.
3698///
3699/// For example:
3700/// \code
3701/// struct Base { Base(int); };
3702/// struct Derived {
3703/// using Base::Base; // creates a UsingDecl and a ConstructorUsingShadowDecl
3704/// };
3705/// \endcode
3706class ConstructorUsingShadowDecl final : public UsingShadowDecl {
3707 /// If this constructor using declaration inherted the constructor
3708 /// from an indirect base class, this is the ConstructorUsingShadowDecl
3709 /// in the named direct base class from which the declaration was inherited.
3710 ConstructorUsingShadowDecl *NominatedBaseClassShadowDecl = nullptr;
3711
3712 /// If this constructor using declaration inherted the constructor
3713 /// from an indirect base class, this is the ConstructorUsingShadowDecl
3714 /// that will be used to construct the unique direct or virtual base class
3715 /// that receives the constructor arguments.
3716 ConstructorUsingShadowDecl *ConstructedBaseClassShadowDecl = nullptr;
3717
3718 /// \c true if the constructor ultimately named by this using shadow
3719 /// declaration is within a virtual base class subobject of the class that
3720 /// contains this declaration.
3721 LLVM_PREFERRED_TYPE(bool)
3722 unsigned IsVirtual : 1;
3723
3724 ConstructorUsingShadowDecl(ASTContext &C, DeclContext *DC, SourceLocation Loc,
3725 UsingDecl *Using, NamedDecl *Target,
3726 bool TargetInVirtualBase)
3727 : UsingShadowDecl(ConstructorUsingShadow, C, DC, Loc,
3728 Using->getDeclName(), Using,
3729 Target->getUnderlyingDecl()),
3730 NominatedBaseClassShadowDecl(
3731 dyn_cast<ConstructorUsingShadowDecl>(Target)),
3732 ConstructedBaseClassShadowDecl(NominatedBaseClassShadowDecl),
3733 IsVirtual(TargetInVirtualBase) {
3734 // If we found a constructor that chains to a constructor for a virtual
3735 // base, we should directly call that virtual base constructor instead.
3736 // FIXME: This logic belongs in Sema.
3737 if (NominatedBaseClassShadowDecl &&
3738 NominatedBaseClassShadowDecl->constructsVirtualBase()) {
3739 ConstructedBaseClassShadowDecl =
3740 NominatedBaseClassShadowDecl->ConstructedBaseClassShadowDecl;
3741 IsVirtual = true;
3742 }
3743 }
3744
3745 ConstructorUsingShadowDecl(ASTContext &C, EmptyShell Empty)
3746 : UsingShadowDecl(ConstructorUsingShadow, C, Empty), IsVirtual(false) {}
3747
3748 void anchor() override;
3749
3750public:
3751 friend class ASTDeclReader;
3752 friend class ASTDeclWriter;
3753
3754 static ConstructorUsingShadowDecl *Create(ASTContext &C, DeclContext *DC,
3755 SourceLocation Loc,
3756 UsingDecl *Using, NamedDecl *Target,
3757 bool IsVirtual);
3758 static ConstructorUsingShadowDecl *CreateDeserialized(ASTContext &C,
3759 GlobalDeclID ID);
3760
3761 /// Override the UsingShadowDecl's getIntroducer, returning the UsingDecl that
3762 /// introduced this.
3766
3767 /// Returns the parent of this using shadow declaration, which
3768 /// is the class in which this is declared.
3769 //@{
3770 const CXXRecordDecl *getParent() const {
3772 }
3776 //@}
3777
3778 /// Get the inheriting constructor declaration for the direct base
3779 /// class from which this using shadow declaration was inherited, if there is
3780 /// one. This can be different for each redeclaration of the same shadow decl.
3781 ConstructorUsingShadowDecl *getNominatedBaseClassShadowDecl() const {
3782 return NominatedBaseClassShadowDecl;
3783 }
3784
3785 /// Get the inheriting constructor declaration for the base class
3786 /// for which we don't have an explicit initializer, if there is one.
3787 ConstructorUsingShadowDecl *getConstructedBaseClassShadowDecl() const {
3788 return ConstructedBaseClassShadowDecl;
3789 }
3790
3791 /// Get the base class that was named in the using declaration. This
3792 /// can be different for each redeclaration of this same shadow decl.
3794
3795 /// Get the base class whose constructor or constructor shadow
3796 /// declaration is passed the constructor arguments.
3798 return cast<CXXRecordDecl>((ConstructedBaseClassShadowDecl
3799 ? ConstructedBaseClassShadowDecl
3800 : getTargetDecl())
3801 ->getDeclContext());
3802 }
3803
3804 /// Returns \c true if the constructed base class is a virtual base
3805 /// class subobject of this declaration's class.
3807 return IsVirtual;
3808 }
3809
3810 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3811 static bool classofKind(Kind K) { return K == ConstructorUsingShadow; }
3812};
3813
3814/// Represents a C++ using-enum-declaration.
3815///
3816/// For example:
3817/// \code
3818/// using enum SomeEnumTag ;
3819/// \endcode
3820
3821class UsingEnumDecl : public BaseUsingDecl, public Mergeable<UsingEnumDecl> {
3822 /// The source location of the 'using' keyword itself.
3823 SourceLocation UsingLocation;
3824 /// The source location of the 'enum' keyword.
3825 SourceLocation EnumLocation;
3826 /// 'qual::SomeEnum' as an EnumType, possibly with Elaborated/Typedef sugar.
3827 TypeSourceInfo *EnumType;
3828
3829 UsingEnumDecl(DeclContext *DC, DeclarationName DN, SourceLocation UL,
3831 : BaseUsingDecl(UsingEnum, DC, NL, DN), UsingLocation(UL), EnumLocation(EL),
3832 EnumType(EnumType){}
3833
3834 void anchor() override;
3835
3836public:
3837 friend class ASTDeclReader;
3838 friend class ASTDeclWriter;
3839
3840 /// The source location of the 'using' keyword.
3841 SourceLocation getUsingLoc() const { return UsingLocation; }
3842 void setUsingLoc(SourceLocation L) { UsingLocation = L; }
3843
3844 /// The source location of the 'enum' keyword.
3845 SourceLocation getEnumLoc() const { return EnumLocation; }
3846 void setEnumLoc(SourceLocation L) { EnumLocation = L; }
3853 // Returns the "qualifier::Name" part as a TypeLoc.
3855 return EnumType->getTypeLoc();
3856 }
3858 return EnumType;
3859 }
3860 void setEnumType(TypeSourceInfo *TSI) { EnumType = TSI; }
3861
3862public:
3864 return EnumType->getType()->castAs<clang::EnumType>()->getDecl();
3865 }
3866
3868 SourceLocation UsingL, SourceLocation EnumL,
3869 SourceLocation NameL, TypeSourceInfo *EnumType);
3870
3872
3873 SourceRange getSourceRange() const override LLVM_READONLY;
3874
3875 /// Retrieves the canonical declaration of this declaration.
3876 UsingEnumDecl *getCanonicalDecl() override {
3878 }
3879 const UsingEnumDecl *getCanonicalDecl() const {
3881 }
3882
3883 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3884 static bool classofKind(Kind K) { return K == UsingEnum; }
3885};
3886
3887/// Represents a pack of using declarations that a single
3888/// using-declarator pack-expanded into.
3889///
3890/// \code
3891/// template<typename ...T> struct X : T... {
3892/// using T::operator()...;
3893/// using T::operator T...;
3894/// };
3895/// \endcode
3896///
3897/// In the second case above, the UsingPackDecl will have the name
3898/// 'operator T' (which contains an unexpanded pack), but the individual
3899/// UsingDecls and UsingShadowDecls will have more reasonable names.
3900class UsingPackDecl final
3901 : public NamedDecl, public Mergeable<UsingPackDecl>,
3902 private llvm::TrailingObjects<UsingPackDecl, NamedDecl *> {
3903 /// The UnresolvedUsingValueDecl or UnresolvedUsingTypenameDecl from
3904 /// which this waas instantiated.
3905 NamedDecl *InstantiatedFrom;
3906
3907 /// The number of using-declarations created by this pack expansion.
3908 unsigned NumExpansions;
3909
3910 UsingPackDecl(DeclContext *DC, NamedDecl *InstantiatedFrom,
3911 ArrayRef<NamedDecl *> UsingDecls)
3912 : NamedDecl(UsingPack, DC,
3913 InstantiatedFrom ? InstantiatedFrom->getLocation()
3914 : SourceLocation(),
3915 InstantiatedFrom ? InstantiatedFrom->getDeclName()
3916 : DeclarationName()),
3917 InstantiatedFrom(InstantiatedFrom), NumExpansions(UsingDecls.size()) {
3918 llvm::uninitialized_copy(UsingDecls, getTrailingObjects());
3919 }
3920
3921 void anchor() override;
3922
3923public:
3924 friend class ASTDeclReader;
3925 friend class ASTDeclWriter;
3927
3928 /// Get the using declaration from which this was instantiated. This will
3929 /// always be an UnresolvedUsingValueDecl or an UnresolvedUsingTypenameDecl
3930 /// that is a pack expansion.
3931 NamedDecl *getInstantiatedFromUsingDecl() const { return InstantiatedFrom; }
3932
3933 /// Get the set of using declarations that this pack expanded into. Note that
3934 /// some of these may still be unresolved.
3936 return getTrailingObjects(NumExpansions);
3937 }
3938
3940 NamedDecl *InstantiatedFrom,
3941 ArrayRef<NamedDecl *> UsingDecls);
3942
3944 unsigned NumExpansions);
3945
3946 SourceRange getSourceRange() const override LLVM_READONLY {
3947 return InstantiatedFrom->getSourceRange();
3948 }
3949
3950 UsingPackDecl *getCanonicalDecl() override { return getFirstDecl(); }
3951 const UsingPackDecl *getCanonicalDecl() const { return getFirstDecl(); }
3952
3953 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3954 static bool classofKind(Kind K) { return K == UsingPack; }
3955};
3956
3957/// Represents a dependent using declaration which was not marked with
3958/// \c typename.
3959///
3960/// Unlike non-dependent using declarations, these *only* bring through
3961/// non-types; otherwise they would break two-phase lookup.
3962///
3963/// \code
3964/// template <class T> class A : public Base<T> {
3965/// using Base<T>::foo;
3966/// };
3967/// \endcode
3968class UnresolvedUsingValueDecl : public ValueDecl,
3969 public Mergeable<UnresolvedUsingValueDecl> {
3970 /// The source location of the 'using' keyword
3971 SourceLocation UsingLocation;
3972
3973 /// If this is a pack expansion, the location of the '...'.
3974 SourceLocation EllipsisLoc;
3975
3976 /// The nested-name-specifier that precedes the name.
3977 NestedNameSpecifierLoc QualifierLoc;
3978
3979 /// Provides source/type location info for the declaration name
3980 /// embedded in the ValueDecl base class.
3981 DeclarationNameLoc DNLoc;
3982
3983 UnresolvedUsingValueDecl(DeclContext *DC, QualType Ty,
3984 SourceLocation UsingLoc,
3985 NestedNameSpecifierLoc QualifierLoc,
3986 const DeclarationNameInfo &NameInfo,
3987 SourceLocation EllipsisLoc)
3988 : ValueDecl(UnresolvedUsingValue, DC,
3989 NameInfo.getLoc(), NameInfo.getName(), Ty),
3990 UsingLocation(UsingLoc), EllipsisLoc(EllipsisLoc),
3991 QualifierLoc(QualifierLoc), DNLoc(NameInfo.getInfo()) {}
3992
3993 void anchor() override;
3994
3995public:
3996 friend class ASTDeclReader;
3997 friend class ASTDeclWriter;
3998
3999 /// Returns the source location of the 'using' keyword.
4000 SourceLocation getUsingLoc() const { return UsingLocation; }
4001
4002 /// Set the source location of the 'using' keyword.
4003 void setUsingLoc(SourceLocation L) { UsingLocation = L; }
4004
4005 /// Return true if it is a C++03 access declaration (no 'using').
4006 bool isAccessDeclaration() const { return UsingLocation.isInvalid(); }
4007
4008 /// Retrieve the nested-name-specifier that qualifies the name,
4009 /// with source-location information.
4010 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
4011
4012 /// Retrieve the nested-name-specifier that qualifies the name.
4014 return QualifierLoc.getNestedNameSpecifier();
4015 }
4016
4020
4021 /// Determine whether this is a pack expansion.
4022 bool isPackExpansion() const {
4023 return EllipsisLoc.isValid();
4024 }
4025
4026 /// Get the location of the ellipsis if this is a pack expansion.
4028 return EllipsisLoc;
4029 }
4030
4033 NestedNameSpecifierLoc QualifierLoc,
4034 const DeclarationNameInfo &NameInfo, SourceLocation EllipsisLoc);
4035
4037 GlobalDeclID ID);
4038
4039 SourceRange getSourceRange() const override LLVM_READONLY;
4040
4041 /// Retrieves the canonical declaration of this declaration.
4042 UnresolvedUsingValueDecl *getCanonicalDecl() override {
4043 return getFirstDecl();
4044 }
4045 const UnresolvedUsingValueDecl *getCanonicalDecl() const {
4046 return getFirstDecl();
4047 }
4048
4049 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4050 static bool classofKind(Kind K) { return K == UnresolvedUsingValue; }
4051};
4052
4053/// Represents a dependent using declaration which was marked with
4054/// \c typename.
4055///
4056/// \code
4057/// template <class T> class A : public Base<T> {
4058/// using typename Base<T>::foo;
4059/// };
4060/// \endcode
4061///
4062/// The type associated with an unresolved using typename decl is
4063/// currently always a typename type.
4064class UnresolvedUsingTypenameDecl
4065 : public TypeDecl,
4066 public Mergeable<UnresolvedUsingTypenameDecl> {
4067 friend class ASTDeclReader;
4068
4069 /// The source location of the 'typename' keyword
4070 SourceLocation TypenameLocation;
4071
4072 /// If this is a pack expansion, the location of the '...'.
4073 SourceLocation EllipsisLoc;
4074
4075 /// The nested-name-specifier that precedes the name.
4076 NestedNameSpecifierLoc QualifierLoc;
4077
4078 UnresolvedUsingTypenameDecl(DeclContext *DC, SourceLocation UsingLoc,
4079 SourceLocation TypenameLoc,
4080 NestedNameSpecifierLoc QualifierLoc,
4081 SourceLocation TargetNameLoc,
4082 IdentifierInfo *TargetName,
4083 SourceLocation EllipsisLoc)
4084 : TypeDecl(UnresolvedUsingTypename, DC, TargetNameLoc, TargetName,
4085 UsingLoc),
4086 TypenameLocation(TypenameLoc), EllipsisLoc(EllipsisLoc),
4087 QualifierLoc(QualifierLoc) {}
4088
4089 void anchor() override;
4090
4091public:
4092 /// Returns the source location of the 'using' keyword.
4094
4095 /// Returns the source location of the 'typename' keyword.
4096 SourceLocation getTypenameLoc() const { return TypenameLocation; }
4097
4098 /// Retrieve the nested-name-specifier that qualifies the name,
4099 /// with source-location information.
4100 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
4101
4102 /// Retrieve the nested-name-specifier that qualifies the name.
4104 return QualifierLoc.getNestedNameSpecifier();
4105 }
4106
4110
4111 /// Determine whether this is a pack expansion.
4112 bool isPackExpansion() const {
4113 return EllipsisLoc.isValid();
4114 }
4115
4116 /// Get the location of the ellipsis if this is a pack expansion.
4118 return EllipsisLoc;
4119 }
4120
4123 SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc,
4124 SourceLocation TargetNameLoc, DeclarationName TargetName,
4125 SourceLocation EllipsisLoc);
4126
4128 GlobalDeclID ID);
4129
4130 /// Retrieves the canonical declaration of this declaration.
4131 UnresolvedUsingTypenameDecl *getCanonicalDecl() override {
4132 return getFirstDecl();
4133 }
4134 const UnresolvedUsingTypenameDecl *getCanonicalDecl() const {
4135 return getFirstDecl();
4136 }
4137
4138 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4139 static bool classofKind(Kind K) { return K == UnresolvedUsingTypename; }
4140};
4141
4142/// This node is generated when a using-declaration that was annotated with
4143/// __attribute__((using_if_exists)) failed to resolve to a known declaration.
4144/// In that case, Sema builds a UsingShadowDecl whose target is an instance of
4145/// this declaration, adding it to the current scope. Referring to this
4146/// declaration in any way is an error.
4147class UnresolvedUsingIfExistsDecl final : public NamedDecl {
4148 UnresolvedUsingIfExistsDecl(DeclContext *DC, SourceLocation Loc,
4149 DeclarationName Name);
4150
4151 void anchor() override;
4152
4153public:
4154 static UnresolvedUsingIfExistsDecl *Create(ASTContext &Ctx, DeclContext *DC,
4155 SourceLocation Loc,
4156 DeclarationName Name);
4157 static UnresolvedUsingIfExistsDecl *CreateDeserialized(ASTContext &Ctx,
4158 GlobalDeclID ID);
4159
4160 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4161 static bool classofKind(Kind K) { return K == Decl::UnresolvedUsingIfExists; }
4162};
4163
4164/// Represents a C++11 static_assert declaration.
4165class StaticAssertDecl : public Decl {
4166 llvm::PointerIntPair<Expr *, 1, bool> AssertExprAndFailed;
4167 Expr *Message;
4168 SourceLocation RParenLoc;
4169
4170 StaticAssertDecl(DeclContext *DC, SourceLocation StaticAssertLoc,
4171 Expr *AssertExpr, Expr *Message, SourceLocation RParenLoc,
4172 bool Failed)
4173 : Decl(StaticAssert, DC, StaticAssertLoc),
4174 AssertExprAndFailed(AssertExpr, Failed), Message(Message),
4175 RParenLoc(RParenLoc) {}
4176
4177 virtual void anchor();
4178
4179public:
4180 friend class ASTDeclReader;
4181
4182 static StaticAssertDecl *Create(ASTContext &C, DeclContext *DC,
4183 SourceLocation StaticAssertLoc,
4184 Expr *AssertExpr, Expr *Message,
4185 SourceLocation RParenLoc, bool Failed);
4186 static StaticAssertDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
4187
4188 Expr *getAssertExpr() { return AssertExprAndFailed.getPointer(); }
4189 const Expr *getAssertExpr() const { return AssertExprAndFailed.getPointer(); }
4190
4191 Expr *getMessage() { return Message; }
4192 const Expr *getMessage() const { return Message; }
4193
4194 bool isFailed() const { return AssertExprAndFailed.getInt(); }
4195
4196 SourceLocation getRParenLoc() const { return RParenLoc; }
4197
4198 SourceRange getSourceRange() const override LLVM_READONLY {
4200 }
4201
4202 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4203 static bool classofKind(Kind K) { return K == StaticAssert; }
4204};
4205
4206/// A binding in a decomposition declaration. For instance, given:
4207///
4208/// int n[3];
4209/// auto &[a, b, c] = n;
4210///
4211/// a, b, and c are BindingDecls, whose bindings are the expressions
4212/// x[0], x[1], and x[2] respectively, where x is the implicit
4213/// DecompositionDecl of type 'int (&)[3]'.
4214class BindingDecl : public ValueDecl {
4215 /// The declaration that this binding binds to part of.
4216 DecompositionDecl *Decomp = nullptr;
4217 /// The binding represented by this declaration. References to this
4218 /// declaration are effectively equivalent to this expression (except
4219 /// that it is only evaluated once at the point of declaration of the
4220 /// binding).
4221 Expr *Binding = nullptr;
4222
4223 BindingDecl(DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id,
4224 QualType T)
4225 : ValueDecl(Decl::Binding, DC, IdLoc, Id, T) {}
4226
4227 void anchor() override;
4228
4229public:
4230 friend class ASTDeclReader;
4231
4232 static BindingDecl *Create(ASTContext &C, DeclContext *DC,
4233 SourceLocation IdLoc, IdentifierInfo *Id,
4234 QualType T);
4235 static BindingDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
4236
4237 /// Get the expression to which this declaration is bound. This may be null
4238 /// in two different cases: while parsing the initializer for the
4239 /// decomposition declaration, and when the initializer is type-dependent.
4240 Expr *getBinding() const { return Binding; }
4241
4242 // Get the array of nested BindingDecls when the binding represents a pack.
4244
4245 /// Get the decomposition declaration that this binding represents a
4246 /// decomposition of.
4247 DecompositionDecl *getDecomposedDecl() const { return Decomp; }
4248
4249 /// Set the binding for this BindingDecl, along with its declared type (which
4250 /// should be a possibly-cv-qualified form of the type of the binding, or a
4251 /// reference to such a type).
4252 void setBinding(QualType DeclaredType, Expr *Binding) {
4253 setType(DeclaredType);
4254 this->Binding = Binding;
4255 }
4256
4257 /// Set the decomposed variable for this BindingDecl.
4258 void setDecomposedDecl(DecompositionDecl *Decomposed) { Decomp = Decomposed; }
4259
4260 /// Get the variable (if any) that holds the value of evaluating the binding.
4261 /// Only present for user-defined bindings for tuple-like types.
4262 VarDecl *getHoldingVar() const;
4263
4264 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4265 static bool classofKind(Kind K) { return K == Decl::Binding; }
4266};
4267
4268/// A decomposition declaration. For instance, given:
4269///
4270/// int n[3];
4271/// auto &[a, b, c] = n;
4272///
4273/// the second line declares a DecompositionDecl of type 'int (&)[3]', and
4274/// three BindingDecls (named a, b, and c). An instance of this class is always
4275/// unnamed, but behaves in almost all other respects like a VarDecl.
4276class DecompositionDecl final
4277 : public VarDecl,
4278 private llvm::TrailingObjects<DecompositionDecl, BindingDecl *> {
4279 /// The closing bracket (before the initializer is expected).
4280 SourceLocation RSquareLoc;
4281 /// The number of BindingDecl*s following this object.
4282 unsigned NumBindings;
4283
4284 DecompositionDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
4285 SourceLocation LSquareLoc, SourceLocation RSquareLoc,
4288 : VarDecl(Decomposition, C, DC, StartLoc, LSquareLoc, nullptr, T, TInfo,
4289 SC),
4290 RSquareLoc(RSquareLoc), NumBindings(Bindings.size()) {
4291 llvm::uninitialized_copy(Bindings, getTrailingObjects());
4292 for (auto *B : Bindings) {
4293 B->setDecomposedDecl(this);
4294 if (B->isParameterPack() && B->getBinding()) {
4295 for (BindingDecl *NestedBD : B->getBindingPackDecls()) {
4296 NestedBD->setDecomposedDecl(this);
4297 }
4298 }
4299 }
4300 }
4301
4302 void anchor() override;
4303
4304public:
4305 friend class ASTDeclReader;
4307
4308 static DecompositionDecl *Create(ASTContext &C, DeclContext *DC,
4309 SourceLocation StartLoc,
4310 SourceLocation LSquareLoc,
4311 SourceLocation RSquareLoc, QualType T,
4312 TypeSourceInfo *TInfo, StorageClass S,
4314 static DecompositionDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID,
4315 unsigned NumBindings);
4316
4317 // Provide the range of bindings which may have a nested pack.
4319 return getTrailingObjects(NumBindings);
4320 }
4321
4322 // Provide a flattened range to visit each binding.
4323 auto flat_bindings() const {
4325 ArrayRef<BindingDecl *> PackBindings;
4326
4327 // Split the bindings into subranges split by the pack.
4328 ArrayRef<BindingDecl *> BeforePackBindings = Bindings.take_until(
4329 [](BindingDecl *BD) { return BD->isParameterPack(); });
4330
4331 Bindings = Bindings.drop_front(BeforePackBindings.size());
4332 if (!Bindings.empty() && Bindings.front()->getBinding()) {
4333 PackBindings = Bindings.front()->getBindingPackDecls();
4334 Bindings = Bindings.drop_front();
4335 }
4336
4337 return llvm::concat<BindingDecl *const>(std::move(BeforePackBindings),
4338 std::move(PackBindings),
4339 std::move(Bindings));
4340 }
4341
4342 /// The closing bracket (before the initializer is expected).
4343 SourceLocation getRSquareLoc() const { return RSquareLoc; }
4344
4345 void printName(raw_ostream &OS, const PrintingPolicy &Policy) const override;
4346
4347 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4348 static bool classofKind(Kind K) { return K == Decomposition; }
4349};
4350
4351/// An instance of this class represents the declaration of a property
4352/// member. This is a Microsoft extension to C++, first introduced in
4353/// Visual Studio .NET 2003 as a parallel to similar features in C#
4354/// and Managed C++.
4355///
4356/// A property must always be a non-static class member.
4357///
4358/// A property member superficially resembles a non-static data
4359/// member, except preceded by a property attribute:
4360/// __declspec(property(get=GetX, put=PutX)) int x;
4361/// Either (but not both) of the 'get' and 'put' names may be omitted.
4362///
4363/// A reference to a property is always an lvalue. If the lvalue
4364/// undergoes lvalue-to-rvalue conversion, then a getter name is
4365/// required, and that member is called with no arguments.
4366/// If the lvalue is assigned into, then a setter name is required,
4367/// and that member is called with one argument, the value assigned.
4368/// Both operations are potentially overloaded. Compound assignments
4369/// are permitted, as are the increment and decrement operators.
4370///
4371/// The getter and putter methods are permitted to be overloaded,
4372/// although their return and parameter types are subject to certain
4373/// restrictions according to the type of the property.
4374///
4375/// A property declared using an incomplete array type may
4376/// additionally be subscripted, adding extra parameters to the getter
4377/// and putter methods.
4378class MSPropertyDecl : public DeclaratorDecl {
4379 IdentifierInfo *GetterId, *SetterId;
4380
4381 MSPropertyDecl(DeclContext *DC, SourceLocation L, DeclarationName N,
4382 QualType T, TypeSourceInfo *TInfo, SourceLocation StartL,
4383 IdentifierInfo *Getter, IdentifierInfo *Setter)
4384 : DeclaratorDecl(MSProperty, DC, L, N, T, TInfo, StartL),
4385 GetterId(Getter), SetterId(Setter) {}
4386
4387 void anchor() override;
4388public:
4389 friend class ASTDeclReader;
4390
4391 static MSPropertyDecl *Create(ASTContext &C, DeclContext *DC,
4393 TypeSourceInfo *TInfo, SourceLocation StartL,
4394 IdentifierInfo *Getter, IdentifierInfo *Setter);
4395 static MSPropertyDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
4396
4397 static bool classof(const Decl *D) { return D->getKind() == MSProperty; }
4398
4399 bool hasGetter() const { return GetterId != nullptr; }
4400 IdentifierInfo* getGetterId() const { return GetterId; }
4401 bool hasSetter() const { return SetterId != nullptr; }
4402 IdentifierInfo* getSetterId() const { return SetterId; }
4403};
4404
4405/// Parts of a decomposed MSGuidDecl. Factored out to avoid unnecessary
4406/// dependencies on DeclCXX.h.
4408 /// {01234567-...
4410 /// ...-89ab-...
4412 /// ...-cdef-...
4414 /// ...-0123-456789abcdef}
4416
4417 uint64_t getPart4And5AsUint64() const {
4418 uint64_t Val;
4419 memcpy(&Val, &Part4And5, sizeof(Part4And5));
4420 return Val;
4421 }
4422};
4423
4424/// A global _GUID constant. These are implicitly created by UuidAttrs.
4425///
4426/// struct _declspec(uuid("01234567-89ab-cdef-0123-456789abcdef")) X{};
4427///
4428/// X is a CXXRecordDecl that contains a UuidAttr that references the (unique)
4429/// MSGuidDecl for the specified UUID.
4430class MSGuidDecl : public ValueDecl,
4431 public Mergeable<MSGuidDecl>,
4432 public llvm::FoldingSetNode {
4433public:
4435
4436private:
4437 /// The decomposed form of the UUID.
4438 Parts PartVal;
4439
4440 /// The resolved value of the UUID as an APValue. Computed on demand and
4441 /// cached.
4442 mutable APValue APVal;
4443
4444 void anchor() override;
4445
4446 MSGuidDecl(DeclContext *DC, QualType T, Parts P);
4447
4448 static MSGuidDecl *Create(const ASTContext &C, QualType T, Parts P);
4449 static MSGuidDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
4450
4451 // Only ASTContext::getMSGuidDecl and deserialization create these.
4452 friend class ASTContext;
4453 friend class ASTReader;
4454 friend class ASTDeclReader;
4455
4456public:
4457 /// Print this UUID in a human-readable format.
4458 void printName(llvm::raw_ostream &OS,
4459 const PrintingPolicy &Policy) const override;
4460
4461 /// Get the decomposed parts of this declaration.
4462 Parts getParts() const { return PartVal; }
4463
4464 /// Get the value of this MSGuidDecl as an APValue. This may fail and return
4465 /// an absent APValue if the type of the declaration is not of the expected
4466 /// shape.
4467 APValue &getAsAPValue() const;
4468
4469 static void Profile(llvm::FoldingSetNodeID &ID, Parts P) {
4470 ID.AddInteger(P.Part1);
4471 ID.AddInteger(P.Part2);
4472 ID.AddInteger(P.Part3);
4473 ID.AddInteger(P.getPart4And5AsUint64());
4474 }
4475 void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, PartVal); }
4476
4477 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4478 static bool classofKind(Kind K) { return K == Decl::MSGuid; }
4479};
4480
4481/// An artificial decl, representing a global anonymous constant value which is
4482/// uniquified by value within a translation unit.
4483///
4484/// These is currently only used to back the LValue returned by
4485/// __builtin_source_location, but could potentially be used for other similar
4486/// situations in the future.
4487class UnnamedGlobalConstantDecl : public ValueDecl,
4488 public Mergeable<UnnamedGlobalConstantDecl>,
4489 public llvm::FoldingSetNode {
4490
4491 // The constant value of this global.
4492 APValue Value;
4493
4494 void anchor() override;
4495
4496 UnnamedGlobalConstantDecl(const ASTContext &C, DeclContext *DC, QualType T,
4497 const APValue &Val);
4498
4499 static UnnamedGlobalConstantDecl *Create(const ASTContext &C, QualType T,
4500 const APValue &APVal);
4501 static UnnamedGlobalConstantDecl *CreateDeserialized(ASTContext &C,
4502 GlobalDeclID ID);
4503
4504 // Only ASTContext::getUnnamedGlobalConstantDecl and deserialization create
4505 // these.
4506 friend class ASTContext;
4507 friend class ASTReader;
4508 friend class ASTDeclReader;
4509
4510public:
4511 /// Print this in a human-readable format.
4512 void printName(llvm::raw_ostream &OS,
4513 const PrintingPolicy &Policy) const override;
4514
4515 const APValue &getValue() const { return Value; }
4516
4517 static void Profile(llvm::FoldingSetNodeID &ID, QualType Ty,
4518 const APValue &APVal) {
4519 Ty.Profile(ID);
4520 APVal.Profile(ID);
4521 }
4522 void Profile(llvm::FoldingSetNodeID &ID) {
4523 Profile(ID, getType(), getValue());
4524 }
4525
4526 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4527 static bool classofKind(Kind K) { return K == Decl::UnnamedGlobalConstant; }
4528};
4529
4530/// Insertion operator for diagnostics. This allows sending an AccessSpecifier
4531/// into a diagnostic with <<.
4532const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
4533 AccessSpecifier AS);
4534
4535} // namespace clang
4536
4537#endif // LLVM_CLANG_AST_DECLCXX_H
#define V(N, I)
#define X(type, name)
Definition Value.h:97
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the LambdaCapture class.
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
Defines the clang::LangOptions interface.
Defines an enumeration for C++ overloaded operators.
llvm::SmallVector< std::pair< const MemRegion *, SVal >, 4 > Bindings
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
C Language Family Type Representation.
Defines the clang::TypeLoc interface and its subclasses.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:223
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition APValue.h:122
void Profile(llvm::FoldingSetNodeID &ID) const
profile this value.
Definition APValue.cpp:487
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:223
Represents an access specifier followed by colon ':'.
Definition DeclCXX.h:86
static AccessSpecDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:60
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition DeclCXX.h:113
static AccessSpecDecl * Create(ASTContext &C, AccessSpecifier AS, DeclContext *DC, SourceLocation ASLoc, SourceLocation ColonLoc)
Definition DeclCXX.h:117
SourceLocation getColonLoc() const
The location of the colon following the access specifier.
Definition DeclCXX.h:108
static bool classof(const Decl *D)
Definition DeclCXX.h:126
static bool classofKind(Kind K)
Definition DeclCXX.h:127
SourceLocation getAccessSpecifierLoc() const
The location of the access specifier.
Definition DeclCXX.h:102
void setAccessSpecifierLoc(SourceLocation ASLoc)
Sets the location of the access specifier.
Definition DeclCXX.h:105
void setColonLoc(SourceLocation CLoc)
Sets the location of the colon.
Definition DeclCXX.h:111
Iterates through the using shadow declarations associated with this using declaration.
Definition DeclCXX.h:3553
std::forward_iterator_tag iterator_category
Definition DeclCXX.h:3561
shadow_iterator(UsingShadowDecl *C)
Definition DeclCXX.h:3565
friend bool operator==(shadow_iterator x, shadow_iterator y)
Definition DeclCXX.h:3581
shadow_iterator operator++(int)
Definition DeclCXX.h:3575
friend bool operator!=(shadow_iterator x, shadow_iterator y)
Definition DeclCXX.h:3584
Represents a C++ declaration that introduces decls from somewhere else.
Definition DeclCXX.h:3525
llvm::iterator_range< shadow_iterator > shadow_range
Definition DeclCXX.h:3589
bool getShadowFlag() const
A bool flag for use by a derived type.
Definition DeclCXX.h:3542
unsigned shadow_size() const
Return the number of shadowed declarations associated with this using declaration.
Definition DeclCXX.h:3603
void addShadowDecl(UsingShadowDecl *S)
Definition DeclCXX.cpp:3516
shadow_range shadows() const
Definition DeclCXX.h:3591
friend class ASTDeclReader
Definition DeclCXX.h:3548
shadow_iterator shadow_end() const
Definition DeclCXX.h:3599
static bool classofKind(Kind K)
Definition DeclCXX.h:3611
BaseUsingDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N)
Definition DeclCXX.h:3534
friend class ASTDeclWriter
Definition DeclCXX.h:3549
shadow_iterator shadow_begin() const
Definition DeclCXX.h:3595
void setShadowFlag(bool V)
A bool flag a derived type may set.
Definition DeclCXX.h:3545
void removeShadowDecl(UsingShadowDecl *S)
Definition DeclCXX.cpp:3525
static bool classof(const Decl *D)
Definition DeclCXX.h:3610
A binding in a decomposition declaration.
Definition DeclCXX.h:4214
VarDecl * getHoldingVar() const
Get the variable (if any) that holds the value of evaluating the binding.
Definition DeclCXX.cpp:3718
void setDecomposedDecl(DecompositionDecl *Decomposed)
Set the decomposed variable for this BindingDecl.
Definition DeclCXX.h:4258
Expr * getBinding() const
Get the expression to which this declaration is bound.
Definition DeclCXX.h:4240
friend class ASTDeclReader
Definition DeclCXX.h:4230
static bool classof(const Decl *D)
Definition DeclCXX.h:4264
DecompositionDecl * getDecomposedDecl() const
Get the decomposition declaration that this binding represents a decomposition of.
Definition DeclCXX.h:4247
void setBinding(QualType DeclaredType, Expr *Binding)
Set the binding for this BindingDecl, along with its declared type (which should be a possibly-cv-qua...
Definition DeclCXX.h:4252
ArrayRef< BindingDecl * > getBindingPackDecls() const
Definition DeclCXX.cpp:3731
static BindingDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:3713
static bool classofKind(Kind K)
Definition DeclCXX.h:4265
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Represents a base class of a C++ class.
Definition DeclCXX.h:146
void setInheritConstructors(bool Inherit=true)
Set that this base class's constructors should be inherited.
Definition DeclCXX.h:216
SourceLocation getBeginLoc() const LLVM_READONLY
Definition DeclCXX.h:194
AccessSpecifier getAccessSpecifierAsWritten() const
Retrieves the access specifier as written in the source code (which may mean that no access specifier...
Definition DeclCXX.h:242
CXXBaseSpecifier(SourceRange R, bool V, bool BC, AccessSpecifier A, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
Definition DeclCXX.h:187
SourceLocation getEllipsisLoc() const
For a pack expansion, determine the location of the ellipsis.
Definition DeclCXX.h:221
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
Definition DeclCXX.h:203
QualType getType() const
Retrieves the type of the base class.
Definition DeclCXX.h:249
TypeSourceInfo * getTypeSourceInfo() const
Retrieves the type and source location of the base class.
Definition DeclCXX.h:254
bool getInheritConstructors() const
Determine whether this base class's constructors get inherited.
Definition DeclCXX.h:213
bool isPackExpansion() const
Determine whether this base specifier is a pack expansion.
Definition DeclCXX.h:210
SourceLocation getBaseTypeLoc() const LLVM_READONLY
Get the location at which the base class type was written.
Definition DeclCXX.h:198
SourceLocation getEndLoc() const LLVM_READONLY
Definition DeclCXX.h:195
bool isBaseOfClass() const
Determine whether this base class is a base of a class declared with the 'class' keyword (vs.
Definition DeclCXX.h:207
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
Definition DeclCXX.h:193
AccessSpecifier getAccessSpecifier() const
Returns the access specifier for this base specifier.
Definition DeclCXX.h:230
Represents a C++ constructor within a class.
Definition DeclCXX.h:2641
std::reverse_iterator< init_const_iterator > init_const_reverse_iterator
Definition DeclCXX.h:2754
init_const_iterator init_end() const
Retrieve an iterator past the last initializer.
Definition DeclCXX.h:2749
init_iterator init_end()
Retrieve an iterator past the last initializer.
Definition DeclCXX.h:2744
std::reverse_iterator< init_iterator > init_reverse_iterator
Definition DeclCXX.h:2753
init_reverse_iterator init_rbegin()
Definition DeclCXX.h:2757
CXXConstructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition DeclCXX.h:2881
void setInheritingConstructor(bool isIC=true)
State that this is an implicit constructor synthesized to model a call to a constructor inherited fro...
Definition DeclCXX.h:2871
bool isExplicit() const
Return true if the declaration is already resolved to be explicit.
Definition DeclCXX.h:2718
init_iterator init_begin()
Retrieve an iterator to the first initializer.
Definition DeclCXX.h:2735
CXXConstructorDecl * getTargetConstructor() const
When this constructor delegates to another, retrieve the target.
Definition DeclCXX.cpp:3040
static bool classofKind(Kind K)
Definition DeclCXX.h:2893
static CXXConstructorDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, uint64_t AllocKind)
Definition DeclCXX.cpp:2998
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
Definition DeclCXX.cpp:3049
bool isDelegatingConstructor() const
Determine whether this constructor is a delegating constructor.
Definition DeclCXX.h:2791
void setCtorClosureDefaultArgs(ArrayRef< CXXDefaultArgExpr * > Args)
Definition DeclCXX.cpp:3143
bool isSpecializationCopyingObject() const
Determine whether this is a member template specialization that would copy the object to itself.
Definition DeclCXX.cpp:3124
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
Definition DeclCXX.h:2876
CXXCtorInitializer ** init_iterator
Iterates through the member/base initializer list.
Definition DeclCXX.h:2721
friend class ASTDeclReader
Definition DeclCXX.h:2688
bool isMoveConstructor() const
Determine whether this constructor is a move constructor (C++11 [class.copy]p3), which can be used to...
Definition DeclCXX.h:2836
init_const_reverse_iterator init_rbegin() const
Definition DeclCXX.h:2760
void setNumCtorInitializers(unsigned numCtorInitializers)
Definition DeclCXX.h:2777
void setExplicitSpecifier(ExplicitSpecifier ES)
Definition DeclCXX.h:2702
init_const_range inits() const
Definition DeclCXX.h:2730
bool isCopyOrMoveConstructor() const
Determine whether this a copy or move constructor.
Definition DeclCXX.h:2848
init_const_reverse_iterator init_rend() const
Definition DeclCXX.h:2767
bool isInheritingConstructor() const
Determine whether this is an implicit constructor synthesized to model a call to a constructor inheri...
Definition DeclCXX.h:2865
init_reverse_iterator init_rend()
Definition DeclCXX.h:2764
llvm::iterator_range< init_iterator > init_range
Definition DeclCXX.h:2726
CXXCtorInitializer *const * init_const_iterator
Iterates through the member/base initializer list.
Definition DeclCXX.h:2724
ArrayRef< CXXDefaultArgExpr * > getCtorClosureDefaultArgs() const
Definition DeclCXX.cpp:3139
friend class ASTDeclWriter
Definition DeclCXX.h:2689
unsigned getNumCtorInitializers() const
Determine the number of arguments used to initialize the member or base.
Definition DeclCXX.h:2773
llvm::iterator_range< init_const_iterator > init_const_range
Definition DeclCXX.h:2727
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:3106
const CXXConstructorDecl * getCanonicalDecl() const
Definition DeclCXX.h:2884
static bool classof(const Decl *D)
Definition DeclCXX.h:2892
void setCtorInitializers(CXXCtorInitializer **Initializers)
Definition DeclCXX.h:2786
ExplicitSpecifier getExplicitSpecifier() const
Definition DeclCXX.h:2713
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:2822
Represents a C++ conversion function within a class.
Definition DeclCXX.h:2976
bool isLambdaToBlockPointerConversion() const
Determine whether this conversion function is a conversion from a lambda closure type to a block poin...
Definition DeclCXX.cpp:3297
bool isExplicit() const
Return true if the declaration is already resolved to be explicit.
Definition DeclCXX.h:3008
static bool classof(const Decl *D)
Definition DeclCXX.h:3028
static bool classofKind(Kind K)
Definition DeclCXX.h:3029
friend class ASTDeclReader
Definition DeclCXX.h:2992
QualType getConversionType() const
Returns the type that this conversion function is converting to.
Definition DeclCXX.h:3012
void setExplicitSpecifier(ExplicitSpecifier ES)
Definition DeclCXX.h:3009
static CXXConversionDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:3275
friend class ASTDeclWriter
Definition DeclCXX.h:2993
const CXXConversionDecl * getCanonicalDecl() const
Definition DeclCXX.h:3023
ExplicitSpecifier getExplicitSpecifier() const
Definition DeclCXX.h:3003
CXXConversionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition DeclCXX.h:3020
Represents a C++ base or member initializer.
Definition DeclCXX.h:2406
FieldDecl * getMember() const
If this is a member initializer, returns the declaration of the non-static data member being initiali...
Definition DeclCXX.h:2546
bool isDelegatingInitializer() const
Determine whether this initializer is creating a delegating constructor.
Definition DeclCXX.h:2506
bool isWritten() const
Determine whether this initializer is explicitly written in the source code.
Definition DeclCXX.h:2578
Expr * getInit() const
Get the initializer.
Definition DeclCXX.h:2608
SourceLocation getRParenLoc() const
Definition DeclCXX.h:2605
SourceLocation getEllipsisLoc() const
Definition DeclCXX.h:2516
SourceLocation getLParenLoc() const
Definition DeclCXX.h:2604
SourceRange getSourceRange() const LLVM_READONLY
Determine the source range covering the entire initializer.
Definition DeclCXX.cpp:2966
int getSourceOrder() const
Return the source position of the initializer, counting from 0.
Definition DeclCXX.h:2582
SourceLocation getSourceLocation() const
Determine the source location of the initializer.
Definition DeclCXX.cpp:2953
bool isAnyMemberInitializer() const
Definition DeclCXX.h:2486
bool isPackExpansion() const
Determine whether this initializer is a pack expansion.
Definition DeclCXX.h:2511
TypeSourceInfo * getTypeSourceInfo() const
Returns the declarator information for a base class or delegating initializer.
Definition DeclCXX.h:2540
bool isMemberInitializer() const
Determine whether this initializer is initializing a non-static data member.
Definition DeclCXX.h:2484
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
Definition DeclCXX.h:2478
void setSourceOrder(int Pos)
Set the source order of this initializer.
Definition DeclCXX.h:2593
bool isIndirectMemberInitializer() const
Definition DeclCXX.h:2490
int64_t getID(const ASTContext &Context) const
Definition DeclCXX.cpp:2934
bool isInClassMemberInitializer() const
Determine whether this initializer is an implicit initializer generated for a field with an initializ...
Definition DeclCXX.h:2500
const Type * getBaseClass() const
If this is a base class initializer, returns the type of the base class.
Definition DeclCXX.cpp:2946
SourceLocation getMemberLocation() const
Definition DeclCXX.h:2566
FieldDecl * getAnyMember() const
Definition DeclCXX.h:2552
IndirectFieldDecl * getIndirectMember() const
Definition DeclCXX.h:2560
TypeLoc getBaseClassLoc() const
If this is a base class initializer, returns the type of the base class with location information.
Definition DeclCXX.cpp:2939
bool isBaseVirtual() const
Returns whether the base is virtual or not.
Definition DeclCXX.h:2532
CXXCtorInitializer(ASTContext &Context, TypeSourceInfo *TInfo, bool IsVirtual, SourceLocation L, Expr *Init, SourceLocation R, SourceLocation EllipsisLoc)
Creates a new base-class initializer.
Definition DeclCXX.cpp:2901
Represents a C++ deduction guide declaration.
Definition DeclCXX.h:2000
void setDeductionCandidateKind(DeductionCandidate K)
Definition DeclCXX.h:2091
void setSourceDeductionGuide(CXXDeductionGuideDecl *DG)
Definition DeclCXX.h:2079
static CXXDeductionGuideDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:2396
bool isExplicit() const
Return true if the declaration is already resolved to be explicit.
Definition DeclCXX.h:2061
ExplicitSpecifier getExplicitSpecifier() const
Definition DeclCXX.h:2058
CXXConstructorDecl * getCorrespondingConstructor() const
Get the constructor from which this deduction guide was generated, if this is an implicit deduction g...
Definition DeclCXX.h:2070
const CXXDeductionGuideDecl * getSourceDeductionGuide() const
Get the deduction guide from which this deduction guide was generated, if it was generated as part of...
Definition DeclCXX.h:2075
static bool classofKind(Kind K)
Definition DeclCXX.h:2102
void setSourceDeductionGuideKind(SourceDeductionGuideKind SK)
Definition DeclCXX.h:2087
TemplateDecl * getDeducedTemplate() const
Get the template for which this guide performs deduction.
Definition DeclCXX.h:2064
DeductionCandidate getDeductionCandidateKind() const
Definition DeclCXX.h:2095
static bool classof(const Decl *D)
Definition DeclCXX.h:2101
SourceDeductionGuideKind getSourceDeductionGuideKind() const
Definition DeclCXX.h:2083
Represents a C++ destructor within a class.
Definition DeclCXX.h:2906
void setGlobalOperatorArrayDelete(FunctionDecl *OD)
Definition DeclCXX.cpp:3216
static CXXDestructorDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:3150
const CXXDestructorDecl * getCanonicalDecl() const
Definition DeclCXX.h:2957
CXXDestructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition DeclCXX.h:2954
friend class ASTDeclReader
Definition DeclCXX.h:2907
const FunctionDecl * getOperatorGlobalDelete() const
Definition DeclCXX.cpp:3235
const FunctionDecl * getGlobalArrayOperatorDelete() const
Definition DeclCXX.cpp:3245
friend class ASTDeclWriter
Definition DeclCXX.h:2908
static bool classofKind(Kind K)
Definition DeclCXX.h:2963
const FunctionDecl * getOperatorDelete() const
Definition DeclCXX.cpp:3230
void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg)
Definition DeclCXX.cpp:3172
bool isCalledByDelete(const FunctionDecl *OpDel=nullptr) const
Will this destructor ever be called when considering which deallocation function is associated with t...
Definition DeclCXX.cpp:3250
void setOperatorArrayDelete(FunctionDecl *OD)
Definition DeclCXX.cpp:3203
Expr * getOperatorDeleteThisArg() const
Definition DeclCXX.h:2945
const FunctionDecl * getArrayOperatorDelete() const
Definition DeclCXX.cpp:3240
static bool classof(const Decl *D)
Definition DeclCXX.h:2962
void setOperatorGlobalDelete(FunctionDecl *OD)
Definition DeclCXX.cpp:3185
A mapping from each virtual member function to its set of final overriders.
A set of all the primary bases for a class.
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2149
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:2719
static bool classofKind(Kind K)
Definition DeclCXX.h:2386
const CXXMethodDecl * getMostRecentDecl() const
Definition DeclCXX.h:2273
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:2439
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:2726
void addOverriddenMethod(const CXXMethodDecl *MD)
Definition DeclCXX.cpp:2805
bool hasInlineBody() const
Definition DeclCXX.cpp:2883
bool isVirtual() const
Definition DeclCXX.h:2204
CXXSpecialMemberKind getSpecialMemberKind() const
Definition DeclCXX.h:2228
const CXXMethodDecl * getDevirtualizedMethod(const Expr *Base, bool IsAppleKext) const
Definition DeclCXX.h:2222
bool isUsualDeallocationFunction(SmallVectorImpl< const FunctionDecl * > &PreventedBy) const
Determine whether this is a usual deallocation function (C++ [basic.stc.dynamic.deallocation]p2),...
Definition DeclCXX.cpp:2609
unsigned getNumExplicitParams() const
Definition DeclCXX.h:2320
bool isVolatile() const
Definition DeclCXX.h:2202
CXXMethodDecl * getMostRecentDecl()
Definition DeclCXX.h:2269
overridden_method_range overridden_methods() const
Definition DeclCXX.cpp:2828
unsigned size_overridden_methods() const
Definition DeclCXX.cpp:2822
const CXXMethodDecl *const * method_iterator
Definition DeclCXX.h:2279
QualType getFunctionObjectParameterReferenceType() const
Return the type of the object pointed by this.
Definition DeclCXX.cpp:2870
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this method.
Definition DeclCXX.h:2342
method_iterator begin_overridden_methods() const
Definition DeclCXX.cpp:2812
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Definition DeclCXX.h:2292
QualType getThisType() const
Return the type of the this pointer.
Definition DeclCXX.cpp:2859
bool isInstance() const
Definition DeclCXX.h:2176
bool isCopyOrMoveConstructorOrAssignment() const
Determine whether this is a copy or move constructor or a copy or move assignment operator.
Definition DeclCXX.cpp:2777
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
Definition DeclCXX.cpp:2751
Qualifiers getMethodQualifiers() const
Definition DeclCXX.h:2327
CXXRecordDecl * getParent()
Return the parent of this method declaration, which is the class in which this method is defined.
Definition DeclCXX.h:2298
QualType getFunctionObjectParameterType() const
Definition DeclCXX.h:2316
const CXXMethodDecl * getCorrespondingMethodDeclaredInClass(const CXXRecordDecl *RD, bool MayBeBase=false) const
Definition DeclCXX.h:2378
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:2524
static bool isStaticOverloadedOperator(OverloadedOperatorKind OOK)
Returns true if the given operator is implicitly static in a record context.
Definition DeclCXX.h:2191
bool isConst() const
Definition DeclCXX.h:2201
CXXMethodDecl * getCorrespondingMethodInClass(const CXXRecordDecl *RD, bool MayBeBase=false)
Find the method in RD that corresponds to this one.
Definition DeclCXX.cpp:2470
bool isStatic() const
Definition DeclCXX.cpp:2417
static bool classof(const Decl *D)
Definition DeclCXX.h:2385
bool isMemcpyEquivalentSpecialMember(const ASTContext &Ctx) const
Returns whether this is a copy/move constructor or assignment operator that can be implemented as a m...
Definition DeclCXX.cpp:2782
const CXXMethodDecl * getCanonicalDecl() const
Definition DeclCXX.h:2265
bool isCopyAssignmentOperator() const
Determine whether this is a copy-assignment operator, regardless of whether it was declared implicitl...
Definition DeclCXX.cpp:2730
CXXMethodDecl(Kind DK, ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin, bool isInline, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, const AssociatedConstraint &TrailingRequiresClause={})
Definition DeclCXX.h:2153
static CXXMethodDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:2515
method_iterator end_overridden_methods() const
Definition DeclCXX.cpp:2817
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition DeclCXX.h:2262
bool isLambdaStaticInvoker() const
Determine whether this is a lambda closure type's static member function that is used for the result ...
Definition DeclCXX.cpp:2895
bool isCopyOrMoveConstructor() const
Determine whether this is a copy or move constructor.
Definition DeclCXX.cpp:2771
const CXXMethodDecl * getCorrespondingMethodInClass(const CXXRecordDecl *RD, bool MayBeBase=false) const
Definition DeclCXX.h:2367
llvm::iterator_range< llvm::TinyPtrVector< const CXXMethodDecl * >::const_iterator > overridden_method_range
Definition DeclCXX.h:2285
An iterator over the friend declarations of a class.
Definition DeclFriend.h:123
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
llvm::function_ref< bool(const CXXBaseSpecifier *Specifier, CXXBasePath &Path)> BaseMatchesCallback
Function type used by lookupInBases() to determine whether a specific base class subobject matches th...
Definition DeclCXX.h:1670
ctor_iterator ctor_end() const
Definition DeclCXX.h:676
bool hasCopyConstructorWithConstParam() const
Determine whether this class has a copy constructor with a parameter type which is a reference to a c...
Definition DeclCXX.h:834
bool hasConstexprDefaultConstructor() const
Determine whether this class has a constexpr default constructor.
Definition DeclCXX.h:1285
bool hasMoveConstructor() const
Determine whether this class has a move constructor.
Definition DeclCXX.h:857
bool hasDefaultConstructor() const
Determine whether this class has any default constructors.
Definition DeclCXX.h:761
friend class ASTWriter
Definition DeclCXX.h:265
friend_range friends() const
Definition DeclFriend.h:183
friend_iterator friend_begin() const
Definition DeclFriend.h:175
bool hasMutableFields() const
Determine whether this class, or any of its class subobjects, contains a mutable field.
Definition DeclCXX.h:1242
bool isHLSLIntangible() const
Returns true if the class contains HLSL intangible type, either as a field or in base class.
Definition DeclCXX.h:1565
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
Definition DeclCXX.cpp:1836
ctor_iterator ctor_begin() const
Definition DeclCXX.h:672
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:2326
bool hasTrivialMoveAssignment() const
Determine whether this class has a trivial move assignment operator (C++11 [class....
Definition DeclCXX.h:1356
void setLambdaTypeInfo(TypeSourceInfo *TS)
Definition DeclCXX.h:1888
bool isTriviallyCopyable() const
Determine whether this class is considered trivially copyable per (C++11 [class]p6).
Definition DeclCXX.cpp:613
bool hasNonTrivialCopyAssignment() const
Determine whether this class has a non-trivial copy assignment operator (C++ [class....
Definition DeclCXX.h:1349
TemplateParameterList * getGenericLambdaTemplateParameterList() const
Retrieve the generic lambda's template parameter list.
Definition DeclCXX.cpp:1813
friend class ASTRecordWriter
Definition DeclCXX.h:264
bool isEffectivelyFinal() const
Determine whether it's impossible for a class to be derived from this class.
Definition DeclCXX.cpp:2341
bool hasSimpleMoveConstructor() const
true if we know for sure that this class has a single, accessible, unambiguous move constructor that ...
Definition DeclCXX.h:734
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:1152
void getIndirectPrimaryBases(CXXIndirectPrimaryBaseSet &Bases) const
Get the indirect primary bases for this class.
bool isPFPType() const
Returns whether the pointer fields in this class should have pointer field protection (PFP) by defaul...
Definition DeclCXX.h:1251
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
Definition DeclCXX.h:1255
void setBases(CXXBaseSpecifier const *const *Bases, unsigned NumBases)
Sets the base classes of this struct or class.
Definition DeclCXX.cpp:185
bool isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e.
Definition DeclCXX.cpp:1681
base_class_iterator bases_end()
Definition DeclCXX.h:617
llvm::iterator_range< friend_iterator > friend_range
Definition DeclCXX.h:683
CXXRecordDecl * getMostRecentDecl()
Definition DeclCXX.h:539
bool hasPrivateFields() const
Definition DeclCXX.h:1200
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
Definition DeclCXX.h:1381
bool hasUserDeclaredDestructor() const
Determine whether this class has a user-declared destructor.
Definition DeclCXX.h:1010
friend class ODRDiagsEmitter
Definition DeclCXX.h:268
unsigned getLambdaDependencyKind() const
Definition DeclCXX.h:1878
void setLambdaIsGeneric(bool IsGeneric)
Definition DeclCXX.h:1899
specific_decl_iterator< CXXConstructorDecl > ctor_iterator
Iterator access to constructor members.
Definition DeclCXX.h:666
bool implicitCopyConstructorHasConstParam() const
Determine whether an implicit copy constructor for this type would have a parameter with a const-qual...
Definition DeclCXX.h:826
bool defaultedDestructorIsDeleted() const
true if a defaulted destructor for this class would be deleted.
Definition DeclCXX.h:718
const FunctionDecl * isLocalClass() const
If the class is a local class [class.local], returns the enclosing function declaration.
Definition DeclCXX.h:1577
bool hasInheritedAssignment() const
Determine whether this class has a using-declaration that names a base class assignment operator.
Definition DeclCXX.h:1435
bool hasUninitializedReferenceMember() const
Whether this class or any of its subobjects has any members of reference type which would make value-...
Definition DeclCXX.h:1167
bool allowConstDefaultInit() const
Determine whether declaring a const variable with this type is ok per core issue 253.
Definition DeclCXX.h:1406
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:2032
bool hasTrivialDestructorForCall() const
Definition DeclCXX.h:1385
bool hasInjectedClassType() const
Determines whether this declaration has is canonically of an injected class type.
Definition DeclCXX.cpp:2164
bool defaultedMoveConstructorIsDeleted() const
true if a defaulted move constructor for this class would be deleted.
Definition DeclCXX.h:710
CXXBaseSpecifier * base_class_iterator
Iterator that traverses the base classes of a class.
Definition DeclCXX.h:517
void completeDefinition() override
Indicates that the definition of this class is now complete.
Definition DeclCXX.cpp:2247
base_class_const_iterator bases_end() const
Definition DeclCXX.h:618
bool isLiteral() const
Determine whether this class is a literal type.
Definition DeclCXX.cpp:1508
bool hasUserDeclaredMoveAssignment() const
Determine whether this class has had a move assignment declared by the user.
Definition DeclCXX.h:969
CXXRecordDecl * getTemplateInstantiationPattern()
Definition DeclCXX.h:1548
bool hasDeletedDestructor() const
Returns the destructor decl for this class.
Definition DeclCXX.cpp:2148
bool defaultedDestructorIsConstexpr() const
Determine whether a defaulted default constructor for this class would be constexpr.
Definition DeclCXX.h:1371
bool mayBeNonDynamicClass() const
Definition DeclCXX.h:586
bool isStandardLayout() const
Determine whether this class is standard-layout per C++ [class]p7.
Definition DeclCXX.h:1234
void setCaptures(ASTContext &Context, ArrayRef< LambdaCapture > Captures)
Set the captures for this lambda closure type.
Definition DeclCXX.cpp:1631
void pushFriendDecl(FriendDecl *FD)
Definition DeclFriend.h:187
unsigned getDeviceLambdaManglingNumber() const
Retrieve the device side mangling number.
Definition DeclCXX.cpp:1857
llvm::iterator_range< base_class_const_iterator > base_class_const_range
Definition DeclCXX.h:605
llvm::iterator_range< capture_const_iterator > capture_const_range
Definition DeclCXX.h:1104
bool hasKnownLambdaInternalLinkage() const
The lambda is known to has internal linkage no matter whether it has name mangling number.
Definition DeclCXX.h:1795
base_class_range bases()
Definition DeclCXX.h:608
specific_decl_iterator< CXXMethodDecl > method_iterator
Iterator access to method members.
Definition DeclCXX.h:646
bool hasProtectedFields() const
Definition DeclCXX.h:1204
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation.
Definition DeclCXX.cpp:606
unsigned getLambdaIndexInContext() const
Retrieve the index of this lambda within the context declaration returned by getLambdaContextDecl().
Definition DeclCXX.h:1816
void setTrivialForCallFlags(CXXMethodDecl *MD)
Definition DeclCXX.cpp:1653
const CXXRecordDecl * getPreviousDecl() const
Definition DeclCXX.h:535
bool isLambda() const
Determine whether this class describes a lambda function object.
Definition DeclCXX.h:1027
friend class ASTDeclMerger
Definition DeclCXX.h:259
bool hasTrivialMoveConstructor() const
Determine whether this class has a trivial move constructor (C++11 [class.copy]p12)
Definition DeclCXX.h:1316
bool needsImplicitDefaultConstructor() const
Determine if we need to declare a default constructor for this class.
Definition DeclCXX.h:770
llvm::function_ref< bool(const CXXRecordDecl *BaseDefinition)> ForallBasesCallback
Function type used by forallBases() as a callback.
Definition DeclCXX.h:1647
void viewInheritance(ASTContext &Context) const
Renders and displays an inheritance diagram for this C++ class and all of its base classes (transitiv...
bool needsImplicitMoveConstructor() const
Determine whether this class should get an implicit move constructor or if any existing special membe...
Definition DeclCXX.h:898
bool hasUserDeclaredCopyAssignment() const
Determine whether this class has a user-declared copy assignment operator.
Definition DeclCXX.h:917
capture_const_iterator captures_end() const
Definition DeclCXX.h:1116
bool isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is provably not derived from the type Base.
void addedSelectedDestructor(CXXDestructorDecl *DD)
Notify the class that this destructor is now selected.
Definition DeclCXX.cpp:1533
unsigned getLambdaManglingNumber() const
If this is the closure type of a lambda expression, retrieve the number to be used for name mangling ...
Definition DeclCXX.h:1788
bool isNeverDependentLambda() const
Definition DeclCXX.h:1874
bool hasFriends() const
Determines whether this record has any friends.
Definition DeclCXX.h:691
method_range methods() const
Definition DeclCXX.h:650
static bool classof(const Decl *D)
Definition DeclCXX.h:1939
bool hasNonTrivialDestructor() const
Determine whether this class has a non-trivial destructor (C++ [class.dtor]p3)
Definition DeclCXX.h:1391
CXXRecordDecl * getDefinition() const
Definition DeclCXX.h:548
bool needsOverloadResolutionForCopyAssignment() const
Determine whether we need to eagerly declare a defaulted copy assignment operator for this class.
Definition DeclCXX.h:939
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
Definition DeclCXX.h:1744
bool isParsingBaseSpecifiers() const
Definition DeclCXX.h:592
friend class ASTReader
Definition DeclCXX.h:263
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:1792
bool hasConstexprNonCopyMoveConstructor() const
Determine whether this class has at least one constexpr constructor other than the copy or move const...
Definition DeclCXX.h:1270
static CXXRecordDecl * CreateLambda(const ASTContext &C, DeclContext *DC, TypeSourceInfo *Info, SourceLocation Loc, unsigned DependencyKind, bool IsGeneric, LambdaCaptureDefault CaptureDefault)
Definition DeclCXX.cpp:142
llvm::iterator_range< conversion_iterator > getVisibleConversionFunctions() const
Get all conversion functions visible in current class, including conversion function templates.
Definition DeclCXX.cpp:1989
bool defaultedDefaultConstructorIsConstexpr() const
Determine whether a defaulted default constructor for this class would be constexpr.
Definition DeclCXX.h:1278
bool hasTrivialCopyConstructor() const
Determine whether this class has a trivial copy constructor (C++ [class.copy]p6, C++11 [class....
Definition DeclCXX.h:1293
void setImplicitMoveAssignmentIsDeleted()
Set that we attempted to declare an implicit move assignment operator, but overload resolution failed...
Definition DeclCXX.h:981
bool hasConstexprDestructor() const
Determine whether this class has a constexpr destructor.
Definition DeclCXX.cpp:601
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
Definition DeclCXX.h:1223
unsigned getNumBases() const
Retrieves the number of base classes of this class.
Definition DeclCXX.h:602
bool hasNonLiteralTypeFieldsOrBases() const
Determine whether this class has a non-literal or/ volatile type non-static data member or base class...
Definition DeclCXX.h:1423
base_class_const_range bases() const
Definition DeclCXX.h:611
friend class ASTDeclReader
Definition DeclCXX.h:260
bool defaultedCopyConstructorIsDeleted() const
true if a defaulted copy constructor for this class would be deleted.
Definition DeclCXX.h:701
bool isStructural() const
Determine whether this is a structural type.
Definition DeclCXX.h:1473
bool hasMoveAssignment() const
Determine whether this class has a move assignment operator.
Definition DeclCXX.h:974
friend class ASTNodeImporter
Definition DeclCXX.h:262
bool isTriviallyCopyConstructible() const
Determine whether this class is considered trivially copyable per.
Definition DeclCXX.cpp:630
bool hasTrivialCopyConstructorForCall() const
Definition DeclCXX.h:1297
bool isCapturelessLambda() const
Definition DeclCXX.h:1073
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
Definition DeclCXX.cpp:2087
bool hasInitMethod() const
Definition DeclCXX.h:1198
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths, bool LookupInDependent=false) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
method_iterator method_begin() const
Method begin iterator.
Definition DeclCXX.h:656
bool lambdaIsDefaultConstructibleAndAssignable() const
Determine whether this lambda should have an implicit default constructor and copy and move assignmen...
Definition DeclCXX.cpp:732
bool isHLSLBuiltinRecord() const
Returns true if the class is a built-in HLSL record.
Definition DeclCXX.h:1568
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
Definition DeclCXX.cpp:2062
bool hasLazyFriends() const
Definition DeclCXX.h:695
base_class_iterator bases_begin()
Definition DeclCXX.h:615
FunctionTemplateDecl * getDependentLambdaCallOperator() const
Retrieve the dependent lambda call operator of the closure type if this is a templated closure type.
Definition DeclCXX.cpp:1739
bool hasTrivialCopyAssignment() const
Determine whether this class has a trivial copy assignment operator (C++ [class.copy]p11,...
Definition DeclCXX.h:1343
void addedEligibleSpecialMemberFunction(const CXXMethodDecl *MD, unsigned SMKind)
Notify the class that an eligible SMF has been added.
Definition DeclCXX.cpp:1538
conversion_iterator conversion_end() const
Definition DeclCXX.h:1134
const CXXBaseSpecifier * base_class_const_iterator
Iterator that traverses the base classes of a class.
Definition DeclCXX.h:520
base_class_range vbases()
Definition DeclCXX.h:625
bool hasUserProvidedDefaultConstructor() const
Whether this class has a user-provided default constructor per C++11.
Definition DeclCXX.h:791
base_class_iterator vbases_begin()
Definition DeclCXX.h:632
capture_const_range captures() const
Definition DeclCXX.h:1106
ctor_range ctors() const
Definition DeclCXX.h:670
void setImplicitMoveConstructorIsDeleted()
Set that we attempted to declare an implicit move constructor, but overload resolution failed so we d...
Definition DeclCXX.h:873
void finishedDefaultedOrDeletedMember(CXXMethodDecl *MD)
Indicates that the declaration of a defaulted or deleted special member function is now complete.
Definition DeclCXX.cpp:1584
bool isAbstract() const
Determine whether this class has a pure virtual function.
Definition DeclCXX.h:1230
base_class_const_iterator bases_begin() const
Definition DeclCXX.h:616
TypeSourceInfo * getLambdaTypeInfo() const
Definition DeclCXX.h:1884
bool hasVariantMembers() const
Determine whether this class has any variant members.
Definition DeclCXX.h:1245
void setImplicitCopyConstructorIsDeleted()
Set that we attempted to declare an implicit copy constructor, but overload resolution failed so we d...
Definition DeclCXX.h:864
CXXRecordDecl(Kind K, TagKind TK, const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl)
Definition DeclCXX.cpp:125
bool isDynamicClass() const
Definition DeclCXX.h:574
bool isCLike() const
True if this class is C-like, without C++-specific features, e.g.
Definition DeclCXX.cpp:1670
void setInstantiationOfMemberClass(CXXRecordDecl *RD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member class RD.
Definition DeclCXX.cpp:2045
bool hasInClassInitializer() const
Whether this class has any in-class initializers for non-static data members (including those in anon...
Definition DeclCXX.h:1157
bool mayBeDynamicClass() const
Definition DeclCXX.h:580
bool needsImplicitCopyConstructor() const
Determine whether this class needs an implicit copy constructor to be lazily declared.
Definition DeclCXX.h:804
base_class_const_iterator vbases_end() const
Definition DeclCXX.h:635
bool hasIrrelevantDestructor() const
Determine whether this class has a destructor which has no semantic effect.
Definition DeclCXX.h:1417
llvm::iterator_range< specific_decl_iterator< CXXConstructorDecl > > ctor_range
Definition DeclCXX.h:667
static CXXRecordDecl * CreateDeserialized(const ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:155
bool isDependentLambda() const
Determine whether this lambda expression was known to be dependent at the time it was created,...
Definition DeclCXX.h:1870
bool hasSimpleMoveAssignment() const
true if we know for sure that this class has a single, accessible, unambiguous move assignment operat...
Definition DeclCXX.h:748
bool hasNonTrivialMoveConstructor() const
Determine whether this class has a non-trivial move constructor (C++11 [class.copy]p12)
Definition DeclCXX.h:1328
bool hasNonTrivialCopyConstructorForCall() const
Definition DeclCXX.h:1308
bool hasDirectFields() const
Determine whether this class has direct non-static data members.
Definition DeclCXX.h:1209
const LambdaCapture * capture_const_iterator
Definition DeclCXX.h:1103
const CXXRecordDecl * getCanonicalDecl() const
Definition DeclCXX.h:526
friend class LambdaExpr
Definition DeclCXX.h:267
MSInheritanceModel getMSInheritanceModel() const
Returns the inheritance model used for this record.
bool hasUserDeclaredCopyConstructor() const
Determine whether this class has a user-declared copy constructor.
Definition DeclCXX.h:798
bool isCXX11StandardLayout() const
Determine whether this class was standard-layout per C++11 [class]p7, specifically using the C++11 ru...
Definition DeclCXX.h:1238
bool nullFieldOffsetIsZero() const
In the Microsoft C++ ABI, use zero for the field offset of a null data member pointer if we can guara...
void setIsHLSLBuiltinRecord(bool Value)
Sets the flag that the class is a built-in HLSL record.
Definition DeclCXX.h:1571
friend class ASTDeclWriter
Definition DeclCXX.h:261
CanQualType getCanonicalTemplateSpecializationType(const ASTContext &Ctx) const
Definition DeclCXX.cpp:2177
bool hasUserDeclaredConstructor() const
Determine whether this class has any user-declared constructors.
Definition DeclCXX.h:785
base_class_const_iterator vbases_begin() const
Definition DeclCXX.h:633
llvm::iterator_range< base_class_iterator > base_class_range
Definition DeclCXX.h:604
unsigned getODRHash() const
Definition DeclCXX.cpp:496
LambdaNumbering getLambdaNumbering() const
Definition DeclCXX.h:1833
bool hasDefinition() const
Definition DeclCXX.h:561
ArrayRef< NamedDecl * > getLambdaExplicitTemplateParameters() const
Retrieve the lambda template parameters that were specified explicitly.
Definition DeclCXX.cpp:1822
void setImplicitCopyAssignmentIsDeleted()
Set that we attempted to declare an implicit copy assignment operator, but overload resolution failed...
Definition DeclCXX.h:923
bool needsImplicitDestructor() const
Determine whether this class needs an implicit destructor to be lazily declared.
Definition DeclCXX.h:1016
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
Definition DeclCXX.cpp:2054
bool isPOD() const
Whether this class is a POD-type (C++ [class]p4)
Definition DeclCXX.h:1180
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:2007
MSInheritanceModel calculateInheritanceModel() const
Calculate what the inheritance model would be for this class.
bool hasSimpleCopyConstructor() const
true if we know for sure that this class has a single, accessible, unambiguous copy constructor that ...
Definition DeclCXX.h:727
bool isCurrentInstantiation(const DeclContext *CurContext) const
Determine whether this dependent class is a current instantiation, when viewed from within the given ...
MSVtorDispMode getMSVtorDispMode() const
Controls when vtordisps will be emitted if this record is used as a virtual base.
bool needsOverloadResolutionForMoveConstructor() const
Determine whether we need to eagerly declare a defaulted move constructor for this class.
Definition DeclCXX.h:909
base_class_iterator vbases_end()
Definition DeclCXX.h:634
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
Definition DeclCXX.cpp:2154
void setInitMethod(bool Val)
Definition DeclCXX.h:1197
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
Definition DeclCXX.h:1195
LambdaCaptureDefault getLambdaCaptureDefault() const
Definition DeclCXX.h:1068
bool hasMemberName(DeclarationName N) const
Determine whether this class has a member with the given name, possibly in a non-dependent base class...
bool needsOverloadResolutionForMoveAssignment() const
Determine whether we need to eagerly declare a move assignment operator for this class.
Definition DeclCXX.h:1003
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
Definition DeclCXX.cpp:2129
bool hasCopyAssignmentWithConstParam() const
Determine whether this class has a copy assignment operator with a parameter type which is a referenc...
Definition DeclCXX.h:961
bool hasNonTrivialMoveAssignment() const
Determine whether this class has a non-trivial move assignment operator (C++11 [class....
Definition DeclCXX.h:1363
bool hasNonTrivialDestructorForCall() const
Definition DeclCXX.h:1395
void setHasTrivialSpecialMemberForCall()
Definition DeclCXX.h:1399
method_iterator method_end() const
Method past-the-end iterator.
Definition DeclCXX.h:661
static bool classofKind(Kind K)
Definition DeclCXX.h:1940
capture_const_iterator captures_begin() const
Definition DeclCXX.h:1110
bool needsOverloadResolutionForDestructor() const
Determine whether we need to eagerly declare a destructor for this class.
Definition DeclCXX.h:1022
bool hasUserDeclaredMoveOperation() const
Whether this class has a user-declared move constructor or assignment operator.
Definition DeclCXX.h:845
llvm::iterator_range< specific_decl_iterator< CXXMethodDecl > > method_range
Definition DeclCXX.h:647
void setLambdaContextDecl(Decl *ContextDecl)
Set the context declaration for a lambda class.
Definition DeclCXX.cpp:1842
UnresolvedSetIterator conversion_iterator
Definition DeclCXX.h:1128
bool hasInheritedConstructor() const
Determine whether this class has a using-declaration that names a user-declared base class constructo...
Definition DeclCXX.h:1429
static bool FindVirtualBaseClass(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, const CXXRecordDecl *BaseRecord)
Base-class lookup callback that determines whether the given base class specifier refers to a specifi...
CXXMethodDecl * getLambdaStaticInvoker() const
Retrieve the lambda static invoker, the address of which is returned by the conversion operator,...
Definition DeclCXX.cpp:1756
bool hasNonTrivialDefaultConstructor() const
Determine whether this class has a non-trivial default constructor (C++11 [class.ctor]p5).
Definition DeclCXX.h:1262
bool needsOverloadResolutionForCopyConstructor() const
Determine whether we need to eagerly declare a defaulted copy constructor for this class.
Definition DeclCXX.h:811
CXXRecordDecl * getDefinitionOrSelf() const
Definition DeclCXX.h:555
static bool FindBaseClass(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, const CXXRecordDecl *BaseRecord)
Base-class lookup callback that determines whether the given base class specifier refers to a specifi...
void setImplicitDestructorIsDeleted()
Set that we attempted to declare an implicit destructor, but overload resolution failed so we deleted...
Definition DeclCXX.h:882
bool hasUserDeclaredMoveConstructor() const
Determine whether this class has had a move constructor declared by the user.
Definition DeclCXX.h:852
bool needsImplicitMoveAssignment() const
Determine whether this class should get an implicit move assignment operator or if any existing speci...
Definition DeclCXX.h:991
bool hasSimpleDestructor() const
true if we know for sure that this class has an accessible destructor that is not deleted.
Definition DeclCXX.h:755
friend_iterator friend_end() const
Definition DeclFriend.h:179
void setDescribedClassTemplate(ClassTemplateDecl *Template)
Definition DeclCXX.cpp:2058
bool isVirtuallyDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is virtually derived from the class Base.
bool isInterfaceLike() const
Definition DeclCXX.cpp:2196
unsigned capture_size() const
Definition DeclCXX.h:1121
void setIsParsingBaseSpecifiers()
Definition DeclCXX.h:590
friend class DeclContext
Definition DeclCXX.h:266
bool hasNonTrivialMoveConstructorForCall() const
Definition DeclCXX.h:1334
bool needsImplicitCopyAssignment() const
Determine whether this class needs an implicit copy assignment operator to be lazily declared.
Definition DeclCXX.h:932
void setLambdaNumbering(LambdaNumbering Numbering)
Set the mangling numbers for a lambda class.
Definition DeclCXX.cpp:1847
bool isAnyDestructorNoReturn() const
Returns true if the class destructor, or any implicitly invoked destructors are marked noreturn.
Definition DeclCXX.h:1561
bool forallBases(ForallBasesCallback BaseMatches) const
Determines if the given callback holds for all the direct or indirect base classes of this type.
base_class_const_range vbases() const
Definition DeclCXX.h:628
void setLambdaDependencyKind(unsigned Kind)
Definition DeclCXX.h:1895
bool hasTrivialMoveConstructorForCall() const
Definition DeclCXX.h:1321
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization,...
Definition DeclCXX.cpp:2039
FunctionDecl * isLocalClass()
Definition DeclCXX.h:1584
bool hasNonTrivialCopyConstructor() const
Determine whether this class has a non-trivial copy constructor (C++ [class.copy]p6,...
Definition DeclCXX.h:1303
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
Definition DeclCXX.cpp:1744
const LambdaCapture * getCapture(unsigned I) const
Definition DeclCXX.h:1123
const CXXRecordDecl * getMostRecentDecl() const
Definition DeclCXX.h:544
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:565
bool hasSimpleCopyAssignment() const
true if we know for sure that this class has a single, accessible, unambiguous copy assignment operat...
Definition DeclCXX.h:741
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition DeclCXX.h:522
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
Definition DeclCXX.cpp:2073
bool isTrivial() const
Determine whether this class is considered trivial.
Definition DeclCXX.h:1451
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
Definition DeclCXX.h:623
conversion_iterator conversion_begin() const
Definition DeclCXX.h:1130
CXXRecordDecl * getPreviousDecl()
Definition DeclCXX.h:530
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
bool implicitCopyAssignmentHasConstParam() const
Determine whether an implicit copy assignment operator for this type would have a parameter with a co...
Definition DeclCXX.h:954
Declaration of a class template.
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition DeclCXX.h:3706
const CXXRecordDecl * getParent() const
Returns the parent of this using shadow declaration, which is the class in which this is declared.
Definition DeclCXX.h:3770
static ConstructorUsingShadowDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:3506
static bool classof(const Decl *D)
Definition DeclCXX.h:3810
CXXRecordDecl * getConstructedBaseClass() const
Get the base class whose constructor or constructor shadow declaration is passed the constructor argu...
Definition DeclCXX.h:3797
static bool classofKind(Kind K)
Definition DeclCXX.h:3811
UsingDecl * getIntroducer() const
Override the UsingShadowDecl's getIntroducer, returning the UsingDecl that introduced this.
Definition DeclCXX.h:3763
bool constructsVirtualBase() const
Returns true if the constructed base class is a virtual base class subobject of this declaration's cl...
Definition DeclCXX.h:3806
ConstructorUsingShadowDecl * getConstructedBaseClassShadowDecl() const
Get the inheriting constructor declaration for the base class for which we don't have an explicit ini...
Definition DeclCXX.h:3787
ConstructorUsingShadowDecl * getNominatedBaseClassShadowDecl() const
Get the inheriting constructor declaration for the direct base class from which this using shadow dec...
Definition DeclCXX.h:3781
CXXRecordDecl * getNominatedBaseClass() const
Get the base class that was named in the using declaration.
Definition DeclCXX.cpp:3510
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
Definition DeclBase.h:2423
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1466
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition DeclBase.h:2126
FunctionDeclBitfields FunctionDeclBits
Definition DeclBase.h:2061
CXXConstructorDeclBitfields CXXConstructorDeclBits
Definition DeclBase.h:2062
decl_iterator decls_end() const
Definition DeclBase.h:2405
bool decls_empty() const
LinkageSpecDeclBitfields LinkageSpecDeclBits
Definition DeclBase.h:2065
decl_iterator decls_begin() const
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
Decl()=delete
SourceLocation getEndLoc() const LLVM_READONLY
Definition DeclBase.h:443
ASTContext & getASTContext() const LLVM_READONLY
Definition DeclBase.cpp:550
virtual Decl * getPreviousDeclImpl()
Implementation of getPreviousDecl(), to be overridden by any subclass that has a redeclaration chain.
Definition DeclBase.h:1012
Kind
Lists the kind of concrete classes of Decl.
Definition DeclBase.h:89
unsigned getIdentifierNamespace() const
Definition DeclBase.h:906
virtual Decl * getNextRedeclarationImpl()
Returns the next redeclaration or itself if this is the only decl.
Definition DeclBase.h:1008
void setAccess(AccessSpecifier AS)
Definition DeclBase.h:510
SourceLocation getLocation() const
Definition DeclBase.h:447
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
Definition DeclBase.h:115
@ IDNS_TagFriend
This declaration is a friend class.
Definition DeclBase.h:157
@ IDNS_OrdinaryFriend
This declaration is a friend function.
Definition DeclBase.h:152
@ IDNS_LocalExtern
This declaration is a function-local extern declaration of a variable or function.
Definition DeclBase.h:175
void setImplicit(bool I=true)
Definition DeclBase.h:602
void setLocation(SourceLocation L)
Definition DeclBase.h:448
DeclContext * getDeclContext()
Definition DeclBase.h:456
virtual Decl * getMostRecentDeclImpl()
Implementation of getMostRecentDecl(), to be overridden by any subclass that has a redeclaration chai...
Definition DeclBase.h:1016
friend class DeclContext
Definition DeclBase.h:260
Kind getKind() const
Definition DeclBase.h:450
const LangOptions & getLangOpts() const LLVM_READONLY
Helper to get the language options from the ASTContext.
Definition DeclBase.cpp:556
DeclarationNameLoc - Additional source/type location info for a declaration name.
The name of a declaration.
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
static DeclarationName getUsingDirectiveName()
Returns the name for all C++ using-directives.
DeclaratorDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL)
Definition Decl.h:800
A decomposition declaration.
Definition DeclCXX.h:4278
void printName(raw_ostream &OS, const PrintingPolicy &Policy) const override
Pretty-print the unqualified name of this declaration.
Definition DeclCXX.cpp:3765
ArrayRef< BindingDecl * > bindings() const
Definition DeclCXX.h:4318
static bool classof(const Decl *D)
Definition DeclCXX.h:4347
auto flat_bindings() const
Definition DeclCXX.h:4323
friend class ASTDeclReader
Definition DeclCXX.h:4305
static bool classofKind(Kind K)
Definition DeclCXX.h:4348
SourceLocation getRSquareLoc() const
The closing bracket (before the initializer is expected).
Definition DeclCXX.h:4343
static DecompositionDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NumBindings)
Definition DeclCXX.cpp:3751
Represents an enum.
Definition Decl.h:4145
Store information needed for an explicit specifier.
Definition DeclCXX.h:1948
bool isExplicit() const
Determine whether this specifier is known to correspond to an explicit declaration.
Definition DeclCXX.h:1972
ExplicitSpecKind getKind() const
Definition DeclCXX.h:1956
bool isInvalid() const
Determine if the explicit specifier is invalid.
Definition DeclCXX.h:1977
static ExplicitSpecifier Invalid()
Definition DeclCXX.h:1985
bool isEquivalent(ExplicitSpecifier Other) const
Check for equivalence of explicit specifiers.
Definition DeclCXX.cpp:2355
const Expr * getExpr() const
Definition DeclCXX.h:1957
void setExpr(Expr *E)
Definition DeclCXX.h:1982
void setKind(ExplicitSpecKind Kind)
Definition DeclCXX.h:1981
static ExplicitSpecifier getFromDecl(const FunctionDecl *Function)
Definition DeclCXX.cpp:2370
bool isSpecified() const
Determine if the declaration had an explicit specifier of any kind.
Definition DeclCXX.h:1961
ExplicitSpecifier(Expr *Expression, ExplicitSpecKind Kind)
Definition DeclCXX.h:1954
This represents one expression.
Definition Expr.h:113
Represents a member of a struct/union/class.
Definition Decl.h:3294
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
Definition DeclFriend.h:46
CXXSpecialMemberKind asSpecialMember() const
Definition Decl.h:2151
Represents a function declaration or definition.
Definition Decl.h:2058
void setIsPureVirtual(bool P=true)
Definition Decl.cpp:3342
bool UsesFPIntrin() const
Determine whether the function was declared in source context that requires constrained FP intrinsics...
Definition Decl.h:3039
QualType getReturnType() const
Definition Decl.h:2975
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition Decl.cpp:3791
FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass S, bool UsesFPIntrin, bool isInlineSpecified, ConstexprSpecKind ConstexprKind, const AssociatedConstraint &TrailingRequiresClause)
Definition Decl.cpp:3067
bool isPureVirtual() const
Whether this virtual function is pure, i.e.
Definition Decl.h:2479
void setRangeEnd(SourceLocation E)
Definition Decl.h:2331
DefaultedFunctionKind getDefaultedFunctionKind() const
Determine the kind of defaulting that would be done for a given function.
Definition Decl.cpp:3288
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
Definition Decl.h:2470
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
Definition Decl.cpp:3870
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5421
Declaration of a template function.
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition TypeBase.h:4617
One of these records is kept for each identifier that is lexed.
Represents a field injected from an anonymous union/struct into the parent scope.
Definition Decl.h:3601
Description of a constructor that was inherited from a base class.
Definition DeclCXX.h:2612
CXXConstructorDecl * getConstructor() const
Definition DeclCXX.h:2625
InheritedConstructor(ConstructorUsingShadowDecl *Shadow, CXXConstructorDecl *BaseCtor)
Definition DeclCXX.h:2618
ConstructorUsingShadowDecl * getShadowDecl() const
Definition DeclCXX.h:2624
Describes the capture of a variable or of this, or of a C++1y init-capture.
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
Definition DeclCXX.h:3337
const ValueDecl * getExtendingDecl() const
Definition DeclCXX.h:3373
APValue * getOrCreateValue(bool MayCreate) const
Get the storage for the constant value of a materialized temporary of static storage duration.
Definition DeclCXX.cpp:3453
static bool classof(const Decl *D)
Definition DeclCXX.h:3403
Stmt::child_range childrenExpr()
Definition DeclCXX.h:3395
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
Definition DeclCXX.cpp:3437
Stmt::const_child_range childrenExpr() const
Definition DeclCXX.h:3399
static LifetimeExtendedTemporaryDecl * Create(Expr *Temp, ValueDecl *EDec, unsigned Mangling)
Definition DeclCXX.h:3362
Expr * getTemporaryExpr()
Retrieve the expression to which the temporary materialization conversion was applied.
Definition DeclCXX.h:3383
static LifetimeExtendedTemporaryDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.h:3367
const Expr * getTemporaryExpr() const
Definition DeclCXX.h:3384
static bool classofKind(Kind K)
Definition DeclCXX.h:3404
void setExternLoc(SourceLocation L)
Definition DeclCXX.h:3085
void setLanguage(LinkageSpecLanguageIDs L)
Set the language specified by this linkage specification.
Definition DeclCXX.h:3072
static bool classofKind(Kind K)
Definition DeclCXX.h:3104
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition DeclCXX.h:3099
void setRBraceLoc(SourceLocation L)
Definition DeclCXX.h:3086
static LinkageSpecDecl * castFromDeclContext(const DeclContext *DC)
Definition DeclCXX.h:3110
static DeclContext * castToDeclContext(const LinkageSpecDecl *D)
Definition DeclCXX.h:3106
LinkageSpecLanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Definition DeclCXX.h:3067
SourceLocation getExternLoc() const
Definition DeclCXX.h:3083
SourceLocation getRBraceLoc() const
Definition DeclCXX.h:3084
SourceLocation getEndLoc() const LLVM_READONLY
Definition DeclCXX.h:3091
static bool classof(const Decl *D)
Definition DeclCXX.h:3103
static LinkageSpecDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:3321
bool hasBraces() const
Determines whether this linkage specification had braces in its syntactic form.
Definition DeclCXX.h:3078
static bool classof(const Decl *D)
Definition DeclCXX.h:4477
Parts getParts() const
Get the decomposed parts of this declaration.
Definition DeclCXX.h:4462
static bool classofKind(Kind K)
Definition DeclCXX.h:4478
friend class ASTReader
Definition DeclCXX.h:4453
friend class ASTDeclReader
Definition DeclCXX.h:4454
static void Profile(llvm::FoldingSetNodeID &ID, Parts P)
Definition DeclCXX.h:4469
friend class ASTContext
Definition DeclCXX.h:4452
void Profile(llvm::FoldingSetNodeID &ID)
Definition DeclCXX.h:4475
APValue & getAsAPValue() const
Get the value of this MSGuidDecl as an APValue.
Definition DeclCXX.cpp:3872
MSGuidDeclParts Parts
Definition DeclCXX.h:4434
void printName(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const override
Print this UUID in a human-readable format.
Definition DeclCXX.cpp:3811
static bool classof(const Decl *D)
Definition DeclCXX.h:4397
bool hasSetter() const
Definition DeclCXX.h:4401
IdentifierInfo * getGetterId() const
Definition DeclCXX.h:4400
friend class ASTDeclReader
Definition DeclCXX.h:4389
bool hasGetter() const
Definition DeclCXX.h:4399
IdentifierInfo * getSetterId() const
Definition DeclCXX.h:4402
static MSPropertyDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:3789
Provides information a specialization of a member of a class template, which may be a member function...
This represents a decl that may have a name.
Definition Decl.h:274
NamedDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N)
Definition Decl.h:286
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition Decl.h:301
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition Decl.h:340
Represents a C++ namespace alias.
Definition DeclCXX.h:3230
static NamespaceAliasDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:3426
const NamespaceAliasDecl * getCanonicalDecl() const
Definition DeclCXX.h:3285
redeclarable_base::redecl_range redecl_range
Definition DeclCXX.h:3273
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition DeclCXX.h:3325
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition DeclCXX.h:3291
friend class ASTDeclReader
Definition DeclCXX.h:3231
SourceLocation getAliasLoc() const
Returns the location of the alias name, i.e.
Definition DeclCXX.h:3313
NamespaceBaseDecl * getAliasedNamespace() const
Retrieve the namespace that this alias refers to, which may either be a NamespaceDecl or a NamespaceA...
Definition DeclCXX.h:3323
static bool classof(const Decl *D)
Definition DeclCXX.h:3329
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
Definition DeclCXX.h:3316
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
Definition DeclCXX.h:3319
NamespaceAliasDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition DeclCXX.h:3282
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Definition DeclCXX.h:3300
redeclarable_base::redecl_iterator redecl_iterator
Definition DeclCXX.h:3274
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of the namespace.
Definition DeclCXX.h:3295
static bool classofKind(Kind K)
Definition DeclCXX.h:3330
const NamespaceDecl * getNamespace() const
Definition DeclCXX.h:3307
Represents C++ namespaces and their aliases.
Definition Decl.h:573
NamespaceDecl * getNamespace()
Definition DeclCXX.cpp:3351
Represent a C++ namespace.
Definition Decl.h:592
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
A (possibly-)qualified type.
Definition TypeBase.h:938
void Profile(llvm::FoldingSetNodeID &ID) const
Definition TypeBase.h:1414
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
Definition TypeBase.h:8687
The collection of all-type qualifiers we support.
Definition TypeBase.h:332
RecordDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl)
Definition Decl.cpp:5269
Provides common interface for the Decls that can be redeclared.
UsingShadowDecl * getNextRedeclaration() const
llvm::iterator_range< redecl_iterator > redecl_range
static DeclContext * castToDeclContext(const RequiresExprBodyDecl *D)
Definition DeclCXX.h:2136
static RequiresExprBodyDecl * castFromDeclContext(const DeclContext *DC)
Definition DeclCXX.h:2140
static bool classofKind(Kind K)
Definition DeclCXX.h:2134
static RequiresExprBodyDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:2411
static bool classof(const Decl *D)
Definition DeclCXX.h:2133
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
const Expr * getMessage() const
Definition DeclCXX.h:4192
bool isFailed() const
Definition DeclCXX.h:4194
friend class ASTDeclReader
Definition DeclCXX.h:4180
static bool classofKind(Kind K)
Definition DeclCXX.h:4203
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition DeclCXX.h:4198
const Expr * getAssertExpr() const
Definition DeclCXX.h:4189
SourceLocation getRParenLoc() const
Definition DeclCXX.h:4196
static StaticAssertDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:3689
static bool classof(const Decl *D)
Definition DeclCXX.h:4202
Stmt - This represents one statement.
Definition Stmt.h:85
llvm::iterator_range< child_iterator > child_range
Definition Stmt.h:1594
llvm::iterator_range< const_child_iterator > const_child_range
Definition Stmt.h:1595
TagTypeKind TagKind
Definition Decl.h:3856
void startDefinition()
Starts the definition of this tag declaration.
Definition Decl.cpp:4967
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition Decl.cpp:4960
bool isUnion() const
Definition Decl.h:4062
The base class of all kinds of template declarations (e.g., class, function, etc.).
Stores a list of template parameters for a TemplateDecl and its derived classes.
friend class ASTContext
Definition Decl.h:3648
TypeDecl(Kind DK, DeclContext *DC, SourceLocation L, const IdentifierInfo *Id, SourceLocation StartL=SourceLocation())
Definition Decl.h:3663
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Decl.h:3681
Base wrapper for a particular "section" of type source info.
Definition TypeLoc.h:59
NestedNameSpecifierLoc getPrefix() const
If this type represents a qualified-id, this returns it's nested name specifier.
Definition TypeLoc.cpp:475
A container of type source information.
Definition TypeBase.h:8473
The base class of the type hierarchy.
Definition TypeBase.h:1879
const T * castAs() const
Member-template castAs<specific type>.
Definition TypeBase.h:9405
const APValue & getValue() const
Definition DeclCXX.h:4515
static bool classofKind(Kind K)
Definition DeclCXX.h:4527
static bool classof(const Decl *D)
Definition DeclCXX.h:4526
void printName(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const override
Print this in a human-readable format.
Definition DeclCXX.cpp:3922
static void Profile(llvm::FoldingSetNodeID &ID, QualType Ty, const APValue &APVal)
Definition DeclCXX.h:4517
void Profile(llvm::FoldingSetNodeID &ID)
Definition DeclCXX.h:4522
The iterator over UnresolvedSets.
static UnresolvedUsingIfExistsDecl * CreateDeserialized(ASTContext &Ctx, GlobalDeclID ID)
Definition DeclCXX.cpp:3665
static bool classof(const Decl *D)
Definition DeclCXX.h:4160
static bool classofKind(Kind K)
Definition DeclCXX.h:4161
Represents a dependent using declaration which was marked with typename.
Definition DeclCXX.h:4066
bool isPackExpansion() const
Determine whether this is a pack expansion.
Definition DeclCXX.h:4112
SourceLocation getTypenameLoc() const
Returns the source location of the 'typename' keyword.
Definition DeclCXX.h:4096
static bool classofKind(Kind K)
Definition DeclCXX.h:4139
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition DeclCXX.h:4100
SourceLocation getUsingLoc() const
Returns the source location of the 'using' keyword.
Definition DeclCXX.h:4093
static bool classof(const Decl *D)
Definition DeclCXX.h:4138
UnresolvedUsingTypenameDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this declaration.
Definition DeclCXX.h:4131
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition DeclCXX.h:4117
const UnresolvedUsingTypenameDecl * getCanonicalDecl() const
Definition DeclCXX.h:4134
DeclarationNameInfo getNameInfo() const
Definition DeclCXX.h:4107
static UnresolvedUsingTypenameDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:3651
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Definition DeclCXX.h:4103
Represents a dependent using declaration which was not marked with typename.
Definition DeclCXX.h:3969
const UnresolvedUsingValueDecl * getCanonicalDecl() const
Definition DeclCXX.h:4045
bool isPackExpansion() const
Determine whether this is a pack expansion.
Definition DeclCXX.h:4022
SourceLocation getUsingLoc() const
Returns the source location of the 'using' keyword.
Definition DeclCXX.h:4000
static bool classofKind(Kind K)
Definition DeclCXX.h:4050
bool isAccessDeclaration() const
Return true if it is a C++03 access declaration (no 'using').
Definition DeclCXX.h:4006
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition DeclCXX.h:4010
static bool classof(const Decl *D)
Definition DeclCXX.h:4049
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Definition DeclCXX.h:4013
DeclarationNameInfo getNameInfo() const
Definition DeclCXX.h:4017
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition DeclCXX.cpp:3629
void setUsingLoc(SourceLocation L)
Set the source location of the 'using' keyword.
Definition DeclCXX.h:4003
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition DeclCXX.h:4027
UnresolvedUsingValueDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this declaration.
Definition DeclCXX.h:4042
static UnresolvedUsingValueDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:3621
Represents a C++ using-declaration.
Definition DeclCXX.h:3620
void setTypename(bool TN)
Sets whether the using declaration has 'typename'.
Definition DeclCXX.h:3672
UsingDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this declaration.
Definition DeclCXX.h:3685
bool hasTypename() const
Return true if the using declaration has 'typename'.
Definition DeclCXX.h:3669
bool isAccessDeclaration() const
Return true if it is a C++03 access declaration (no 'using').
Definition DeclCXX.h:3666
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition DeclCXX.cpp:3560
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Definition DeclCXX.h:3657
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition DeclCXX.h:3654
friend class ASTDeclReader
Definition DeclCXX.h:3643
void setUsingLoc(SourceLocation L)
Set the source location of the 'using' keyword.
Definition DeclCXX.h:3650
static UsingDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:3554
const UsingDecl * getCanonicalDecl() const
Definition DeclCXX.h:3688
friend class ASTDeclWriter
Definition DeclCXX.h:3644
DeclarationNameInfo getNameInfo() const
Definition DeclCXX.h:3661
static bool classof(const Decl *D)
Definition DeclCXX.h:3692
static bool classofKind(Kind K)
Definition DeclCXX.h:3693
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
Definition DeclCXX.h:3647
Represents C++ using-directive.
Definition DeclCXX.h:3125
static UsingDirectiveDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:3343
const NamedDecl * getNominatedNamespaceAsWritten() const
Definition DeclCXX.h:3179
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition DeclCXX.h:3214
const DeclContext * getCommonAncestor() const
Definition DeclCXX.h:3193
static bool classofKind(Kind K)
Definition DeclCXX.h:3219
friend class ASTDeclReader
Definition DeclCXX.h:3163
SourceLocation getUsingLoc() const
Return the location of the using keyword.
Definition DeclCXX.h:3196
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
Definition DeclCXX.cpp:3357
const NamespaceDecl * getNominatedNamespace() const
Definition DeclCXX.h:3186
static bool classof(const Decl *D)
Definition DeclCXX.h:3218
NamedDecl * getNominatedNamespaceAsWritten()
Definition DeclCXX.h:3178
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
Definition DeclCXX.h:3192
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
Definition DeclCXX.h:3200
SourceLocation getIdentLocation() const
Returns the location of this using declaration's identifier.
Definition DeclCXX.h:3203
friend class DeclContext
Definition DeclCXX.h:3166
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of the namespace.
Definition DeclCXX.h:3174
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition DeclCXX.h:3170
Represents a C++ using-enum-declaration.
Definition DeclCXX.h:3821
void setEnumType(TypeSourceInfo *TSI)
Definition DeclCXX.h:3860
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition DeclCXX.cpp:3584
void setEnumLoc(SourceLocation L)
Definition DeclCXX.h:3846
NestedNameSpecifierLoc getQualifierLoc() const
Definition DeclCXX.h:3850
SourceLocation getEnumLoc() const
The source location of the 'enum' keyword.
Definition DeclCXX.h:3845
void setUsingLoc(SourceLocation L)
Definition DeclCXX.h:3842
UsingEnumDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this declaration.
Definition DeclCXX.h:3876
friend class ASTDeclReader
Definition DeclCXX.h:3837
EnumDecl * getEnumDecl() const
Definition DeclCXX.h:3863
friend class ASTDeclWriter
Definition DeclCXX.h:3838
const UsingEnumDecl * getCanonicalDecl() const
Definition DeclCXX.h:3879
TypeSourceInfo * getEnumType() const
Definition DeclCXX.h:3857
static bool classofKind(Kind K)
Definition DeclCXX.h:3884
static UsingEnumDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:3577
static bool classof(const Decl *D)
Definition DeclCXX.h:3883
NestedNameSpecifier getQualifier() const
Definition DeclCXX.h:3847
TypeLoc getEnumTypeLoc() const
Definition DeclCXX.h:3854
SourceLocation getUsingLoc() const
The source location of the 'using' keyword.
Definition DeclCXX.h:3841
Represents a pack of using declarations that a single using-declarator pack-expanded into.
Definition DeclCXX.h:3902
static UsingPackDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NumExpansions)
Definition DeclCXX.cpp:3597
const UsingPackDecl * getCanonicalDecl() const
Definition DeclCXX.h:3951
UsingPackDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition DeclCXX.h:3950
NamedDecl * getInstantiatedFromUsingDecl() const
Get the using declaration from which this was instantiated.
Definition DeclCXX.h:3931
static bool classof(const Decl *D)
Definition DeclCXX.h:3953
friend class ASTDeclReader
Definition DeclCXX.h:3924
static bool classofKind(Kind K)
Definition DeclCXX.h:3954
ArrayRef< NamedDecl * > expansions() const
Get the set of using declarations that this pack expanded into.
Definition DeclCXX.h:3935
friend class ASTDeclWriter
Definition DeclCXX.h:3925
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition DeclCXX.h:3946
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3428
UsingShadowDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
UsingShadowDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition DeclCXX.h:3483
UsingShadowDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
redeclarable_base::redecl_range redecl_range
Definition DeclCXX.h:3473
friend class ASTDeclReader
Definition DeclCXX.h:3461
static UsingShadowDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, DeclarationName Name, BaseUsingDecl *Introducer, NamedDecl *Target)
Definition DeclCXX.h:3464
UsingShadowDecl * getNextUsingShadowDecl() const
The next using shadow declaration contained in the shadow decl chain of the using declaration which i...
Definition DeclCXX.h:3512
void setTargetDecl(NamedDecl *ND)
Sets the underlying declaration which has been brought into the local scope.
Definition DeclCXX.h:3496
static bool classofKind(Kind K)
Definition DeclCXX.h:3517
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition DeclCXX.h:3492
friend class ASTDeclWriter
Definition DeclCXX.h:3462
redeclarable_base::redecl_iterator redecl_iterator
Definition DeclCXX.h:3474
UsingShadowDecl(Kind K, ASTContext &C, DeclContext *DC, SourceLocation Loc, DeclarationName Name, BaseUsingDecl *Introducer, NamedDecl *Target)
Definition DeclCXX.cpp:3466
static UsingShadowDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:3482
static bool classof(const Decl *D)
Definition DeclCXX.h:3516
friend class BaseUsingDecl
Definition DeclCXX.h:3429
BaseUsingDecl * getIntroducer() const
Gets the (written or instantiated) using declaration that introduced this declaration.
Definition DeclCXX.cpp:3487
const UsingShadowDecl * getCanonicalDecl() const
Definition DeclCXX.h:3486
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:712
ValueDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T)
Definition Decl.h:718
void setType(QualType newType)
Definition Decl.h:724
QualType getType() const
Definition Decl.h:723
bool isParameterPack() const
Determine whether this value is actually a function parameter pack, init-capture pack,...
Definition Decl.cpp:5654
Represents a variable declaration or definition.
Definition Decl.h:932
VarDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass SC)
Definition Decl.cpp:2116
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
bool isa(CodeGen::Address addr)
Definition Address.h:330
ConstexprSpecKind
Define the kind of constexpr specifier.
Definition Specifiers.h:36
LinkageSpecLanguageIDs
Represents the language in a linkage specification.
Definition DeclCXX.h:3036
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
Definition TypeBase.h:1799
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
LazyOffsetPtr< CXXCtorInitializer *, uint64_t, &ExternalASTSource::GetExternalCXXCtorInitializers > LazyCXXCtorInitializersPtr
A lazy pointer to a set of CXXCtorInitializers.
LazyOffsetPtr< CXXBaseSpecifier, uint64_t, &ExternalASTSource::GetExternalCXXBaseSpecifiers > LazyCXXBaseSpecifiersPtr
A lazy pointer to a set of CXXBaseSpecifiers.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition Specifiers.h:124
@ AS_public
Definition Specifiers.h:125
@ AS_none
Definition Specifiers.h:128
@ AS_private
Definition Specifiers.h:127
LazyOffsetPtr< Decl, GlobalDeclID, &ExternalASTSource::GetExternalDecl > LazyDeclPtr
A lazy pointer to a declaration.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
StorageClass
Storage classes.
Definition Specifiers.h:249
@ SC_None
Definition Specifiers.h:251
StorageDuration
The storage duration for an object (per C++ [basic.stc]).
Definition Specifiers.h:338
const FunctionProtoType * T
@ Template
We are parsing a template declaration.
Definition Parser.h:81
MSVtorDispMode
In the Microsoft ABI, this controls the placement of virtual displacement members used to implement v...
Definition LangOptions.h:38
CXXSpecialMemberKind
Kinds of C++ special members.
Definition Decl.h:2018
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
Definition Lambda.h:22
@ LCD_None
Definition Lambda.h:23
DeductionCandidate
Only used by CXXDeductionGuideDecl.
Definition DeclBase.h:1438
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
Definition Specifiers.h:411
ExplicitSpecKind
Define the meaning of possible values of the kind in ExplicitSpecifier.
Definition Specifiers.h:29
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition Specifiers.h:189
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition Specifiers.h:279
U cast(CodeGen::Address addr)
Definition Address.h:327
@ Other
Other implicit parameter.
Definition Decl.h:1774
__packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 uint8_t
__packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 __packed_splat4 uint16_t
__packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 uint32_t
#define false
Definition stdbool.h:26
Information about how a lambda is numbered within its context.
Definition DeclCXX.h:1822
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...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
const DeclarationNameLoc & getInfo() const
Parts of a decomposed MSGuidDecl.
Definition DeclCXX.h:4407
uint16_t Part2
...-89ab-...
Definition DeclCXX.h:4411
uint32_t Part1
{01234567-...
Definition DeclCXX.h:4409
uint16_t Part3
...-cdef-...
Definition DeclCXX.h:4413
uint8_t Part4And5[8]
...-0123-456789abcdef}
Definition DeclCXX.h:4415
uint64_t getPart4And5AsUint64() const
Definition DeclCXX.h:4417
Describes how types, statements, expressions, and declarations should be printed.