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