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