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