clang 22.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;
57class ClassTemplateDecl;
58class ConstructorUsingShadowDecl;
59class CXXBasePath;
60class CXXBasePaths;
61class CXXConstructorDecl;
62class CXXDestructorDecl;
63class CXXFinalOverriderMap;
64class CXXIndirectPrimaryBaseSet;
65class CXXMethodDecl;
66class DecompositionDecl;
67class FriendDecl;
68class FunctionTemplateDecl;
69class IdentifierInfo;
70class MemberSpecializationInfo;
71class BaseUsingDecl;
72class TemplateDecl;
73class TemplateParameterList;
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
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
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.
243 return (AccessSpecifier)Access;
244 }
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:
289 };
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:
511 CXXRecordDecl(Kind K, TagKind TK, const ASTContext &C, DeclContext *DC,
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
523 return cast<CXXRecordDecl>(RecordDecl::getCanonicalDecl());
524 }
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,
566 CXXRecordDecl *PrevDecl = nullptr);
569 unsigned DependencyKind, bool IsGeneric,
570 LambdaCaptureDefault CaptureDefault);
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
610 }
613 }
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
627 }
630 }
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.
658 }
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
1099 }
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 /// Determine whether this class has a trivial default constructor
1239 /// (C++11 [class.ctor]p5).
1241 return hasDefaultConstructor() &&
1242 (data().HasTrivialSpecialMembers & SMF_DefaultConstructor);
1243 }
1244
1245 /// Determine whether this class has a non-trivial default constructor
1246 /// (C++11 [class.ctor]p5).
1248 return (data().DeclaredNonTrivialSpecialMembers & SMF_DefaultConstructor) ||
1250 !(data().HasTrivialSpecialMembers & SMF_DefaultConstructor));
1251 }
1252
1253 /// Determine whether this class has at least one constexpr constructor
1254 /// other than the copy or move constructors.
1256 return data().HasConstexprNonCopyMoveConstructor ||
1259 }
1260
1261 /// Determine whether a defaulted default constructor for this class
1262 /// would be constexpr.
1264 return data().DefaultedDefaultConstructorIsConstexpr &&
1266 getLangOpts().CPlusPlus20);
1267 }
1268
1269 /// Determine whether this class has a constexpr default constructor.
1271 return data().HasConstexprDefaultConstructor ||
1274 }
1275
1276 /// Determine whether this class has a trivial copy constructor
1277 /// (C++ [class.copy]p6, C++11 [class.copy]p12)
1279 return data().HasTrivialSpecialMembers & SMF_CopyConstructor;
1280 }
1281
1283 return data().HasTrivialSpecialMembersForCall & SMF_CopyConstructor;
1284 }
1285
1286 /// Determine whether this class has a non-trivial copy constructor
1287 /// (C++ [class.copy]p6, C++11 [class.copy]p12)
1289 return data().DeclaredNonTrivialSpecialMembers & SMF_CopyConstructor ||
1291 }
1292
1294 return (data().DeclaredNonTrivialSpecialMembersForCall &
1295 SMF_CopyConstructor) ||
1297 }
1298
1299 /// Determine whether this class has a trivial move constructor
1300 /// (C++11 [class.copy]p12)
1302 return hasMoveConstructor() &&
1303 (data().HasTrivialSpecialMembers & SMF_MoveConstructor);
1304 }
1305
1307 return hasMoveConstructor() &&
1308 (data().HasTrivialSpecialMembersForCall & SMF_MoveConstructor);
1309 }
1310
1311 /// Determine whether this class has a non-trivial move constructor
1312 /// (C++11 [class.copy]p12)
1314 return (data().DeclaredNonTrivialSpecialMembers & SMF_MoveConstructor) ||
1316 !(data().HasTrivialSpecialMembers & SMF_MoveConstructor));
1317 }
1318
1320 return (data().DeclaredNonTrivialSpecialMembersForCall &
1321 SMF_MoveConstructor) ||
1323 !(data().HasTrivialSpecialMembersForCall & SMF_MoveConstructor));
1324 }
1325
1326 /// Determine whether this class has a trivial copy assignment operator
1327 /// (C++ [class.copy]p11, C++11 [class.copy]p25)
1329 return data().HasTrivialSpecialMembers & SMF_CopyAssignment;
1330 }
1331
1332 /// Determine whether this class has a non-trivial copy assignment
1333 /// operator (C++ [class.copy]p11, C++11 [class.copy]p25)
1335 return data().DeclaredNonTrivialSpecialMembers & SMF_CopyAssignment ||
1337 }
1338
1339 /// Determine whether this class has a trivial move assignment operator
1340 /// (C++11 [class.copy]p25)
1342 return hasMoveAssignment() &&
1343 (data().HasTrivialSpecialMembers & SMF_MoveAssignment);
1344 }
1345
1346 /// Determine whether this class has a non-trivial move assignment
1347 /// operator (C++11 [class.copy]p25)
1349 return (data().DeclaredNonTrivialSpecialMembers & SMF_MoveAssignment) ||
1351 !(data().HasTrivialSpecialMembers & SMF_MoveAssignment));
1352 }
1353
1354 /// Determine whether a defaulted default constructor for this class
1355 /// would be constexpr.
1357 return data().DefaultedDestructorIsConstexpr &&
1358 getLangOpts().CPlusPlus20;
1359 }
1360
1361 /// Determine whether this class has a constexpr destructor.
1362 bool hasConstexprDestructor() const;
1363
1364 /// Determine whether this class has a trivial destructor
1365 /// (C++ [class.dtor]p3)
1367 return data().HasTrivialSpecialMembers & SMF_Destructor;
1368 }
1369
1371 return data().HasTrivialSpecialMembersForCall & SMF_Destructor;
1372 }
1373
1374 /// Determine whether this class has a non-trivial destructor
1375 /// (C++ [class.dtor]p3)
1377 return !(data().HasTrivialSpecialMembers & SMF_Destructor);
1378 }
1379
1381 return !(data().HasTrivialSpecialMembersForCall & SMF_Destructor);
1382 }
1383
1385 data().HasTrivialSpecialMembersForCall =
1386 (SMF_CopyConstructor | SMF_MoveConstructor | SMF_Destructor);
1387 }
1388
1389 /// Determine whether declaring a const variable with this type is ok
1390 /// per core issue 253.
1392 return !data().HasUninitializedFields ||
1393 !(data().HasDefaultedDefaultConstructor ||
1395 }
1396
1397 /// Determine whether this class has a destructor which has no
1398 /// semantic effect.
1399 ///
1400 /// Any such destructor will be trivial, public, defaulted and not deleted,
1401 /// and will call only irrelevant destructors.
1403 return data().HasIrrelevantDestructor;
1404 }
1405
1406 /// Determine whether this class has a non-literal or/ volatile type
1407 /// non-static data member or base class.
1409 return data().HasNonLiteralTypeFieldsOrBases;
1410 }
1411
1412 /// Determine whether this class has a using-declaration that names
1413 /// a user-declared base class constructor.
1415 return data().HasInheritedConstructor;
1416 }
1417
1418 /// Determine whether this class has a using-declaration that names
1419 /// a base class assignment operator.
1421 return data().HasInheritedAssignment;
1422 }
1423
1424 /// Determine whether this class is considered trivially copyable per
1425 /// (C++11 [class]p6).
1426 bool isTriviallyCopyable() const;
1427
1428 /// Determine whether this class is considered trivially copyable per
1429 bool isTriviallyCopyConstructible() const;
1430
1431 /// Determine whether this class is considered trivial.
1432 ///
1433 /// C++11 [class]p6:
1434 /// "A trivial class is a class that has a trivial default constructor and
1435 /// is trivially copyable."
1436 bool isTrivial() const {
1438 }
1439
1440 /// Determine whether this class is a literal type.
1441 ///
1442 /// C++20 [basic.types]p10:
1443 /// A class type that has all the following properties:
1444 /// - it has a constexpr destructor
1445 /// - all of its non-static non-variant data members and base classes
1446 /// are of non-volatile literal types, and it:
1447 /// - is a closure type
1448 /// - is an aggregate union type that has either no variant members
1449 /// or at least one variant member of non-volatile literal type
1450 /// - is a non-union aggregate type for which each of its anonymous
1451 /// union members satisfies the above requirements for an aggregate
1452 /// union type, or
1453 /// - has at least one constexpr constructor or constructor template
1454 /// that is not a copy or move constructor.
1455 bool isLiteral() const;
1456
1457 /// Determine whether this is a structural type.
1458 bool isStructural() const {
1459 return isLiteral() && data().StructuralIfLiteral;
1460 }
1461
1462 /// Notify the class that this destructor is now selected.
1463 ///
1464 /// Important properties of the class depend on destructor properties. Since
1465 /// C++20, it is possible to have multiple destructor declarations in a class
1466 /// out of which one will be selected at the end.
1467 /// This is called separately from addedMember because it has to be deferred
1468 /// to the completion of the class.
1470
1471 /// Notify the class that an eligible SMF has been added.
1472 /// This updates triviality and destructor based properties of the class accordingly.
1473 void addedEligibleSpecialMemberFunction(const CXXMethodDecl *MD, unsigned SMKind);
1474
1475 /// If this record is an instantiation of a member class,
1476 /// retrieves the member class from which it was instantiated.
1477 ///
1478 /// This routine will return non-null for (non-templated) member
1479 /// classes of class templates. For example, given:
1480 ///
1481 /// \code
1482 /// template<typename T>
1483 /// struct X {
1484 /// struct A { };
1485 /// };
1486 /// \endcode
1487 ///
1488 /// The declaration for X<int>::A is a (non-templated) CXXRecordDecl
1489 /// whose parent is the class template specialization X<int>. For
1490 /// this declaration, getInstantiatedFromMemberClass() will return
1491 /// the CXXRecordDecl X<T>::A. When a complete definition of
1492 /// X<int>::A is required, it will be instantiated from the
1493 /// declaration returned by getInstantiatedFromMemberClass().
1495
1496 /// If this class is an instantiation of a member class of a
1497 /// class template specialization, retrieves the member specialization
1498 /// information.
1500
1501 /// Specify that this record is an instantiation of the
1502 /// member class \p RD.
1505
1506 /// Retrieves the class template that is described by this
1507 /// class declaration.
1508 ///
1509 /// Every class template is represented as a ClassTemplateDecl and a
1510 /// CXXRecordDecl. The former contains template properties (such as
1511 /// the template parameter lists) while the latter contains the
1512 /// actual description of the template's
1513 /// contents. ClassTemplateDecl::getTemplatedDecl() retrieves the
1514 /// CXXRecordDecl that from a ClassTemplateDecl, while
1515 /// getDescribedClassTemplate() retrieves the ClassTemplateDecl from
1516 /// a CXXRecordDecl.
1518
1520
1521 /// Determine whether this particular class is a specialization or
1522 /// instantiation of a class template or member class of a class template,
1523 /// and how it was instantiated or specialized.
1525
1526 /// Set the kind of specialization or template instantiation this is.
1528
1529 /// Retrieve the record declaration from which this record could be
1530 /// instantiated. Returns null if this class is not a template instantiation.
1532
1534 return const_cast<CXXRecordDecl *>(const_cast<const CXXRecordDecl *>(this)
1536 }
1537
1538 /// Returns the destructor decl for this class.
1540
1541 /// Returns the destructor decl for this class.
1542 bool hasDeletedDestructor() const;
1543
1544 /// Returns true if the class destructor, or any implicitly invoked
1545 /// destructors are marked noreturn.
1546 bool isAnyDestructorNoReturn() const { return data().IsAnyDestructorNoReturn; }
1547
1548 /// Returns true if the class contains HLSL intangible type, either as
1549 /// a field or in base class.
1550 bool isHLSLIntangible() const { return data().IsHLSLIntangible; }
1551
1552 /// If the class is a local class [class.local], returns
1553 /// the enclosing function declaration.
1555 if (const auto *RD = dyn_cast<CXXRecordDecl>(getDeclContext()))
1556 return RD->isLocalClass();
1557
1558 return dyn_cast<FunctionDecl>(getDeclContext());
1559 }
1560
1562 return const_cast<FunctionDecl*>(
1563 const_cast<const CXXRecordDecl*>(this)->isLocalClass());
1564 }
1565
1566 /// Determine whether this dependent class is a current instantiation,
1567 /// when viewed from within the given context.
1568 bool isCurrentInstantiation(const DeclContext *CurContext) const;
1569
1570 /// Determine whether this class is derived from the class \p Base.
1571 ///
1572 /// This routine only determines whether this class is derived from \p Base,
1573 /// but does not account for factors that may make a Derived -> Base class
1574 /// ill-formed, such as private/protected inheritance or multiple, ambiguous
1575 /// base class subobjects.
1576 ///
1577 /// \param Base the base class we are searching for.
1578 ///
1579 /// \returns true if this class is derived from Base, false otherwise.
1580 bool isDerivedFrom(const CXXRecordDecl *Base) const;
1581
1582 /// Determine whether this class is derived from the type \p Base.
1583 ///
1584 /// This routine only determines whether this class is derived from \p Base,
1585 /// but does not account for factors that may make a Derived -> Base class
1586 /// ill-formed, such as private/protected inheritance or multiple, ambiguous
1587 /// base class subobjects.
1588 ///
1589 /// \param Base the base class we are searching for.
1590 ///
1591 /// \param Paths will contain the paths taken from the current class to the
1592 /// given \p Base class.
1593 ///
1594 /// \returns true if this class is derived from \p Base, false otherwise.
1595 ///
1596 /// \todo add a separate parameter to configure IsDerivedFrom, rather than
1597 /// tangling input and output in \p Paths
1598 bool isDerivedFrom(const CXXRecordDecl *Base, CXXBasePaths &Paths) const;
1599
1600 /// Determine whether this class is virtually derived from
1601 /// the class \p Base.
1602 ///
1603 /// This routine only determines whether this class is virtually
1604 /// derived from \p Base, but does not account for factors that may
1605 /// make a Derived -> Base class ill-formed, such as
1606 /// private/protected inheritance or multiple, ambiguous base class
1607 /// subobjects.
1608 ///
1609 /// \param Base the base class we are searching for.
1610 ///
1611 /// \returns true if this class is virtually derived from Base,
1612 /// false otherwise.
1613 bool isVirtuallyDerivedFrom(const CXXRecordDecl *Base) const;
1614
1615 /// Determine whether this class is provably not derived from
1616 /// the type \p Base.
1617 bool isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const;
1618
1619 /// Function type used by forallBases() as a callback.
1620 ///
1621 /// \param BaseDefinition the definition of the base class
1622 ///
1623 /// \returns true if this base matched the search criteria
1625 llvm::function_ref<bool(const CXXRecordDecl *BaseDefinition)>;
1626
1627 /// Determines if the given callback holds for all the direct
1628 /// or indirect base classes of this type.
1629 ///
1630 /// The class itself does not count as a base class. This routine
1631 /// returns false if the class has non-computable base classes.
1632 ///
1633 /// \param BaseMatches Callback invoked for each (direct or indirect) base
1634 /// class of this type until a call returns false.
1635 bool forallBases(ForallBasesCallback BaseMatches) const;
1636
1637 /// Function type used by lookupInBases() to determine whether a
1638 /// specific base class subobject matches the lookup criteria.
1639 ///
1640 /// \param Specifier the base-class specifier that describes the inheritance
1641 /// from the base class we are trying to match.
1642 ///
1643 /// \param Path the current path, from the most-derived class down to the
1644 /// base named by the \p Specifier.
1645 ///
1646 /// \returns true if this base matched the search criteria, false otherwise.
1648 llvm::function_ref<bool(const CXXBaseSpecifier *Specifier,
1649 CXXBasePath &Path)>;
1650
1651 /// Look for entities within the base classes of this C++ class,
1652 /// transitively searching all base class subobjects.
1653 ///
1654 /// This routine uses the callback function \p BaseMatches to find base
1655 /// classes meeting some search criteria, walking all base class subobjects
1656 /// and populating the given \p Paths structure with the paths through the
1657 /// inheritance hierarchy that resulted in a match. On a successful search,
1658 /// the \p Paths structure can be queried to retrieve the matching paths and
1659 /// to determine if there were any ambiguities.
1660 ///
1661 /// \param BaseMatches callback function used to determine whether a given
1662 /// base matches the user-defined search criteria.
1663 ///
1664 /// \param Paths used to record the paths from this class to its base class
1665 /// subobjects that match the search criteria.
1666 ///
1667 /// \param LookupInDependent can be set to true to extend the search to
1668 /// dependent base classes.
1669 ///
1670 /// \returns true if there exists any path from this class to a base class
1671 /// subobject that matches the search criteria.
1672 bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths,
1673 bool LookupInDependent = false) const;
1674
1675 /// Base-class lookup callback that determines whether the given
1676 /// base class specifier refers to a specific class declaration.
1677 ///
1678 /// This callback can be used with \c lookupInBases() to determine whether
1679 /// a given derived class has is a base class subobject of a particular type.
1680 /// The base record pointer should refer to the canonical CXXRecordDecl of the
1681 /// base class that we are searching for.
1682 static bool FindBaseClass(const CXXBaseSpecifier *Specifier,
1683 CXXBasePath &Path, const CXXRecordDecl *BaseRecord);
1684
1685 /// Base-class lookup callback that determines whether the
1686 /// given base class specifier refers to a specific class
1687 /// declaration and describes virtual derivation.
1688 ///
1689 /// This callback can be used with \c lookupInBases() to determine
1690 /// whether a given derived class has is a virtual base class
1691 /// subobject of a particular type. The base record pointer should
1692 /// refer to the canonical CXXRecordDecl of the base class that we
1693 /// are searching for.
1696 const CXXRecordDecl *BaseRecord);
1697
1698 /// Retrieve the final overriders for each virtual member
1699 /// function in the class hierarchy where this class is the
1700 /// most-derived class in the class hierarchy.
1701 void getFinalOverriders(CXXFinalOverriderMap &FinaOverriders) const;
1702
1703 /// Get the indirect primary bases for this class.
1705
1706 /// Determine whether this class has a member with the given name, possibly
1707 /// in a non-dependent base class.
1708 ///
1709 /// No check for ambiguity is performed, so this should never be used when
1710 /// implementing language semantics, but it may be appropriate for warnings,
1711 /// static analysis, or similar.
1712 bool hasMemberName(DeclarationName N) const;
1713
1714 /// Renders and displays an inheritance diagram
1715 /// for this C++ class and all of its base classes (transitively) using
1716 /// GraphViz.
1717 void viewInheritance(ASTContext& Context) const;
1718
1719 /// Calculates the access of a decl that is reached
1720 /// along a path.
1722 AccessSpecifier DeclAccess) {
1723 assert(DeclAccess != AS_none);
1724 if (DeclAccess == AS_private) return AS_none;
1725 return (PathAccess > DeclAccess ? PathAccess : DeclAccess);
1726 }
1727
1728 /// Indicates that the declaration of a defaulted or deleted special
1729 /// member function is now complete.
1731
1733
1734 /// Indicates that the definition of this class is now complete.
1735 void completeDefinition() override;
1736
1737 /// Indicates that the definition of this class is now complete,
1738 /// and provides a final overrider map to help determine
1739 ///
1740 /// \param FinalOverriders The final overrider map for this class, which can
1741 /// be provided as an optimization for abstract-class checking. If NULL,
1742 /// final overriders will be computed if they are needed to complete the
1743 /// definition.
1744 void completeDefinition(CXXFinalOverriderMap *FinalOverriders);
1745
1746 /// Determine whether this class may end up being abstract, even though
1747 /// it is not yet known to be abstract.
1748 ///
1749 /// \returns true if this class is not known to be abstract but has any
1750 /// base classes that are abstract. In this case, \c completeDefinition()
1751 /// will need to compute final overriders to determine whether the class is
1752 /// actually abstract.
1753 bool mayBeAbstract() const;
1754
1755 /// Determine whether it's impossible for a class to be derived from this
1756 /// class. This is best-effort, and may conservatively return false.
1757 bool isEffectivelyFinal() const;
1758
1759 /// If this is the closure type of a lambda expression, retrieve the
1760 /// number to be used for name mangling in the Itanium C++ ABI.
1761 ///
1762 /// Zero indicates that this closure type has internal linkage, so the
1763 /// mangling number does not matter, while a non-zero value indicates which
1764 /// lambda expression this is in this particular context.
1765 unsigned getLambdaManglingNumber() const {
1766 assert(isLambda() && "Not a lambda closure type!");
1767 return getLambdaData().ManglingNumber;
1768 }
1769
1770 /// The lambda is known to has internal linkage no matter whether it has name
1771 /// mangling number.
1773 assert(isLambda() && "Not a lambda closure type!");
1774 return getLambdaData().HasKnownInternalLinkage;
1775 }
1776
1777 /// Retrieve the declaration that provides additional context for a
1778 /// lambda, when the normal declaration context is not specific enough.
1779 ///
1780 /// Certain contexts (default arguments of in-class function parameters and
1781 /// the initializers of data members) have separate name mangling rules for
1782 /// lambdas within the Itanium C++ ABI. For these cases, this routine provides
1783 /// the declaration in which the lambda occurs, e.g., the function parameter
1784 /// or the non-static data member. Otherwise, it returns NULL to imply that
1785 /// the declaration context suffices.
1786 Decl *getLambdaContextDecl() const;
1787
1788 /// Retrieve the index of this lambda within the context declaration returned
1789 /// by getLambdaContextDecl().
1790 unsigned getLambdaIndexInContext() const {
1791 assert(isLambda() && "Not a lambda closure type!");
1792 return getLambdaData().IndexInContext;
1793 }
1794
1795 /// Information about how a lambda is numbered within its context.
1797 Decl *ContextDecl = nullptr;
1798 unsigned IndexInContext = 0;
1799 unsigned ManglingNumber = 0;
1802 };
1803
1804 /// Set the mangling numbers and context declaration for a lambda class.
1805 void setLambdaNumbering(LambdaNumbering Numbering);
1806
1807 // Get the mangling numbers and context declaration for a lambda class.
1812 }
1813
1814 /// Retrieve the device side mangling number.
1815 unsigned getDeviceLambdaManglingNumber() const;
1816
1817 /// Returns the inheritance model used for this record.
1819
1820 /// Calculate what the inheritance model would be for this class.
1822
1823 /// In the Microsoft C++ ABI, use zero for the field offset of a null data
1824 /// member pointer if we can guarantee that zero is not a valid field offset,
1825 /// or if the member pointer has multiple fields. Polymorphic classes have a
1826 /// vfptr at offset zero, so we can use zero for null. If there are multiple
1827 /// fields, we can use zero even if it is a valid field offset because
1828 /// null-ness testing will check the other fields.
1829 bool nullFieldOffsetIsZero() const;
1830
1831 /// Controls when vtordisps will be emitted if this record is used as a
1832 /// virtual base.
1834
1835 /// Determine whether this lambda expression was known to be dependent
1836 /// at the time it was created, even if its context does not appear to be
1837 /// dependent.
1838 ///
1839 /// This flag is a workaround for an issue with parsing, where default
1840 /// arguments are parsed before their enclosing function declarations have
1841 /// been created. This means that any lambda expressions within those
1842 /// default arguments will have as their DeclContext the context enclosing
1843 /// the function declaration, which may be non-dependent even when the
1844 /// function declaration itself is dependent. This flag indicates when we
1845 /// know that the lambda is dependent despite that.
1846 bool isDependentLambda() const {
1847 return isLambda() && getLambdaData().DependencyKind == LDK_AlwaysDependent;
1848 }
1849
1851 return isLambda() && getLambdaData().DependencyKind == LDK_NeverDependent;
1852 }
1853
1854 unsigned getLambdaDependencyKind() const {
1855 if (!isLambda())
1856 return LDK_Unknown;
1857 return getLambdaData().DependencyKind;
1858 }
1859
1861 return getLambdaData().MethodTyInfo;
1862 }
1863
1865 assert(DefinitionData && DefinitionData->IsLambda &&
1866 "setting lambda property of non-lambda class");
1867 auto &DL = static_cast<LambdaDefinitionData &>(*DefinitionData);
1868 DL.MethodTyInfo = TS;
1869 }
1870
1872 getLambdaData().DependencyKind = Kind;
1873 }
1874
1875 void setLambdaIsGeneric(bool IsGeneric) {
1876 assert(DefinitionData && DefinitionData->IsLambda &&
1877 "setting lambda property of non-lambda class");
1878 auto &DL = static_cast<LambdaDefinitionData &>(*DefinitionData);
1879 DL.IsGenericLambda = IsGeneric;
1880 }
1881
1882 /// Determines whether this declaration represents the
1883 /// injected class name.
1884 ///
1885 /// The injected class name in C++ is the name of the class that
1886 /// appears inside the class itself. For example:
1887 ///
1888 /// \code
1889 /// struct C {
1890 /// // C is implicitly declared here as a synonym for the class name.
1891 /// };
1892 ///
1893 /// C::C c; // same as "C c;"
1894 /// \endcode
1895 bool isInjectedClassName() const;
1896
1897 /// Determines whether this declaration has is canonically of an injected
1898 /// class type. These are non-instantiated class template patterns, which can
1899 /// be used from within the class template itself. For example:
1900 ///
1901 /// \code
1902 /// template<class T> struct C {
1903 /// C *t; // Here `C *` is a pointer to an injected class type.
1904 /// };
1905 /// \endcode
1906 bool hasInjectedClassType() const;
1907
1910
1911 // Determine whether this type is an Interface Like type for
1912 // __interface inheritance purposes.
1913 bool isInterfaceLike() const;
1914
1915 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1916 static bool classofKind(Kind K) {
1917 return K >= firstCXXRecord && K <= lastCXXRecord;
1918 }
1919 void markAbstract() { data().Abstract = true; }
1920};
1921
1922/// Store information needed for an explicit specifier.
1923/// Used by CXXDeductionGuideDecl, CXXConstructorDecl and CXXConversionDecl.
1925 llvm::PointerIntPair<Expr *, 2, ExplicitSpecKind> ExplicitSpec{
1927
1928public:
1931 : ExplicitSpec(Expression, Kind) {}
1932 ExplicitSpecKind getKind() const { return ExplicitSpec.getInt(); }
1933 const Expr *getExpr() const { return ExplicitSpec.getPointer(); }
1934 Expr *getExpr() { return ExplicitSpec.getPointer(); }
1935
1936 /// Determine if the declaration had an explicit specifier of any kind.
1937 bool isSpecified() const {
1938 return ExplicitSpec.getInt() != ExplicitSpecKind::ResolvedFalse ||
1939 ExplicitSpec.getPointer();
1940 }
1941
1942 /// Check for equivalence of explicit specifiers.
1943 /// \return true if the explicit specifier are equivalent, false otherwise.
1944 bool isEquivalent(const ExplicitSpecifier Other) const;
1945 /// Determine whether this specifier is known to correspond to an explicit
1946 /// declaration. Returns false if the specifier is absent or has an
1947 /// expression that is value-dependent or evaluates to false.
1948 bool isExplicit() const {
1949 return ExplicitSpec.getInt() == ExplicitSpecKind::ResolvedTrue;
1950 }
1951 /// Determine if the explicit specifier is invalid.
1952 /// This state occurs after a substitution failures.
1953 bool isInvalid() const {
1954 return ExplicitSpec.getInt() == ExplicitSpecKind::Unresolved &&
1955 !ExplicitSpec.getPointer();
1956 }
1957 void setKind(ExplicitSpecKind Kind) { ExplicitSpec.setInt(Kind); }
1958 void setExpr(Expr *E) { ExplicitSpec.setPointer(E); }
1959 // Retrieve the explicit specifier in the given declaration, if any.
1962 return getFromDecl(const_cast<FunctionDecl *>(Function));
1963 }
1966 }
1967};
1968
1969/// Represents a C++ deduction guide declaration.
1970///
1971/// \code
1972/// template<typename T> struct A { A(); A(T); };
1973/// A() -> A<int>;
1974/// \endcode
1975///
1976/// In this example, there will be an explicit deduction guide from the
1977/// second line, and implicit deduction guide templates synthesized from
1978/// the constructors of \c A.
1980 void anchor() override;
1981
1982public:
1983 // Represents the relationship between this deduction guide and the
1984 // deduction guide that it was generated from (or lack thereof).
1985 // See the SourceDeductionGuide member for more details.
1986 enum class SourceDeductionGuideKind : uint8_t {
1987 None,
1988 Alias,
1989 };
1990
1991private:
1994 const DeclarationNameInfo &NameInfo, QualType T,
1995 TypeSourceInfo *TInfo, SourceLocation EndLocation,
1997 const AssociatedConstraint &TrailingRequiresClause,
1998 const CXXDeductionGuideDecl *GeneratedFrom,
1999 SourceDeductionGuideKind SourceKind)
2000 : FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo,
2002 TrailingRequiresClause),
2003 Ctor(Ctor), ExplicitSpec(ES),
2004 SourceDeductionGuide(GeneratedFrom, SourceKind) {
2005 if (EndLocation.isValid())
2006 setRangeEnd(EndLocation);
2008 }
2009
2010 CXXConstructorDecl *Ctor;
2011 ExplicitSpecifier ExplicitSpec;
2012 // The deduction guide, if any, that this deduction guide was generated from,
2013 // in the case of alias template deduction. The SourceDeductionGuideKind
2014 // member indicates which of these sources applies, or is None otherwise.
2015 llvm::PointerIntPair<const CXXDeductionGuideDecl *, 2,
2017 SourceDeductionGuide;
2018 void setExplicitSpecifier(ExplicitSpecifier ES) { ExplicitSpec = ES; }
2019
2020public:
2021 friend class ASTDeclReader;
2022 friend class ASTDeclWriter;
2023
2024 static CXXDeductionGuideDecl *
2026 ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T,
2027 TypeSourceInfo *TInfo, SourceLocation EndLocation,
2028 CXXConstructorDecl *Ctor = nullptr,
2030 const AssociatedConstraint &TrailingRequiresClause = {},
2031 const CXXDeductionGuideDecl *SourceDG = nullptr,
2033
2036
2037 ExplicitSpecifier getExplicitSpecifier() { return ExplicitSpec; }
2038 const ExplicitSpecifier getExplicitSpecifier() const { return ExplicitSpec; }
2039
2040 /// Return true if the declaration is already resolved to be explicit.
2041 bool isExplicit() const { return ExplicitSpec.isExplicit(); }
2042
2043 /// Get the template for which this guide performs deduction.
2046 }
2047
2048 /// Get the constructor from which this deduction guide was generated, if
2049 /// this is an implicit deduction guide.
2051
2052 /// Get the deduction guide from which this deduction guide was generated,
2053 /// if it was generated as part of alias template deduction or from an
2054 /// inherited constructor.
2056 return SourceDeductionGuide.getPointer();
2057 }
2058
2060 SourceDeductionGuide.setPointer(DG);
2061 }
2062
2064 return SourceDeductionGuide.getInt();
2065 }
2066
2068 SourceDeductionGuide.setInt(SK);
2069 }
2070
2072 FunctionDeclBits.DeductionCandidateKind = static_cast<unsigned char>(K);
2073 }
2074
2076 return static_cast<DeductionCandidate>(
2077 FunctionDeclBits.DeductionCandidateKind);
2078 }
2079
2080 // Implement isa/cast/dyncast/etc.
2081 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2082 static bool classofKind(Kind K) { return K == CXXDeductionGuide; }
2083};
2084
2085/// \brief Represents the body of a requires-expression.
2086///
2087/// This decl exists merely to serve as the DeclContext for the local
2088/// parameters of the requires expression as well as other declarations inside
2089/// it.
2090///
2091/// \code
2092/// template<typename T> requires requires (T t) { {t++} -> regular; }
2093/// \endcode
2094///
2095/// In this example, a RequiresExpr object will be generated for the expression,
2096/// and a RequiresExprBodyDecl will be created to hold the parameter t and the
2097/// template argument list imposed by the compound requirement.
2098class RequiresExprBodyDecl : public Decl, public DeclContext {
2100 : Decl(RequiresExprBody, DC, StartLoc), DeclContext(RequiresExprBody) {}
2101
2102public:
2103 friend class ASTDeclReader;
2104 friend class ASTDeclWriter;
2105
2107 SourceLocation StartLoc);
2108
2111
2112 // Implement isa/cast/dyncast/etc.
2113 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2114 static bool classofKind(Kind K) { return K == RequiresExprBody; }
2115
2117 return static_cast<DeclContext *>(const_cast<RequiresExprBodyDecl *>(D));
2118 }
2119
2121 return static_cast<RequiresExprBodyDecl *>(const_cast<DeclContext *>(DC));
2122 }
2123};
2124
2125/// Represents a static or instance method of a struct/union/class.
2126///
2127/// In the terminology of the C++ Standard, these are the (static and
2128/// non-static) member functions, whether virtual or not.
2130 void anchor() override;
2131
2132protected:
2134 SourceLocation StartLoc, const DeclarationNameInfo &NameInfo,
2136 bool UsesFPIntrin, bool isInline,
2137 ConstexprSpecKind ConstexprKind, SourceLocation EndLocation,
2138 const AssociatedConstraint &TrailingRequiresClause = {})
2139 : FunctionDecl(DK, C, RD, StartLoc, NameInfo, T, TInfo, SC, UsesFPIntrin,
2140 isInline, ConstexprKind, TrailingRequiresClause) {
2141 if (EndLocation.isValid())
2142 setRangeEnd(EndLocation);
2143 }
2144
2145public:
2146 static CXXMethodDecl *
2147 Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
2148 const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo,
2149 StorageClass SC, bool UsesFPIntrin, bool isInline,
2150 ConstexprSpecKind ConstexprKind, SourceLocation EndLocation,
2151 const AssociatedConstraint &TrailingRequiresClause = {});
2152
2153 static CXXMethodDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
2154
2155 bool isStatic() const;
2156 bool isInstance() const { return !isStatic(); }
2157
2158 /// [C++2b][dcl.fct]/p7
2159 /// An explicit object member function is a non-static
2160 /// member function with an explicit object parameter. e.g.,
2161 /// void func(this SomeType);
2162 bool isExplicitObjectMemberFunction() const;
2163
2164 /// [C++2b][dcl.fct]/p7
2165 /// An implicit object member function is a non-static
2166 /// member function without an explicit object parameter.
2167 bool isImplicitObjectMemberFunction() const;
2168
2169 /// Returns true if the given operator is implicitly static in a record
2170 /// context.
2172 // [class.free]p1:
2173 // Any allocation function for a class T is a static member
2174 // (even if not explicitly declared static).
2175 // [class.free]p6 Any deallocation function for a class X is a static member
2176 // (even if not explicitly declared static).
2177 return OOK == OO_New || OOK == OO_Array_New || OOK == OO_Delete ||
2178 OOK == OO_Array_Delete;
2179 }
2180
2181 bool isConst() const { return getType()->castAs<FunctionType>()->isConst(); }
2182 bool isVolatile() const { return getType()->castAs<FunctionType>()->isVolatile(); }
2183
2184 bool isVirtual() const {
2185 CXXMethodDecl *CD = const_cast<CXXMethodDecl*>(this)->getCanonicalDecl();
2186
2187 // Member function is virtual if it is marked explicitly so, or if it is
2188 // declared in __interface -- then it is automatically pure virtual.
2189 if (CD->isVirtualAsWritten() || CD->isPureVirtual())
2190 return true;
2191
2192 return CD->size_overridden_methods() != 0;
2193 }
2194
2195 /// If it's possible to devirtualize a call to this method, return the called
2196 /// function. Otherwise, return null.
2197
2198 /// \param Base The object on which this virtual function is called.
2199 /// \param IsAppleKext True if we are compiling for Apple kext.
2200 CXXMethodDecl *getDevirtualizedMethod(const Expr *Base, bool IsAppleKext);
2201
2203 bool IsAppleKext) const {
2204 return const_cast<CXXMethodDecl *>(this)->getDevirtualizedMethod(
2205 Base, IsAppleKext);
2206 }
2207
2208 /// Determine whether this is a usual deallocation function (C++
2209 /// [basic.stc.dynamic.deallocation]p2), which is an overloaded delete or
2210 /// delete[] operator with a particular signature. Populates \p PreventedBy
2211 /// with the declarations of the functions of the same kind if they were the
2212 /// reason for this function returning false. This is used by
2213 /// Sema::isUsualDeallocationFunction to reconsider the answer based on the
2214 /// context.
2216 SmallVectorImpl<const FunctionDecl *> &PreventedBy) const;
2217
2218 /// Determine whether this is a copy-assignment operator, regardless
2219 /// of whether it was declared implicitly or explicitly.
2220 bool isCopyAssignmentOperator() const;
2221
2222 /// Determine whether this is a move assignment operator.
2223 bool isMoveAssignmentOperator() const;
2224
2226 return cast<CXXMethodDecl>(FunctionDecl::getCanonicalDecl());
2227 }
2229 return const_cast<CXXMethodDecl*>(this)->getCanonicalDecl();
2230 }
2231
2233 return cast<CXXMethodDecl>(
2234 static_cast<FunctionDecl *>(this)->getMostRecentDecl());
2235 }
2237 return const_cast<CXXMethodDecl*>(this)->getMostRecentDecl();
2238 }
2239
2240 void addOverriddenMethod(const CXXMethodDecl *MD);
2241
2242 using method_iterator = const CXXMethodDecl *const *;
2243
2246 unsigned size_overridden_methods() const;
2247
2248 using overridden_method_range = llvm::iterator_range<
2249 llvm::TinyPtrVector<const CXXMethodDecl *>::const_iterator>;
2250
2252
2253 /// Return the parent of this method declaration, which
2254 /// is the class in which this method is defined.
2255 const CXXRecordDecl *getParent() const {
2256 return cast<CXXRecordDecl>(FunctionDecl::getParent());
2257 }
2258
2259 /// Return the parent of this method declaration, which
2260 /// is the class in which this method is defined.
2262 return const_cast<CXXRecordDecl *>(
2263 cast<CXXRecordDecl>(FunctionDecl::getParent()));
2264 }
2265
2266 /// Return the type of the \c this pointer.
2267 ///
2268 /// Should only be called for instance (i.e., non-static) methods. Note
2269 /// that for the call operator of a lambda closure type, this returns the
2270 /// desugared 'this' type (a pointer to the closure type), not the captured
2271 /// 'this' type.
2272 QualType getThisType() const;
2273
2274 /// Return the type of the object pointed by \c this.
2275 ///
2276 /// See getThisType() for usage restriction.
2277
2281 }
2282
2283 unsigned getNumExplicitParams() const {
2284 return getNumParams() - (isExplicitObjectMemberFunction() ? 1 : 0);
2285 }
2286
2287 static QualType getThisType(const FunctionProtoType *FPT,
2288 const CXXRecordDecl *Decl);
2289
2291 return getType()->castAs<FunctionProtoType>()->getMethodQuals();
2292 }
2293
2294 /// Retrieve the ref-qualifier associated with this method.
2295 ///
2296 /// In the following example, \c f() has an lvalue ref-qualifier, \c g()
2297 /// has an rvalue ref-qualifier, and \c h() has no ref-qualifier.
2298 /// @code
2299 /// struct X {
2300 /// void f() &;
2301 /// void g() &&;
2302 /// void h();
2303 /// };
2304 /// @endcode
2307 }
2308
2309 bool hasInlineBody() const;
2310
2311 /// Determine whether this is a lambda closure type's static member
2312 /// function that is used for the result of the lambda's conversion to
2313 /// function pointer (for a lambda with no captures).
2314 ///
2315 /// The function itself, if used, will have a placeholder body that will be
2316 /// supplied by IR generation to either forward to the function call operator
2317 /// or clone the function call operator.
2318 bool isLambdaStaticInvoker() const;
2319
2320 /// Find the method in \p RD that corresponds to this one.
2321 ///
2322 /// Find if \p RD or one of the classes it inherits from override this method.
2323 /// If so, return it. \p RD is assumed to be a subclass of the class defining
2324 /// this method (or be the class itself), unless \p MayBeBase is set to true.
2327 bool MayBeBase = false);
2328
2329 const CXXMethodDecl *
2331 bool MayBeBase = false) const {
2332 return const_cast<CXXMethodDecl *>(this)
2333 ->getCorrespondingMethodInClass(RD, MayBeBase);
2334 }
2335
2336 /// Find if \p RD declares a function that overrides this function, and if so,
2337 /// return it. Does not search base classes.
2339 bool MayBeBase = false);
2340 const CXXMethodDecl *
2342 bool MayBeBase = false) const {
2343 return const_cast<CXXMethodDecl *>(this)
2345 }
2346
2347 // Implement isa/cast/dyncast/etc.
2348 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2349 static bool classofKind(Kind K) {
2350 return K >= firstCXXMethod && K <= lastCXXMethod;
2351 }
2352};
2353
2354/// Represents a C++ base or member initializer.
2355///
2356/// This is part of a constructor initializer that
2357/// initializes one non-static member variable or one base class. For
2358/// example, in the following, both 'A(a)' and 'f(3.14159)' are member
2359/// initializers:
2360///
2361/// \code
2362/// class A { };
2363/// class B : public A {
2364/// float f;
2365/// public:
2366/// B(A& a) : A(a), f(3.14159) { }
2367/// };
2368/// \endcode
2370 /// Either the base class name/delegating constructor type (stored as
2371 /// a TypeSourceInfo*), an normal field (FieldDecl), or an anonymous field
2372 /// (IndirectFieldDecl*) being initialized.
2373 llvm::PointerUnion<TypeSourceInfo *, FieldDecl *, IndirectFieldDecl *>
2374 Initializee;
2375
2376 /// The argument used to initialize the base or member, which may
2377 /// end up constructing an object (when multiple arguments are involved).
2378 Stmt *Init;
2379
2380 /// The source location for the field name or, for a base initializer
2381 /// pack expansion, the location of the ellipsis.
2382 ///
2383 /// In the case of a delegating
2384 /// constructor, it will still include the type's source location as the
2385 /// Initializee points to the CXXConstructorDecl (to allow loop detection).
2386 SourceLocation MemberOrEllipsisLocation;
2387
2388 /// Location of the left paren of the ctor-initializer.
2389 SourceLocation LParenLoc;
2390
2391 /// Location of the right paren of the ctor-initializer.
2392 SourceLocation RParenLoc;
2393
2394 /// If the initializee is a type, whether that type makes this
2395 /// a delegating initialization.
2396 LLVM_PREFERRED_TYPE(bool)
2397 unsigned IsDelegating : 1;
2398
2399 /// If the initializer is a base initializer, this keeps track
2400 /// of whether the base is virtual or not.
2401 LLVM_PREFERRED_TYPE(bool)
2402 unsigned IsVirtual : 1;
2403
2404 /// Whether or not the initializer is explicitly written
2405 /// in the sources.
2406 LLVM_PREFERRED_TYPE(bool)
2407 unsigned IsWritten : 1;
2408
2409 /// If IsWritten is true, then this number keeps track of the textual order
2410 /// of this initializer in the original sources, counting from 0.
2411 unsigned SourceOrder : 13;
2412
2413public:
2414 /// Creates a new base-class initializer.
2415 explicit
2416 CXXCtorInitializer(ASTContext &Context, TypeSourceInfo *TInfo, bool IsVirtual,
2418 SourceLocation EllipsisLoc);
2419
2420 /// Creates a new member initializer.
2421 explicit
2423 SourceLocation MemberLoc, SourceLocation L, Expr *Init,
2424 SourceLocation R);
2425
2426 /// Creates a new anonymous field initializer.
2427 explicit
2429 SourceLocation MemberLoc, SourceLocation L, Expr *Init,
2430 SourceLocation R);
2431
2432 /// Creates a new delegating initializer.
2433 explicit
2435 SourceLocation L, Expr *Init, SourceLocation R);
2436
2437 /// \return Unique reproducible object identifier.
2438 int64_t getID(const ASTContext &Context) const;
2439
2440 /// Determine whether this initializer is initializing a base class.
2441 bool isBaseInitializer() const {
2442 return isa<TypeSourceInfo *>(Initializee) && !IsDelegating;
2443 }
2444
2445 /// Determine whether this initializer is initializing a non-static
2446 /// data member.
2447 bool isMemberInitializer() const { return isa<FieldDecl *>(Initializee); }
2448
2451 }
2452
2454 return isa<IndirectFieldDecl *>(Initializee);
2455 }
2456
2457 /// Determine whether this initializer is an implicit initializer
2458 /// generated for a field with an initializer defined on the member
2459 /// declaration.
2460 ///
2461 /// In-class member initializers (also known as "non-static data member
2462 /// initializations", NSDMIs) were introduced in C++11.
2464 return Init->getStmtClass() == Stmt::CXXDefaultInitExprClass;
2465 }
2466
2467 /// Determine whether this initializer is creating a delegating
2468 /// constructor.
2470 return isa<TypeSourceInfo *>(Initializee) && IsDelegating;
2471 }
2472
2473 /// Determine whether this initializer is a pack expansion.
2474 bool isPackExpansion() const {
2475 return isBaseInitializer() && MemberOrEllipsisLocation.isValid();
2476 }
2477
2478 // For a pack expansion, returns the location of the ellipsis.
2480 if (!isPackExpansion())
2481 return {};
2482 return MemberOrEllipsisLocation;
2483 }
2484
2485 /// If this is a base class initializer, returns the type of the
2486 /// base class with location information. Otherwise, returns an NULL
2487 /// type location.
2488 TypeLoc getBaseClassLoc() const;
2489
2490 /// If this is a base class initializer, returns the type of the base class.
2491 /// Otherwise, returns null.
2492 const Type *getBaseClass() const;
2493
2494 /// Returns whether the base is virtual or not.
2495 bool isBaseVirtual() const {
2496 assert(isBaseInitializer() && "Must call this on base initializer!");
2497
2498 return IsVirtual;
2499 }
2500
2501 /// Returns the declarator information for a base class or delegating
2502 /// initializer.
2504 return Initializee.dyn_cast<TypeSourceInfo *>();
2505 }
2506
2507 /// If this is a member initializer, returns the declaration of the
2508 /// non-static data member being initialized. Otherwise, returns null.
2510 if (isMemberInitializer())
2511 return cast<FieldDecl *>(Initializee);
2512 return nullptr;
2513 }
2514
2516 if (isMemberInitializer())
2517 return cast<FieldDecl *>(Initializee);
2519 return cast<IndirectFieldDecl *>(Initializee)->getAnonField();
2520 return nullptr;
2521 }
2522
2525 return cast<IndirectFieldDecl *>(Initializee);
2526 return nullptr;
2527 }
2528
2530 return MemberOrEllipsisLocation;
2531 }
2532
2533 /// Determine the source location of the initializer.
2535
2536 /// Determine the source range covering the entire initializer.
2537 SourceRange getSourceRange() const LLVM_READONLY;
2538
2539 /// Determine whether this initializer is explicitly written
2540 /// in the source code.
2541 bool isWritten() const { return IsWritten; }
2542
2543 /// Return the source position of the initializer, counting from 0.
2544 /// If the initializer was implicit, -1 is returned.
2545 int getSourceOrder() const {
2546 return IsWritten ? static_cast<int>(SourceOrder) : -1;
2547 }
2548
2549 /// Set the source order of this initializer.
2550 ///
2551 /// This can only be called once for each initializer; it cannot be called
2552 /// on an initializer having a positive number of (implicit) array indices.
2553 ///
2554 /// This assumes that the initializer was written in the source code, and
2555 /// ensures that isWritten() returns true.
2556 void setSourceOrder(int Pos) {
2557 assert(!IsWritten &&
2558 "setSourceOrder() used on implicit initializer");
2559 assert(SourceOrder == 0 &&
2560 "calling twice setSourceOrder() on the same initializer");
2561 assert(Pos >= 0 &&
2562 "setSourceOrder() used to make an initializer implicit");
2563 IsWritten = true;
2564 SourceOrder = static_cast<unsigned>(Pos);
2565 }
2566
2567 SourceLocation getLParenLoc() const { return LParenLoc; }
2568 SourceLocation getRParenLoc() const { return RParenLoc; }
2569
2570 /// Get the initializer.
2571 Expr *getInit() const { return static_cast<Expr *>(Init); }
2572};
2573
2574/// Description of a constructor that was inherited from a base class.
2576 ConstructorUsingShadowDecl *Shadow = nullptr;
2577 CXXConstructorDecl *BaseCtor = nullptr;
2578
2579public:
2582 CXXConstructorDecl *BaseCtor)
2583 : Shadow(Shadow), BaseCtor(BaseCtor) {}
2584
2585 explicit operator bool() const { return Shadow; }
2586
2587 ConstructorUsingShadowDecl *getShadowDecl() const { return Shadow; }
2588 CXXConstructorDecl *getConstructor() const { return BaseCtor; }
2589};
2590
2591/// Represents a C++ constructor within a class.
2592///
2593/// For example:
2594///
2595/// \code
2596/// class X {
2597/// public:
2598/// explicit X(int); // represented by a CXXConstructorDecl.
2599/// };
2600/// \endcode
2602 : public CXXMethodDecl,
2603 private llvm::TrailingObjects<CXXConstructorDecl, InheritedConstructor,
2604 ExplicitSpecifier> {
2605 // This class stores some data in DeclContext::CXXConstructorDeclBits
2606 // to save some space. Use the provided accessors to access it.
2607
2608 /// \name Support for base and member initializers.
2609 /// \{
2610 /// The arguments used to initialize the base or member.
2611 LazyCXXCtorInitializersPtr CtorInitializers;
2612
2614 const DeclarationNameInfo &NameInfo, QualType T,
2616 bool UsesFPIntrin, bool isInline,
2617 bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind,
2618 InheritedConstructor Inherited,
2619 const AssociatedConstraint &TrailingRequiresClause);
2620
2621 void anchor() override;
2622
2623 size_t numTrailingObjects(OverloadToken<InheritedConstructor>) const {
2624 return CXXConstructorDeclBits.IsInheritingConstructor;
2625 }
2626
2627 ExplicitSpecifier getExplicitSpecifierInternal() const {
2628 if (CXXConstructorDeclBits.HasTrailingExplicitSpecifier)
2629 return *getTrailingObjects<ExplicitSpecifier>();
2630 return ExplicitSpecifier(
2631 nullptr, CXXConstructorDeclBits.IsSimpleExplicit
2634 }
2635
2636 enum TrailingAllocKind {
2637 TAKInheritsConstructor = 1,
2638 TAKHasTailExplicit = 1 << 1,
2639 };
2640
2641 uint64_t getTrailingAllocKind() const {
2642 uint64_t Kind = 0;
2643 if (CXXConstructorDeclBits.IsInheritingConstructor)
2644 Kind |= TAKInheritsConstructor;
2645 if (CXXConstructorDeclBits.HasTrailingExplicitSpecifier)
2646 Kind |= TAKHasTailExplicit;
2647 return Kind;
2648 }
2649
2650public:
2651 friend class ASTDeclReader;
2652 friend class ASTDeclWriter;
2654
2656 uint64_t AllocKind);
2657 static CXXConstructorDecl *
2659 const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo,
2660 ExplicitSpecifier ES, bool UsesFPIntrin, bool isInline,
2661 bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind,
2663 const AssociatedConstraint &TrailingRequiresClause = {});
2664
2666 assert((!ES.getExpr() ||
2667 CXXConstructorDeclBits.HasTrailingExplicitSpecifier) &&
2668 "cannot set this explicit specifier. no trail-allocated space for "
2669 "explicit");
2670 if (ES.getExpr())
2671 *getCanonicalDecl()->getTrailingObjects<ExplicitSpecifier>() = ES;
2672 else
2673 CXXConstructorDeclBits.IsSimpleExplicit = ES.isExplicit();
2674 }
2675
2677 return getCanonicalDecl()->getExplicitSpecifierInternal();
2678 }
2680 return getCanonicalDecl()->getExplicitSpecifierInternal();
2681 }
2682
2683 /// Return true if the declaration is already resolved to be explicit.
2684 bool isExplicit() const { return getExplicitSpecifier().isExplicit(); }
2685
2686 /// Iterates through the member/base initializer list.
2688
2689 /// Iterates through the member/base initializer list.
2691
2692 using init_range = llvm::iterator_range<init_iterator>;
2693 using init_const_range = llvm::iterator_range<init_const_iterator>;
2694
2698 }
2699
2700 /// Retrieve an iterator to the first initializer.
2702 const auto *ConstThis = this;
2703 return const_cast<init_iterator>(ConstThis->init_begin());
2704 }
2705
2706 /// Retrieve an iterator to the first initializer.
2708
2709 /// Retrieve an iterator past the last initializer.
2712 }
2713
2714 /// Retrieve an iterator past the last initializer.
2717 }
2718
2719 using init_reverse_iterator = std::reverse_iterator<init_iterator>;
2721 std::reverse_iterator<init_const_iterator>;
2722
2725 }
2728 }
2729
2732 }
2735 }
2736
2737 /// Determine the number of arguments used to initialize the member
2738 /// or base.
2739 unsigned getNumCtorInitializers() const {
2740 return CXXConstructorDeclBits.NumCtorInitializers;
2741 }
2742
2743 void setNumCtorInitializers(unsigned numCtorInitializers) {
2744 CXXConstructorDeclBits.NumCtorInitializers = numCtorInitializers;
2745 // This assert added because NumCtorInitializers is stored
2746 // in CXXConstructorDeclBits as a bitfield and its width has
2747 // been shrunk from 32 bits to fit into CXXConstructorDeclBitfields.
2748 assert(CXXConstructorDeclBits.NumCtorInitializers ==
2749 numCtorInitializers && "NumCtorInitializers overflow!");
2750 }
2751
2753 CtorInitializers = Initializers;
2754 }
2755
2756 /// Determine whether this constructor is a delegating constructor.
2758 return (getNumCtorInitializers() == 1) &&
2760 }
2761
2762 /// When this constructor delegates to another, retrieve the target.
2764
2765 /// Whether this constructor is a default
2766 /// constructor (C++ [class.ctor]p5), which can be used to
2767 /// default-initialize a class of this type.
2768 bool isDefaultConstructor() const;
2769
2770 /// Whether this constructor is a copy constructor (C++ [class.copy]p2,
2771 /// which can be used to copy the class.
2772 ///
2773 /// \p TypeQuals will be set to the qualifiers on the
2774 /// argument type. For example, \p TypeQuals would be set to \c
2775 /// Qualifiers::Const for the following copy constructor:
2776 ///
2777 /// \code
2778 /// class X {
2779 /// public:
2780 /// X(const X&);
2781 /// };
2782 /// \endcode
2783 bool isCopyConstructor(unsigned &TypeQuals) const;
2784
2785 /// Whether this constructor is a copy
2786 /// constructor (C++ [class.copy]p2, which can be used to copy the
2787 /// class.
2788 bool isCopyConstructor() const {
2789 unsigned TypeQuals = 0;
2790 return isCopyConstructor(TypeQuals);
2791 }
2792
2793 /// Determine whether this constructor is a move constructor
2794 /// (C++11 [class.copy]p3), which can be used to move values of the class.
2795 ///
2796 /// \param TypeQuals If this constructor is a move constructor, will be set
2797 /// to the type qualifiers on the referent of the first parameter's type.
2798 bool isMoveConstructor(unsigned &TypeQuals) const;
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 bool isMoveConstructor() const {
2803 unsigned TypeQuals = 0;
2804 return isMoveConstructor(TypeQuals);
2805 }
2806
2807 /// Determine whether this is a copy or move constructor.
2808 ///
2809 /// \param TypeQuals Will be set to the type qualifiers on the reference
2810 /// parameter, if in fact this is a copy or move constructor.
2811 bool isCopyOrMoveConstructor(unsigned &TypeQuals) const;
2812
2813 /// Determine whether this a copy or move constructor.
2815 unsigned Quals;
2816 return isCopyOrMoveConstructor(Quals);
2817 }
2818
2819 /// Whether this constructor is a
2820 /// converting constructor (C++ [class.conv.ctor]), which can be
2821 /// used for user-defined conversions.
2822 bool isConvertingConstructor(bool AllowExplicit) const;
2823
2824 /// Determine whether this is a member template specialization that
2825 /// would copy the object to itself. Such constructors are never used to copy
2826 /// an object.
2827 bool isSpecializationCopyingObject() const;
2828
2829 /// Determine whether this is an implicit constructor synthesized to
2830 /// model a call to a constructor inherited from a base class.
2832 return CXXConstructorDeclBits.IsInheritingConstructor;
2833 }
2834
2835 /// State that this is an implicit constructor synthesized to
2836 /// model a call to a constructor inherited from a base class.
2837 void setInheritingConstructor(bool isIC = true) {
2838 CXXConstructorDeclBits.IsInheritingConstructor = isIC;
2839 }
2840
2841 /// Get the constructor that this inheriting constructor is based on.
2843 return isInheritingConstructor() ?
2844 *getTrailingObjects<InheritedConstructor>() : InheritedConstructor();
2845 }
2846
2848 return cast<CXXConstructorDecl>(FunctionDecl::getCanonicalDecl());
2849 }
2851 return const_cast<CXXConstructorDecl*>(this)->getCanonicalDecl();
2852 }
2853
2854 // Implement isa/cast/dyncast/etc.
2855 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2856 static bool classofKind(Kind K) { return K == CXXConstructor; }
2857};
2858
2859/// Represents a C++ destructor within a class.
2860///
2861/// For example:
2862///
2863/// \code
2864/// class X {
2865/// public:
2866/// ~X(); // represented by a CXXDestructorDecl.
2867/// };
2868/// \endcode
2870 friend class ASTDeclReader;
2871 friend class ASTDeclWriter;
2872
2873 // FIXME: Don't allocate storage for these except in the first declaration
2874 // of a virtual destructor.
2875 FunctionDecl *OperatorDelete = nullptr;
2876 Expr *OperatorDeleteThisArg = nullptr;
2877
2879 const DeclarationNameInfo &NameInfo, QualType T,
2880 TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline,
2881 bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind,
2882 const AssociatedConstraint &TrailingRequiresClause = {})
2883 : CXXMethodDecl(CXXDestructor, C, RD, StartLoc, NameInfo, T, TInfo,
2884 SC_None, UsesFPIntrin, isInline, ConstexprKind,
2885 SourceLocation(), TrailingRequiresClause) {
2886 setImplicit(isImplicitlyDeclared);
2887 }
2888
2889 void anchor() override;
2890
2891public:
2892 static CXXDestructorDecl *
2893 Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
2894 const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo,
2895 bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared,
2896 ConstexprSpecKind ConstexprKind,
2897 const AssociatedConstraint &TrailingRequiresClause = {});
2898 static CXXDestructorDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
2899
2900 void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg);
2901
2903 return getCanonicalDecl()->OperatorDelete;
2904 }
2905
2907 return getCanonicalDecl()->OperatorDeleteThisArg;
2908 }
2909
2910 /// Will this destructor ever be called when considering which deallocation
2911 /// function is associated with the destructor? Can optionally be passed an
2912 /// 'operator delete' function declaration to test against specifically.
2913 bool isCalledByDelete(const FunctionDecl *OpDel = nullptr) const;
2914
2916 return cast<CXXDestructorDecl>(FunctionDecl::getCanonicalDecl());
2917 }
2919 return const_cast<CXXDestructorDecl*>(this)->getCanonicalDecl();
2920 }
2921
2922 // Implement isa/cast/dyncast/etc.
2923 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2924 static bool classofKind(Kind K) { return K == CXXDestructor; }
2925};
2926
2927/// Represents a C++ conversion function within a class.
2928///
2929/// For example:
2930///
2931/// \code
2932/// class X {
2933/// public:
2934/// operator bool();
2935/// };
2936/// \endcode
2939 const DeclarationNameInfo &NameInfo, QualType T,
2940 TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline,
2941 ExplicitSpecifier ES, ConstexprSpecKind ConstexprKind,
2942 SourceLocation EndLocation,
2943 const AssociatedConstraint &TrailingRequiresClause = {})
2944 : CXXMethodDecl(CXXConversion, C, RD, StartLoc, NameInfo, T, TInfo,
2945 SC_None, UsesFPIntrin, isInline, ConstexprKind,
2946 EndLocation, TrailingRequiresClause),
2947 ExplicitSpec(ES) {}
2948 void anchor() override;
2949
2950 ExplicitSpecifier ExplicitSpec;
2951
2952public:
2953 friend class ASTDeclReader;
2954 friend class ASTDeclWriter;
2955
2956 static CXXConversionDecl *
2958 const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo,
2959 bool UsesFPIntrin, bool isInline, ExplicitSpecifier ES,
2960 ConstexprSpecKind ConstexprKind, SourceLocation EndLocation,
2961 const AssociatedConstraint &TrailingRequiresClause = {});
2963
2965 return getCanonicalDecl()->ExplicitSpec;
2966 }
2967
2969 return getCanonicalDecl()->ExplicitSpec;
2970 }
2971
2972 /// Return true if the declaration is already resolved to be explicit.
2973 bool isExplicit() const { return getExplicitSpecifier().isExplicit(); }
2974 void setExplicitSpecifier(ExplicitSpecifier ES) { ExplicitSpec = ES; }
2975
2976 /// Returns the type that this conversion function is converting to.
2978 return getType()->castAs<FunctionType>()->getReturnType();
2979 }
2980
2981 /// Determine whether this conversion function is a conversion from
2982 /// a lambda closure type to a block pointer.
2984
2986 return cast<CXXConversionDecl>(FunctionDecl::getCanonicalDecl());
2987 }
2989 return const_cast<CXXConversionDecl*>(this)->getCanonicalDecl();
2990 }
2991
2992 // Implement isa/cast/dyncast/etc.
2993 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2994 static bool classofKind(Kind K) { return K == CXXConversion; }
2995};
2996
2997/// Represents the language in a linkage specification.
2998///
2999/// The values are part of the serialization ABI for
3000/// ASTs and cannot be changed without altering that ABI.
3001enum class LinkageSpecLanguageIDs { C = 1, CXX = 2 };
3002
3003/// Represents a linkage specification.
3004///
3005/// For example:
3006/// \code
3007/// extern "C" void foo();
3008/// \endcode
3009class LinkageSpecDecl : public Decl, public DeclContext {
3010 virtual void anchor();
3011 // This class stores some data in DeclContext::LinkageSpecDeclBits to save
3012 // some space. Use the provided accessors to access it.
3013
3014 /// The source location for the extern keyword.
3015 SourceLocation ExternLoc;
3016
3017 /// The source location for the right brace (if valid).
3018 SourceLocation RBraceLoc;
3019
3022 bool HasBraces);
3023
3024public:
3026 SourceLocation ExternLoc,
3027 SourceLocation LangLoc,
3028 LinkageSpecLanguageIDs Lang, bool HasBraces);
3030
3031 /// Return the language specified by this linkage specification.
3033 return static_cast<LinkageSpecLanguageIDs>(LinkageSpecDeclBits.Language);
3034 }
3035
3036 /// Set the language specified by this linkage specification.
3038 LinkageSpecDeclBits.Language = llvm::to_underlying(L);
3039 }
3040
3041 /// Determines whether this linkage specification had braces in
3042 /// its syntactic form.
3043 bool hasBraces() const {
3044 assert(!RBraceLoc.isValid() || LinkageSpecDeclBits.HasBraces);
3045 return LinkageSpecDeclBits.HasBraces;
3046 }
3047
3048 SourceLocation getExternLoc() const { return ExternLoc; }
3049 SourceLocation getRBraceLoc() const { return RBraceLoc; }
3050 void setExternLoc(SourceLocation L) { ExternLoc = L; }
3052 RBraceLoc = L;
3053 LinkageSpecDeclBits.HasBraces = RBraceLoc.isValid();
3054 }
3055
3056 SourceLocation getEndLoc() const LLVM_READONLY {
3057 if (hasBraces())
3058 return getRBraceLoc();
3059 // No braces: get the end location of the (only) declaration in context
3060 // (if present).
3061 return decls_empty() ? getLocation() : decls_begin()->getEndLoc();
3062 }
3063
3064 SourceRange getSourceRange() const override LLVM_READONLY {
3065 return SourceRange(ExternLoc, getEndLoc());
3066 }
3067
3068 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3069 static bool classofKind(Kind K) { return K == LinkageSpec; }
3070
3072 return static_cast<DeclContext *>(const_cast<LinkageSpecDecl*>(D));
3073 }
3074
3076 return static_cast<LinkageSpecDecl *>(const_cast<DeclContext*>(DC));
3077 }
3078};
3079
3080/// Represents C++ using-directive.
3081///
3082/// For example:
3083/// \code
3084/// using namespace std;
3085/// \endcode
3086///
3087/// \note UsingDirectiveDecl should be Decl not NamedDecl, but we provide
3088/// artificial names for all using-directives in order to store
3089/// them in DeclContext effectively.
3091 /// The location of the \c using keyword.
3092 SourceLocation UsingLoc;
3093
3094 /// The location of the \c namespace keyword.
3095 SourceLocation NamespaceLoc;
3096
3097 /// The nested-name-specifier that precedes the namespace.
3098 NestedNameSpecifierLoc QualifierLoc;
3099
3100 /// The namespace nominated by this using-directive.
3101 NamedDecl *NominatedNamespace;
3102
3103 /// Enclosing context containing both using-directive and nominated
3104 /// namespace.
3105 DeclContext *CommonAncestor;
3106
3108 SourceLocation NamespcLoc,
3109 NestedNameSpecifierLoc QualifierLoc,
3110 SourceLocation IdentLoc,
3111 NamedDecl *Nominated,
3112 DeclContext *CommonAncestor)
3113 : NamedDecl(UsingDirective, DC, IdentLoc, getName()), UsingLoc(UsingLoc),
3114 NamespaceLoc(NamespcLoc), QualifierLoc(QualifierLoc),
3115 NominatedNamespace(Nominated), CommonAncestor(CommonAncestor) {}
3116
3117 /// Returns special DeclarationName used by using-directives.
3118 ///
3119 /// This is only used by DeclContext for storing UsingDirectiveDecls in
3120 /// its lookup structure.
3121 static DeclarationName getName() {
3123 }
3124
3125 void anchor() override;
3126
3127public:
3128 friend class ASTDeclReader;
3129
3130 // Friend for getUsingDirectiveName.
3131 friend class DeclContext;
3132
3133 /// Retrieve the nested-name-specifier that qualifies the
3134 /// name of the namespace, with source-location information.
3135 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3136
3137 /// Retrieve the nested-name-specifier that qualifies the
3138 /// name of the namespace.
3140 return QualifierLoc.getNestedNameSpecifier();
3141 }
3142
3143 NamedDecl *getNominatedNamespaceAsWritten() { return NominatedNamespace; }
3145 return NominatedNamespace;
3146 }
3147
3148 /// Returns the namespace nominated by this using-directive.
3150
3152 return const_cast<UsingDirectiveDecl*>(this)->getNominatedNamespace();
3153 }
3154
3155 /// Returns the common ancestor context of this using-directive and
3156 /// its nominated namespace.
3157 DeclContext *getCommonAncestor() { return CommonAncestor; }
3158 const DeclContext *getCommonAncestor() const { return CommonAncestor; }
3159
3160 /// Return the location of the \c using keyword.
3161 SourceLocation getUsingLoc() const { return UsingLoc; }
3162
3163 // FIXME: Could omit 'Key' in name.
3164 /// Returns the location of the \c namespace keyword.
3165 SourceLocation getNamespaceKeyLocation() const { return NamespaceLoc; }
3166
3167 /// Returns the location of this using declaration's identifier.
3169
3171 SourceLocation UsingLoc,
3172 SourceLocation NamespaceLoc,
3173 NestedNameSpecifierLoc QualifierLoc,
3174 SourceLocation IdentLoc,
3175 NamedDecl *Nominated,
3176 DeclContext *CommonAncestor);
3178
3179 SourceRange getSourceRange() const override LLVM_READONLY {
3180 return SourceRange(UsingLoc, getLocation());
3181 }
3182
3183 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3184 static bool classofKind(Kind K) { return K == UsingDirective; }
3185};
3186
3187/// Represents a C++ namespace alias.
3188///
3189/// For example:
3190///
3191/// \code
3192/// namespace Foo = Bar;
3193/// \endcode
3195 public Redeclarable<NamespaceAliasDecl> {
3196 friend class ASTDeclReader;
3197
3198 /// The location of the \c namespace keyword.
3199 SourceLocation NamespaceLoc;
3200
3201 /// The location of the namespace's identifier.
3202 ///
3203 /// This is accessed by TargetNameLoc.
3204 SourceLocation IdentLoc;
3205
3206 /// The nested-name-specifier that precedes the namespace.
3207 NestedNameSpecifierLoc QualifierLoc;
3208
3209 /// The Decl that this alias points to, either a NamespaceDecl or
3210 /// a NamespaceAliasDecl.
3211 NamespaceBaseDecl *Namespace;
3212
3214 SourceLocation NamespaceLoc, SourceLocation AliasLoc,
3215 IdentifierInfo *Alias, NestedNameSpecifierLoc QualifierLoc,
3216 SourceLocation IdentLoc, NamespaceBaseDecl *Namespace)
3217 : NamespaceBaseDecl(NamespaceAlias, DC, AliasLoc, Alias),
3218 redeclarable_base(C), NamespaceLoc(NamespaceLoc), IdentLoc(IdentLoc),
3219 QualifierLoc(QualifierLoc), Namespace(Namespace) {}
3220
3221 void anchor() override;
3222
3223 using redeclarable_base = Redeclarable<NamespaceAliasDecl>;
3224
3225 NamespaceAliasDecl *getNextRedeclarationImpl() override;
3226 NamespaceAliasDecl *getPreviousDeclImpl() override;
3227 NamespaceAliasDecl *getMostRecentDeclImpl() override;
3228
3229public:
3230 static NamespaceAliasDecl *
3231 Create(ASTContext &C, DeclContext *DC, SourceLocation NamespaceLoc,
3232 SourceLocation AliasLoc, IdentifierInfo *Alias,
3233 NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc,
3234 NamespaceBaseDecl *Namespace);
3235
3237
3239 using redecl_iterator = redeclarable_base::redecl_iterator;
3240
3246
3248 return getFirstDecl();
3249 }
3251 return getFirstDecl();
3252 }
3253
3254 /// Retrieve the nested-name-specifier that qualifies the
3255 /// name of the namespace, with source-location information.
3256 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3257
3258 /// Retrieve the nested-name-specifier that qualifies the
3259 /// name of the namespace.
3261 return QualifierLoc.getNestedNameSpecifier();
3262 }
3263
3264 /// Retrieve the namespace declaration aliased by this directive.
3266 if (auto *AD = dyn_cast<NamespaceAliasDecl>(Namespace))
3267 return AD->getNamespace();
3268
3269 return cast<NamespaceDecl>(Namespace);
3270 }
3271
3273 return const_cast<NamespaceAliasDecl *>(this)->getNamespace();
3274 }
3275
3276 /// Returns the location of the alias name, i.e. 'foo' in
3277 /// "namespace foo = ns::bar;".
3279
3280 /// Returns the location of the \c namespace keyword.
3281 SourceLocation getNamespaceLoc() const { return NamespaceLoc; }
3282
3283 /// Returns the location of the identifier in the named namespace.
3284 SourceLocation getTargetNameLoc() const { return IdentLoc; }
3285
3286 /// Retrieve the namespace that this alias refers to, which
3287 /// may either be a NamespaceDecl or a NamespaceAliasDecl.
3288 NamespaceBaseDecl *getAliasedNamespace() const { return Namespace; }
3289
3290 SourceRange getSourceRange() const override LLVM_READONLY {
3291 return SourceRange(NamespaceLoc, IdentLoc);
3292 }
3293
3294 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3295 static bool classofKind(Kind K) { return K == NamespaceAlias; }
3296};
3297
3298/// Implicit declaration of a temporary that was materialized by
3299/// a MaterializeTemporaryExpr and lifetime-extended by a declaration
3301 : public Decl,
3302 public Mergeable<LifetimeExtendedTemporaryDecl> {
3304 friend class ASTDeclReader;
3305
3306 Stmt *ExprWithTemporary = nullptr;
3307
3308 /// The declaration which lifetime-extended this reference, if any.
3309 /// Either a VarDecl, or (for a ctor-initializer) a FieldDecl.
3310 ValueDecl *ExtendingDecl = nullptr;
3311 unsigned ManglingNumber;
3312
3313 mutable APValue *Value = nullptr;
3314
3315 LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
3316
3317 LifetimeExtendedTemporaryDecl(Expr *Temp, ValueDecl *EDecl, unsigned Mangling)
3318 : Decl(Decl::LifetimeExtendedTemporary, EDecl->getDeclContext(),
3319 EDecl->getLocation()),
3320 ExprWithTemporary(Temp), ExtendingDecl(EDecl),
3321 ManglingNumber(Mangling) {}
3322
3324 : Decl(Decl::LifetimeExtendedTemporary, EmptyShell{}) {}
3325
3326public:
3328 unsigned Mangling) {
3329 return new (EDec->getASTContext(), EDec->getDeclContext())
3330 LifetimeExtendedTemporaryDecl(Temp, EDec, Mangling);
3331 }
3333 GlobalDeclID ID) {
3335 }
3336
3337 ValueDecl *getExtendingDecl() { return ExtendingDecl; }
3338 const ValueDecl *getExtendingDecl() const { return ExtendingDecl; }
3339
3340 /// Retrieve the storage duration for the materialized temporary.
3342
3343 /// Retrieve the expression to which the temporary materialization conversion
3344 /// was applied. This isn't necessarily the initializer of the temporary due
3345 /// to the C++98 delayed materialization rules, but
3346 /// skipRValueSubobjectAdjustments can be used to find said initializer within
3347 /// the subexpression.
3348 Expr *getTemporaryExpr() { return cast<Expr>(ExprWithTemporary); }
3349 const Expr *getTemporaryExpr() const { return cast<Expr>(ExprWithTemporary); }
3350
3351 unsigned getManglingNumber() const { return ManglingNumber; }
3352
3353 /// Get the storage for the constant value of a materialized temporary
3354 /// of static storage duration.
3355 APValue *getOrCreateValue(bool MayCreate) const;
3356
3357 APValue *getValue() const { return Value; }
3358
3359 // Iterators
3361 return Stmt::child_range(&ExprWithTemporary, &ExprWithTemporary + 1);
3362 }
3363
3365 return Stmt::const_child_range(&ExprWithTemporary, &ExprWithTemporary + 1);
3366 }
3367
3368 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3369 static bool classofKind(Kind K) {
3370 return K == Decl::LifetimeExtendedTemporary;
3371 }
3372};
3373
3374/// Represents a shadow declaration implicitly introduced into a scope by a
3375/// (resolved) using-declaration or using-enum-declaration to achieve
3376/// the desired lookup semantics.
3377///
3378/// For example:
3379/// \code
3380/// namespace A {
3381/// void foo();
3382/// void foo(int);
3383/// struct foo {};
3384/// enum bar { bar1, bar2 };
3385/// }
3386/// namespace B {
3387/// // add a UsingDecl and three UsingShadowDecls (named foo) to B.
3388/// using A::foo;
3389/// // adds UsingEnumDecl and two UsingShadowDecls (named bar1 and bar2) to B.
3390/// using enum A::bar;
3391/// }
3392/// \endcode
3393class UsingShadowDecl : public NamedDecl, public Redeclarable<UsingShadowDecl> {
3394 friend class BaseUsingDecl;
3395
3396 /// The referenced declaration.
3397 NamedDecl *Underlying = nullptr;
3398
3399 /// The using declaration which introduced this decl or the next using
3400 /// shadow declaration contained in the aforementioned using declaration.
3401 NamedDecl *UsingOrNextShadow = nullptr;
3402
3403 void anchor() override;
3404
3406
3407 UsingShadowDecl *getNextRedeclarationImpl() override {
3408 return getNextRedeclaration();
3409 }
3410
3411 UsingShadowDecl *getPreviousDeclImpl() override {
3412 return getPreviousDecl();
3413 }
3414
3415 UsingShadowDecl *getMostRecentDeclImpl() override {
3416 return getMostRecentDecl();
3417 }
3418
3419protected:
3420 UsingShadowDecl(Kind K, ASTContext &C, DeclContext *DC, SourceLocation Loc,
3421 DeclarationName Name, BaseUsingDecl *Introducer,
3422 NamedDecl *Target);
3423 UsingShadowDecl(Kind K, ASTContext &C, EmptyShell);
3424
3425public:
3426 friend class ASTDeclReader;
3427 friend class ASTDeclWriter;
3428
3431 BaseUsingDecl *Introducer, NamedDecl *Target) {
3432 return new (C, DC)
3433 UsingShadowDecl(UsingShadow, C, DC, Loc, Name, Introducer, Target);
3434 }
3435
3437
3439 using redecl_iterator = redeclarable_base::redecl_iterator;
3440
3447
3449 return getFirstDecl();
3450 }
3452 return getFirstDecl();
3453 }
3454
3455 /// Gets the underlying declaration which has been brought into the
3456 /// local scope.
3457 NamedDecl *getTargetDecl() const { return Underlying; }
3458
3459 /// Sets the underlying declaration which has been brought into the
3460 /// local scope.
3462 assert(ND && "Target decl is null!");
3463 Underlying = ND;
3464 // A UsingShadowDecl is never a friend or local extern declaration, even
3465 // if it is a shadow declaration for one.
3469 }
3470
3471 /// Gets the (written or instantiated) using declaration that introduced this
3472 /// declaration.
3474
3475 /// The next using shadow declaration contained in the shadow decl
3476 /// chain of the using declaration which introduced this decl.
3478 return dyn_cast_or_null<UsingShadowDecl>(UsingOrNextShadow);
3479 }
3480
3481 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3482 static bool classofKind(Kind K) {
3483 return K == Decl::UsingShadow || K == Decl::ConstructorUsingShadow;
3484 }
3485};
3486
3487/// Represents a C++ declaration that introduces decls from somewhere else. It
3488/// provides a set of the shadow decls so introduced.
3489
3490class BaseUsingDecl : public NamedDecl {
3491 /// The first shadow declaration of the shadow decl chain associated
3492 /// with this using declaration.
3493 ///
3494 /// The bool member of the pair is a bool flag a derived type may use
3495 /// (UsingDecl makes use of it).
3496 llvm::PointerIntPair<UsingShadowDecl *, 1, bool> FirstUsingShadow;
3497
3498protected:
3500 : NamedDecl(DK, DC, L, N), FirstUsingShadow(nullptr, false) {}
3501
3502private:
3503 void anchor() override;
3504
3505protected:
3506 /// A bool flag for use by a derived type
3507 bool getShadowFlag() const { return FirstUsingShadow.getInt(); }
3508
3509 /// A bool flag a derived type may set
3510 void setShadowFlag(bool V) { FirstUsingShadow.setInt(V); }
3511
3512public:
3513 friend class ASTDeclReader;
3514 friend class ASTDeclWriter;
3515
3516 /// Iterates through the using shadow declarations associated with
3517 /// this using declaration.
3519 /// The current using shadow declaration.
3520 UsingShadowDecl *Current = nullptr;
3521
3522 public:
3526 using iterator_category = std::forward_iterator_tag;
3527 using difference_type = std::ptrdiff_t;
3528
3529 shadow_iterator() = default;
3530 explicit shadow_iterator(UsingShadowDecl *C) : Current(C) {}
3531
3532 reference operator*() const { return Current; }
3533 pointer operator->() const { return Current; }
3534
3536 Current = Current->getNextUsingShadowDecl();
3537 return *this;
3538 }
3539
3541 shadow_iterator tmp(*this);
3542 ++(*this);
3543 return tmp;
3544 }
3545
3547 return x.Current == y.Current;
3548 }
3550 return x.Current != y.Current;
3551 }
3552 };
3553
3554 using shadow_range = llvm::iterator_range<shadow_iterator>;
3555
3558 }
3559
3561 return shadow_iterator(FirstUsingShadow.getPointer());
3562 }
3563
3565
3566 /// Return the number of shadowed declarations associated with this
3567 /// using declaration.
3568 unsigned shadow_size() const {
3569 return std::distance(shadow_begin(), shadow_end());
3570 }
3571
3574
3575 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3576 static bool classofKind(Kind K) { return K == Using || K == UsingEnum; }
3577};
3578
3579/// Represents a C++ using-declaration.
3580///
3581/// For example:
3582/// \code
3583/// using someNameSpace::someIdentifier;
3584/// \endcode
3585class UsingDecl : public BaseUsingDecl, public Mergeable<UsingDecl> {
3586 /// The source location of the 'using' keyword itself.
3587 SourceLocation UsingLocation;
3588
3589 /// The nested-name-specifier that precedes the name.
3590 NestedNameSpecifierLoc QualifierLoc;
3591
3592 /// Provides source/type location info for the declaration name
3593 /// embedded in the ValueDecl base class.
3594 DeclarationNameLoc DNLoc;
3595
3597 NestedNameSpecifierLoc QualifierLoc,
3598 const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
3599 : BaseUsingDecl(Using, DC, NameInfo.getLoc(), NameInfo.getName()),
3600 UsingLocation(UL), QualifierLoc(QualifierLoc),
3601 DNLoc(NameInfo.getInfo()) {
3602 setShadowFlag(HasTypenameKeyword);
3603 }
3604
3605 void anchor() override;
3606
3607public:
3608 friend class ASTDeclReader;
3609 friend class ASTDeclWriter;
3610
3611 /// Return the source location of the 'using' keyword.
3612 SourceLocation getUsingLoc() const { return UsingLocation; }
3613
3614 /// Set the source location of the 'using' keyword.
3615 void setUsingLoc(SourceLocation L) { UsingLocation = L; }
3616
3617 /// Retrieve the nested-name-specifier that qualifies the name,
3618 /// with source-location information.
3619 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3620
3621 /// Retrieve the nested-name-specifier that qualifies the name.
3623 return QualifierLoc.getNestedNameSpecifier();
3624 }
3625
3627 return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc);
3628 }
3629
3630 /// Return true if it is a C++03 access declaration (no 'using').
3631 bool isAccessDeclaration() const { return UsingLocation.isInvalid(); }
3632
3633 /// Return true if the using declaration has 'typename'.
3634 bool hasTypename() const { return getShadowFlag(); }
3635
3636 /// Sets whether the using declaration has 'typename'.
3637 void setTypename(bool TN) { setShadowFlag(TN); }
3638
3639 static UsingDecl *Create(ASTContext &C, DeclContext *DC,
3640 SourceLocation UsingL,
3641 NestedNameSpecifierLoc QualifierLoc,
3642 const DeclarationNameInfo &NameInfo,
3643 bool HasTypenameKeyword);
3644
3646
3647 SourceRange getSourceRange() const override LLVM_READONLY;
3648
3649 /// Retrieves the canonical declaration of this declaration.
3651 return cast<UsingDecl>(getFirstDecl());
3652 }
3654 return cast<UsingDecl>(getFirstDecl());
3655 }
3656
3657 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3658 static bool classofKind(Kind K) { return K == Using; }
3659};
3660
3661/// Represents a shadow constructor declaration introduced into a
3662/// class by a C++11 using-declaration that names a constructor.
3663///
3664/// For example:
3665/// \code
3666/// struct Base { Base(int); };
3667/// struct Derived {
3668/// using Base::Base; // creates a UsingDecl and a ConstructorUsingShadowDecl
3669/// };
3670/// \endcode
3672 /// If this constructor using declaration inherted the constructor
3673 /// from an indirect base class, this is the ConstructorUsingShadowDecl
3674 /// in the named direct base class from which the declaration was inherited.
3675 ConstructorUsingShadowDecl *NominatedBaseClassShadowDecl = nullptr;
3676
3677 /// If this constructor using declaration inherted the constructor
3678 /// from an indirect base class, this is the ConstructorUsingShadowDecl
3679 /// that will be used to construct the unique direct or virtual base class
3680 /// that receives the constructor arguments.
3681 ConstructorUsingShadowDecl *ConstructedBaseClassShadowDecl = nullptr;
3682
3683 /// \c true if the constructor ultimately named by this using shadow
3684 /// declaration is within a virtual base class subobject of the class that
3685 /// contains this declaration.
3686 LLVM_PREFERRED_TYPE(bool)
3687 unsigned IsVirtual : 1;
3688
3690 UsingDecl *Using, NamedDecl *Target,
3691 bool TargetInVirtualBase)
3692 : UsingShadowDecl(ConstructorUsingShadow, C, DC, Loc,
3693 Using->getDeclName(), Using,
3694 Target->getUnderlyingDecl()),
3695 NominatedBaseClassShadowDecl(
3696 dyn_cast<ConstructorUsingShadowDecl>(Target)),
3697 ConstructedBaseClassShadowDecl(NominatedBaseClassShadowDecl),
3698 IsVirtual(TargetInVirtualBase) {
3699 // If we found a constructor that chains to a constructor for a virtual
3700 // base, we should directly call that virtual base constructor instead.
3701 // FIXME: This logic belongs in Sema.
3702 if (NominatedBaseClassShadowDecl &&
3703 NominatedBaseClassShadowDecl->constructsVirtualBase()) {
3704 ConstructedBaseClassShadowDecl =
3705 NominatedBaseClassShadowDecl->ConstructedBaseClassShadowDecl;
3706 IsVirtual = true;
3707 }
3708 }
3709
3711 : UsingShadowDecl(ConstructorUsingShadow, C, Empty), IsVirtual(false) {}
3712
3713 void anchor() override;
3714
3715public:
3716 friend class ASTDeclReader;
3717 friend class ASTDeclWriter;
3718
3721 UsingDecl *Using, NamedDecl *Target,
3722 bool IsVirtual);
3725
3726 /// Override the UsingShadowDecl's getIntroducer, returning the UsingDecl that
3727 /// introduced this.
3729 return cast<UsingDecl>(UsingShadowDecl::getIntroducer());
3730 }
3731
3732 /// Returns the parent of this using shadow declaration, which
3733 /// is the class in which this is declared.
3734 //@{
3735 const CXXRecordDecl *getParent() const {
3736 return cast<CXXRecordDecl>(getDeclContext());
3737 }
3739 return cast<CXXRecordDecl>(getDeclContext());
3740 }
3741 //@}
3742
3743 /// Get the inheriting constructor declaration for the direct base
3744 /// class from which this using shadow declaration was inherited, if there is
3745 /// one. This can be different for each redeclaration of the same shadow decl.
3747 return NominatedBaseClassShadowDecl;
3748 }
3749
3750 /// Get the inheriting constructor declaration for the base class
3751 /// for which we don't have an explicit initializer, if there is one.
3753 return ConstructedBaseClassShadowDecl;
3754 }
3755
3756 /// Get the base class that was named in the using declaration. This
3757 /// can be different for each redeclaration of this same shadow decl.
3759
3760 /// Get the base class whose constructor or constructor shadow
3761 /// declaration is passed the constructor arguments.
3763 return cast<CXXRecordDecl>((ConstructedBaseClassShadowDecl
3764 ? ConstructedBaseClassShadowDecl
3765 : getTargetDecl())
3766 ->getDeclContext());
3767 }
3768
3769 /// Returns \c true if the constructed base class is a virtual base
3770 /// class subobject of this declaration's class.
3772 return IsVirtual;
3773 }
3774
3775 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3776 static bool classofKind(Kind K) { return K == ConstructorUsingShadow; }
3777};
3778
3779/// Represents a C++ using-enum-declaration.
3780///
3781/// For example:
3782/// \code
3783/// using enum SomeEnumTag ;
3784/// \endcode
3785
3786class UsingEnumDecl : public BaseUsingDecl, public Mergeable<UsingEnumDecl> {
3787 /// The source location of the 'using' keyword itself.
3788 SourceLocation UsingLocation;
3789 /// The source location of the 'enum' keyword.
3790 SourceLocation EnumLocation;
3791 /// 'qual::SomeEnum' as an EnumType, possibly with Elaborated/Typedef sugar.
3793
3796 : BaseUsingDecl(UsingEnum, DC, NL, DN), UsingLocation(UL), EnumLocation(EL),
3798
3799 void anchor() override;
3800
3801public:
3802 friend class ASTDeclReader;
3803 friend class ASTDeclWriter;
3804
3805 /// The source location of the 'using' keyword.
3806 SourceLocation getUsingLoc() const { return UsingLocation; }
3807 void setUsingLoc(SourceLocation L) { UsingLocation = L; }
3808
3809 /// The source location of the 'enum' keyword.
3810 SourceLocation getEnumLoc() const { return EnumLocation; }
3811 void setEnumLoc(SourceLocation L) { EnumLocation = L; }
3814 }
3816 return getEnumTypeLoc().getPrefix();
3817 }
3818 // Returns the "qualifier::Name" part as a TypeLoc.
3820 return EnumType->getTypeLoc();
3821 }
3823 return EnumType;
3824 }
3826
3827public:
3829 return EnumType->getType()->castAs<clang::EnumType>()->getOriginalDecl();
3830 }
3831
3833 SourceLocation UsingL, SourceLocation EnumL,
3835
3837
3838 SourceRange getSourceRange() const override LLVM_READONLY;
3839
3840 /// Retrieves the canonical declaration of this declaration.
3842 return cast<UsingEnumDecl>(getFirstDecl());
3843 }
3845 return cast<UsingEnumDecl>(getFirstDecl());
3846 }
3847
3848 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3849 static bool classofKind(Kind K) { return K == UsingEnum; }
3850};
3851
3852/// Represents a pack of using declarations that a single
3853/// using-declarator pack-expanded into.
3854///
3855/// \code
3856/// template<typename ...T> struct X : T... {
3857/// using T::operator()...;
3858/// using T::operator T...;
3859/// };
3860/// \endcode
3861///
3862/// In the second case above, the UsingPackDecl will have the name
3863/// 'operator T' (which contains an unexpanded pack), but the individual
3864/// UsingDecls and UsingShadowDecls will have more reasonable names.
3865class UsingPackDecl final
3866 : public NamedDecl, public Mergeable<UsingPackDecl>,
3867 private llvm::TrailingObjects<UsingPackDecl, NamedDecl *> {
3868 /// The UnresolvedUsingValueDecl or UnresolvedUsingTypenameDecl from
3869 /// which this waas instantiated.
3870 NamedDecl *InstantiatedFrom;
3871
3872 /// The number of using-declarations created by this pack expansion.
3873 unsigned NumExpansions;
3874
3875 UsingPackDecl(DeclContext *DC, NamedDecl *InstantiatedFrom,
3876 ArrayRef<NamedDecl *> UsingDecls)
3877 : NamedDecl(UsingPack, DC,
3878 InstantiatedFrom ? InstantiatedFrom->getLocation()
3879 : SourceLocation(),
3880 InstantiatedFrom ? InstantiatedFrom->getDeclName()
3881 : DeclarationName()),
3882 InstantiatedFrom(InstantiatedFrom), NumExpansions(UsingDecls.size()) {
3883 llvm::uninitialized_copy(UsingDecls, getTrailingObjects());
3884 }
3885
3886 void anchor() override;
3887
3888public:
3889 friend class ASTDeclReader;
3890 friend class ASTDeclWriter;
3892
3893 /// Get the using declaration from which this was instantiated. This will
3894 /// always be an UnresolvedUsingValueDecl or an UnresolvedUsingTypenameDecl
3895 /// that is a pack expansion.
3896 NamedDecl *getInstantiatedFromUsingDecl() const { return InstantiatedFrom; }
3897
3898 /// Get the set of using declarations that this pack expanded into. Note that
3899 /// some of these may still be unresolved.
3901 return getTrailingObjects(NumExpansions);
3902 }
3903
3905 NamedDecl *InstantiatedFrom,
3906 ArrayRef<NamedDecl *> UsingDecls);
3907
3909 unsigned NumExpansions);
3910
3911 SourceRange getSourceRange() const override LLVM_READONLY {
3912 return InstantiatedFrom->getSourceRange();
3913 }
3914
3916 const UsingPackDecl *getCanonicalDecl() const { return getFirstDecl(); }
3917
3918 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3919 static bool classofKind(Kind K) { return K == UsingPack; }
3920};
3921
3922/// Represents a dependent using declaration which was not marked with
3923/// \c typename.
3924///
3925/// Unlike non-dependent using declarations, these *only* bring through
3926/// non-types; otherwise they would break two-phase lookup.
3927///
3928/// \code
3929/// template <class T> class A : public Base<T> {
3930/// using Base<T>::foo;
3931/// };
3932/// \endcode
3934 public Mergeable<UnresolvedUsingValueDecl> {
3935 /// The source location of the 'using' keyword
3936 SourceLocation UsingLocation;
3937
3938 /// If this is a pack expansion, the location of the '...'.
3939 SourceLocation EllipsisLoc;
3940
3941 /// The nested-name-specifier that precedes the name.
3942 NestedNameSpecifierLoc QualifierLoc;
3943
3944 /// Provides source/type location info for the declaration name
3945 /// embedded in the ValueDecl base class.
3946 DeclarationNameLoc DNLoc;
3947
3949 SourceLocation UsingLoc,
3950 NestedNameSpecifierLoc QualifierLoc,
3951 const DeclarationNameInfo &NameInfo,
3952 SourceLocation EllipsisLoc)
3953 : ValueDecl(UnresolvedUsingValue, DC,
3954 NameInfo.getLoc(), NameInfo.getName(), Ty),
3955 UsingLocation(UsingLoc), EllipsisLoc(EllipsisLoc),
3956 QualifierLoc(QualifierLoc), DNLoc(NameInfo.getInfo()) {}
3957
3958 void anchor() override;
3959
3960public:
3961 friend class ASTDeclReader;
3962 friend class ASTDeclWriter;
3963
3964 /// Returns the source location of the 'using' keyword.
3965 SourceLocation getUsingLoc() const { return UsingLocation; }
3966
3967 /// Set the source location of the 'using' keyword.
3968 void setUsingLoc(SourceLocation L) { UsingLocation = L; }
3969
3970 /// Return true if it is a C++03 access declaration (no 'using').
3971 bool isAccessDeclaration() const { return UsingLocation.isInvalid(); }
3972
3973 /// Retrieve the nested-name-specifier that qualifies the name,
3974 /// with source-location information.
3975 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3976
3977 /// Retrieve the nested-name-specifier that qualifies the name.
3979 return QualifierLoc.getNestedNameSpecifier();
3980 }
3981
3983 return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc);
3984 }
3985
3986 /// Determine whether this is a pack expansion.
3987 bool isPackExpansion() const {
3988 return EllipsisLoc.isValid();
3989 }
3990
3991 /// Get the location of the ellipsis if this is a pack expansion.
3993 return EllipsisLoc;
3994 }
3995
3998 NestedNameSpecifierLoc QualifierLoc,
3999 const DeclarationNameInfo &NameInfo, SourceLocation EllipsisLoc);
4000
4003
4004 SourceRange getSourceRange() const override LLVM_READONLY;
4005
4006 /// Retrieves the canonical declaration of this declaration.
4008 return getFirstDecl();
4009 }
4011 return getFirstDecl();
4012 }
4013
4014 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4015 static bool classofKind(Kind K) { return K == UnresolvedUsingValue; }
4016};
4017
4018/// Represents a dependent using declaration which was marked with
4019/// \c typename.
4020///
4021/// \code
4022/// template <class T> class A : public Base<T> {
4023/// using typename Base<T>::foo;
4024/// };
4025/// \endcode
4026///
4027/// The type associated with an unresolved using typename decl is
4028/// currently always a typename type.
4030 : public TypeDecl,
4031 public Mergeable<UnresolvedUsingTypenameDecl> {
4032 friend class ASTDeclReader;
4033
4034 /// The source location of the 'typename' keyword
4035 SourceLocation TypenameLocation;
4036
4037 /// If this is a pack expansion, the location of the '...'.
4038 SourceLocation EllipsisLoc;
4039
4040 /// The nested-name-specifier that precedes the name.
4041 NestedNameSpecifierLoc QualifierLoc;
4042
4044 SourceLocation TypenameLoc,
4045 NestedNameSpecifierLoc QualifierLoc,
4046 SourceLocation TargetNameLoc,
4047 IdentifierInfo *TargetName,
4048 SourceLocation EllipsisLoc)
4049 : TypeDecl(UnresolvedUsingTypename, DC, TargetNameLoc, TargetName,
4050 UsingLoc),
4051 TypenameLocation(TypenameLoc), EllipsisLoc(EllipsisLoc),
4052 QualifierLoc(QualifierLoc) {}
4053
4054 void anchor() override;
4055
4056public:
4057 /// Returns the source location of the 'using' keyword.
4059
4060 /// Returns the source location of the 'typename' keyword.
4061 SourceLocation getTypenameLoc() const { return TypenameLocation; }
4062
4063 /// Retrieve the nested-name-specifier that qualifies the name,
4064 /// with source-location information.
4065 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
4066
4067 /// Retrieve the nested-name-specifier that qualifies the name.
4069 return QualifierLoc.getNestedNameSpecifier();
4070 }
4071
4074 }
4075
4076 /// Determine whether this is a pack expansion.
4077 bool isPackExpansion() const {
4078 return EllipsisLoc.isValid();
4079 }
4080
4081 /// Get the location of the ellipsis if this is a pack expansion.
4083 return EllipsisLoc;
4084 }
4085
4088 SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc,
4089 SourceLocation TargetNameLoc, DeclarationName TargetName,
4090 SourceLocation EllipsisLoc);
4091
4094
4095 /// Retrieves the canonical declaration of this declaration.
4097 return getFirstDecl();
4098 }
4100 return getFirstDecl();
4101 }
4102
4103 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4104 static bool classofKind(Kind K) { return K == UnresolvedUsingTypename; }
4105};
4106
4107/// This node is generated when a using-declaration that was annotated with
4108/// __attribute__((using_if_exists)) failed to resolve to a known declaration.
4109/// In that case, Sema builds a UsingShadowDecl whose target is an instance of
4110/// this declaration, adding it to the current scope. Referring to this
4111/// declaration in any way is an error.
4114 DeclarationName Name);
4115
4116 void anchor() override;
4117
4118public:
4121 DeclarationName Name);
4124
4125 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4126 static bool classofKind(Kind K) { return K == Decl::UnresolvedUsingIfExists; }
4127};
4128
4129/// Represents a C++11 static_assert declaration.
4130class StaticAssertDecl : public Decl {
4131 llvm::PointerIntPair<Expr *, 1, bool> AssertExprAndFailed;
4132 Expr *Message;
4133 SourceLocation RParenLoc;
4134
4135 StaticAssertDecl(DeclContext *DC, SourceLocation StaticAssertLoc,
4136 Expr *AssertExpr, Expr *Message, SourceLocation RParenLoc,
4137 bool Failed)
4138 : Decl(StaticAssert, DC, StaticAssertLoc),
4139 AssertExprAndFailed(AssertExpr, Failed), Message(Message),
4140 RParenLoc(RParenLoc) {}
4141
4142 virtual void anchor();
4143
4144public:
4145 friend class ASTDeclReader;
4146
4148 SourceLocation StaticAssertLoc,
4149 Expr *AssertExpr, Expr *Message,
4150 SourceLocation RParenLoc, bool Failed);
4152
4153 Expr *getAssertExpr() { return AssertExprAndFailed.getPointer(); }
4154 const Expr *getAssertExpr() const { return AssertExprAndFailed.getPointer(); }
4155
4156 Expr *getMessage() { return Message; }
4157 const Expr *getMessage() const { return Message; }
4158
4159 bool isFailed() const { return AssertExprAndFailed.getInt(); }
4160
4161 SourceLocation getRParenLoc() const { return RParenLoc; }
4162
4163 SourceRange getSourceRange() const override LLVM_READONLY {
4165 }
4166
4167 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4168 static bool classofKind(Kind K) { return K == StaticAssert; }
4169};
4170
4171/// A binding in a decomposition declaration. For instance, given:
4172///
4173/// int n[3];
4174/// auto &[a, b, c] = n;
4175///
4176/// a, b, and c are BindingDecls, whose bindings are the expressions
4177/// x[0], x[1], and x[2] respectively, where x is the implicit
4178/// DecompositionDecl of type 'int (&)[3]'.
4179class BindingDecl : public ValueDecl {
4180 /// The declaration that this binding binds to part of.
4181 ValueDecl *Decomp = nullptr;
4182 /// The binding represented by this declaration. References to this
4183 /// declaration are effectively equivalent to this expression (except
4184 /// that it is only evaluated once at the point of declaration of the
4185 /// binding).
4186 Expr *Binding = nullptr;
4187
4189 QualType T)
4190 : ValueDecl(Decl::Binding, DC, IdLoc, Id, T) {}
4191
4192 void anchor() override;
4193
4194public:
4195 friend class ASTDeclReader;
4196
4199 QualType T);
4201
4202 /// Get the expression to which this declaration is bound. This may be null
4203 /// in two different cases: while parsing the initializer for the
4204 /// decomposition declaration, and when the initializer is type-dependent.
4205 Expr *getBinding() const { return Binding; }
4206
4207 // Get the array of nested BindingDecls when the binding represents a pack.
4209
4210 /// Get the decomposition declaration that this binding represents a
4211 /// decomposition of.
4212 ValueDecl *getDecomposedDecl() const { return Decomp; }
4213
4214 /// Set the binding for this BindingDecl, along with its declared type (which
4215 /// should be a possibly-cv-qualified form of the type of the binding, or a
4216 /// reference to such a type).
4217 void setBinding(QualType DeclaredType, Expr *Binding) {
4218 setType(DeclaredType);
4219 this->Binding = Binding;
4220 }
4221
4222 /// Set the decomposed variable for this BindingDecl.
4223 void setDecomposedDecl(ValueDecl *Decomposed) { Decomp = Decomposed; }
4224
4225 /// Get the variable (if any) that holds the value of evaluating the binding.
4226 /// Only present for user-defined bindings for tuple-like types.
4227 VarDecl *getHoldingVar() const;
4228
4229 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4230 static bool classofKind(Kind K) { return K == Decl::Binding; }
4231};
4232
4233/// A decomposition declaration. For instance, given:
4234///
4235/// int n[3];
4236/// auto &[a, b, c] = n;
4237///
4238/// the second line declares a DecompositionDecl of type 'int (&)[3]', and
4239/// three BindingDecls (named a, b, and c). An instance of this class is always
4240/// unnamed, but behaves in almost all other respects like a VarDecl.
4242 : public VarDecl,
4243 private llvm::TrailingObjects<DecompositionDecl, BindingDecl *> {
4244 /// The number of BindingDecl*s following this object.
4245 unsigned NumBindings;
4246
4248 SourceLocation LSquareLoc, QualType T,
4249 TypeSourceInfo *TInfo, StorageClass SC,
4251 : VarDecl(Decomposition, C, DC, StartLoc, LSquareLoc, nullptr, T, TInfo,
4252 SC),
4253 NumBindings(Bindings.size()) {
4254 llvm::uninitialized_copy(Bindings, getTrailingObjects());
4255 for (auto *B : Bindings) {
4256 B->setDecomposedDecl(this);
4257 if (B->isParameterPack() && B->getBinding()) {
4258 for (BindingDecl *NestedBD : B->getBindingPackDecls()) {
4259 NestedBD->setDecomposedDecl(this);
4260 }
4261 }
4262 }
4263 }
4264
4265 void anchor() override;
4266
4267public:
4268 friend class ASTDeclReader;
4270
4272 SourceLocation StartLoc,
4273 SourceLocation LSquareLoc,
4274 QualType T, TypeSourceInfo *TInfo,
4275 StorageClass S,
4278 unsigned NumBindings);
4279
4280 // Provide the range of bindings which may have a nested pack.
4282 return getTrailingObjects(NumBindings);
4283 }
4284
4285 // Provide a flattened range to visit each binding.
4286 auto flat_bindings() const {
4288 ArrayRef<BindingDecl *> PackBindings;
4289
4290 // Split the bindings into subranges split by the pack.
4291 ArrayRef<BindingDecl *> BeforePackBindings = Bindings.take_until(
4292 [](BindingDecl *BD) { return BD->isParameterPack(); });
4293
4294 Bindings = Bindings.drop_front(BeforePackBindings.size());
4295 if (!Bindings.empty() && Bindings.front()->getBinding()) {
4296 PackBindings = Bindings.front()->getBindingPackDecls();
4297 Bindings = Bindings.drop_front();
4298 }
4299
4300 return llvm::concat<BindingDecl *const>(std::move(BeforePackBindings),
4301 std::move(PackBindings),
4302 std::move(Bindings));
4303 }
4304
4305 void printName(raw_ostream &OS, const PrintingPolicy &Policy) const override;
4306
4307 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4308 static bool classofKind(Kind K) { return K == Decomposition; }
4309};
4310
4311/// An instance of this class represents the declaration of a property
4312/// member. This is a Microsoft extension to C++, first introduced in
4313/// Visual Studio .NET 2003 as a parallel to similar features in C#
4314/// and Managed C++.
4315///
4316/// A property must always be a non-static class member.
4317///
4318/// A property member superficially resembles a non-static data
4319/// member, except preceded by a property attribute:
4320/// __declspec(property(get=GetX, put=PutX)) int x;
4321/// Either (but not both) of the 'get' and 'put' names may be omitted.
4322///
4323/// A reference to a property is always an lvalue. If the lvalue
4324/// undergoes lvalue-to-rvalue conversion, then a getter name is
4325/// required, and that member is called with no arguments.
4326/// If the lvalue is assigned into, then a setter name is required,
4327/// and that member is called with one argument, the value assigned.
4328/// Both operations are potentially overloaded. Compound assignments
4329/// are permitted, as are the increment and decrement operators.
4330///
4331/// The getter and putter methods are permitted to be overloaded,
4332/// although their return and parameter types are subject to certain
4333/// restrictions according to the type of the property.
4334///
4335/// A property declared using an incomplete array type may
4336/// additionally be subscripted, adding extra parameters to the getter
4337/// and putter methods.
4339 IdentifierInfo *GetterId, *SetterId;
4340
4342 QualType T, TypeSourceInfo *TInfo, SourceLocation StartL,
4343 IdentifierInfo *Getter, IdentifierInfo *Setter)
4344 : DeclaratorDecl(MSProperty, DC, L, N, T, TInfo, StartL),
4345 GetterId(Getter), SetterId(Setter) {}
4346
4347 void anchor() override;
4348public:
4349 friend class ASTDeclReader;
4350
4353 TypeSourceInfo *TInfo, SourceLocation StartL,
4354 IdentifierInfo *Getter, IdentifierInfo *Setter);
4356
4357 static bool classof(const Decl *D) { return D->getKind() == MSProperty; }
4358
4359 bool hasGetter() const { return GetterId != nullptr; }
4360 IdentifierInfo* getGetterId() const { return GetterId; }
4361 bool hasSetter() const { return SetterId != nullptr; }
4362 IdentifierInfo* getSetterId() const { return SetterId; }
4363};
4364
4365/// Parts of a decomposed MSGuidDecl. Factored out to avoid unnecessary
4366/// dependencies on DeclCXX.h.
4368 /// {01234567-...
4369 uint32_t Part1;
4370 /// ...-89ab-...
4371 uint16_t Part2;
4372 /// ...-cdef-...
4373 uint16_t Part3;
4374 /// ...-0123-456789abcdef}
4375 uint8_t Part4And5[8];
4376
4377 uint64_t getPart4And5AsUint64() const {
4378 uint64_t Val;
4379 memcpy(&Val, &Part4And5, sizeof(Part4And5));
4380 return Val;
4381 }
4382};
4383
4384/// A global _GUID constant. These are implicitly created by UuidAttrs.
4385///
4386/// struct _declspec(uuid("01234567-89ab-cdef-0123-456789abcdef")) X{};
4387///
4388/// X is a CXXRecordDecl that contains a UuidAttr that references the (unique)
4389/// MSGuidDecl for the specified UUID.
4390class MSGuidDecl : public ValueDecl,
4391 public Mergeable<MSGuidDecl>,
4392 public llvm::FoldingSetNode {
4393public:
4395
4396private:
4397 /// The decomposed form of the UUID.
4398 Parts PartVal;
4399
4400 /// The resolved value of the UUID as an APValue. Computed on demand and
4401 /// cached.
4402 mutable APValue APVal;
4403
4404 void anchor() override;
4405
4407
4408 static MSGuidDecl *Create(const ASTContext &C, QualType T, Parts P);
4409 static MSGuidDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
4410
4411 // Only ASTContext::getMSGuidDecl and deserialization create these.
4412 friend class ASTContext;
4413 friend class ASTReader;
4414 friend class ASTDeclReader;
4415
4416public:
4417 /// Print this UUID in a human-readable format.
4418 void printName(llvm::raw_ostream &OS,
4419 const PrintingPolicy &Policy) const override;
4420
4421 /// Get the decomposed parts of this declaration.
4422 Parts getParts() const { return PartVal; }
4423
4424 /// Get the value of this MSGuidDecl as an APValue. This may fail and return
4425 /// an absent APValue if the type of the declaration is not of the expected
4426 /// shape.
4427 APValue &getAsAPValue() const;
4428
4429 static void Profile(llvm::FoldingSetNodeID &ID, Parts P) {
4430 ID.AddInteger(P.Part1);
4431 ID.AddInteger(P.Part2);
4432 ID.AddInteger(P.Part3);
4433 ID.AddInteger(P.getPart4And5AsUint64());
4434 }
4435 void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, PartVal); }
4436
4437 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4438 static bool classofKind(Kind K) { return K == Decl::MSGuid; }
4439};
4440
4441/// An artificial decl, representing a global anonymous constant value which is
4442/// uniquified by value within a translation unit.
4443///
4444/// These is currently only used to back the LValue returned by
4445/// __builtin_source_location, but could potentially be used for other similar
4446/// situations in the future.
4448 public Mergeable<UnnamedGlobalConstantDecl>,
4449 public llvm::FoldingSetNode {
4450
4451 // The constant value of this global.
4452 APValue Value;
4453
4454 void anchor() override;
4455
4457 const APValue &Val);
4458
4460 const APValue &APVal);
4461 static UnnamedGlobalConstantDecl *CreateDeserialized(ASTContext &C,
4463
4464 // Only ASTContext::getUnnamedGlobalConstantDecl and deserialization create
4465 // these.
4466 friend class ASTContext;
4467 friend class ASTReader;
4468 friend class ASTDeclReader;
4469
4470public:
4471 /// Print this in a human-readable format.
4472 void printName(llvm::raw_ostream &OS,
4473 const PrintingPolicy &Policy) const override;
4474
4475 const APValue &getValue() const { return Value; }
4476
4477 static void Profile(llvm::FoldingSetNodeID &ID, QualType Ty,
4478 const APValue &APVal) {
4479 Ty.Profile(ID);
4480 APVal.Profile(ID);
4481 }
4482 void Profile(llvm::FoldingSetNodeID &ID) {
4483 Profile(ID, getType(), getValue());
4484 }
4485
4486 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4487 static bool classofKind(Kind K) { return K == Decl::UnnamedGlobalConstant; }
4488};
4489
4490/// Insertion operator for diagnostics. This allows sending an AccessSpecifier
4491/// into a diagnostic with <<.
4492const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
4493 AccessSpecifier AS);
4494
4495} // namespace clang
4496
4497#endif // LLVM_CLANG_AST_DECLCXX_H
#define V(N, I)
Definition: ASTContext.h:3597
StringRef P
static char ID
Definition: Arena.cpp:183
const Decl * D
IndirectLocalPath & Path
const LambdaCapture * Capture
enum clang::sema::@1840::IndirectLocalPathEntry::EntryKind Kind
Expr * E
#define X(type, name)
Definition: Value.h:145
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.
llvm::MachO::Target Target
Definition: MachO.h:51
Defines an enumeration for C++ overloaded operators.
uint32_t Id
Definition: SemaARM.cpp:1179
SourceRange Range
Definition: SemaObjC.cpp:753
SourceLocation Loc
Definition: SemaObjC.cpp:754
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.
NestedNameSpecifier Specifier
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition: APValue.h:122
void Profile(llvm::FoldingSetNodeID &ID) const
profile this value.
Definition: APValue.cpp:489
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:188
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:429
An object for streaming information to a record.
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:97
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:3518
shadow_iterator & operator++()
Definition: DeclCXX.h:3535
std::forward_iterator_tag iterator_category
Definition: DeclCXX.h:3526
shadow_iterator(UsingShadowDecl *C)
Definition: DeclCXX.h:3530
friend bool operator==(shadow_iterator x, shadow_iterator y)
Definition: DeclCXX.h:3546
shadow_iterator operator++(int)
Definition: DeclCXX.h:3540
friend bool operator!=(shadow_iterator x, shadow_iterator y)
Definition: DeclCXX.h:3549
Represents a C++ declaration that introduces decls from somewhere else.
Definition: DeclCXX.h:3490
llvm::iterator_range< shadow_iterator > shadow_range
Definition: DeclCXX.h:3554
bool getShadowFlag() const
A bool flag for use by a derived type.
Definition: DeclCXX.h:3507
unsigned shadow_size() const
Return the number of shadowed declarations associated with this using declaration.
Definition: DeclCXX.h:3568
void addShadowDecl(UsingShadowDecl *S)
Definition: DeclCXX.cpp:3387
shadow_range shadows() const
Definition: DeclCXX.h:3556
shadow_iterator shadow_end() const
Definition: DeclCXX.h:3564
static bool classofKind(Kind K)
Definition: DeclCXX.h:3576
BaseUsingDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N)
Definition: DeclCXX.h:3499
shadow_iterator shadow_begin() const
Definition: DeclCXX.h:3560
void setShadowFlag(bool V)
A bool flag a derived type may set.
Definition: DeclCXX.h:3510
void removeShadowDecl(UsingShadowDecl *S)
Definition: DeclCXX.cpp:3396
static bool classof(const Decl *D)
Definition: DeclCXX.h:3575
A binding in a decomposition declaration.
Definition: DeclCXX.h:4179
VarDecl * getHoldingVar() const
Get the variable (if any) that holds the value of evaluating the binding.
Definition: DeclCXX.cpp:3589
ValueDecl * getDecomposedDecl() const
Get the decomposition declaration that this binding represents a decomposition of.
Definition: DeclCXX.h:4212
Expr * getBinding() const
Get the expression to which this declaration is bound.
Definition: DeclCXX.h:4205
static bool classof(const Decl *D)
Definition: DeclCXX.h:4229
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:4217
void setDecomposedDecl(ValueDecl *Decomposed)
Set the decomposed variable for this BindingDecl.
Definition: DeclCXX.h:4223
ArrayRef< BindingDecl * > getBindingPackDecls() const
Definition: DeclCXX.cpp:3602
static BindingDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclCXX.cpp:3584
static bool classofKind(Kind K)
Definition: DeclCXX.h:4230
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:2604
init_const_iterator init_end() const
Retrieve an iterator past the last initializer.
Definition: DeclCXX.h:2715
init_iterator init_end()
Retrieve an iterator past the last initializer.
Definition: DeclCXX.h:2710
std::reverse_iterator< init_iterator > init_reverse_iterator
Definition: DeclCXX.h:2719
std::reverse_iterator< init_const_iterator > init_const_reverse_iterator
Definition: DeclCXX.h:2721
init_reverse_iterator init_rbegin()
Definition: DeclCXX.h:2723
CXXConstructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:2847
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:2837
bool isExplicit() const
Return true if the declaration is already resolved to be explicit.
Definition: DeclCXX.h:2684
ExplicitSpecifier getExplicitSpecifier()
Definition: DeclCXX.h:2676
init_iterator init_begin()
Retrieve an iterator to the first initializer.
Definition: DeclCXX.h:2701
CXXConstructorDecl * getTargetConstructor() const
When this constructor delegates to another, retrieve the target.
Definition: DeclCXX.cpp:2990
static bool classofKind(Kind K)
Definition: DeclCXX.h:2856
static CXXConstructorDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, uint64_t AllocKind)
Definition: DeclCXX.cpp:2948
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
Definition: DeclCXX.cpp:2999
bool isDelegatingConstructor() const
Determine whether this constructor is a delegating constructor.
Definition: DeclCXX.h:2757
bool isSpecializationCopyingObject() const
Determine whether this is a member template specialization that would copy the object to itself.
Definition: DeclCXX.cpp:3074
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
Definition: DeclCXX.h:2842
bool isMoveConstructor() const
Determine whether this constructor is a move constructor (C++11 [class.copy]p3), which can be used to...
Definition: DeclCXX.h:2802
init_const_reverse_iterator init_rbegin() const
Definition: DeclCXX.h:2726
void setNumCtorInitializers(unsigned numCtorInitializers)
Definition: DeclCXX.h:2743
void setExplicitSpecifier(ExplicitSpecifier ES)
Definition: DeclCXX.h:2665
init_const_range inits() const
Definition: DeclCXX.h:2696
bool isCopyOrMoveConstructor() const
Determine whether this a copy or move constructor.
Definition: DeclCXX.h:2814
init_const_reverse_iterator init_rend() const
Definition: DeclCXX.h:2733
bool isInheritingConstructor() const
Determine whether this is an implicit constructor synthesized to model a call to a constructor inheri...
Definition: DeclCXX.h:2831
init_reverse_iterator init_rend()
Definition: DeclCXX.h:2730
llvm::iterator_range< init_iterator > init_range
Definition: DeclCXX.h:2692
CXXCtorInitializer *const * init_const_iterator
Iterates through the member/base initializer list.
Definition: DeclCXX.h:2690
const ExplicitSpecifier getExplicitSpecifier() const
Definition: DeclCXX.h:2679
unsigned getNumCtorInitializers() const
Determine the number of arguments used to initialize the member or base.
Definition: DeclCXX.h:2739
llvm::iterator_range< init_const_iterator > init_const_range
Definition: DeclCXX.h:2693
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:3056
const CXXConstructorDecl * getCanonicalDecl() const
Definition: DeclCXX.h:2850
static bool classof(const Decl *D)
Definition: DeclCXX.h:2855
void setCtorInitializers(CXXCtorInitializer **Initializers)
Definition: DeclCXX.h:2752
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:2788
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2937
bool isLambdaToBlockPointerConversion() const
Determine whether this conversion function is a conversion from a lambda closure type to a block poin...
Definition: DeclCXX.cpp:3168
bool isExplicit() const
Return true if the declaration is already resolved to be explicit.
Definition: DeclCXX.h:2973
static bool classof(const Decl *D)
Definition: DeclCXX.h:2993
static bool classofKind(Kind K)
Definition: DeclCXX.h:2994
ExplicitSpecifier getExplicitSpecifier()
Definition: DeclCXX.h:2964
QualType getConversionType() const
Returns the type that this conversion function is converting to.
Definition: DeclCXX.h:2977
void setExplicitSpecifier(ExplicitSpecifier ES)
Definition: DeclCXX.h:2974
static CXXConversionDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclCXX.cpp:3146
const CXXConversionDecl * getCanonicalDecl() const
Definition: DeclCXX.h:2988
CXXConversionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:2985
const ExplicitSpecifier getExplicitSpecifier() const
Definition: DeclCXX.h:2968
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2369
FieldDecl * getMember() const
If this is a member initializer, returns the declaration of the non-static data member being initiali...
Definition: DeclCXX.h:2509
bool isDelegatingInitializer() const
Determine whether this initializer is creating a delegating constructor.
Definition: DeclCXX.h:2469
bool isWritten() const
Determine whether this initializer is explicitly written in the source code.
Definition: DeclCXX.h:2541
Expr * getInit() const
Get the initializer.
Definition: DeclCXX.h:2571
SourceLocation getRParenLoc() const
Definition: DeclCXX.h:2568
SourceLocation getEllipsisLoc() const
Definition: DeclCXX.h:2479
SourceLocation getLParenLoc() const
Definition: DeclCXX.h:2567
SourceRange getSourceRange() const LLVM_READONLY
Determine the source range covering the entire initializer.
Definition: DeclCXX.cpp:2916
int getSourceOrder() const
Return the source position of the initializer, counting from 0.
Definition: DeclCXX.h:2545
SourceLocation getSourceLocation() const
Determine the source location of the initializer.
Definition: DeclCXX.cpp:2903
bool isAnyMemberInitializer() const
Definition: DeclCXX.h:2449
bool isPackExpansion() const
Determine whether this initializer is a pack expansion.
Definition: DeclCXX.h:2474
TypeSourceInfo * getTypeSourceInfo() const
Returns the declarator information for a base class or delegating initializer.
Definition: DeclCXX.h:2503
bool isMemberInitializer() const
Determine whether this initializer is initializing a non-static data member.
Definition: DeclCXX.h:2447
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
Definition: DeclCXX.h:2441
void setSourceOrder(int Pos)
Set the source order of this initializer.
Definition: DeclCXX.h:2556
bool isIndirectMemberInitializer() const
Definition: DeclCXX.h:2453
int64_t getID(const ASTContext &Context) const
Definition: DeclCXX.cpp:2884
bool isInClassMemberInitializer() const
Determine whether this initializer is an implicit initializer generated for a field with an initializ...
Definition: DeclCXX.h:2463
const Type * getBaseClass() const
If this is a base class initializer, returns the type of the base class.
Definition: DeclCXX.cpp:2896
SourceLocation getMemberLocation() const
Definition: DeclCXX.h:2529
FieldDecl * getAnyMember() const
Definition: DeclCXX.h:2515
IndirectFieldDecl * getIndirectMember() const
Definition: DeclCXX.h:2523
TypeLoc getBaseClassLoc() const
If this is a base class initializer, returns the type of the base class with location information.
Definition: DeclCXX.cpp:2889
bool isBaseVirtual() const
Returns whether the base is virtual or not.
Definition: DeclCXX.h:2495
Represents a C++ deduction guide declaration.
Definition: DeclCXX.h:1979
void setDeductionCandidateKind(DeductionCandidate K)
Definition: DeclCXX.h:2071
void setSourceDeductionGuide(CXXDeductionGuideDecl *DG)
Definition: DeclCXX.h:2059
static CXXDeductionGuideDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclCXX.cpp:2380
bool isExplicit() const
Return true if the declaration is already resolved to be explicit.
Definition: DeclCXX.h:2041
CXXConstructorDecl * getCorrespondingConstructor() const
Get the constructor from which this deduction guide was generated, if this is an implicit deduction g...
Definition: DeclCXX.h:2050
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:2055
ExplicitSpecifier getExplicitSpecifier()
Definition: DeclCXX.h:2037
static bool classofKind(Kind K)
Definition: DeclCXX.h:2082
void setSourceDeductionGuideKind(SourceDeductionGuideKind SK)
Definition: DeclCXX.h:2067
TemplateDecl * getDeducedTemplate() const
Get the template for which this guide performs deduction.
Definition: DeclCXX.h:2044
DeductionCandidate getDeductionCandidateKind() const
Definition: DeclCXX.h:2075
const ExplicitSpecifier getExplicitSpecifier() const
Definition: DeclCXX.h:2038
static bool classof(const Decl *D)
Definition: DeclCXX.h:2081
SourceDeductionGuideKind getSourceDeductionGuideKind() const
Definition: DeclCXX.h:2063
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2869
const FunctionDecl * getOperatorDelete() const
Definition: DeclCXX.h:2902
static CXXDestructorDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclCXX.cpp:3090
const CXXDestructorDecl * getCanonicalDecl() const
Definition: DeclCXX.h:2918
CXXDestructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:2915
static bool classofKind(Kind K)
Definition: DeclCXX.h:2924
void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg)
Definition: DeclCXX.cpp:3112
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:3122
Expr * getOperatorDeleteThisArg() const
Definition: DeclCXX.h:2906
static bool classof(const Decl *D)
Definition: DeclCXX.h:2923
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:2129
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:2703
static bool classofKind(Kind K)
Definition: DeclCXX.h:2349
const CXXMethodDecl * getMostRecentDecl() const
Definition: DeclCXX.h:2236
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:2423
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:2710
void addOverriddenMethod(const CXXMethodDecl *MD)
Definition: DeclCXX.cpp:2755
bool hasInlineBody() const
Definition: DeclCXX.cpp:2833
bool isVirtual() const
Definition: DeclCXX.h:2184
const CXXMethodDecl * getDevirtualizedMethod(const Expr *Base, bool IsAppleKext) const
Definition: DeclCXX.h:2202
bool isUsualDeallocationFunction(SmallVectorImpl< const FunctionDecl * > &PreventedBy) const
Determine whether this is a usual deallocation function (C++ [basic.stc.dynamic.deallocation]p2),...
Definition: DeclCXX.cpp:2593
unsigned getNumExplicitParams() const
Definition: DeclCXX.h:2283
bool isVolatile() const
Definition: DeclCXX.h:2182
CXXMethodDecl * getMostRecentDecl()
Definition: DeclCXX.h:2232
overridden_method_range overridden_methods() const
Definition: DeclCXX.cpp:2778
unsigned size_overridden_methods() const
Definition: DeclCXX.cpp:2772
const CXXMethodDecl *const * method_iterator
Definition: DeclCXX.h:2242
QualType getFunctionObjectParameterReferenceType() const
Return the type of the object pointed by this.
Definition: DeclCXX.cpp:2820
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this method.
Definition: DeclCXX.h:2305
method_iterator begin_overridden_methods() const
Definition: DeclCXX.cpp:2762
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Definition: DeclCXX.h:2255
QualType getThisType() const
Return the type of the this pointer.
Definition: DeclCXX.cpp:2809
bool isInstance() const
Definition: DeclCXX.h:2156
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
Definition: DeclCXX.cpp:2735
Qualifiers getMethodQualifiers() const
Definition: DeclCXX.h:2290
CXXRecordDecl * getParent()
Return the parent of this method declaration, which is the class in which this method is defined.
Definition: DeclCXX.h:2261
QualType getFunctionObjectParameterType() const
Definition: DeclCXX.h:2279
const CXXMethodDecl * getCorrespondingMethodDeclaredInClass(const CXXRecordDecl *RD, bool MayBeBase=false) const
Definition: DeclCXX.h:2341
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:2508
static bool isStaticOverloadedOperator(OverloadedOperatorKind OOK)
Returns true if the given operator is implicitly static in a record context.
Definition: DeclCXX.h:2171
bool isConst() const
Definition: DeclCXX.h:2181
CXXMethodDecl * getCorrespondingMethodInClass(const CXXRecordDecl *RD, bool MayBeBase=false)
Find the method in RD that corresponds to this one.
Definition: DeclCXX.cpp:2454
llvm::iterator_range< llvm::TinyPtrVector< const CXXMethodDecl * >::const_iterator > overridden_method_range
Definition: DeclCXX.h:2249
bool isStatic() const
Definition: DeclCXX.cpp:2401
static bool classof(const Decl *D)
Definition: DeclCXX.h:2348
const CXXMethodDecl * getCanonicalDecl() const
Definition: DeclCXX.h:2228
bool isCopyAssignmentOperator() const
Determine whether this is a copy-assignment operator, regardless of whether it was declared implicitl...
Definition: DeclCXX.cpp:2714
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:2133
static CXXMethodDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclCXX.cpp:2499
method_iterator end_overridden_methods() const
Definition: DeclCXX.cpp:2767
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:2225
bool isLambdaStaticInvoker() const
Determine whether this is a lambda closure type's static member function that is used for the result ...
Definition: DeclCXX.cpp:2845
const CXXMethodDecl * getCorrespondingMethodInClass(const CXXRecordDecl *RD, bool MayBeBase=false) const
Definition: DeclCXX.h:2330
An iterator over the friend declarations of a class.
Definition: DeclFriend.h:198
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
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:1270
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_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:1550
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
Definition: DeclCXX.cpp:1828
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:2310
bool hasTrivialMoveAssignment() const
Determine whether this class has a trivial move assignment operator (C++11 [class....
Definition: DeclCXX.h:1341
void setLambdaTypeInfo(TypeSourceInfo *TS)
Definition: DeclCXX.h:1864
bool isTriviallyCopyable() const
Determine whether this class is considered trivially copyable per (C++11 [class]p6).
Definition: DeclCXX.cpp:607
bool hasNonTrivialCopyAssignment() const
Determine whether this class has a non-trivial copy assignment operator (C++ [class....
Definition: DeclCXX.h:1334
TemplateParameterList * getGenericLambdaTemplateParameterList() const
Retrieve the generic lambda's template parameter list.
Definition: DeclCXX.cpp:1805
bool isEffectivelyFinal() const
Determine whether it's impossible for a class to be derived from this class.
Definition: DeclCXX.cpp:2325
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 hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
Definition: DeclCXX.h:1240
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:1673
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:1366
bool hasUserDeclaredDestructor() const
Determine whether this class has a user-declared destructor.
Definition: DeclCXX.h:1001
unsigned getLambdaDependencyKind() const
Definition: DeclCXX.h:1854
void setLambdaIsGeneric(bool IsGeneric)
Definition: DeclCXX.h:1875
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:1554
bool hasInheritedAssignment() const
Determine whether this class has a using-declaration that names a base class assignment operator.
Definition: DeclCXX.h:1420
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:1391
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:2020
bool hasTrivialDestructorForCall() const
Definition: DeclCXX.h:1370
bool hasInjectedClassType() const
Determines whether this declaration has is canonically of an injected class type.
Definition: DeclCXX.cpp:2156
bool defaultedMoveConstructorIsDeleted() const
true if a defaulted move constructor for this class would be deleted.
Definition: DeclCXX.h:706
void completeDefinition() override
Indicates that the definition of this class is now complete.
Definition: DeclCXX.cpp:2239
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:1500
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:1533
bool hasDeletedDestructor() const
Returns the destructor decl for this class.
Definition: DeclCXX.cpp:2140
bool defaultedDestructorIsConstexpr() const
Determine whether a defaulted default constructor for this class would be constexpr.
Definition: DeclCXX.h:1356
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:1623
void pushFriendDecl(FriendDecl *FD)
Definition: DeclFriend.h:262
unsigned getDeviceLambdaManglingNumber() const
Retrieve the device side mangling number.
Definition: DeclCXX.cpp:1845
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:1772
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:600
unsigned getLambdaIndexInContext() const
Retrieve the index of this lambda within the context declaration returned by getLambdaContextDecl().
Definition: DeclCXX.h:1790
void setTrivialForCallFlags(CXXMethodDecl *MD)
Definition: DeclCXX.cpp:1645
const CXXRecordDecl * getPreviousDecl() const
Definition: DeclCXX.h:535
bool isLambda() const
Determine whether this class describes a lambda function object.
Definition: DeclCXX.h:1018
bool hasTrivialMoveConstructor() const
Determine whether this class has a trivial move constructor (C++11 [class.copy]p12)
Definition: DeclCXX.h:1301
bool needsImplicitDefaultConstructor() const
Determine if we need to declare a default constructor for this class.
Definition: DeclCXX.h:766
void viewInheritance(ASTContext &Context) const
Renders and displays an inheritance diagram for this C++ class and all of its base classes (transitiv...
Definition: InheritViz.cpp:135
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:1525
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:1765
bool isNeverDependentLambda() const
Definition: DeclCXX.h:1850
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:1915
bool hasNonTrivialDestructor() const
Determine whether this class has a non-trivial destructor (C++ [class.dtor]p3)
Definition: DeclCXX.h:1376
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:1721
bool isParsingBaseSpecifiers() const
Definition: DeclCXX.h:592
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:1784
bool hasConstexprNonCopyMoveConstructor() const
Determine whether this class has at least one constexpr constructor other than the copy or move const...
Definition: DeclCXX.h:1255
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:1977
bool defaultedDefaultConstructorIsConstexpr() const
Determine whether a defaulted default constructor for this class would be constexpr.
Definition: DeclCXX.h:1263
bool hasTrivialCopyConstructor() const
Determine whether this class has a trivial copy constructor (C++ [class.copy]p6, C++11 [class....
Definition: DeclCXX.h:1278
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:595
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:1408
base_class_const_range bases() const
Definition: DeclCXX.h:611
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:1458
bool hasMoveAssignment() const
Determine whether this class has a move assignment operator.
Definition: DeclCXX.h:966
bool isTriviallyCopyConstructible() const
Determine whether this class is considered trivially copyable per.
Definition: DeclCXX.cpp:624
bool hasTrivialCopyConstructorForCall() const
Definition: DeclCXX.h:1282
bool isCapturelessLambda() const
Definition: DeclCXX.h:1064
llvm::iterator_range< specific_decl_iterator< CXXMethodDecl > > method_range
Definition: DeclCXX.h:648
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
Definition: DeclCXX.cpp:2075
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:726
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
Definition: DeclCXX.cpp:2050
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:1731
bool hasTrivialCopyAssignment() const
Determine whether this class has a trivial copy assignment operator (C++ [class.copy]p11,...
Definition: DeclCXX.h:1328
void addedEligibleSpecialMemberFunction(const CXXMethodDecl *MD, unsigned SMKind)
Notify the class that an eligible SMF has been added.
Definition: DeclCXX.cpp:1530
conversion_iterator conversion_end() const
Definition: DeclCXX.h:1125
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:1576
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:1860
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:1662
void setInstantiationOfMemberClass(CXXRecordDecl *RD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member class RD.
Definition: DeclCXX.cpp:2033
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:1402
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:1846
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:1313
bool hasNonTrivialCopyConstructorForCall() const
Definition: DeclCXX.h:1293
bool hasDirectFields() const
Determine whether this class has direct non-static data members.
Definition: DeclCXX.h:1200
const CXXRecordDecl * getCanonicalDecl() const
Definition: DeclCXX.h:526
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...
CanQualType getCanonicalTemplateSpecializationType(const ASTContext &Ctx) const
Definition: DeclCXX.cpp:2169
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:490
LambdaNumbering getLambdaNumbering() const
Definition: DeclCXX.h:1808
llvm::iterator_range< specific_decl_iterator< CXXConstructorDecl > > ctor_range
Definition: DeclCXX.h:668
bool hasDefinition() const
Definition: DeclCXX.h:561
ArrayRef< NamedDecl * > getLambdaExplicitTemplateParameters() const
Retrieve the lambda template parameters that were specified explicitly.
Definition: DeclCXX.cpp:1814
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:2042
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...
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:1649
void removeConversion(const NamedDecl *Old)
Removes a conversion function from this class.
Definition: DeclCXX.cpp:1995
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:2146
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:2121
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:1348
bool hasNonTrivialDestructorForCall() const
Definition: DeclCXX.h:1380
void setHasTrivialSpecialMemberForCall()
Definition: DeclCXX.h:1384
method_iterator method_end() const
Method past-the-end iterator.
Definition: DeclCXX.h:661
static bool classofKind(Kind K)
Definition: DeclCXX.h:1916
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
llvm::iterator_range< base_class_const_iterator > base_class_const_range
Definition: DeclCXX.h:606
bool hasUserDeclaredMoveOperation() const
Whether this class has a user-declared move constructor or assignment operator.
Definition: DeclCXX.h:839
llvm::function_ref< bool(const CXXRecordDecl *BaseDefinition)> ForallBasesCallback
Function type used by forallBases() as a callback.
Definition: DeclCXX.h:1625
bool hasInheritedConstructor() const
Determine whether this class has a using-declaration that names a user-declared base class constructo...
Definition: DeclCXX.h:1414
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:1748
bool hasNonTrivialDefaultConstructor() const
Determine whether this class has a non-trivial default constructor (C++11 [class.ctor]p5).
Definition: DeclCXX.h:1247
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:2046
bool isVirtuallyDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is virtually derived from the class Base.
bool isInterfaceLike() const
Definition: DeclCXX.cpp:2188
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:1319
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 and context declaration for a lambda class.
Definition: DeclCXX.cpp:1834
bool isAnyDestructorNoReturn() const
Returns true if the class destructor, or any implicitly invoked destructors are marked noreturn.
Definition: DeclCXX.h:1546
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:1871
bool hasTrivialMoveConstructorForCall() const
Definition: DeclCXX.h:1306
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization,...
Definition: DeclCXX.cpp:2027
FunctionDecl * isLocalClass()
Definition: DeclCXX.h:1561
bool hasNonTrivialCopyConstructor() const
Determine whether this class has a non-trivial copy constructor (C++ [class.copy]p6,...
Definition: DeclCXX.h:1288
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
Definition: DeclCXX.cpp:1736
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:559
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:2061
bool isTrivial() const
Determine whether this class is considered trivial.
Definition: DeclCXX.h:1436
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:3671
const CXXRecordDecl * getParent() const
Returns the parent of this using shadow declaration, which is the class in which this is declared.
Definition: DeclCXX.h:3735
static ConstructorUsingShadowDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclCXX.cpp:3377
CXXRecordDecl * getParent()
Definition: DeclCXX.h:3738
static bool classof(const Decl *D)
Definition: DeclCXX.h:3775
CXXRecordDecl * getConstructedBaseClass() const
Get the base class whose constructor or constructor shadow declaration is passed the constructor argu...
Definition: DeclCXX.h:3762
static bool classofKind(Kind K)
Definition: DeclCXX.h:3776
UsingDecl * getIntroducer() const
Override the UsingShadowDecl's getIntroducer, returning the UsingDecl that introduced this.
Definition: DeclCXX.h:3728
bool constructsVirtualBase() const
Returns true if the constructed base class is a virtual base class subobject of this declaration's cl...
Definition: DeclCXX.h:3771
ConstructorUsingShadowDecl * getConstructedBaseClassShadowDecl() const
Get the inheriting constructor declaration for the base class for which we don't have an explicit ini...
Definition: DeclCXX.h:3752
ConstructorUsingShadowDecl * getNominatedBaseClassShadowDecl() const
Get the inheriting constructor declaration for the direct base class from which this using shadow dec...
Definition: DeclCXX.h:3746
CXXRecordDecl * getNominatedBaseClass() const
Get the base class that was named in the using declaration.
Definition: DeclCXX.cpp:3381
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
Definition: DeclBase.cpp:1655
LinkageSpecDeclBitfields LinkageSpecDeclBits
Definition: DeclBase.h:2048
decl_iterator decls_begin() const
Definition: DeclBase.cpp:1649
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:524
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:89
unsigned getIdentifierNamespace() const
Definition: DeclBase.h:889
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
friend class DeclContext
Definition: DeclBase.h:252
const LangOptions & getLangOpts() const LLVM_READONLY
Helper to get the language options from the ASTContext.
Definition: DeclBase.cpp:530
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.
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:779
A decomposition declaration.
Definition: DeclCXX.h:4243
void printName(raw_ostream &OS, const PrintingPolicy &Policy) const override
Pretty-print the unqualified name of this declaration.
Definition: DeclCXX.cpp:3638
ArrayRef< BindingDecl * > bindings() const
Definition: DeclCXX.h:4281
static bool classof(const Decl *D)
Definition: DeclCXX.h:4307
auto flat_bindings() const
Definition: DeclCXX.h:4286
static bool classofKind(Kind K)
Definition: DeclCXX.h:4308
static DecompositionDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NumBindings)
Definition: DeclCXX.cpp:3624
Represents an enum.
Definition: Decl.h:4000
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
Definition: TypeBase.h:6522
Store information needed for an explicit specifier.
Definition: DeclCXX.h:1924
bool isExplicit() const
Determine whether this specifier is known to correspond to an explicit declaration.
Definition: DeclCXX.h:1948
ExplicitSpecKind getKind() const
Definition: DeclCXX.h:1932
bool isInvalid() const
Determine if the explicit specifier is invalid.
Definition: DeclCXX.h:1953
static ExplicitSpecifier Invalid()
Definition: DeclCXX.h:1964
static const ExplicitSpecifier getFromDecl(const FunctionDecl *Function)
Definition: DeclCXX.h:1961
const Expr * getExpr() const
Definition: DeclCXX.h:1933
void setExpr(Expr *E)
Definition: DeclCXX.h:1958
void setKind(ExplicitSpecKind Kind)
Definition: DeclCXX.h:1957
static ExplicitSpecifier getFromDecl(FunctionDecl *Function)
Definition: DeclCXX.cpp:2354
bool isSpecified() const
Determine if the declaration had an explicit specifier of any kind.
Definition: DeclCXX.h:1937
bool isEquivalent(const ExplicitSpecifier Other) const
Check for equivalence of explicit specifiers.
Definition: DeclCXX.cpp:2339
ExplicitSpecifier(Expr *Expression, ExplicitSpecKind Kind)
Definition: DeclCXX.h:1930
This represents one expression.
Definition: Expr.h:112
Represents a member of a struct/union/class.
Definition: Decl.h:3153
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:1999
void setIsPureVirtual(bool P=true)
Definition: Decl.cpp:3290
bool UsesFPIntrin() const
Determine whether the function was declared in source context that requires constrained FP intrinsics...
Definition: Decl.h:2902
QualType getReturnType() const
Definition: Decl.h:2838
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: Decl.cpp:3684
bool isPureVirtual() const
Whether this virtual function is pure, i.e.
Definition: Decl.h:2352
void setRangeEnd(SourceLocation E)
Definition: Decl.h:2217
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
Definition: Decl.h:2343
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
Definition: Decl.cpp:3763
Represents a prototype with parameter type info, e.g.
Definition: TypeBase.h:5282
Declaration of a template function.
Definition: DeclTemplate.h:952
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: TypeBase.h:4478
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:3460
Description of a constructor that was inherited from a base class.
Definition: DeclCXX.h:2575
CXXConstructorDecl * getConstructor() const
Definition: DeclCXX.h:2588
InheritedConstructor(ConstructorUsingShadowDecl *Shadow, CXXConstructorDecl *BaseCtor)
Definition: DeclCXX.h:2581
ConstructorUsingShadowDecl * getShadowDecl() const
Definition: DeclCXX.h:2587
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:25
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1970
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
Definition: DeclCXX.h:3302
const ValueDecl * getExtendingDecl() const
Definition: DeclCXX.h:3338
unsigned getManglingNumber() const
Definition: DeclCXX.h:3351
APValue * getOrCreateValue(bool MayCreate) const
Get the storage for the constant value of a materialized temporary of static storage duration.
Definition: DeclCXX.cpp:3324
static bool classof(const Decl *D)
Definition: DeclCXX.h:3368
Stmt::child_range childrenExpr()
Definition: DeclCXX.h:3360
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
Definition: DeclCXX.cpp:3308
Stmt::const_child_range childrenExpr() const
Definition: DeclCXX.h:3364
static LifetimeExtendedTemporaryDecl * Create(Expr *Temp, ValueDecl *EDec, unsigned Mangling)
Definition: DeclCXX.h:3327
Expr * getTemporaryExpr()
Retrieve the expression to which the temporary materialization conversion was applied.
Definition: DeclCXX.h:3348
static LifetimeExtendedTemporaryDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclCXX.h:3332
const Expr * getTemporaryExpr() const
Definition: DeclCXX.h:3349
static bool classofKind(Kind K)
Definition: DeclCXX.h:3369
Represents a linkage specification.
Definition: DeclCXX.h:3009
void setExternLoc(SourceLocation L)
Definition: DeclCXX.h:3050
void setLanguage(LinkageSpecLanguageIDs L)
Set the language specified by this linkage specification.
Definition: DeclCXX.h:3037
static bool classofKind(Kind K)
Definition: DeclCXX.h:3069
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclCXX.h:3064
void setRBraceLoc(SourceLocation L)
Definition: DeclCXX.h:3051
static LinkageSpecDecl * castFromDeclContext(const DeclContext *DC)
Definition: DeclCXX.h:3075
static DeclContext * castToDeclContext(const LinkageSpecDecl *D)
Definition: DeclCXX.h:3071
LinkageSpecLanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Definition: DeclCXX.h:3032
SourceLocation getExternLoc() const
Definition: DeclCXX.h:3048
SourceLocation getRBraceLoc() const
Definition: DeclCXX.h:3049
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclCXX.h:3056
static bool classof(const Decl *D)
Definition: DeclCXX.h:3068
static LinkageSpecDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclCXX.cpp:3192
bool hasBraces() const
Determines whether this linkage specification had braces in its syntactic form.
Definition: DeclCXX.h:3043
A global _GUID constant.
Definition: DeclCXX.h:4392
static bool classof(const Decl *D)
Definition: DeclCXX.h:4437
Parts getParts() const
Get the decomposed parts of this declaration.
Definition: DeclCXX.h:4422
static bool classofKind(Kind K)
Definition: DeclCXX.h:4438
static void Profile(llvm::FoldingSetNodeID &ID, Parts P)
Definition: DeclCXX.h:4429
void Profile(llvm::FoldingSetNodeID &ID)
Definition: DeclCXX.h:4435
APValue & getAsAPValue() const
Get the value of this MSGuidDecl as an APValue.
Definition: DeclCXX.cpp:3745
void printName(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const override
Print this UUID in a human-readable format.
Definition: DeclCXX.cpp:3684
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:4338
static bool classof(const Decl *D)
Definition: DeclCXX.h:4357
bool hasSetter() const
Definition: DeclCXX.h:4361
IdentifierInfo * getGetterId() const
Definition: DeclCXX.h:4360
bool hasGetter() const
Definition: DeclCXX.h:4359
IdentifierInfo * getSetterId() const
Definition: DeclCXX.h:4362
static MSPropertyDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclCXX.cpp:3662
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4914
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:614
Provides common interface for the Decls that cannot be redeclared, but can be merged if the same decl...
Definition: Redeclarable.h:311
UsingDecl * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Definition: Redeclarable.h:317
This represents a decl that may have a name.
Definition: Decl.h:273
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:339
NamedDecl * getMostRecentDecl()
Definition: Decl.h:500
Represents a C++ namespace alias.
Definition: DeclCXX.h:3195
static NamespaceAliasDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclCXX.cpp:3297
const NamespaceAliasDecl * getCanonicalDecl() const
Definition: DeclCXX.h:3250
redeclarable_base::redecl_range redecl_range
Definition: DeclCXX.h:3238
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclCXX.h:3290
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition: DeclCXX.h:3256
SourceLocation getAliasLoc() const
Returns the location of the alias name, i.e.
Definition: DeclCXX.h:3278
NamespaceBaseDecl * getAliasedNamespace() const
Retrieve the namespace that this alias refers to, which may either be a NamespaceDecl or a NamespaceA...
Definition: DeclCXX.h:3288
static bool classof(const Decl *D)
Definition: DeclCXX.h:3294
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
Definition: DeclCXX.h:3281
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
Definition: DeclCXX.h:3284
NamespaceAliasDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:3247
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Definition: DeclCXX.h:3265
redeclarable_base::redecl_iterator redecl_iterator
Definition: DeclCXX.h:3239
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of the namespace.
Definition: DeclCXX.h:3260
static bool classofKind(Kind K)
Definition: DeclCXX.h:3295
const NamespaceDecl * getNamespace() const
Definition: DeclCXX.h:3272
Represents C++ namespaces and their aliases.
Definition: Decl.h:572
NamespaceDecl * getNamespace()
Definition: DeclCXX.cpp:3222
Represent a C++ namespace.
Definition: Decl.h:591
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:1398
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:8528
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition: TypeBase.h:8437
The collection of all-type qualifiers we support.
Definition: TypeBase.h:331
Represents a struct/union/class.
Definition: Decl.h:4305
Provides common interface for the Decls that can be redeclared.
Definition: Redeclarable.h:84
NamespaceAliasDecl * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Definition: Redeclarable.h:213
UsingShadowDecl * getNextRedeclaration() const
Definition: Redeclarable.h:185
NamespaceAliasDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Definition: Redeclarable.h:201
llvm::iterator_range< redecl_iterator > redecl_range
Definition: Redeclarable.h:289
NamespaceAliasDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
Definition: Redeclarable.h:223
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Definition: Redeclarable.h:220
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Definition: Redeclarable.h:293
Represents the body of a requires-expression.
Definition: DeclCXX.h:2098
static DeclContext * castToDeclContext(const RequiresExprBodyDecl *D)
Definition: DeclCXX.h:2116
static RequiresExprBodyDecl * castFromDeclContext(const DeclContext *DC)
Definition: DeclCXX.h:2120
static bool classofKind(Kind K)
Definition: DeclCXX.h:2114
static RequiresExprBodyDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclCXX.cpp:2395
static bool classof(const Decl *D)
Definition: DeclCXX.h:2113
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.
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:4130
const Expr * getMessage() const
Definition: DeclCXX.h:4157
bool isFailed() const
Definition: DeclCXX.h:4159
static bool classofKind(Kind K)
Definition: DeclCXX.h:4168
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclCXX.h:4163
const Expr * getAssertExpr() const
Definition: DeclCXX.h:4154
SourceLocation getRParenLoc() const
Definition: DeclCXX.h:4161
static StaticAssertDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclCXX.cpp:3560
static bool classof(const Decl *D)
Definition: DeclCXX.h:4167
Stmt - This represents one statement.
Definition: Stmt.h:85
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:1572
llvm::iterator_range< const_child_iterator > const_child_range
Definition: Stmt.h:1573
TagTypeKind TagKind
Definition: Decl.h:3715
void startDefinition()
Starts the definition of this tag declaration.
Definition: Decl.cpp:4843
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: Decl.cpp:4836
bool isUnion() const
Definition: Decl.h:3915
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:396
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:74
Represents a declaration of a type.
Definition: Decl.h:3506
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Decl.h:3540
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:474
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:193
A container of type source information.
Definition: TypeBase.h:8314
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:272
QualType getType() const
Return the type wrapped by this type source info.
Definition: TypeBase.h:8325
The base class of the type hierarchy.
Definition: TypeBase.h:1833
const T * castAs() const
Member-template castAs<specific type>.
Definition: TypeBase.h:9226
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Definition: DeclCXX.h:4449
const APValue & getValue() const
Definition: DeclCXX.h:4475
static bool classofKind(Kind K)
Definition: DeclCXX.h:4487
static bool classof(const Decl *D)
Definition: DeclCXX.h:4486
void printName(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const override
Print this in a human-readable format.
Definition: DeclCXX.cpp:3795
static void Profile(llvm::FoldingSetNodeID &ID, QualType Ty, const APValue &APVal)
Definition: DeclCXX.h:4477
void Profile(llvm::FoldingSetNodeID &ID)
Definition: DeclCXX.h:4482
The iterator over UnresolvedSets.
Definition: UnresolvedSet.h:35
This node is generated when a using-declaration that was annotated with attribute((using_if_exists)) ...
Definition: DeclCXX.h:4112
static UnresolvedUsingIfExistsDecl * CreateDeserialized(ASTContext &Ctx, GlobalDeclID ID)
Definition: DeclCXX.cpp:3536
static bool classof(const Decl *D)
Definition: DeclCXX.h:4125
static bool classofKind(Kind K)
Definition: DeclCXX.h:4126
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:4031
bool isPackExpansion() const
Determine whether this is a pack expansion.
Definition: DeclCXX.h:4077
SourceLocation getTypenameLoc() const
Returns the source location of the 'typename' keyword.
Definition: DeclCXX.h:4061
static bool classofKind(Kind K)
Definition: DeclCXX.h:4104
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:4065
SourceLocation getUsingLoc() const
Returns the source location of the 'using' keyword.
Definition: DeclCXX.h:4058
static bool classof(const Decl *D)
Definition: DeclCXX.h:4103
UnresolvedUsingTypenameDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this declaration.
Definition: DeclCXX.h:4096
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition: DeclCXX.h:4082
const UnresolvedUsingTypenameDecl * getCanonicalDecl() const
Definition: DeclCXX.h:4099
DeclarationNameInfo getNameInfo() const
Definition: DeclCXX.h:4072
static UnresolvedUsingTypenameDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclCXX.cpp:3522
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Definition: DeclCXX.h:4068
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3934
const UnresolvedUsingValueDecl * getCanonicalDecl() const
Definition: DeclCXX.h:4010
bool isPackExpansion() const
Determine whether this is a pack expansion.
Definition: DeclCXX.h:3987
SourceLocation getUsingLoc() const
Returns the source location of the 'using' keyword.
Definition: DeclCXX.h:3965
static bool classofKind(Kind K)
Definition: DeclCXX.h:4015
bool isAccessDeclaration() const
Return true if it is a C++03 access declaration (no 'using').
Definition: DeclCXX.h:3971
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3975
static bool classof(const Decl *D)
Definition: DeclCXX.h:4014
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Definition: DeclCXX.h:3978
DeclarationNameInfo getNameInfo() const
Definition: DeclCXX.h:3982
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclCXX.cpp:3500
void setUsingLoc(SourceLocation L)
Set the source location of the 'using' keyword.
Definition: DeclCXX.h:3968
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition: DeclCXX.h:3992
UnresolvedUsingValueDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this declaration.
Definition: DeclCXX.h:4007
static UnresolvedUsingValueDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclCXX.cpp:3492
Represents a C++ using-declaration.
Definition: DeclCXX.h:3585
void setTypename(bool TN)
Sets whether the using declaration has 'typename'.
Definition: DeclCXX.h:3637
UsingDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this declaration.
Definition: DeclCXX.h:3650
bool hasTypename() const
Return true if the using declaration has 'typename'.
Definition: DeclCXX.h:3634
bool isAccessDeclaration() const
Return true if it is a C++03 access declaration (no 'using').
Definition: DeclCXX.h:3631
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclCXX.cpp:3431
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Definition: DeclCXX.h:3622
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3619
void setUsingLoc(SourceLocation L)
Set the source location of the 'using' keyword.
Definition: DeclCXX.h:3615
static UsingDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclCXX.cpp:3425
const UsingDecl * getCanonicalDecl() const
Definition: DeclCXX.h:3653
DeclarationNameInfo getNameInfo() const
Definition: DeclCXX.h:3626
static bool classof(const Decl *D)
Definition: DeclCXX.h:3657
static bool classofKind(Kind K)
Definition: DeclCXX.h:3658
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
Definition: DeclCXX.h:3612
Represents C++ using-directive.
Definition: DeclCXX.h:3090
static UsingDirectiveDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclCXX.cpp:3214
const NamedDecl * getNominatedNamespaceAsWritten() const
Definition: DeclCXX.h:3144
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclCXX.h:3179
const DeclContext * getCommonAncestor() const
Definition: DeclCXX.h:3158
static bool classofKind(Kind K)
Definition: DeclCXX.h:3184
SourceLocation getUsingLoc() const
Return the location of the using keyword.
Definition: DeclCXX.h:3161
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
Definition: DeclCXX.cpp:3228
const NamespaceDecl * getNominatedNamespace() const
Definition: DeclCXX.h:3151
static bool classof(const Decl *D)
Definition: DeclCXX.h:3183
NamedDecl * getNominatedNamespaceAsWritten()
Definition: DeclCXX.h:3143
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
Definition: DeclCXX.h:3157
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
Definition: DeclCXX.h:3165
SourceLocation getIdentLocation() const
Returns the location of this using declaration's identifier.
Definition: DeclCXX.h:3168
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of the namespace.
Definition: DeclCXX.h:3139
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition: DeclCXX.h:3135
Represents a C++ using-enum-declaration.
Definition: DeclCXX.h:3786
void setEnumType(TypeSourceInfo *TSI)
Definition: DeclCXX.h:3825
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclCXX.cpp:3455
void setEnumLoc(SourceLocation L)
Definition: DeclCXX.h:3811
NestedNameSpecifierLoc getQualifierLoc() const
Definition: DeclCXX.h:3815
SourceLocation getEnumLoc() const
The source location of the 'enum' keyword.
Definition: DeclCXX.h:3810
void setUsingLoc(SourceLocation L)
Definition: DeclCXX.h:3807
UsingEnumDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this declaration.
Definition: DeclCXX.h:3841
EnumDecl * getEnumDecl() const
Definition: DeclCXX.h:3828
const UsingEnumDecl * getCanonicalDecl() const
Definition: DeclCXX.h:3844
TypeSourceInfo * getEnumType() const
Definition: DeclCXX.h:3822
static bool classofKind(Kind K)
Definition: DeclCXX.h:3849
static UsingEnumDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclCXX.cpp:3448
static bool classof(const Decl *D)
Definition: DeclCXX.h:3848
NestedNameSpecifier getQualifier() const
Definition: DeclCXX.h:3812
TypeLoc getEnumTypeLoc() const
Definition: DeclCXX.h:3819
SourceLocation getUsingLoc() const
The source location of the 'using' keyword.
Definition: DeclCXX.h:3806
Represents a pack of using declarations that a single using-declarator pack-expanded into.
Definition: DeclCXX.h:3867
friend TrailingObjects
Definition: DeclCXX.h:3891
static UsingPackDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NumExpansions)
Definition: DeclCXX.cpp:3468
const UsingPackDecl * getCanonicalDecl() const
Definition: DeclCXX.h:3916
UsingPackDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:3915
NamedDecl * getInstantiatedFromUsingDecl() const
Get the using declaration from which this was instantiated.
Definition: DeclCXX.h:3896
static bool classof(const Decl *D)
Definition: DeclCXX.h:3918
static bool classofKind(Kind K)
Definition: DeclCXX.h:3919
ArrayRef< NamedDecl * > expansions() const
Get the set of using declarations that this pack expanded into.
Definition: DeclCXX.h:3900
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclCXX.h:3911
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3393
UsingShadowDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:3448
redeclarable_base::redecl_range redecl_range
Definition: DeclCXX.h:3438
static UsingShadowDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, DeclarationName Name, BaseUsingDecl *Introducer, NamedDecl *Target)
Definition: DeclCXX.h:3429
UsingShadowDecl * getNextUsingShadowDecl() const
The next using shadow declaration contained in the shadow decl chain of the using declaration which i...
Definition: DeclCXX.h:3477
void setTargetDecl(NamedDecl *ND)
Sets the underlying declaration which has been brought into the local scope.
Definition: DeclCXX.h:3461
static bool classofKind(Kind K)
Definition: DeclCXX.h:3482
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition: DeclCXX.h:3457
redeclarable_base::redecl_iterator redecl_iterator
Definition: DeclCXX.h:3439
UsingShadowDecl(Kind K, ASTContext &C, DeclContext *DC, SourceLocation Loc, DeclarationName Name, BaseUsingDecl *Introducer, NamedDecl *Target)
Definition: DeclCXX.cpp:3337
static UsingShadowDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclCXX.cpp:3353
static bool classof(const Decl *D)
Definition: DeclCXX.h:3481
friend class BaseUsingDecl
Definition: DeclCXX.h:3394
BaseUsingDecl * getIntroducer() const
Gets the (written or instantiated) using declaration that introduced this declaration.
Definition: DeclCXX.cpp:3358
const UsingShadowDecl * getCanonicalDecl() const
Definition: DeclCXX.h:3451
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:711
void setType(QualType newType)
Definition: Decl.h:723
QualType getType() const
Definition: Decl.h:722
bool isParameterPack() const
Determine whether this value is actually a function parameter pack, init-capture pack,...
Definition: Decl.cpp:5457
Represents a variable declaration or definition.
Definition: Decl.h:925
#define bool
Definition: gpuintrin.h:32
The JSON file list parser is used to communicate input to InstallAPI.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
ConstexprSpecKind
Define the kind of constexpr specifier.
Definition: Specifiers.h:35
LinkageSpecLanguageIDs
Represents the language in a linkage specification.
Definition: DeclCXX.h:3001
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
Definition: TypeBase.h:1780
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
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
StorageClass
Storage classes.
Definition: Specifiers.h:248
@ SC_None
Definition: Specifiers.h:250
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
StorageDuration
The storage duration for an object (per C++ [basic.stc]).
Definition: Specifiers.h:339
@ Template
We are parsing a template declaration.
MSVtorDispMode
In the Microsoft ABI, this controls the placement of virtual displacement members used to implement v...
Definition: LangOptions.h:37
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
Definition: Lambda.h:22
@ LCD_None
Definition: Lambda.h:23
LazyOffsetPtr< Decl, GlobalDeclID, &ExternalASTSource::GetExternalDecl > LazyDeclPtr
A lazy pointer to a declaration.
const FunctionProtoType * T
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
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
LazyOffsetPtr< CXXBaseSpecifier, uint64_t, &ExternalASTSource::GetExternalCXXBaseSpecifiers > LazyCXXBaseSpecifiersPtr
A lazy pointer to a set of CXXBaseSpecifiers.
@ Other
Other implicit parameter.
#define false
Definition: stdbool.h:26
Information about how a lambda is numbered within its context.
Definition: DeclCXX.h:1796
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:4367
uint16_t Part2
...-89ab-...
Definition: DeclCXX.h:4371
uint32_t Part1
{01234567-...
Definition: DeclCXX.h:4369
uint16_t Part3
...-cdef-...
Definition: DeclCXX.h:4373
uint8_t Part4And5[8]
...-0123-456789abcdef}
Definition: DeclCXX.h:4375
uint64_t getPart4And5AsUint64() const
Definition: DeclCXX.h:4377
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57