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