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