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