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