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