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