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