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