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