Coverage Report

Created: 2022-01-25 06:29

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