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