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