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