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