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