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