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