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