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