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