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