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