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