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