Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/AST/ExprCXX.h
Line
Count
Source (jump to first uncovered line)
1
//===- ExprCXX.h - Classes for representing expressions ---------*- 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 clang::Expr interface and subclasses for C++ expressions.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_CLANG_AST_EXPRCXX_H
15
#define LLVM_CLANG_AST_EXPRCXX_H
16
17
#include "clang/AST/Decl.h"
18
#include "clang/AST/DeclBase.h"
19
#include "clang/AST/DeclCXX.h"
20
#include "clang/AST/DeclarationName.h"
21
#include "clang/AST/Expr.h"
22
#include "clang/AST/NestedNameSpecifier.h"
23
#include "clang/AST/OperationKinds.h"
24
#include "clang/AST/Stmt.h"
25
#include "clang/AST/TemplateBase.h"
26
#include "clang/AST/Type.h"
27
#include "clang/AST/UnresolvedSet.h"
28
#include "clang/Basic/ExceptionSpecificationType.h"
29
#include "clang/Basic/ExpressionTraits.h"
30
#include "clang/Basic/LLVM.h"
31
#include "clang/Basic/Lambda.h"
32
#include "clang/Basic/LangOptions.h"
33
#include "clang/Basic/OperatorKinds.h"
34
#include "clang/Basic/SourceLocation.h"
35
#include "clang/Basic/Specifiers.h"
36
#include "clang/Basic/TypeTraits.h"
37
#include "llvm/ADT/ArrayRef.h"
38
#include "llvm/ADT/None.h"
39
#include "llvm/ADT/Optional.h"
40
#include "llvm/ADT/PointerUnion.h"
41
#include "llvm/ADT/StringRef.h"
42
#include "llvm/ADT/iterator_range.h"
43
#include "llvm/Support/Casting.h"
44
#include "llvm/Support/Compiler.h"
45
#include "llvm/Support/TrailingObjects.h"
46
#include <cassert>
47
#include <cstddef>
48
#include <cstdint>
49
#include <memory>
50
51
namespace clang {
52
53
class ASTContext;
54
class DeclAccessPair;
55
class IdentifierInfo;
56
class LambdaCapture;
57
class NonTypeTemplateParmDecl;
58
class TemplateParameterList;
59
60
//===--------------------------------------------------------------------===//
61
// C++ Expressions.
62
//===--------------------------------------------------------------------===//
63
64
/// A call to an overloaded operator written using operator
65
/// syntax.
66
///
67
/// Represents a call to an overloaded operator written using operator
68
/// syntax, e.g., "x + y" or "*p". While semantically equivalent to a
69
/// normal call, this AST node provides better information about the
70
/// syntactic representation of the call.
71
///
72
/// In a C++ template, this expression node kind will be used whenever
73
/// any of the arguments are type-dependent. In this case, the
74
/// function itself will be a (possibly empty) set of functions and
75
/// function templates that were found by name lookup at template
76
/// definition time.
77
class CXXOperatorCallExpr final : public CallExpr {
78
  friend class ASTStmtReader;
79
  friend class ASTStmtWriter;
80
81
  SourceRange Range;
82
83
  // CXXOperatorCallExpr has some trailing objects belonging
84
  // to CallExpr. See CallExpr for the details.
85
86
  SourceRange getSourceRangeImpl() const LLVM_READONLY;
87
88
  CXXOperatorCallExpr(OverloadedOperatorKind OpKind, Expr *Fn,
89
                      ArrayRef<Expr *> Args, QualType Ty, ExprValueKind VK,
90
                      SourceLocation OperatorLoc, FPOptions FPFeatures,
91
                      ADLCallKind UsesADL);
92
93
  CXXOperatorCallExpr(unsigned NumArgs, EmptyShell Empty);
94
95
public:
96
  static CXXOperatorCallExpr *
97
  Create(const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn,
98
         ArrayRef<Expr *> Args, QualType Ty, ExprValueKind VK,
99
         SourceLocation OperatorLoc, FPOptions FPFeatures,
100
         ADLCallKind UsesADL = NotADL);
101
102
  static CXXOperatorCallExpr *CreateEmpty(const ASTContext &Ctx,
103
                                          unsigned NumArgs, EmptyShell Empty);
104
105
  /// Returns the kind of overloaded operator that this expression refers to.
106
2.90M
  OverloadedOperatorKind getOperator() const {
107
2.90M
    return static_cast<OverloadedOperatorKind>(
108
2.90M
        CXXOperatorCallExprBits.OperatorKind);
109
2.90M
  }
110
111
51.3k
  static bool isAssignmentOp(OverloadedOperatorKind Opc) {
112
51.3k
    return Opc == OO_Equal || 
Opc == OO_StarEqual43.5k
||
Opc == OO_SlashEqual43.4k
||
113
51.3k
           
Opc == OO_PercentEqual43.3k
||
Opc == OO_PlusEqual43.3k
||
114
51.3k
           
Opc == OO_MinusEqual42.6k
||
Opc == OO_LessLessEqual42.5k
||
115
51.3k
           
Opc == OO_GreaterGreaterEqual42.5k
||
Opc == OO_AmpEqual42.5k
||
116
51.3k
           
Opc == OO_CaretEqual42.5k
||
Opc == OO_PipeEqual42.5k
;
117
51.3k
  }
118
51.3k
  bool isAssignmentOp() const { return isAssignmentOp(getOperator()); }
119
120
  /// Is this written as an infix binary operator?
121
  bool isInfixBinaryOp() const;
122
123
  /// Returns the location of the operator symbol in the expression.
124
  ///
125
  /// When \c getOperator()==OO_Call, this is the location of the right
126
  /// parentheses; when \c getOperator()==OO_Subscript, this is the location
127
  /// of the right bracket.
128
841k
  SourceLocation getOperatorLoc() const { return getRParenLoc(); }
129
130
955k
  SourceLocation getExprLoc() const LLVM_READONLY {
131
955k
    OverloadedOperatorKind Operator = getOperator();
132
955k
    return (Operator < OO_Plus || Operator >= OO_Arrow ||
133
955k
            
Operator == OO_PlusPlus743k
||
Operator == OO_MinusMinus711k
)
134
955k
               ? 
getBeginLoc()245k
135
955k
               : 
getOperatorLoc()709k
;
136
955k
  }
137
138
1.66M
  SourceLocation getBeginLoc() const { return Range.getBegin(); }
139
204k
  SourceLocation getEndLoc() const { return Range.getEnd(); }
140
110k
  SourceRange getSourceRange() const { return Range; }
141
142
34.3M
  static bool classof(const Stmt *T) {
143
34.3M
    return T->getStmtClass() == CXXOperatorCallExprClass;
144
34.3M
  }
145
146
  // Set the FP contractability status of this operator. Only meaningful for
147
  // operations on floating point types.
148
0
  void setFPFeatures(FPOptions F) {
149
0
    CXXOperatorCallExprBits.FPFeatures = F.getInt();
150
0
  }
151
95.0k
  FPOptions getFPFeatures() const {
152
95.0k
    return FPOptions(CXXOperatorCallExprBits.FPFeatures);
153
95.0k
  }
154
155
  // Get the FP contractability status of this operator. Only meaningful for
156
  // operations on floating point types.
157
0
  bool isFPContractableWithinStatement() const {
158
0
    return getFPFeatures().allowFPContractWithinStatement();
159
0
  }
160
};
161
162
/// Represents a call to a member function that
163
/// may be written either with member call syntax (e.g., "obj.func()"
164
/// or "objptr->func()") or with normal function-call syntax
165
/// ("func()") within a member function that ends up calling a member
166
/// function. The callee in either case is a MemberExpr that contains
167
/// both the object argument and the member function, while the
168
/// arguments are the arguments within the parentheses (not including
169
/// the object argument).
170
class CXXMemberCallExpr final : public CallExpr {
171
  // CXXMemberCallExpr has some trailing objects belonging
172
  // to CallExpr. See CallExpr for the details.
173
174
  CXXMemberCallExpr(Expr *Fn, ArrayRef<Expr *> Args, QualType Ty,
175
                    ExprValueKind VK, SourceLocation RP, unsigned MinNumArgs);
176
177
  CXXMemberCallExpr(unsigned NumArgs, EmptyShell Empty);
178
179
public:
180
  static CXXMemberCallExpr *Create(const ASTContext &Ctx, Expr *Fn,
181
                                   ArrayRef<Expr *> Args, QualType Ty,
182
                                   ExprValueKind VK, SourceLocation RP,
183
                                   unsigned MinNumArgs = 0);
184
185
  static CXXMemberCallExpr *CreateEmpty(const ASTContext &Ctx, unsigned NumArgs,
186
                                        EmptyShell Empty);
187
188
  /// Retrieve the implicit object argument for the member call.
189
  ///
190
  /// For example, in "x.f(5)", this returns the sub-expression "x".
191
  Expr *getImplicitObjectArgument() const;
192
193
  /// Retrieve the type of the object argument.
194
  ///
195
  /// Note that this always returns a non-pointer type.
196
  QualType getObjectType() const;
197
198
  /// Retrieve the declaration of the called method.
199
  CXXMethodDecl *getMethodDecl() const;
200
201
  /// Retrieve the CXXRecordDecl for the underlying type of
202
  /// the implicit object argument.
203
  ///
204
  /// Note that this is may not be the same declaration as that of the class
205
  /// context of the CXXMethodDecl which this function is calling.
206
  /// FIXME: Returns 0 for member pointer call exprs.
207
  CXXRecordDecl *getRecordDecl() const;
208
209
2.31M
  SourceLocation getExprLoc() const LLVM_READONLY {
210
2.31M
    SourceLocation CLoc = getCallee()->getExprLoc();
211
2.31M
    if (CLoc.isValid())
212
2.26M
      return CLoc;
213
49.1k
214
49.1k
    return getBeginLoc();
215
49.1k
  }
216
217
6.78M
  static bool classof(const Stmt *T) {
218
6.78M
    return T->getStmtClass() == CXXMemberCallExprClass;
219
6.78M
  }
220
};
221
222
/// Represents a call to a CUDA kernel function.
223
class CUDAKernelCallExpr final : public CallExpr {
224
  friend class ASTStmtReader;
225
226
  enum { CONFIG, END_PREARG };
227
228
  // CUDAKernelCallExpr has some trailing objects belonging
229
  // to CallExpr. See CallExpr for the details.
230
231
  CUDAKernelCallExpr(Expr *Fn, CallExpr *Config, ArrayRef<Expr *> Args,
232
                     QualType Ty, ExprValueKind VK, SourceLocation RP,
233
                     unsigned MinNumArgs);
234
235
  CUDAKernelCallExpr(unsigned NumArgs, EmptyShell Empty);
236
237
public:
238
  static CUDAKernelCallExpr *Create(const ASTContext &Ctx, Expr *Fn,
239
                                    CallExpr *Config, ArrayRef<Expr *> Args,
240
                                    QualType Ty, ExprValueKind VK,
241
                                    SourceLocation RP, unsigned MinNumArgs = 0);
242
243
  static CUDAKernelCallExpr *CreateEmpty(const ASTContext &Ctx,
244
                                         unsigned NumArgs, EmptyShell Empty);
245
246
15
  const CallExpr *getConfig() const {
247
15
    return cast_or_null<CallExpr>(getPreArg(CONFIG));
248
15
  }
249
4
  CallExpr *getConfig() { return cast_or_null<CallExpr>(getPreArg(CONFIG)); }
250
251
654k
  static bool classof(const Stmt *T) {
252
654k
    return T->getStmtClass() == CUDAKernelCallExprClass;
253
654k
  }
254
};
255
256
/// Abstract class common to all of the C++ "named"/"keyword" casts.
257
///
258
/// This abstract class is inherited by all of the classes
259
/// representing "named" casts: CXXStaticCastExpr for \c static_cast,
260
/// CXXDynamicCastExpr for \c dynamic_cast, CXXReinterpretCastExpr for
261
/// reinterpret_cast, and CXXConstCastExpr for \c const_cast.
262
class CXXNamedCastExpr : public ExplicitCastExpr {
263
private:
264
  // the location of the casting op
265
  SourceLocation Loc;
266
267
  // the location of the right parenthesis
268
  SourceLocation RParenLoc;
269
270
  // range for '<' '>'
271
  SourceRange AngleBrackets;
272
273
protected:
274
  friend class ASTStmtReader;
275
276
  CXXNamedCastExpr(StmtClass SC, QualType ty, ExprValueKind VK,
277
                   CastKind kind, Expr *op, unsigned PathSize,
278
                   TypeSourceInfo *writtenTy, SourceLocation l,
279
                   SourceLocation RParenLoc,
280
                   SourceRange AngleBrackets)
281
      : ExplicitCastExpr(SC, ty, VK, kind, op, PathSize, writtenTy), Loc(l),
282
285k
        RParenLoc(RParenLoc), AngleBrackets(AngleBrackets) {}
283
284
  explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize)
285
61
      : ExplicitCastExpr(SC, Shell, PathSize) {}
286
287
public:
288
  const char *getCastName() const;
289
290
  /// Retrieve the location of the cast operator keyword, e.g.,
291
  /// \c static_cast.
292
46.4k
  SourceLocation getOperatorLoc() const { return Loc; }
293
294
  /// Retrieve the location of the closing parenthesis.
295
46.4k
  SourceLocation getRParenLoc() const { return RParenLoc; }
296
297
825k
  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
298
45.8k
  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
299
138k
  SourceRange getAngleBrackets() const LLVM_READONLY { return AngleBrackets; }
300
301
75
  static bool classof(const Stmt *T) {
302
75
    switch (T->getStmtClass()) {
303
75
    case CXXStaticCastExprClass:
304
22
    case CXXDynamicCastExprClass:
305
22
    case CXXReinterpretCastExprClass:
306
22
    case CXXConstCastExprClass:
307
22
      return true;
308
53
    default:
309
53
      return false;
310
75
    }
311
75
  }
312
};
313
314
/// A C++ \c static_cast expression (C++ [expr.static.cast]).
315
///
316
/// This expression node represents a C++ static cast, e.g.,
317
/// \c static_cast<int>(1.0).
318
class CXXStaticCastExpr final
319
    : public CXXNamedCastExpr,
320
      private llvm::TrailingObjects<CXXStaticCastExpr, CXXBaseSpecifier *> {
321
  CXXStaticCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op,
322
                    unsigned pathSize, TypeSourceInfo *writtenTy,
323
                    SourceLocation l, SourceLocation RParenLoc,
324
                    SourceRange AngleBrackets)
325
      : CXXNamedCastExpr(CXXStaticCastExprClass, ty, vk, kind, op, pathSize,
326
206k
                         writtenTy, l, RParenLoc, AngleBrackets) {}
327
328
  explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize)
329
43
      : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize) {}
330
331
public:
332
  friend class CastExpr;
333
  friend TrailingObjects;
334
335
  static CXXStaticCastExpr *Create(const ASTContext &Context, QualType T,
336
                                   ExprValueKind VK, CastKind K, Expr *Op,
337
                                   const CXXCastPath *Path,
338
                                   TypeSourceInfo *Written, SourceLocation L,
339
                                   SourceLocation RParenLoc,
340
                                   SourceRange AngleBrackets);
341
  static CXXStaticCastExpr *CreateEmpty(const ASTContext &Context,
342
                                        unsigned PathSize);
343
344
27
  static bool classof(const Stmt *T) {
345
27
    return T->getStmtClass() == CXXStaticCastExprClass;
346
27
  }
347
};
348
349
/// A C++ @c dynamic_cast expression (C++ [expr.dynamic.cast]).
350
///
351
/// This expression node represents a dynamic cast, e.g.,
352
/// \c dynamic_cast<Derived*>(BasePtr). Such a cast may perform a run-time
353
/// check to determine how to perform the type conversion.
354
class CXXDynamicCastExpr final
355
    : public CXXNamedCastExpr,
356
      private llvm::TrailingObjects<CXXDynamicCastExpr, CXXBaseSpecifier *> {
357
  CXXDynamicCastExpr(QualType ty, ExprValueKind VK, CastKind kind,
358
                     Expr *op, unsigned pathSize, TypeSourceInfo *writtenTy,
359
                     SourceLocation l, SourceLocation RParenLoc,
360
                     SourceRange AngleBrackets)
361
      : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, VK, kind, op, pathSize,
362
2.03k
                         writtenTy, l, RParenLoc, AngleBrackets) {}
363
364
  explicit CXXDynamicCastExpr(EmptyShell Empty, unsigned pathSize)
365
2
      : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize) {}
366
367
public:
368
  friend class CastExpr;
369
  friend TrailingObjects;
370
371
  static CXXDynamicCastExpr *Create(const ASTContext &Context, QualType T,
372
                                    ExprValueKind VK, CastKind Kind, Expr *Op,
373
                                    const CXXCastPath *Path,
374
                                    TypeSourceInfo *Written, SourceLocation L,
375
                                    SourceLocation RParenLoc,
376
                                    SourceRange AngleBrackets);
377
378
  static CXXDynamicCastExpr *CreateEmpty(const ASTContext &Context,
379
                                         unsigned pathSize);
380
381
  bool isAlwaysNull() const;
382
383
1.30M
  static bool classof(const Stmt *T) {
384
1.30M
    return T->getStmtClass() == CXXDynamicCastExprClass;
385
1.30M
  }
386
};
387
388
/// A C++ @c reinterpret_cast expression (C++ [expr.reinterpret.cast]).
389
///
390
/// This expression node represents a reinterpret cast, e.g.,
391
/// @c reinterpret_cast<int>(VoidPtr).
392
///
393
/// A reinterpret_cast provides a differently-typed view of a value but
394
/// (in Clang, as in most C++ implementations) performs no actual work at
395
/// run time.
396
class CXXReinterpretCastExpr final
397
    : public CXXNamedCastExpr,
398
      private llvm::TrailingObjects<CXXReinterpretCastExpr,
399
                                    CXXBaseSpecifier *> {
400
  CXXReinterpretCastExpr(QualType ty, ExprValueKind vk, CastKind kind,
401
                         Expr *op, unsigned pathSize,
402
                         TypeSourceInfo *writtenTy, SourceLocation l,
403
                         SourceLocation RParenLoc,
404
                         SourceRange AngleBrackets)
405
      : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, vk, kind, op,
406
67.0k
                         pathSize, writtenTy, l, RParenLoc, AngleBrackets) {}
407
408
  CXXReinterpretCastExpr(EmptyShell Empty, unsigned pathSize)
409
14
      : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize) {}
410
411
public:
412
  friend class CastExpr;
413
  friend TrailingObjects;
414
415
  static CXXReinterpretCastExpr *Create(const ASTContext &Context, QualType T,
416
                                        ExprValueKind VK, CastKind Kind,
417
                                        Expr *Op, const CXXCastPath *Path,
418
                                 TypeSourceInfo *WrittenTy, SourceLocation L,
419
                                        SourceLocation RParenLoc,
420
                                        SourceRange AngleBrackets);
421
  static CXXReinterpretCastExpr *CreateEmpty(const ASTContext &Context,
422
                                             unsigned pathSize);
423
424
225k
  static bool classof(const Stmt *T) {
425
225k
    return T->getStmtClass() == CXXReinterpretCastExprClass;
426
225k
  }
427
};
428
429
/// A C++ \c const_cast expression (C++ [expr.const.cast]).
430
///
431
/// This expression node represents a const cast, e.g.,
432
/// \c const_cast<char*>(PtrToConstChar).
433
///
434
/// A const_cast can remove type qualifiers but does not change the underlying
435
/// value.
436
class CXXConstCastExpr final
437
    : public CXXNamedCastExpr,
438
      private llvm::TrailingObjects<CXXConstCastExpr, CXXBaseSpecifier *> {
439
  CXXConstCastExpr(QualType ty, ExprValueKind VK, Expr *op,
440
                   TypeSourceInfo *writtenTy, SourceLocation l,
441
                   SourceLocation RParenLoc, SourceRange AngleBrackets)
442
      : CXXNamedCastExpr(CXXConstCastExprClass, ty, VK, CK_NoOp, op,
443
10.5k
                         0, writtenTy, l, RParenLoc, AngleBrackets) {}
444
445
  explicit CXXConstCastExpr(EmptyShell Empty)
446
2
      : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0) {}
447
448
public:
449
  friend class CastExpr;
450
  friend TrailingObjects;
451
452
  static CXXConstCastExpr *Create(const ASTContext &Context, QualType T,
453
                                  ExprValueKind VK, Expr *Op,
454
                                  TypeSourceInfo *WrittenTy, SourceLocation L,
455
                                  SourceLocation RParenLoc,
456
                                  SourceRange AngleBrackets);
457
  static CXXConstCastExpr *CreateEmpty(const ASTContext &Context);
458
459
3
  static bool classof(const Stmt *T) {
460
3
    return T->getStmtClass() == CXXConstCastExprClass;
461
3
  }
462
};
463
464
/// A call to a literal operator (C++11 [over.literal])
465
/// written as a user-defined literal (C++11 [lit.ext]).
466
///
467
/// Represents a user-defined literal, e.g. "foo"_bar or 1.23_xyz. While this
468
/// is semantically equivalent to a normal call, this AST node provides better
469
/// information about the syntactic representation of the literal.
470
///
471
/// Since literal operators are never found by ADL and can only be declared at
472
/// namespace scope, a user-defined literal is never dependent.
473
class UserDefinedLiteral final : public CallExpr {
474
  friend class ASTStmtReader;
475
  friend class ASTStmtWriter;
476
477
  /// The location of a ud-suffix within the literal.
478
  SourceLocation UDSuffixLoc;
479
480
  // UserDefinedLiteral has some trailing objects belonging
481
  // to CallExpr. See CallExpr for the details.
482
483
  UserDefinedLiteral(Expr *Fn, ArrayRef<Expr *> Args, QualType Ty,
484
                     ExprValueKind VK, SourceLocation LitEndLoc,
485
                     SourceLocation SuffixLoc);
486
487
  UserDefinedLiteral(unsigned NumArgs, EmptyShell Empty);
488
489
public:
490
  static UserDefinedLiteral *Create(const ASTContext &Ctx, Expr *Fn,
491
                                    ArrayRef<Expr *> Args, QualType Ty,
492
                                    ExprValueKind VK, SourceLocation LitEndLoc,
493
                                    SourceLocation SuffixLoc);
494
495
  static UserDefinedLiteral *CreateEmpty(const ASTContext &Ctx,
496
                                         unsigned NumArgs, EmptyShell Empty);
497
498
  /// The kind of literal operator which is invoked.
499
  enum LiteralOperatorKind {
500
    /// Raw form: operator "" X (const char *)
501
    LOK_Raw,
502
503
    /// Raw form: operator "" X<cs...> ()
504
    LOK_Template,
505
506
    /// operator "" X (unsigned long long)
507
    LOK_Integer,
508
509
    /// operator "" X (long double)
510
    LOK_Floating,
511
512
    /// operator "" X (const CharT *, size_t)
513
    LOK_String,
514
515
    /// operator "" X (CharT)
516
    LOK_Character
517
  };
518
519
  /// Returns the kind of literal operator invocation
520
  /// which this expression represents.
521
  LiteralOperatorKind getLiteralOperatorKind() const;
522
523
  /// If this is not a raw user-defined literal, get the
524
  /// underlying cooked literal (representing the literal with the suffix
525
  /// removed).
526
  Expr *getCookedLiteral();
527
0
  const Expr *getCookedLiteral() const {
528
0
    return const_cast<UserDefinedLiteral*>(this)->getCookedLiteral();
529
0
  }
530
531
7.75k
  SourceLocation getBeginLoc() const {
532
7.75k
    if (getLiteralOperatorKind() == LOK_Template)
533
452
      return getRParenLoc();
534
7.30k
    return getArg(0)->getBeginLoc();
535
7.30k
  }
536
537
10
  SourceLocation getEndLoc() const { return getRParenLoc(); }
538
539
  /// Returns the location of a ud-suffix in the expression.
540
  ///
541
  /// For a string literal, there may be multiple identical suffixes. This
542
  /// returns the first.
543
0
  SourceLocation getUDSuffixLoc() const { return UDSuffixLoc; }
544
545
  /// Returns the ud-suffix specified for this literal.
546
  const IdentifierInfo *getUDSuffix() const;
547
548
0
  static bool classof(const Stmt *S) {
549
0
    return S->getStmtClass() == UserDefinedLiteralClass;
550
0
  }
551
};
552
553
/// A boolean literal, per ([C++ lex.bool] Boolean literals).
554
class CXXBoolLiteralExpr : public Expr {
555
public:
556
  CXXBoolLiteralExpr(bool Val, QualType Ty, SourceLocation Loc)
557
      : Expr(CXXBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
558
821k
             false, false) {
559
821k
    CXXBoolLiteralExprBits.Value = Val;
560
821k
    CXXBoolLiteralExprBits.Loc = Loc;
561
821k
  }
562
563
  explicit CXXBoolLiteralExpr(EmptyShell Empty)
564
206
      : Expr(CXXBoolLiteralExprClass, Empty) {}
565
566
964k
  bool getValue() const { return CXXBoolLiteralExprBits.Value; }
567
206
  void setValue(bool V) { CXXBoolLiteralExprBits.Value = V; }
568
569
2.93M
  SourceLocation getBeginLoc() const { return getLocation(); }
570
36.8k
  SourceLocation getEndLoc() const { return getLocation(); }
571
572
2.97M
  SourceLocation getLocation() const { return CXXBoolLiteralExprBits.Loc; }
573
206
  void setLocation(SourceLocation L) { CXXBoolLiteralExprBits.Loc = L; }
574
575
248k
  static bool classof(const Stmt *T) {
576
248k
    return T->getStmtClass() == CXXBoolLiteralExprClass;
577
248k
  }
578
579
  // Iterators
580
1.18M
  child_range children() {
581
1.18M
    return child_range(child_iterator(), child_iterator());
582
1.18M
  }
583
584
0
  const_child_range children() const {
585
0
    return const_child_range(const_child_iterator(), const_child_iterator());
586
0
  }
587
};
588
589
/// The null pointer literal (C++11 [lex.nullptr])
590
///
591
/// Introduced in C++11, the only literal of type \c nullptr_t is \c nullptr.
592
class CXXNullPtrLiteralExpr : public Expr {
593
public:
594
  CXXNullPtrLiteralExpr(QualType Ty, SourceLocation Loc)
595
      : Expr(CXXNullPtrLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false,
596
134k
             false, false, false) {
597
134k
    CXXNullPtrLiteralExprBits.Loc = Loc;
598
134k
  }
599
600
  explicit CXXNullPtrLiteralExpr(EmptyShell Empty)
601
10
      : Expr(CXXNullPtrLiteralExprClass, Empty) {}
602
603
622k
  SourceLocation getBeginLoc() const { return getLocation(); }
604
36.9k
  SourceLocation getEndLoc() const { return getLocation(); }
605
606
659k
  SourceLocation getLocation() const { return CXXNullPtrLiteralExprBits.Loc; }
607
10
  void setLocation(SourceLocation L) { CXXNullPtrLiteralExprBits.Loc = L; }
608
609
544
  static bool classof(const Stmt *T) {
610
544
    return T->getStmtClass() == CXXNullPtrLiteralExprClass;
611
544
  }
612
613
261k
  child_range children() {
614
261k
    return child_range(child_iterator(), child_iterator());
615
261k
  }
616
617
0
  const_child_range children() const {
618
0
    return const_child_range(const_child_iterator(), const_child_iterator());
619
0
  }
620
};
621
622
/// Implicit construction of a std::initializer_list<T> object from an
623
/// array temporary within list-initialization (C++11 [dcl.init.list]p5).
624
class CXXStdInitializerListExpr : public Expr {
625
  Stmt *SubExpr = nullptr;
626
627
  CXXStdInitializerListExpr(EmptyShell Empty)
628
1
      : Expr(CXXStdInitializerListExprClass, Empty) {}
629
630
public:
631
  friend class ASTReader;
632
  friend class ASTStmtReader;
633
634
  CXXStdInitializerListExpr(QualType Ty, Expr *SubExpr)
635
      : Expr(CXXStdInitializerListExprClass, Ty, VK_RValue, OK_Ordinary,
636
             Ty->isDependentType(), SubExpr->isValueDependent(),
637
             SubExpr->isInstantiationDependent(),
638
             SubExpr->containsUnexpandedParameterPack()),
639
645
        SubExpr(SubExpr) {}
640
641
682
  Expr *getSubExpr() { return static_cast<Expr*>(SubExpr); }
642
164
  const Expr *getSubExpr() const { return static_cast<const Expr*>(SubExpr); }
643
644
2.54k
  SourceLocation getBeginLoc() const LLVM_READONLY {
645
2.54k
    return SubExpr->getBeginLoc();
646
2.54k
  }
647
648
34
  SourceLocation getEndLoc() const LLVM_READONLY {
649
34
    return SubExpr->getEndLoc();
650
34
  }
651
652
  /// Retrieve the source range of the expression.
653
44
  SourceRange getSourceRange() const LLVM_READONLY {
654
44
    return SubExpr->getSourceRange();
655
44
  }
656
657
5.23M
  static bool classof(const Stmt *S) {
658
5.23M
    return S->getStmtClass() == CXXStdInitializerListExprClass;
659
5.23M
  }
660
661
2.04k
  child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
662
663
0
  const_child_range children() const {
664
0
    return const_child_range(&SubExpr, &SubExpr + 1);
665
0
  }
666
};
667
668
/// A C++ \c typeid expression (C++ [expr.typeid]), which gets
669
/// the \c type_info that corresponds to the supplied type, or the (possibly
670
/// dynamic) type of the supplied expression.
671
///
672
/// This represents code like \c typeid(int) or \c typeid(*objPtr)
673
class CXXTypeidExpr : public Expr {
674
private:
675
  llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
676
  SourceRange Range;
677
678
public:
679
  CXXTypeidExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R)
680
      : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary,
681
             // typeid is never type-dependent (C++ [temp.dep.expr]p4)
682
             false,
683
             // typeid is value-dependent if the type or expression are
684
             // dependent
685
             Operand->getType()->isDependentType(),
686
             Operand->getType()->isInstantiationDependentType(),
687
             Operand->getType()->containsUnexpandedParameterPack()),
688
3.16k
        Operand(Operand), Range(R) {}
689
690
  CXXTypeidExpr(QualType Ty, Expr *Operand, SourceRange R)
691
      : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary,
692
             // typeid is never type-dependent (C++ [temp.dep.expr]p4)
693
             false,
694
             // typeid is value-dependent if the type or expression are
695
             // dependent
696
             Operand->isTypeDependent() || Operand->isValueDependent(),
697
             Operand->isInstantiationDependent(),
698
             Operand->containsUnexpandedParameterPack()),
699
199
        Operand(Operand), Range(R) {}
700
701
  CXXTypeidExpr(EmptyShell Empty, bool isExpr)
702
2
      : Expr(CXXTypeidExprClass, Empty) {
703
2
    if (isExpr)
704
1
      Operand = (Expr*)nullptr;
705
1
    else
706
1
      Operand = (TypeSourceInfo*)nullptr;
707
2
  }
708
709
  /// Determine whether this typeid has a type operand which is potentially
710
  /// evaluated, per C++11 [expr.typeid]p3.
711
  bool isPotentiallyEvaluated() const;
712
713
4.57k
  bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); }
714
715
  /// Retrieves the type operand of this typeid() expression after
716
  /// various required adjustments (removing reference types, cv-qualifiers).
717
  QualType getTypeOperand(ASTContext &Context) const;
718
719
  /// Retrieve source information for the type operand.
720
111
  TypeSourceInfo *getTypeOperandSourceInfo() const {
721
111
    assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
722
111
    return Operand.get<TypeSourceInfo *>();
723
111
  }
724
725
1
  void setTypeOperandSourceInfo(TypeSourceInfo *TSI) {
726
1
    assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
727
1
    Operand = TSI;
728
1
  }
729
730
685
  Expr *getExprOperand() const {
731
685
    assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
732
685
    return static_cast<Expr*>(Operand.get<Stmt *>());
733
685
  }
734
735
1
  void setExprOperand(Expr *E) {
736
1
    assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
737
1
    Operand = E;
738
1
  }
739
740
8.95k
  SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
741
783
  SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
742
77
  SourceRange getSourceRange() const LLVM_READONLY { return Range; }
743
2
  void setSourceRange(SourceRange R) { Range = R; }
744
745
3.61k
  static bool classof(const Stmt *T) {
746
3.61k
    return T->getStmtClass() == CXXTypeidExprClass;
747
3.61k
  }
748
749
  // Iterators
750
1.25k
  child_range children() {
751
1.25k
    if (isTypeOperand())
752
1.02k
      return child_range(child_iterator(), child_iterator());
753
227
    auto **begin = reinterpret_cast<Stmt **>(&Operand);
754
227
    return child_range(begin, begin + 1);
755
227
  }
756
757
0
  const_child_range children() const {
758
0
    if (isTypeOperand())
759
0
      return const_child_range(const_child_iterator(), const_child_iterator());
760
0
761
0
    auto **begin =
762
0
        reinterpret_cast<Stmt **>(&const_cast<CXXTypeidExpr *>(this)->Operand);
763
0
    return const_child_range(begin, begin + 1);
764
0
  }
765
};
766
767
/// A member reference to an MSPropertyDecl.
768
///
769
/// This expression always has pseudo-object type, and therefore it is
770
/// typically not encountered in a fully-typechecked expression except
771
/// within the syntactic form of a PseudoObjectExpr.
772
class MSPropertyRefExpr : public Expr {
773
  Expr *BaseExpr;
774
  MSPropertyDecl *TheDecl;
775
  SourceLocation MemberLoc;
776
  bool IsArrow;
777
  NestedNameSpecifierLoc QualifierLoc;
778
779
public:
780
  friend class ASTStmtReader;
781
782
  MSPropertyRefExpr(Expr *baseExpr, MSPropertyDecl *decl, bool isArrow,
783
                    QualType ty, ExprValueKind VK,
784
                    NestedNameSpecifierLoc qualifierLoc,
785
                    SourceLocation nameLoc)
786
      : Expr(MSPropertyRefExprClass, ty, VK, OK_Ordinary,
787
             /*type-dependent*/ false, baseExpr->isValueDependent(),
788
             baseExpr->isInstantiationDependent(),
789
             baseExpr->containsUnexpandedParameterPack()),
790
        BaseExpr(baseExpr), TheDecl(decl),
791
        MemberLoc(nameLoc), IsArrow(isArrow),
792
532
        QualifierLoc(qualifierLoc) {}
793
794
22
  MSPropertyRefExpr(EmptyShell Empty) : Expr(MSPropertyRefExprClass, Empty) {}
795
796
601
  SourceRange getSourceRange() const LLVM_READONLY {
797
601
    return SourceRange(getBeginLoc(), getEndLoc());
798
601
  }
799
800
1.90k
  bool isImplicitAccess() const {
801
1.90k
    return getBaseExpr() && getBaseExpr()->isImplicitCXXThis();
802
1.90k
  }
803
804
1.90k
  SourceLocation getBeginLoc() const {
805
1.90k
    if (!isImplicitAccess())
806
1.66k
      return BaseExpr->getBeginLoc();
807
237
    else if (QualifierLoc)
808
18
      return QualifierLoc.getBeginLoc();
809
219
    else
810
219
        return MemberLoc;
811
1.90k
  }
812
813
639
  SourceLocation getEndLoc() const { return getMemberLoc(); }
814
815
368
  child_range children() {
816
368
    return child_range((Stmt**)&BaseExpr, (Stmt**)&BaseExpr + 1);
817
368
  }
818
819
0
  const_child_range children() const {
820
0
    auto Children = const_cast<MSPropertyRefExpr *>(this)->children();
821
0
    return const_child_range(Children.begin(), Children.end());
822
0
  }
823
824
916
  static bool classof(const Stmt *T) {
825
916
    return T->getStmtClass() == MSPropertyRefExprClass;
826
916
  }
827
828
4.40k
  Expr *getBaseExpr() const { return BaseExpr; }
829
1.01k
  MSPropertyDecl *getPropertyDecl() const { return TheDecl; }
830
611
  bool isArrow() const { return IsArrow; }
831
1.28k
  SourceLocation getMemberLoc() const { return MemberLoc; }
832
613
  NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
833
};
834
835
/// MS property subscript expression.
836
/// MSVC supports 'property' attribute and allows to apply it to the
837
/// declaration of an empty array in a class or structure definition.
838
/// For example:
839
/// \code
840
/// __declspec(property(get=GetX, put=PutX)) int x[];
841
/// \endcode
842
/// The above statement indicates that x[] can be used with one or more array
843
/// indices. In this case, i=p->x[a][b] will be turned into i=p->GetX(a, b), and
844
/// p->x[a][b] = i will be turned into p->PutX(a, b, i).
845
/// This is a syntactic pseudo-object expression.
846
class MSPropertySubscriptExpr : public Expr {
847
  friend class ASTStmtReader;
848
849
  enum { BASE_EXPR, IDX_EXPR, NUM_SUBEXPRS = 2 };
850
851
  Stmt *SubExprs[NUM_SUBEXPRS];
852
  SourceLocation RBracketLoc;
853
854
36
  void setBase(Expr *Base) { SubExprs[BASE_EXPR] = Base; }
855
36
  void setIdx(Expr *Idx) { SubExprs[IDX_EXPR] = Idx; }
856
857
public:
858
  MSPropertySubscriptExpr(Expr *Base, Expr *Idx, QualType Ty, ExprValueKind VK,
859
                          ExprObjectKind OK, SourceLocation RBracketLoc)
860
      : Expr(MSPropertySubscriptExprClass, Ty, VK, OK, Idx->isTypeDependent(),
861
             Idx->isValueDependent(), Idx->isInstantiationDependent(),
862
             Idx->containsUnexpandedParameterPack()),
863
312
        RBracketLoc(RBracketLoc) {
864
312
    SubExprs[BASE_EXPR] = Base;
865
312
    SubExprs[IDX_EXPR] = Idx;
866
312
  }
867
868
  /// Create an empty array subscript expression.
869
  explicit MSPropertySubscriptExpr(EmptyShell Shell)
870
36
      : Expr(MSPropertySubscriptExprClass, Shell) {}
871
872
430
  Expr *getBase() { return cast<Expr>(SubExprs[BASE_EXPR]); }
873
933
  const Expr *getBase() const { return cast<Expr>(SubExprs[BASE_EXPR]); }
874
875
408
  Expr *getIdx() { return cast<Expr>(SubExprs[IDX_EXPR]); }
876
0
  const Expr *getIdx() const { return cast<Expr>(SubExprs[IDX_EXPR]); }
877
878
537
  SourceLocation getBeginLoc() const LLVM_READONLY {
879
537
    return getBase()->getBeginLoc();
880
537
  }
881
882
96
  SourceLocation getEndLoc() const LLVM_READONLY { return RBracketLoc; }
883
884
224
  SourceLocation getRBracketLoc() const { return RBracketLoc; }
885
36
  void setRBracketLoc(SourceLocation L) { RBracketLoc = L; }
886
887
396
  SourceLocation getExprLoc() const LLVM_READONLY {
888
396
    return getBase()->getExprLoc();
889
396
  }
890
891
528
  static bool classof(const Stmt *T) {
892
528
    return T->getStmtClass() == MSPropertySubscriptExprClass;
893
528
  }
894
895
  // Iterators
896
220
  child_range children() {
897
220
    return child_range(&SubExprs[0], &SubExprs[0] + NUM_SUBEXPRS);
898
220
  }
899
900
0
  const_child_range children() const {
901
0
    return const_child_range(&SubExprs[0], &SubExprs[0] + NUM_SUBEXPRS);
902
0
  }
903
};
904
905
/// A Microsoft C++ @c __uuidof expression, which gets
906
/// the _GUID that corresponds to the supplied type or expression.
907
///
908
/// This represents code like @c __uuidof(COMTYPE) or @c __uuidof(*comPtr)
909
class CXXUuidofExpr : public Expr {
910
private:
911
  llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
912
  StringRef UuidStr;
913
  SourceRange Range;
914
915
public:
916
  CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, StringRef UuidStr,
917
                SourceRange R)
918
      : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, false,
919
             Operand->getType()->isDependentType(),
920
             Operand->getType()->isInstantiationDependentType(),
921
             Operand->getType()->containsUnexpandedParameterPack()),
922
115
        Operand(Operand), UuidStr(UuidStr), Range(R) {}
923
924
  CXXUuidofExpr(QualType Ty, Expr *Operand, StringRef UuidStr, SourceRange R)
925
      : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, false,
926
             Operand->isTypeDependent(), Operand->isInstantiationDependent(),
927
             Operand->containsUnexpandedParameterPack()),
928
22
        Operand(Operand), UuidStr(UuidStr), Range(R) {}
929
930
  CXXUuidofExpr(EmptyShell Empty, bool isExpr)
931
1
    : Expr(CXXUuidofExprClass, Empty) {
932
1
    if (isExpr)
933
1
      Operand = (Expr*)nullptr;
934
0
    else
935
0
      Operand = (TypeSourceInfo*)nullptr;
936
1
  }
937
938
219
  bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); }
939
940
  /// Retrieves the type operand of this __uuidof() expression after
941
  /// various required adjustments (removing reference types, cv-qualifiers).
942
  QualType getTypeOperand(ASTContext &Context) const;
943
944
  /// Retrieve source information for the type operand.
945
84
  TypeSourceInfo *getTypeOperandSourceInfo() const {
946
84
    assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
947
84
    return Operand.get<TypeSourceInfo *>();
948
84
  }
949
950
0
  void setTypeOperandSourceInfo(TypeSourceInfo *TSI) {
951
0
    assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
952
0
    Operand = TSI;
953
0
  }
954
955
4
  Expr *getExprOperand() const {
956
4
    assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)");
957
4
    return static_cast<Expr*>(Operand.get<Stmt *>());
958
4
  }
959
960
1
  void setExprOperand(Expr *E) {
961
1
    assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)");
962
1
    Operand = E;
963
1
  }
964
965
1
  void setUuidStr(StringRef US) { UuidStr = US; }
966
87
  StringRef getUuidStr() const { return UuidStr; }
967
968
454
  SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
969
45
  SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
970
28
  SourceRange getSourceRange() const LLVM_READONLY { return Range; }
971
1
  void setSourceRange(SourceRange R) { Range = R; }
972
973
2.36k
  static bool classof(const Stmt *T) {
974
2.36k
    return T->getStmtClass() == CXXUuidofExprClass;
975
2.36k
  }
976
977
  // Iterators
978
134
  child_range children() {
979
134
    if (isTypeOperand())
980
113
      return child_range(child_iterator(), child_iterator());
981
21
    auto **begin = reinterpret_cast<Stmt **>(&Operand);
982
21
    return child_range(begin, begin + 1);
983
21
  }
984
985
0
  const_child_range children() const {
986
0
    if (isTypeOperand())
987
0
      return const_child_range(const_child_iterator(), const_child_iterator());
988
0
    auto **begin =
989
0
        reinterpret_cast<Stmt **>(&const_cast<CXXUuidofExpr *>(this)->Operand);
990
0
    return const_child_range(begin, begin + 1);
991
0
  }
992
};
993
994
/// Represents the \c this expression in C++.
995
///
996
/// This is a pointer to the object on which the current member function is
997
/// executing (C++ [expr.prim]p3). Example:
998
///
999
/// \code
1000
/// class Foo {
1001
/// public:
1002
///   void bar();
1003
///   void test() { this->bar(); }
1004
/// };
1005
/// \endcode
1006
class CXXThisExpr : public Expr {
1007
public:
1008
  CXXThisExpr(SourceLocation L, QualType Ty, bool IsImplicit)
1009
      : Expr(CXXThisExprClass, Ty, VK_RValue, OK_Ordinary,
1010
             // 'this' is type-dependent if the class type of the enclosing
1011
             // member function is dependent (C++ [temp.dep.expr]p2)
1012
             Ty->isDependentType(), Ty->isDependentType(),
1013
             Ty->isInstantiationDependentType(),
1014
2.34M
             /*ContainsUnexpandedParameterPack=*/false) {
1015
2.34M
    CXXThisExprBits.IsImplicit = IsImplicit;
1016
2.34M
    CXXThisExprBits.Loc = L;
1017
2.34M
  }
1018
1019
4.65k
  CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {}
1020
1021
5.85M
  SourceLocation getLocation() const { return CXXThisExprBits.Loc; }
1022
4.65k
  void setLocation(SourceLocation L) { CXXThisExprBits.Loc = L; }
1023
1024
5.43M
  SourceLocation getBeginLoc() const { return getLocation(); }
1025
419k
  SourceLocation getEndLoc() const { return getLocation(); }
1026
1027
9.31M
  bool isImplicit() const { return CXXThisExprBits.IsImplicit; }
1028
4.65k
  void setImplicit(bool I) { CXXThisExprBits.IsImplicit = I; }
1029
1030
21.1M
  static bool classof(const Stmt *T) {
1031
21.1M
    return T->getStmtClass() == CXXThisExprClass;
1032
21.1M
  }
1033
1034
  // Iterators
1035
2.22M
  child_range children() {
1036
2.22M
    return child_range(child_iterator(), child_iterator());
1037
2.22M
  }
1038
1039
0
  const_child_range children() const {
1040
0
    return const_child_range(const_child_iterator(), const_child_iterator());
1041
0
  }
1042
};
1043
1044
/// A C++ throw-expression (C++ [except.throw]).
1045
///
1046
/// This handles 'throw' (for re-throwing the current exception) and
1047
/// 'throw' assignment-expression.  When assignment-expression isn't
1048
/// present, Op will be null.
1049
class CXXThrowExpr : public Expr {
1050
  friend class ASTStmtReader;
1051
1052
  /// The optional expression in the throw statement.
1053
  Stmt *Operand;
1054
1055
public:
1056
  // \p Ty is the void type which is used as the result type of the
1057
  // expression. The \p Loc is the location of the throw keyword.
1058
  // \p Operand is the expression in the throw statement, and can be
1059
  // null if not present.
1060
  CXXThrowExpr(Expr *Operand, QualType Ty, SourceLocation Loc,
1061
               bool IsThrownVariableInScope)
1062
      : Expr(CXXThrowExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
1063
             Operand && Operand->isInstantiationDependent(),
1064
             Operand && Operand->containsUnexpandedParameterPack()),
1065
10.2k
        Operand(Operand) {
1066
10.2k
    CXXThrowExprBits.ThrowLoc = Loc;
1067
10.2k
    CXXThrowExprBits.IsThrownVariableInScope = IsThrownVariableInScope;
1068
10.2k
  }
1069
4
  CXXThrowExpr(EmptyShell Empty) : Expr(CXXThrowExprClass, Empty) {}
1070
1071
1.77k
  const Expr *getSubExpr() const { return cast_or_null<Expr>(Operand); }
1072
459
  Expr *getSubExpr() { return cast_or_null<Expr>(Operand); }
1073
1074
31.8k
  SourceLocation getThrowLoc() const { return CXXThrowExprBits.ThrowLoc; }
1075
1076
  /// Determines whether the variable thrown by this expression (if any!)
1077
  /// is within the innermost try block.
1078
  ///
1079
  /// This information is required to determine whether the NRVO can apply to
1080
  /// this variable.
1081
175
  bool isThrownVariableInScope() const {
1082
175
    return CXXThrowExprBits.IsThrownVariableInScope;
1083
175
  }
1084
1085
31.6k
  SourceLocation getBeginLoc() const { return getThrowLoc(); }
1086
21
  SourceLocation getEndLoc() const LLVM_READONLY {
1087
21
    if (!getSubExpr())
1088
7
      return getThrowLoc();
1089
14
    return getSubExpr()->getEndLoc();
1090
14
  }
1091
1092
449k
  static bool classof(const Stmt *T) {
1093
449k
    return T->getStmtClass() == CXXThrowExprClass;
1094
449k
  }
1095
1096
  // Iterators
1097
20.7k
  child_range children() {
1098
20.7k
    return child_range(&Operand, Operand ? 
&Operand + 18.65k
:
&Operand12.1k
);
1099
20.7k
  }
1100
1101
0
  const_child_range children() const {
1102
0
    return const_child_range(&Operand, Operand ? &Operand + 1 : &Operand);
1103
0
  }
1104
};
1105
1106
/// A default argument (C++ [dcl.fct.default]).
1107
///
1108
/// This wraps up a function call argument that was created from the
1109
/// corresponding parameter's default argument, when the call did not
1110
/// explicitly supply arguments for all of the parameters.
1111
class CXXDefaultArgExpr final : public Expr {
1112
  friend class ASTStmtReader;
1113
1114
  /// The parameter whose default is being used.
1115
  ParmVarDecl *Param;
1116
1117
  /// The context where the default argument expression was used.
1118
  DeclContext *UsedContext;
1119
1120
  CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *Param,
1121
      DeclContext *UsedContext)
1122
      : Expr(SC,
1123
             Param->hasUnparsedDefaultArg()
1124
                 ? Param->getType().getNonReferenceType()
1125
                 : Param->getDefaultArg()->getType(),
1126
             Param->getDefaultArg()->getValueKind(),
1127
             Param->getDefaultArg()->getObjectKind(), false, false, false,
1128
             false),
1129
44.6k
        Param(Param), UsedContext(UsedContext) {
1130
44.6k
    CXXDefaultArgExprBits.Loc = Loc;
1131
44.6k
  }
1132
1133
public:
1134
446
  CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {}
1135
1136
  // \p Param is the parameter whose default argument is used by this
1137
  // expression.
1138
  static CXXDefaultArgExpr *Create(const ASTContext &C, SourceLocation Loc,
1139
                                   ParmVarDecl *Param,
1140
44.6k
                                   DeclContext *UsedContext) {
1141
44.6k
    return new (C)
1142
44.6k
        CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param, UsedContext);
1143
44.6k
  }
1144
1145
  // Retrieve the parameter that the argument was created from.
1146
5.27k
  const ParmVarDecl *getParam() const { return Param; }
1147
15.2k
  ParmVarDecl *getParam() { return Param; }
1148
1149
  // Retrieve the actual argument to the function call.
1150
5.24k
  const Expr *getExpr() const { return getParam()->getDefaultArg(); }
1151
14.7k
  Expr *getExpr() { return getParam()->getDefaultArg(); }
1152
1153
300
  const DeclContext *getUsedContext() const { return UsedContext; }
1154
448
  DeclContext *getUsedContext() { return UsedContext; }
1155
1156
  /// Retrieve the location where this default argument was actually used.
1157
62.9k
  SourceLocation getUsedLocation() const { return CXXDefaultArgExprBits.Loc; }
1158
1159
  /// Default argument expressions have no representation in the
1160
  /// source, so they have an empty source range.
1161
11.0k
  SourceLocation getBeginLoc() const { return SourceLocation(); }
1162
4.49k
  SourceLocation getEndLoc() const { return SourceLocation(); }
1163
1164
62.2k
  SourceLocation getExprLoc() const { return getUsedLocation(); }
1165
1166
7.33M
  static bool classof(const Stmt *T) {
1167
7.33M
    return T->getStmtClass() == CXXDefaultArgExprClass;
1168
7.33M
  }
1169
1170
  // Iterators
1171
113k
  child_range children() {
1172
113k
    return child_range(child_iterator(), child_iterator());
1173
113k
  }
1174
1175
0
  const_child_range children() const {
1176
0
    return const_child_range(const_child_iterator(), const_child_iterator());
1177
0
  }
1178
};
1179
1180
/// A use of a default initializer in a constructor or in aggregate
1181
/// initialization.
1182
///
1183
/// This wraps a use of a C++ default initializer (technically,
1184
/// a brace-or-equal-initializer for a non-static data member) when it
1185
/// is implicitly used in a mem-initializer-list in a constructor
1186
/// (C++11 [class.base.init]p8) or in aggregate initialization
1187
/// (C++1y [dcl.init.aggr]p7).
1188
class CXXDefaultInitExpr : public Expr {
1189
  friend class ASTReader;
1190
  friend class ASTStmtReader;
1191
1192
  /// The field whose default is being used.
1193
  FieldDecl *Field;
1194
1195
  /// The context where the default initializer expression was used.
1196
  DeclContext *UsedContext;
1197
1198
  CXXDefaultInitExpr(const ASTContext &Ctx, SourceLocation Loc,
1199
                     FieldDecl *Field, QualType Ty, DeclContext *UsedContext);
1200
1201
4
  CXXDefaultInitExpr(EmptyShell Empty) : Expr(CXXDefaultInitExprClass, Empty) {}
1202
1203
public:
1204
  /// \p Field is the non-static data member whose default initializer is used
1205
  /// by this expression.
1206
  static CXXDefaultInitExpr *Create(const ASTContext &Ctx, SourceLocation Loc,
1207
2.45k
                                    FieldDecl *Field, DeclContext *UsedContext) {
1208
2.45k
    return new (Ctx) CXXDefaultInitExpr(Ctx, Loc, Field, Field->getType(), UsedContext);
1209
2.45k
  }
1210
1211
  /// Get the field whose initializer will be used.
1212
2.31k
  FieldDecl *getField() { return Field; }
1213
2.23k
  const FieldDecl *getField() const { return Field; }
1214
1215
  /// Get the initialization expression that will be used.
1216
2.65k
  const Expr *getExpr() const {
1217
2.65k
    assert(Field->getInClassInitializer() && "initializer hasn't been parsed");
1218
2.65k
    return Field->getInClassInitializer();
1219
2.65k
  }
1220
6.24k
  Expr *getExpr() {
1221
6.24k
    assert(Field->getInClassInitializer() && "initializer hasn't been parsed");
1222
6.24k
    return Field->getInClassInitializer();
1223
6.24k
  }
1224
1225
186
  const DeclContext *getUsedContext() const { return UsedContext; }
1226
12
  DeclContext *getUsedContext() { return UsedContext; }
1227
1228
  /// Retrieve the location where this default initializer expression was
1229
  /// actually used.
1230
186
  SourceLocation getUsedLocation() const { return getBeginLoc(); }
1231
1232
4.01k
  SourceLocation getBeginLoc() const { return CXXDefaultInitExprBits.Loc; }
1233
950
  SourceLocation getEndLoc() const { return CXXDefaultInitExprBits.Loc; }
1234
1235
14.6M
  static bool classof(const Stmt *T) {
1236
14.6M
    return T->getStmtClass() == CXXDefaultInitExprClass;
1237
14.6M
  }
1238
1239
  // Iterators
1240
1.05k
  child_range children() {
1241
1.05k
    return child_range(child_iterator(), child_iterator());
1242
1.05k
  }
1243
1244
0
  const_child_range children() const {
1245
0
    return const_child_range(const_child_iterator(), const_child_iterator());
1246
0
  }
1247
};
1248
1249
/// Represents a C++ temporary.
1250
class CXXTemporary {
1251
  /// The destructor that needs to be called.
1252
  const CXXDestructorDecl *Destructor;
1253
1254
  explicit CXXTemporary(const CXXDestructorDecl *destructor)
1255
58.8k
      : Destructor(destructor) {}
1256
1257
public:
1258
  static CXXTemporary *Create(const ASTContext &C,
1259
                              const CXXDestructorDecl *Destructor);
1260
1261
13.9k
  const CXXDestructorDecl *getDestructor() const { return Destructor; }
1262
1263
7.10k
  void setDestructor(const CXXDestructorDecl *Dtor) {
1264
7.10k
    Destructor = Dtor;
1265
7.10k
  }
1266
};
1267
1268
/// Represents binding an expression to a temporary.
1269
///
1270
/// This ensures the destructor is called for the temporary. It should only be
1271
/// needed for non-POD, non-trivially destructable class types. For example:
1272
///
1273
/// \code
1274
///   struct S {
1275
///     S() { }  // User defined constructor makes S non-POD.
1276
///     ~S() { } // User defined destructor makes it non-trivial.
1277
///   };
1278
///   void test() {
1279
///     const S &s_ref = S(); // Requires a CXXBindTemporaryExpr.
1280
///   }
1281
/// \endcode
1282
class CXXBindTemporaryExpr : public Expr {
1283
  CXXTemporary *Temp = nullptr;
1284
  Stmt *SubExpr = nullptr;
1285
1286
  CXXBindTemporaryExpr(CXXTemporary *temp, Expr* SubExpr)
1287
      : Expr(CXXBindTemporaryExprClass, SubExpr->getType(),
1288
             VK_RValue, OK_Ordinary, SubExpr->isTypeDependent(),
1289
             SubExpr->isValueDependent(),
1290
             SubExpr->isInstantiationDependent(),
1291
             SubExpr->containsUnexpandedParameterPack()),
1292
57.7k
        Temp(temp), SubExpr(SubExpr) {}
1293
1294
public:
1295
  CXXBindTemporaryExpr(EmptyShell Empty)
1296
1.10k
      : Expr(CXXBindTemporaryExprClass, Empty) {}
1297
1298
  static CXXBindTemporaryExpr *Create(const ASTContext &C, CXXTemporary *Temp,
1299
                                      Expr* SubExpr);
1300
1301
19.3k
  CXXTemporary *getTemporary() { return Temp; }
1302
3.31k
  const CXXTemporary *getTemporary() const { return Temp; }
1303
1.10k
  void setTemporary(CXXTemporary *T) { Temp = T; }
1304
1305
151k
  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
1306
69.7k
  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
1307
1.10k
  void setSubExpr(Expr *E) { SubExpr = E; }
1308
1309
526k
  SourceLocation getBeginLoc() const LLVM_READONLY {
1310
526k
    return SubExpr->getBeginLoc();
1311
526k
  }
1312
1313
15.0k
  SourceLocation getEndLoc() const LLVM_READONLY {
1314
15.0k
    return SubExpr->getEndLoc();
1315
15.0k
  }
1316
1317
  // Implement isa/cast/dyncast/etc.
1318
12.3M
  static bool classof(const Stmt *T) {
1319
12.3M
    return T->getStmtClass() == CXXBindTemporaryExprClass;
1320
12.3M
  }
1321
1322
  // Iterators
1323
96.3k
  child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
1324
1325
0
  const_child_range children() const {
1326
0
    return const_child_range(&SubExpr, &SubExpr + 1);
1327
0
  }
1328
};
1329
1330
/// Represents a call to a C++ constructor.
1331
class CXXConstructExpr : public Expr {
1332
  friend class ASTStmtReader;
1333
1334
public:
1335
  enum ConstructionKind {
1336
    CK_Complete,
1337
    CK_NonVirtualBase,
1338
    CK_VirtualBase,
1339
    CK_Delegating
1340
  };
1341
1342
private:
1343
  /// A pointer to the constructor which will be ultimately called.
1344
  CXXConstructorDecl *Constructor;
1345
1346
  SourceRange ParenOrBraceRange;
1347
1348
  /// The number of arguments.
1349
  unsigned NumArgs;
1350
1351
  // We would like to stash the arguments of the constructor call after
1352
  // CXXConstructExpr. However CXXConstructExpr is used as a base class of
1353
  // CXXTemporaryObjectExpr which makes the use of llvm::TrailingObjects
1354
  // impossible.
1355
  //
1356
  // Instead we manually stash the trailing object after the full object
1357
  // containing CXXConstructExpr (that is either CXXConstructExpr or
1358
  // CXXTemporaryObjectExpr).
1359
  //
1360
  // The trailing objects are:
1361
  //
1362
  // * An array of getNumArgs() "Stmt *" for the arguments of the
1363
  //   constructor call.
1364
1365
  /// Return a pointer to the start of the trailing arguments.
1366
  /// Defined just after CXXTemporaryObjectExpr.
1367
  inline Stmt **getTrailingArgs();
1368
417k
  const Stmt *const *getTrailingArgs() const {
1369
417k
    return const_cast<CXXConstructExpr *>(this)->getTrailingArgs();
1370
417k
  }
1371
1372
protected:
1373
  /// Build a C++ construction expression.
1374
  CXXConstructExpr(StmtClass SC, QualType Ty, SourceLocation Loc,
1375
                   CXXConstructorDecl *Ctor, bool Elidable,
1376
                   ArrayRef<Expr *> Args, bool HadMultipleCandidates,
1377
                   bool ListInitialization, bool StdInitListInitialization,
1378
                   bool ZeroInitialization, ConstructionKind ConstructKind,
1379
                   SourceRange ParenOrBraceRange);
1380
1381
  /// Build an empty C++ construction expression.
1382
  CXXConstructExpr(StmtClass SC, EmptyShell Empty, unsigned NumArgs);
1383
1384
  /// Return the size in bytes of the trailing objects. Used by
1385
  /// CXXTemporaryObjectExpr to allocate the right amount of storage.
1386
425k
  static unsigned sizeOfTrailingObjects(unsigned NumArgs) {
1387
425k
    return NumArgs * sizeof(Stmt *);
1388
425k
  }
1389
1390
public:
1391
  /// Create a C++ construction expression.
1392
  static CXXConstructExpr *
1393
  Create(const ASTContext &Ctx, QualType Ty, SourceLocation Loc,
1394
         CXXConstructorDecl *Ctor, bool Elidable, ArrayRef<Expr *> Args,
1395
         bool HadMultipleCandidates, bool ListInitialization,
1396
         bool StdInitListInitialization, bool ZeroInitialization,
1397
         ConstructionKind ConstructKind, SourceRange ParenOrBraceRange);
1398
1399
  /// Create an empty C++ construction expression.
1400
  static CXXConstructExpr *CreateEmpty(const ASTContext &Ctx, unsigned NumArgs);
1401
1402
  /// Get the constructor that this expression will (ultimately) call.
1403
1.03M
  CXXConstructorDecl *getConstructor() const { return Constructor; }
1404
1405
1.03M
  SourceLocation getLocation() const { return CXXConstructExprBits.Loc; }
1406
0
  void setLocation(SourceLocation Loc) { CXXConstructExprBits.Loc = Loc; }
1407
1408
  /// Whether this construction is elidable.
1409
156k
  bool isElidable() const { return CXXConstructExprBits.Elidable; }
1410
0
  void setElidable(bool E) { CXXConstructExprBits.Elidable = E; }
1411
1412
  /// Whether the referred constructor was resolved from
1413
  /// an overloaded set having size greater than 1.
1414
5.37k
  bool hadMultipleCandidates() const {
1415
5.37k
    return CXXConstructExprBits.HadMultipleCandidates;
1416
5.37k
  }
1417
0
  void setHadMultipleCandidates(bool V) {
1418
0
    CXXConstructExprBits.HadMultipleCandidates = V;
1419
0
  }
1420
1421
  /// Whether this constructor call was written as list-initialization.
1422
359k
  bool isListInitialization() const {
1423
359k
    return CXXConstructExprBits.ListInitialization;
1424
359k
  }
1425
0
  void setListInitialization(bool V) {
1426
0
    CXXConstructExprBits.ListInitialization = V;
1427
0
  }
1428
1429
  /// Whether this constructor call was written as list-initialization,
1430
  /// but was interpreted as forming a std::initializer_list<T> from the list
1431
  /// and passing that as a single constructor argument.
1432
  /// See C++11 [over.match.list]p1 bullet 1.
1433
8.50k
  bool isStdInitListInitialization() const {
1434
8.50k
    return CXXConstructExprBits.StdInitListInitialization;
1435
8.50k
  }
1436
0
  void setStdInitListInitialization(bool V) {
1437
0
    CXXConstructExprBits.StdInitListInitialization = V;
1438
0
  }
1439
1440
  /// Whether this construction first requires
1441
  /// zero-initialization before the initializer is called.
1442
175k
  bool requiresZeroInitialization() const {
1443
175k
    return CXXConstructExprBits.ZeroInitialization;
1444
175k
  }
1445
0
  void setRequiresZeroInitialization(bool ZeroInit) {
1446
0
    CXXConstructExprBits.ZeroInitialization = ZeroInit;
1447
0
  }
1448
1449
  /// Determine whether this constructor is actually constructing
1450
  /// a base class (rather than a complete object).
1451
159k
  ConstructionKind getConstructionKind() const {
1452
159k
    return static_cast<ConstructionKind>(CXXConstructExprBits.ConstructionKind);
1453
159k
  }
1454
0
  void setConstructionKind(ConstructionKind CK) {
1455
0
    CXXConstructExprBits.ConstructionKind = CK;
1456
0
  }
1457
1458
  using arg_iterator = ExprIterator;
1459
  using const_arg_iterator = ConstExprIterator;
1460
  using arg_range = llvm::iterator_range<arg_iterator>;
1461
  using const_arg_range = llvm::iterator_range<const_arg_iterator>;
1462
1463
124
  arg_range arguments() { return arg_range(arg_begin(), arg_end()); }
1464
72.0k
  const_arg_range arguments() const {
1465
72.0k
    return const_arg_range(arg_begin(), arg_end());
1466
72.0k
  }
1467
1468
5.69k
  arg_iterator arg_begin() { return getTrailingArgs(); }
1469
2.84k
  arg_iterator arg_end() { return arg_begin() + getNumArgs(); }
1470
145k
  const_arg_iterator arg_begin() const { return getTrailingArgs(); }
1471
72.5k
  const_arg_iterator arg_end() const { return arg_begin() + getNumArgs(); }
1472
1473
390k
  Expr **getArgs() { return reinterpret_cast<Expr **>(getTrailingArgs()); }
1474
272k
  const Expr *const *getArgs() const {
1475
272k
    return reinterpret_cast<const Expr *const *>(getTrailingArgs());
1476
272k
  }
1477
1478
  /// Return the number of arguments to the constructor call.
1479
1.57M
  unsigned getNumArgs() const { return NumArgs; }
1480
1481
  /// Return the specified argument.
1482
99.8k
  Expr *getArg(unsigned Arg) {
1483
99.8k
    assert(Arg < getNumArgs() && "Arg access out of range!");
1484
99.8k
    return getArgs()[Arg];
1485
99.8k
  }
1486
263k
  const Expr *getArg(unsigned Arg) const {
1487
263k
    assert(Arg < getNumArgs() && "Arg access out of range!");
1488
263k
    return getArgs()[Arg];
1489
263k
  }
1490
1491
  /// Set the specified argument.
1492
2.57k
  void setArg(unsigned Arg, Expr *ArgExpr) {
1493
2.57k
    assert(Arg < getNumArgs() && "Arg access out of range!");
1494
2.57k
    getArgs()[Arg] = ArgExpr;
1495
2.57k
  }
1496
1497
  SourceLocation getBeginLoc() const LLVM_READONLY;
1498
  SourceLocation getEndLoc() const LLVM_READONLY;
1499
35.9k
  SourceRange getParenOrBraceRange() const { return ParenOrBraceRange; }
1500
14.4k
  void setParenOrBraceRange(SourceRange Range) { ParenOrBraceRange = Range; }
1501
1502
5.91M
  static bool classof(const Stmt *T) {
1503
5.91M
    return T->getStmtClass() == CXXConstructExprClass ||
1504
5.91M
           
T->getStmtClass() == CXXTemporaryObjectExprClass5.50M
;
1505
5.91M
  }
1506
1507
  // Iterators
1508
892k
  child_range children() {
1509
892k
    return child_range(getTrailingArgs(), getTrailingArgs() + getNumArgs());
1510
892k
  }
1511
1512
0
  const_child_range children() const {
1513
0
    auto Children = const_cast<CXXConstructExpr *>(this)->children();
1514
0
    return const_child_range(Children.begin(), Children.end());
1515
0
  }
1516
};
1517
1518
/// Represents a call to an inherited base class constructor from an
1519
/// inheriting constructor. This call implicitly forwards the arguments from
1520
/// the enclosing context (an inheriting constructor) to the specified inherited
1521
/// base class constructor.
1522
class CXXInheritedCtorInitExpr : public Expr {
1523
private:
1524
  CXXConstructorDecl *Constructor = nullptr;
1525
1526
  /// The location of the using declaration.
1527
  SourceLocation Loc;
1528
1529
  /// Whether this is the construction of a virtual base.
1530
  unsigned ConstructsVirtualBase : 1;
1531
1532
  /// Whether the constructor is inherited from a virtual base class of the
1533
  /// class that we construct.
1534
  unsigned InheritedFromVirtualBase : 1;
1535
1536
public:
1537
  friend class ASTStmtReader;
1538
1539
  /// Construct a C++ inheriting construction expression.
1540
  CXXInheritedCtorInitExpr(SourceLocation Loc, QualType T,
1541
                           CXXConstructorDecl *Ctor, bool ConstructsVirtualBase,
1542
                           bool InheritedFromVirtualBase)
1543
      : Expr(CXXInheritedCtorInitExprClass, T, VK_RValue, OK_Ordinary, false,
1544
             false, false, false),
1545
        Constructor(Ctor), Loc(Loc),
1546
        ConstructsVirtualBase(ConstructsVirtualBase),
1547
213
        InheritedFromVirtualBase(InheritedFromVirtualBase) {
1548
213
    assert(!T->isDependentType());
1549
213
  }
1550
1551
  /// Construct an empty C++ inheriting construction expression.
1552
  explicit CXXInheritedCtorInitExpr(EmptyShell Empty)
1553
      : Expr(CXXInheritedCtorInitExprClass, Empty),
1554
0
        ConstructsVirtualBase(false), InheritedFromVirtualBase(false) {}
1555
1556
  /// Get the constructor that this expression will call.
1557
128
  CXXConstructorDecl *getConstructor() const { return Constructor; }
1558
1559
  /// Determine whether this constructor is actually constructing
1560
  /// a base class (rather than a complete object).
1561
110
  bool constructsVBase() const { return ConstructsVirtualBase; }
1562
0
  CXXConstructExpr::ConstructionKind getConstructionKind() const {
1563
0
    return ConstructsVirtualBase ? CXXConstructExpr::CK_VirtualBase
1564
0
                                 : CXXConstructExpr::CK_NonVirtualBase;
1565
0
  }
1566
1567
  /// Determine whether the inherited constructor is inherited from a
1568
  /// virtual base of the object we construct. If so, we are not responsible
1569
  /// for calling the inherited constructor (the complete object constructor
1570
  /// does that), and so we don't need to pass any arguments.
1571
110
  bool inheritedFromVBase() const { return InheritedFromVirtualBase; }
1572
1573
263
  SourceLocation getLocation() const LLVM_READONLY { return Loc; }
1574
148
  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
1575
5
  SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
1576
1577
  static bool classof(const Stmt *T) {
1578
    return T->getStmtClass() == CXXInheritedCtorInitExprClass;
1579
  }
1580
1581
324
  child_range children() {
1582
324
    return child_range(child_iterator(), child_iterator());
1583
324
  }
1584
1585
0
  const_child_range children() const {
1586
0
    return const_child_range(const_child_iterator(), const_child_iterator());
1587
0
  }
1588
};
1589
1590
/// Represents an explicit C++ type conversion that uses "functional"
1591
/// notation (C++ [expr.type.conv]).
1592
///
1593
/// Example:
1594
/// \code
1595
///   x = int(0.5);
1596
/// \endcode
1597
class CXXFunctionalCastExpr final
1598
    : public ExplicitCastExpr,
1599
      private llvm::TrailingObjects<CXXFunctionalCastExpr, CXXBaseSpecifier *> {
1600
  SourceLocation LParenLoc;
1601
  SourceLocation RParenLoc;
1602
1603
  CXXFunctionalCastExpr(QualType ty, ExprValueKind VK,
1604
                        TypeSourceInfo *writtenTy,
1605
                        CastKind kind, Expr *castExpr, unsigned pathSize,
1606
                        SourceLocation lParenLoc, SourceLocation rParenLoc)
1607
      : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, VK, kind,
1608
                         castExpr, pathSize, writtenTy),
1609
86.9k
        LParenLoc(lParenLoc), RParenLoc(rParenLoc) {}
1610
1611
  explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize)
1612
34
      : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize) {}
1613
1614
public:
1615
  friend class CastExpr;
1616
  friend TrailingObjects;
1617
1618
  static CXXFunctionalCastExpr *Create(const ASTContext &Context, QualType T,
1619
                                       ExprValueKind VK,
1620
                                       TypeSourceInfo *Written,
1621
                                       CastKind Kind, Expr *Op,
1622
                                       const CXXCastPath *Path,
1623
                                       SourceLocation LPLoc,
1624
                                       SourceLocation RPLoc);
1625
  static CXXFunctionalCastExpr *CreateEmpty(const ASTContext &Context,
1626
                                            unsigned PathSize);
1627
1628
6.45k
  SourceLocation getLParenLoc() const { return LParenLoc; }
1629
34
  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
1630
6.06k
  SourceLocation getRParenLoc() const { return RParenLoc; }
1631
34
  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1632
1633
  /// Determine whether this expression models list-initialization.
1634
6.01k
  bool isListInitialization() const { return LParenLoc.isInvalid(); }
1635
1636
  SourceLocation getBeginLoc() const LLVM_READONLY;
1637
  SourceLocation getEndLoc() const LLVM_READONLY;
1638
1639
3.17k
  static bool classof(const Stmt *T) {
1640
3.17k
    return T->getStmtClass() == CXXFunctionalCastExprClass;
1641
3.17k
  }
1642
};
1643
1644
/// Represents a C++ functional cast expression that builds a
1645
/// temporary object.
1646
///
1647
/// This expression type represents a C++ "functional" cast
1648
/// (C++[expr.type.conv]) with N != 1 arguments that invokes a
1649
/// constructor to build a temporary object. With N == 1 arguments the
1650
/// functional cast expression will be represented by CXXFunctionalCastExpr.
1651
/// Example:
1652
/// \code
1653
/// struct X { X(int, float); }
1654
///
1655
/// X create_X() {
1656
///   return X(1, 3.14f); // creates a CXXTemporaryObjectExpr
1657
/// };
1658
/// \endcode
1659
class CXXTemporaryObjectExpr final : public CXXConstructExpr {
1660
  friend class ASTStmtReader;
1661
1662
  // CXXTemporaryObjectExpr has some trailing objects belonging
1663
  // to CXXConstructExpr. See the comment inside CXXConstructExpr
1664
  // for more details.
1665
1666
  TypeSourceInfo *TSI;
1667
1668
  CXXTemporaryObjectExpr(CXXConstructorDecl *Cons, QualType Ty,
1669
                         TypeSourceInfo *TSI, ArrayRef<Expr *> Args,
1670
                         SourceRange ParenOrBraceRange,
1671
                         bool HadMultipleCandidates, bool ListInitialization,
1672
                         bool StdInitListInitialization,
1673
                         bool ZeroInitialization);
1674
1675
  CXXTemporaryObjectExpr(EmptyShell Empty, unsigned NumArgs);
1676
1677
public:
1678
  static CXXTemporaryObjectExpr *
1679
  Create(const ASTContext &Ctx, CXXConstructorDecl *Cons, QualType Ty,
1680
         TypeSourceInfo *TSI, ArrayRef<Expr *> Args,
1681
         SourceRange ParenOrBraceRange, bool HadMultipleCandidates,
1682
         bool ListInitialization, bool StdInitListInitialization,
1683
         bool ZeroInitialization);
1684
1685
  static CXXTemporaryObjectExpr *CreateEmpty(const ASTContext &Ctx,
1686
                                             unsigned NumArgs);
1687
1688
1.00M
  TypeSourceInfo *getTypeSourceInfo() const { return TSI; }
1689
1690
  SourceLocation getBeginLoc() const LLVM_READONLY;
1691
  SourceLocation getEndLoc() const LLVM_READONLY;
1692
1693
4.14M
  static bool classof(const Stmt *T) {
1694
4.14M
    return T->getStmtClass() == CXXTemporaryObjectExprClass;
1695
4.14M
  }
1696
};
1697
1698
3.01M
Stmt **CXXConstructExpr::getTrailingArgs() {
1699
3.01M
  if (auto *E = dyn_cast<CXXTemporaryObjectExpr>(this))
1700
334k
    return reinterpret_cast<Stmt **>(E + 1);
1701
2.68M
  assert((getStmtClass() == CXXConstructExprClass) &&
1702
2.68M
         "Unexpected class deriving from CXXConstructExpr!");
1703
2.68M
  return reinterpret_cast<Stmt **>(this + 1);
1704
2.68M
}
1705
1706
/// A C++ lambda expression, which produces a function object
1707
/// (of unspecified type) that can be invoked later.
1708
///
1709
/// Example:
1710
/// \code
1711
/// void low_pass_filter(std::vector<double> &values, double cutoff) {
1712
///   values.erase(std::remove_if(values.begin(), values.end(),
1713
///                               [=](double value) { return value > cutoff; });
1714
/// }
1715
/// \endcode
1716
///
1717
/// C++11 lambda expressions can capture local variables, either by copying
1718
/// the values of those local variables at the time the function
1719
/// object is constructed (not when it is called!) or by holding a
1720
/// reference to the local variable. These captures can occur either
1721
/// implicitly or can be written explicitly between the square
1722
/// brackets ([...]) that start the lambda expression.
1723
///
1724
/// C++1y introduces a new form of "capture" called an init-capture that
1725
/// includes an initializing expression (rather than capturing a variable),
1726
/// and which can never occur implicitly.
1727
class LambdaExpr final : public Expr,
1728
                         private llvm::TrailingObjects<LambdaExpr, Stmt *> {
1729
  /// The source range that covers the lambda introducer ([...]).
1730
  SourceRange IntroducerRange;
1731
1732
  /// The source location of this lambda's capture-default ('=' or '&').
1733
  SourceLocation CaptureDefaultLoc;
1734
1735
  /// The number of captures.
1736
  unsigned NumCaptures : 16;
1737
1738
  /// The default capture kind, which is a value of type
1739
  /// LambdaCaptureDefault.
1740
  unsigned CaptureDefault : 2;
1741
1742
  /// Whether this lambda had an explicit parameter list vs. an
1743
  /// implicit (and empty) parameter list.
1744
  unsigned ExplicitParams : 1;
1745
1746
  /// Whether this lambda had the result type explicitly specified.
1747
  unsigned ExplicitResultType : 1;
1748
1749
  /// The location of the closing brace ('}') that completes
1750
  /// the lambda.
1751
  ///
1752
  /// The location of the brace is also available by looking up the
1753
  /// function call operator in the lambda class. However, it is
1754
  /// stored here to improve the performance of getSourceRange(), and
1755
  /// to avoid having to deserialize the function call operator from a
1756
  /// module file just to determine the source range.
1757
  SourceLocation ClosingBrace;
1758
1759
  /// Construct a lambda expression.
1760
  LambdaExpr(QualType T, SourceRange IntroducerRange,
1761
             LambdaCaptureDefault CaptureDefault,
1762
             SourceLocation CaptureDefaultLoc, ArrayRef<LambdaCapture> Captures,
1763
             bool ExplicitParams, bool ExplicitResultType,
1764
             ArrayRef<Expr *> CaptureInits, SourceLocation ClosingBrace,
1765
             bool ContainsUnexpandedParameterPack);
1766
1767
  /// Construct an empty lambda expression.
1768
  LambdaExpr(EmptyShell Empty, unsigned NumCaptures)
1769
      : Expr(LambdaExprClass, Empty), NumCaptures(NumCaptures),
1770
        CaptureDefault(LCD_None), ExplicitParams(false),
1771
490
        ExplicitResultType(false) {
1772
490
    getStoredStmts()[NumCaptures] = nullptr;
1773
490
  }
1774
1775
47.5k
  Stmt **getStoredStmts() { return getTrailingObjects<Stmt *>(); }
1776
1777
6.30k
  Stmt *const *getStoredStmts() const { return getTrailingObjects<Stmt *>(); }
1778
1779
public:
1780
  friend class ASTStmtReader;
1781
  friend class ASTStmtWriter;
1782
  friend TrailingObjects;
1783
1784
  /// Construct a new lambda expression.
1785
  static LambdaExpr *
1786
  Create(const ASTContext &C, CXXRecordDecl *Class, SourceRange IntroducerRange,
1787
         LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc,
1788
         ArrayRef<LambdaCapture> Captures, bool ExplicitParams,
1789
         bool ExplicitResultType, ArrayRef<Expr *> CaptureInits,
1790
         SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack);
1791
1792
  /// Construct a new lambda expression that will be deserialized from
1793
  /// an external source.
1794
  static LambdaExpr *CreateDeserialized(const ASTContext &C,
1795
                                        unsigned NumCaptures);
1796
1797
  /// Determine the default capture kind for this lambda.
1798
3.13k
  LambdaCaptureDefault getCaptureDefault() const {
1799
3.13k
    return static_cast<LambdaCaptureDefault>(CaptureDefault);
1800
3.13k
  }
1801
1802
  /// Retrieve the location of this lambda's capture-default, if any.
1803
1.51k
  SourceLocation getCaptureDefaultLoc() const {
1804
1.51k
    return CaptureDefaultLoc;
1805
1.51k
  }
1806
1807
  /// Determine whether one of this lambda's captures is an init-capture.
1808
  bool isInitCapture(const LambdaCapture *Capture) const;
1809
1810
  /// An iterator that walks over the captures of the lambda,
1811
  /// both implicit and explicit.
1812
  using capture_iterator = const LambdaCapture *;
1813
1814
  /// An iterator over a range of lambda captures.
1815
  using capture_range = llvm::iterator_range<capture_iterator>;
1816
1817
  /// Retrieve this lambda's captures.
1818
  capture_range captures() const;
1819
1820
  /// Retrieve an iterator pointing to the first lambda capture.
1821
  capture_iterator capture_begin() const;
1822
1823
  /// Retrieve an iterator pointing past the end of the
1824
  /// sequence of lambda captures.
1825
  capture_iterator capture_end() const;
1826
1827
  /// Determine the number of captures in this lambda.
1828
449
  unsigned capture_size() const { return NumCaptures; }
1829
1830
  /// Retrieve this lambda's explicit captures.
1831
  capture_range explicit_captures() const;
1832
1833
  /// Retrieve an iterator pointing to the first explicit
1834
  /// lambda capture.
1835
  capture_iterator explicit_capture_begin() const;
1836
1837
  /// Retrieve an iterator pointing past the end of the sequence of
1838
  /// explicit lambda captures.
1839
  capture_iterator explicit_capture_end() const;
1840
1841
  /// Retrieve this lambda's implicit captures.
1842
  capture_range implicit_captures() const;
1843
1844
  /// Retrieve an iterator pointing to the first implicit
1845
  /// lambda capture.
1846
  capture_iterator implicit_capture_begin() const;
1847
1848
  /// Retrieve an iterator pointing past the end of the sequence of
1849
  /// implicit lambda captures.
1850
  capture_iterator implicit_capture_end() const;
1851
1852
  /// Iterator that walks over the capture initialization
1853
  /// arguments.
1854
  using capture_init_iterator = Expr **;
1855
1856
  /// Const iterator that walks over the capture initialization
1857
  /// arguments.
1858
  using const_capture_init_iterator = Expr *const *;
1859
1860
  /// Retrieve the initialization expressions for this lambda's captures.
1861
1.91k
  llvm::iterator_range<capture_init_iterator> capture_inits() {
1862
1.91k
    return llvm::make_range(capture_init_begin(), capture_init_end());
1863
1.91k
  }
1864
1865
  /// Retrieve the initialization expressions for this lambda's captures.
1866
545
  llvm::iterator_range<const_capture_init_iterator> capture_inits() const {
1867
545
    return llvm::make_range(capture_init_begin(), capture_init_end());
1868
545
  }
1869
1870
  /// Retrieve the first initialization argument for this
1871
  /// lambda expression (which initializes the first capture field).
1872
26.3k
  capture_init_iterator capture_init_begin() {
1873
26.3k
    return reinterpret_cast<Expr **>(getStoredStmts());
1874
26.3k
  }
1875
1876
  /// Retrieve the first initialization argument for this
1877
  /// lambda expression (which initializes the first capture field).
1878
1.64k
  const_capture_init_iterator capture_init_begin() const {
1879
1.64k
    return reinterpret_cast<Expr *const *>(getStoredStmts());
1880
1.64k
  }
1881
1882
  /// Retrieve the iterator pointing one past the last
1883
  /// initialization argument for this lambda expression.
1884
13.0k
  capture_init_iterator capture_init_end() {
1885
13.0k
    return capture_init_begin() + NumCaptures;
1886
13.0k
  }
1887
1888
  /// Retrieve the iterator pointing one past the last
1889
  /// initialization argument for this lambda expression.
1890
730
  const_capture_init_iterator capture_init_end() const {
1891
730
    return capture_init_begin() + NumCaptures;
1892
730
  }
1893
1894
  /// Retrieve the source range covering the lambda introducer,
1895
  /// which contains the explicit capture list surrounded by square
1896
  /// brackets ([...]).
1897
4.50k
  SourceRange getIntroducerRange() const { return IntroducerRange; }
1898
1899
  /// Retrieve the class that corresponds to the lambda.
1900
  ///
1901
  /// This is the "closure type" (C++1y [expr.prim.lambda]), and stores the
1902
  /// captures in its fields and provides the various operations permitted
1903
  /// on a lambda (copying, calling).
1904
  CXXRecordDecl *getLambdaClass() const;
1905
1906
  /// Retrieve the function call operator associated with this
1907
  /// lambda expression.
1908
  CXXMethodDecl *getCallOperator() const;
1909
1910
  /// If this is a generic lambda expression, retrieve the template
1911
  /// parameter list associated with it, or else return null.
1912
  TemplateParameterList *getTemplateParameterList() const;
1913
1914
  /// Get the template parameters were explicitly specified (as opposed to being
1915
  /// invented by use of an auto parameter).
1916
  ArrayRef<NamedDecl *> getExplicitTemplateParameters() const;
1917
1918
  /// Whether this is a generic lambda.
1919
5
  bool isGenericLambda() const { return getTemplateParameterList(); }
1920
1921
  /// Retrieve the body of the lambda.
1922
  CompoundStmt *getBody() const;
1923
1924
  /// Determine whether the lambda is mutable, meaning that any
1925
  /// captures values can be modified.
1926
  bool isMutable() const;
1927
1928
  /// Determine whether this lambda has an explicit parameter
1929
  /// list vs. an implicit (empty) parameter list.
1930
1.91k
  bool hasExplicitParameters() const { return ExplicitParams; }
1931
1932
  /// Whether this lambda had its result type explicitly specified.
1933
1.87k
  bool hasExplicitResultType() const { return ExplicitResultType; }
1934
1935
3.99M
  static bool classof(const Stmt *T) {
1936
3.99M
    return T->getStmtClass() == LambdaExprClass;
1937
3.99M
  }
1938
1939
65.7k
  SourceLocation getBeginLoc() const LLVM_READONLY {
1940
65.7k
    return IntroducerRange.getBegin();
1941
65.7k
  }
1942
1943
2.17k
  SourceLocation getEndLoc() const LLVM_READONLY { return ClosingBrace; }
1944
1945
6.99k
  child_range children() {
1946
6.99k
    // Includes initialization exprs plus body stmt
1947
6.99k
    return child_range(getStoredStmts(), getStoredStmts() + NumCaptures + 1);
1948
6.99k
  }
1949
1950
0
  const_child_range children() const {
1951
0
    return const_child_range(getStoredStmts(),
1952
0
                             getStoredStmts() + NumCaptures + 1);
1953
0
  }
1954
};
1955
1956
/// An expression "T()" which creates a value-initialized rvalue of type
1957
/// T, which is a non-class type.  See (C++98 [5.2.3p2]).
1958
class CXXScalarValueInitExpr : public Expr {
1959
  friend class ASTStmtReader;
1960
1961
  TypeSourceInfo *TypeInfo;
1962
1963
public:
1964
  /// Create an explicitly-written scalar-value initialization
1965
  /// expression.
1966
  CXXScalarValueInitExpr(QualType Type, TypeSourceInfo *TypeInfo,
1967
                         SourceLocation RParenLoc)
1968
      : Expr(CXXScalarValueInitExprClass, Type, VK_RValue, OK_Ordinary, false,
1969
             false, Type->isInstantiationDependentType(),
1970
             Type->containsUnexpandedParameterPack()),
1971
17.0k
        TypeInfo(TypeInfo) {
1972
17.0k
    CXXScalarValueInitExprBits.RParenLoc = RParenLoc;
1973
17.0k
  }
1974
1975
  explicit CXXScalarValueInitExpr(EmptyShell Shell)
1976
41
      : Expr(CXXScalarValueInitExprClass, Shell) {}
1977
1978
335
  TypeSourceInfo *getTypeSourceInfo() const {
1979
335
    return TypeInfo;
1980
335
  }
1981
1982
453
  SourceLocation getRParenLoc() const {
1983
453
    return CXXScalarValueInitExprBits.RParenLoc;
1984
453
  }
1985
1986
  SourceLocation getBeginLoc() const LLVM_READONLY;
1987
223
  SourceLocation getEndLoc() const { return getRParenLoc(); }
1988
1989
112k
  static bool classof(const Stmt *T) {
1990
112k
    return T->getStmtClass() == CXXScalarValueInitExprClass;
1991
112k
  }
1992
1993
  // Iterators
1994
18.3k
  child_range children() {
1995
18.3k
    return child_range(child_iterator(), child_iterator());
1996
18.3k
  }
1997
1998
0
  const_child_range children() const {
1999
0
    return const_child_range(const_child_iterator(), const_child_iterator());
2000
0
  }
2001
};
2002
2003
/// Represents a new-expression for memory allocation and constructor
2004
/// calls, e.g: "new CXXNewExpr(foo)".
2005
class CXXNewExpr final
2006
    : public Expr,
2007
      private llvm::TrailingObjects<CXXNewExpr, Stmt *, SourceRange> {
2008
  friend class ASTStmtReader;
2009
  friend class ASTStmtWriter;
2010
  friend TrailingObjects;
2011
2012
  /// Points to the allocation function used.
2013
  FunctionDecl *OperatorNew;
2014
2015
  /// Points to the deallocation function used in case of error. May be null.
2016
  FunctionDecl *OperatorDelete;
2017
2018
  /// The allocated type-source information, as written in the source.
2019
  TypeSourceInfo *AllocatedTypeInfo;
2020
2021
  /// Range of the entire new expression.
2022
  SourceRange Range;
2023
2024
  /// Source-range of a paren-delimited initializer.
2025
  SourceRange DirectInitRange;
2026
2027
  // CXXNewExpr is followed by several optional trailing objects.
2028
  // They are in order:
2029
  //
2030
  // * An optional "Stmt *" for the array size expression.
2031
  //    Present if and ony if isArray().
2032
  //
2033
  // * An optional "Stmt *" for the init expression.
2034
  //    Present if and only if hasInitializer().
2035
  //
2036
  // * An array of getNumPlacementArgs() "Stmt *" for the placement new
2037
  //   arguments, if any.
2038
  //
2039
  // * An optional SourceRange for the range covering the parenthesized type-id
2040
  //    if the allocated type was expressed as a parenthesized type-id.
2041
  //    Present if and only if isParenTypeId().
2042
84.0k
  unsigned arraySizeOffset() const { return 0; }
2043
78.2k
  unsigned initExprOffset() const { return arraySizeOffset() + isArray(); }
2044
39.5k
  unsigned placementNewArgsOffset() const {
2045
39.5k
    return initExprOffset() + hasInitializer();
2046
39.5k
  }
2047
2048
28.7k
  unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
2049
28.7k
    return isArray() + hasInitializer() + getNumPlacementArgs();
2050
28.7k
  }
2051
2052
0
  unsigned numTrailingObjects(OverloadToken<SourceRange>) const {
2053
0
    return isParenTypeId();
2054
0
  }
2055
2056
public:
2057
  enum InitializationStyle {
2058
    /// New-expression has no initializer as written.
2059
    NoInit,
2060
2061
    /// New-expression has a C++98 paren-delimited initializer.
2062
    CallInit,
2063
2064
    /// New-expression has a C++11 list-initializer.
2065
    ListInit
2066
  };
2067
2068
private:
2069
  /// Build a c++ new expression.
2070
  CXXNewExpr(bool IsGlobalNew, FunctionDecl *OperatorNew,
2071
             FunctionDecl *OperatorDelete, bool ShouldPassAlignment,
2072
             bool UsualArrayDeleteWantsSize, ArrayRef<Expr *> PlacementArgs,
2073
             SourceRange TypeIdParens, Optional<Expr *> ArraySize,
2074
             InitializationStyle InitializationStyle, Expr *Initializer,
2075
             QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
2076
             SourceRange DirectInitRange);
2077
2078
  /// Build an empty c++ new expression.
2079
  CXXNewExpr(EmptyShell Empty, bool IsArray, unsigned NumPlacementArgs,
2080
             bool IsParenTypeId);
2081
2082
public:
2083
  /// Create a c++ new expression.
2084
  static CXXNewExpr *
2085
  Create(const ASTContext &Ctx, bool IsGlobalNew, FunctionDecl *OperatorNew,
2086
         FunctionDecl *OperatorDelete, bool ShouldPassAlignment,
2087
         bool UsualArrayDeleteWantsSize, ArrayRef<Expr *> PlacementArgs,
2088
         SourceRange TypeIdParens, Optional<Expr *> ArraySize,
2089
         InitializationStyle InitializationStyle, Expr *Initializer,
2090
         QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
2091
         SourceRange DirectInitRange);
2092
2093
  /// Create an empty c++ new expression.
2094
  static CXXNewExpr *CreateEmpty(const ASTContext &Ctx, bool IsArray,
2095
                                 bool HasInit, unsigned NumPlacementArgs,
2096
                                 bool IsParenTypeId);
2097
2098
15.9k
  QualType getAllocatedType() const {
2099
15.9k
    assert(getType()->isPointerType());
2100
15.9k
    return getType()->getAs<PointerType>()->getPointeeType();
2101
15.9k
  }
2102
2103
13.2k
  TypeSourceInfo *getAllocatedTypeSourceInfo() const {
2104
13.2k
    return AllocatedTypeInfo;
2105
13.2k
  }
2106
2107
  /// True if the allocation result needs to be null-checked.
2108
  ///
2109
  /// C++11 [expr.new]p13:
2110
  ///   If the allocation function returns null, initialization shall
2111
  ///   not be done, the deallocation function shall not be called,
2112
  ///   and the value of the new-expression shall be null.
2113
  ///
2114
  /// C++ DR1748:
2115
  ///   If the allocation function is a reserved placement allocation
2116
  ///   function that returns null, the behavior is undefined.
2117
  ///
2118
  /// An allocation function is not allowed to return null unless it
2119
  /// has a non-throwing exception-specification.  The '03 rule is
2120
  /// identical except that the definition of a non-throwing
2121
  /// exception specification is just "is it throw()?".
2122
  bool shouldNullCheckAllocation() const;
2123
2124
36.3k
  FunctionDecl *getOperatorNew() const { return OperatorNew; }
2125
18
  void setOperatorNew(FunctionDecl *D) { OperatorNew = D; }
2126
16.2k
  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
2127
18
  void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; }
2128
2129
142k
  bool isArray() const { return CXXNewExprBits.IsArray; }
2130
2131
4.71k
  Optional<Expr *> getArraySize() {
2132
4.71k
    if (!isArray())
2133
3.34k
      return None;
2134
1.37k
    return cast_or_null<Expr>(getTrailingObjects<Stmt *>()[arraySizeOffset()]);
2135
1.37k
  }
2136
2.22k
  Optional<const Expr *> getArraySize() const {
2137
2.22k
    if (!isArray())
2138
5
      return None;
2139
2.21k
    return cast_or_null<Expr>(getTrailingObjects<Stmt *>()[arraySizeOffset()]);
2140
2.21k
  }
2141
2142
52.0k
  unsigned getNumPlacementArgs() const {
2143
52.0k
    return CXXNewExprBits.NumPlacementArgs;
2144
52.0k
  }
2145
2146
5.96k
  Expr **getPlacementArgs() {
2147
5.96k
    return reinterpret_cast<Expr **>(getTrailingObjects<Stmt *>() +
2148
5.96k
                                     placementNewArgsOffset());
2149
5.96k
  }
2150
2151
2.37k
  Expr *getPlacementArg(unsigned I) {
2152
2.37k
    assert((I < getNumPlacementArgs()) && "Index out of range!");
2153
2.37k
    return getPlacementArgs()[I];
2154
2.37k
  }
2155
2.34k
  const Expr *getPlacementArg(unsigned I) const {
2156
2.34k
    return const_cast<CXXNewExpr *>(this)->getPlacementArg(I);
2157
2.34k
  }
2158
2159
3.80k
  bool isParenTypeId() const { return CXXNewExprBits.IsParenTypeId; }
2160
3.58k
  SourceRange getTypeIdParens() const {
2161
3.58k
    return isParenTypeId() ? 
getTrailingObjects<SourceRange>()[0]7
2162
3.58k
                           : 
SourceRange()3.57k
;
2163
3.58k
  }
2164
2165
3.76k
  bool isGlobalNew() const { return CXXNewExprBits.IsGlobalNew; }
2166
2167
  /// Whether this new-expression has any initializer at all.
2168
87.9k
  bool hasInitializer() const {
2169
87.9k
    return CXXNewExprBits.StoredInitializationStyle > 0;
2170
87.9k
  }
2171
2172
  /// The kind of initializer this new-expression has.
2173
26.3k
  InitializationStyle getInitializationStyle() const {
2174
26.3k
    if (CXXNewExprBits.StoredInitializationStyle == 0)
2175
3.07k
      return NoInit;
2176
23.2k
    return static_cast<InitializationStyle>(
2177
23.2k
        CXXNewExprBits.StoredInitializationStyle - 1);
2178
23.2k
  }
2179
2180
  /// The initializer of this new-expression.
2181
9.23k
  Expr *getInitializer() {
2182
9.23k
    return hasInitializer()
2183
9.23k
               ? 
cast<Expr>(getTrailingObjects<Stmt *>()[initExprOffset()])7.90k
2184
9.23k
               : 
nullptr1.32k
;
2185
9.23k
  }
2186
8.82k
  const Expr *getInitializer() const {
2187
8.82k
    return hasInitializer()
2188
8.82k
               ? 
cast<Expr>(getTrailingObjects<Stmt *>()[initExprOffset()])7.57k
2189
8.82k
               : 
nullptr1.24k
;
2190
8.82k
  }
2191
2192
  /// Returns the CXXConstructExpr from this new-expression, or null.
2193
3.22k
  const CXXConstructExpr *getConstructExpr() const {
2194
3.22k
    return dyn_cast_or_null<CXXConstructExpr>(getInitializer());
2195
3.22k
  }
2196
2197
  /// Indicates whether the required alignment should be implicitly passed to
2198
  /// the allocation function.
2199
27.7k
  bool passAlignment() const { return CXXNewExprBits.ShouldPassAlignment; }
2200
2201
  /// Answers whether the usual array deallocation function for the
2202
  /// allocated type expects the size of the allocation as a
2203
  /// parameter.
2204
742
  bool doesUsualArrayDeleteWantSize() const {
2205
742
    return CXXNewExprBits.UsualArrayDeleteWantsSize;
2206
742
  }
2207
2208
  using arg_iterator = ExprIterator;
2209
  using const_arg_iterator = ConstExprIterator;
2210
2211
3
  llvm::iterator_range<arg_iterator> placement_arguments() {
2212
3
    return llvm::make_range(placement_arg_begin(), placement_arg_end());
2213
3
  }
2214
2215
5.05k
  llvm::iterator_range<const_arg_iterator> placement_arguments() const {
2216
5.05k
    return llvm::make_range(placement_arg_begin(), placement_arg_end());
2217
5.05k
  }
2218
2219
6.29k
  arg_iterator placement_arg_begin() {
2220
6.29k
    return getTrailingObjects<Stmt *>() + placementNewArgsOffset();
2221
6.29k
  }
2222
3.14k
  arg_iterator placement_arg_end() {
2223
3.14k
    return placement_arg_begin() + getNumPlacementArgs();
2224
3.14k
  }
2225
10.1k
  const_arg_iterator placement_arg_begin() const {
2226
10.1k
    return getTrailingObjects<Stmt *>() + placementNewArgsOffset();
2227
10.1k
  }
2228
5.06k
  const_arg_iterator placement_arg_end() const {
2229
5.06k
    return placement_arg_begin() + getNumPlacementArgs();
2230
5.06k
  }
2231
2232
  using raw_arg_iterator = Stmt **;
2233
2234
57.4k
  raw_arg_iterator raw_arg_begin() { return getTrailingObjects<Stmt *>(); }
2235
28.7k
  raw_arg_iterator raw_arg_end() {
2236
28.7k
    return raw_arg_begin() + numTrailingObjects(OverloadToken<Stmt *>());
2237
28.7k
  }
2238
0
  const_arg_iterator raw_arg_begin() const {
2239
0
    return getTrailingObjects<Stmt *>();
2240
0
  }
2241
0
  const_arg_iterator raw_arg_end() const {
2242
0
    return raw_arg_begin() + numTrailingObjects(OverloadToken<Stmt *>());
2243
0
  }
2244
2245
98.7k
  SourceLocation getBeginLoc() const { return Range.getBegin(); }
2246
1.17k
  SourceLocation getEndLoc() const { return Range.getEnd(); }
2247
2248
3.60k
  SourceRange getDirectInitRange() const { return DirectInitRange; }
2249
5.66k
  SourceRange getSourceRange() const { return Range; }
2250
2251
1.26M
  static bool classof(const Stmt *T) {
2252
1.26M
    return T->getStmtClass() == CXXNewExprClass;
2253
1.26M
  }
2254
2255
  // Iterators
2256
28.6k
  child_range children() { return child_range(raw_arg_begin(), raw_arg_end()); }
2257
2258
0
  const_child_range children() const {
2259
0
    return const_child_range(const_cast<CXXNewExpr *>(this)->children());
2260
0
  }
2261
};
2262
2263
/// Represents a \c delete expression for memory deallocation and
2264
/// destructor calls, e.g. "delete[] pArray".
2265
class CXXDeleteExpr : public Expr {
2266
  friend class ASTStmtReader;
2267
2268
  /// Points to the operator delete overload that is used. Could be a member.
2269
  FunctionDecl *OperatorDelete = nullptr;
2270
2271
  /// The pointer expression to be deleted.
2272
  Stmt *Argument = nullptr;
2273
2274
public:
2275
  CXXDeleteExpr(QualType Ty, bool GlobalDelete, bool ArrayForm,
2276
                bool ArrayFormAsWritten, bool UsualArrayDeleteWantsSize,
2277
                FunctionDecl *OperatorDelete, Expr *Arg, SourceLocation Loc)
2278
      : Expr(CXXDeleteExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
2279
             Arg->isInstantiationDependent(),
2280
             Arg->containsUnexpandedParameterPack()),
2281
6.55k
        OperatorDelete(OperatorDelete), Argument(Arg) {
2282
6.55k
    CXXDeleteExprBits.GlobalDelete = GlobalDelete;
2283
6.55k
    CXXDeleteExprBits.ArrayForm = ArrayForm;
2284
6.55k
    CXXDeleteExprBits.ArrayFormAsWritten = ArrayFormAsWritten;
2285
6.55k
    CXXDeleteExprBits.UsualArrayDeleteWantsSize = UsualArrayDeleteWantsSize;
2286
6.55k
    CXXDeleteExprBits.Loc = Loc;
2287
6.55k
  }
2288
2289
2
  explicit CXXDeleteExpr(EmptyShell Shell) : Expr(CXXDeleteExprClass, Shell) {}
2290
2291
1.58k
  bool isGlobalDelete() const { return CXXDeleteExprBits.GlobalDelete; }
2292
6.11k
  bool isArrayForm() const { return CXXDeleteExprBits.ArrayForm; }
2293
51
  bool isArrayFormAsWritten() const {
2294
51
    return CXXDeleteExprBits.ArrayFormAsWritten;
2295
51
  }
2296
2297
  /// Answers whether the usual array deallocation function for the
2298
  /// allocated type expects the size of the allocation as a
2299
  /// parameter.  This can be true even if the actual deallocation
2300
  /// function that we're using doesn't want a size.
2301
723
  bool doesUsualArrayDeleteWantSize() const {
2302
723
    return CXXDeleteExprBits.UsualArrayDeleteWantsSize;
2303
723
  }
2304
2305
4.84k
  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
2306
2307
2.51k
  Expr *getArgument() { return cast<Expr>(Argument); }
2308
8.15k
  const Expr *getArgument() const { return cast<Expr>(Argument); }
2309
2310
  /// Retrieve the type being destroyed.
2311
  ///
2312
  /// If the type being destroyed is a dependent type which may or may not
2313
  /// be a pointer, return an invalid type.
2314
  QualType getDestroyedType() const;
2315
2316
27.7k
  SourceLocation getBeginLoc() const { return CXXDeleteExprBits.Loc; }
2317
2.07k
  SourceLocation getEndLoc() const LLVM_READONLY {
2318
2.07k
    return Argument->getEndLoc();
2319
2.07k
  }
2320
2321
12.1k
  static bool classof(const Stmt *T) {
2322
12.1k
    return T->getStmtClass() == CXXDeleteExprClass;
2323
12.1k
  }
2324
2325
  // Iterators
2326
14.7k
  child_range children() { return child_range(&Argument, &Argument + 1); }
2327
2328
0
  const_child_range children() const {
2329
0
    return const_child_range(&Argument, &Argument + 1);
2330
0
  }
2331
};
2332
2333
/// Stores the type being destroyed by a pseudo-destructor expression.
2334
class PseudoDestructorTypeStorage {
2335
  /// Either the type source information or the name of the type, if
2336
  /// it couldn't be resolved due to type-dependence.
2337
  llvm::PointerUnion<TypeSourceInfo *, IdentifierInfo *> Type;
2338
2339
  /// The starting source location of the pseudo-destructor type.
2340
  SourceLocation Location;
2341
2342
public:
2343
7.97k
  PseudoDestructorTypeStorage() = default;
2344
2345
  PseudoDestructorTypeStorage(IdentifierInfo *II, SourceLocation Loc)
2346
6
      : Type(II), Location(Loc) {}
2347
2348
  PseudoDestructorTypeStorage(TypeSourceInfo *Info);
2349
2350
45.3k
  TypeSourceInfo *getTypeSourceInfo() const {
2351
45.3k
    return Type.dyn_cast<TypeSourceInfo *>();
2352
45.3k
  }
2353
2354
1.97k
  IdentifierInfo *getIdentifier() const {
2355
1.97k
    return Type.dyn_cast<IdentifierInfo *>();
2356
1.97k
  }
2357
2358
2.01k
  SourceLocation getLocation() const { return Location; }
2359
};
2360
2361
/// Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
2362
///
2363
/// A pseudo-destructor is an expression that looks like a member access to a
2364
/// destructor of a scalar type, except that scalar types don't have
2365
/// destructors. For example:
2366
///
2367
/// \code
2368
/// typedef int T;
2369
/// void f(int *p) {
2370
///   p->T::~T();
2371
/// }
2372
/// \endcode
2373
///
2374
/// Pseudo-destructors typically occur when instantiating templates such as:
2375
///
2376
/// \code
2377
/// template<typename T>
2378
/// void destroy(T* ptr) {
2379
///   ptr->T::~T();
2380
/// }
2381
/// \endcode
2382
///
2383
/// for scalar types. A pseudo-destructor expression has no run-time semantics
2384
/// beyond evaluating the base expression.
2385
class CXXPseudoDestructorExpr : public Expr {
2386
  friend class ASTStmtReader;
2387
2388
  /// The base expression (that is being destroyed).
2389
  Stmt *Base = nullptr;
2390
2391
  /// Whether the operator was an arrow ('->'); otherwise, it was a
2392
  /// period ('.').
2393
  bool IsArrow : 1;
2394
2395
  /// The location of the '.' or '->' operator.
2396
  SourceLocation OperatorLoc;
2397
2398
  /// The nested-name-specifier that follows the operator, if present.
2399
  NestedNameSpecifierLoc QualifierLoc;
2400
2401
  /// The type that precedes the '::' in a qualified pseudo-destructor
2402
  /// expression.
2403
  TypeSourceInfo *ScopeType = nullptr;
2404
2405
  /// The location of the '::' in a qualified pseudo-destructor
2406
  /// expression.
2407
  SourceLocation ColonColonLoc;
2408
2409
  /// The location of the '~'.
2410
  SourceLocation TildeLoc;
2411
2412
  /// The type being destroyed, or its name if we were unable to
2413
  /// resolve the name.
2414
  PseudoDestructorTypeStorage DestroyedType;
2415
2416
public:
2417
  CXXPseudoDestructorExpr(const ASTContext &Context,
2418
                          Expr *Base, bool isArrow, SourceLocation OperatorLoc,
2419
                          NestedNameSpecifierLoc QualifierLoc,
2420
                          TypeSourceInfo *ScopeType,
2421
                          SourceLocation ColonColonLoc,
2422
                          SourceLocation TildeLoc,
2423
                          PseudoDestructorTypeStorage DestroyedType);
2424
2425
  explicit CXXPseudoDestructorExpr(EmptyShell Shell)
2426
0
      : Expr(CXXPseudoDestructorExprClass, Shell), IsArrow(false) {}
2427
2428
2.45k
  Expr *getBase() const { return cast<Expr>(Base); }
2429
2430
  /// Determines whether this member expression actually had
2431
  /// a C++ nested-name-specifier prior to the name of the member, e.g.,
2432
  /// x->Base::foo.
2433
0
  bool hasQualifier() const { return QualifierLoc.hasQualifier(); }
2434
2435
  /// Retrieves the nested-name-specifier that qualifies the type name,
2436
  /// with source-location information.
2437
1.97k
  NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
2438
2439
  /// If the member name was qualified, retrieves the
2440
  /// nested-name-specifier that precedes the member name. Otherwise, returns
2441
  /// null.
2442
4.87k
  NestedNameSpecifier *getQualifier() const {
2443
4.87k
    return QualifierLoc.getNestedNameSpecifier();
2444
4.87k
  }
2445
2446
  /// Determine whether this pseudo-destructor expression was written
2447
  /// using an '->' (otherwise, it used a '.').
2448
8.80k
  bool isArrow() const { return IsArrow; }
2449
2450
  /// Retrieve the location of the '.' or '->' operator.
2451
3.93k
  SourceLocation getOperatorLoc() const { return OperatorLoc; }
2452
2453
  /// Retrieve the scope type in a qualified pseudo-destructor
2454
  /// expression.
2455
  ///
2456
  /// Pseudo-destructor expressions can have extra qualification within them
2457
  /// that is not part of the nested-name-specifier, e.g., \c p->T::~T().
2458
  /// Here, if the object type of the expression is (or may be) a scalar type,
2459
  /// \p T may also be a scalar type and, therefore, cannot be part of a
2460
  /// nested-name-specifier. It is stored as the "scope type" of the pseudo-
2461
  /// destructor expression.
2462
11.7k
  TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; }
2463
2464
  /// Retrieve the location of the '::' in a qualified pseudo-destructor
2465
  /// expression.
2466
1.96k
  SourceLocation getColonColonLoc() const { return ColonColonLoc; }
2467
2468
  /// Retrieve the location of the '~'.
2469
1.97k
  SourceLocation getTildeLoc() const { return TildeLoc; }
2470
2471
  /// Retrieve the source location information for the type
2472
  /// being destroyed.
2473
  ///
2474
  /// This type-source information is available for non-dependent
2475
  /// pseudo-destructor expressions and some dependent pseudo-destructor
2476
  /// expressions. Returns null if we only have the identifier for a
2477
  /// dependent pseudo-destructor expression.
2478
13.6k
  TypeSourceInfo *getDestroyedTypeInfo() const {
2479
13.6k
    return DestroyedType.getTypeSourceInfo();
2480
13.6k
  }
2481
2482
  /// In a dependent pseudo-destructor expression for which we do not
2483
  /// have full type information on the destroyed type, provides the name
2484
  /// of the destroyed type.
2485
16
  IdentifierInfo *getDestroyedTypeIdentifier() const {
2486
16
    return DestroyedType.getIdentifier();
2487
16
  }
2488
2489
  /// Retrieve the type being destroyed.
2490
  QualType getDestroyedType() const;
2491
2492
  /// Retrieve the starting location of the type being destroyed.
2493
9
  SourceLocation getDestroyedTypeLoc() const {
2494
9
    return DestroyedType.getLocation();
2495
9
  }
2496
2497
  /// Set the name of destroyed type for a dependent pseudo-destructor
2498
  /// expression.
2499
0
  void setDestroyedType(IdentifierInfo *II, SourceLocation Loc) {
2500
0
    DestroyedType = PseudoDestructorTypeStorage(II, Loc);
2501
0
  }
2502
2503
  /// Set the destroyed type.
2504
0
  void setDestroyedType(TypeSourceInfo *Info) {
2505
0
    DestroyedType = PseudoDestructorTypeStorage(Info);
2506
0
  }
2507
2508
15.5k
  SourceLocation getBeginLoc() const LLVM_READONLY {
2509
15.5k
    return Base->getBeginLoc();
2510
15.5k
  }
2511
  SourceLocation getEndLoc() const LLVM_READONLY;
2512
2513
5.64M
  static bool classof(const Stmt *T) {
2514
5.64M
    return T->getStmtClass() == CXXPseudoDestructorExprClass;
2515
5.64M
  }
2516
2517
  // Iterators
2518
7.25k
  child_range children() { return child_range(&Base, &Base + 1); }
2519
2520
0
  const_child_range children() const {
2521
0
    return const_child_range(&Base, &Base + 1);
2522
0
  }
2523
};
2524
2525
/// A type trait used in the implementation of various C++11 and
2526
/// Library TR1 trait templates.
2527
///
2528
/// \code
2529
///   __is_pod(int) == true
2530
///   __is_enum(std::string) == false
2531
///   __is_trivially_constructible(vector<int>, int*, int*)
2532
/// \endcode
2533
class TypeTraitExpr final
2534
    : public Expr,
2535
      private llvm::TrailingObjects<TypeTraitExpr, TypeSourceInfo *> {
2536
  /// The location of the type trait keyword.
2537
  SourceLocation Loc;
2538
2539
  ///  The location of the closing parenthesis.
2540
  SourceLocation RParenLoc;
2541
2542
  // Note: The TypeSourceInfos for the arguments are allocated after the
2543
  // TypeTraitExpr.
2544
2545
  TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind,
2546
                ArrayRef<TypeSourceInfo *> Args,
2547
                SourceLocation RParenLoc,
2548
                bool Value);
2549
2550
4
  TypeTraitExpr(EmptyShell Empty) : Expr(TypeTraitExprClass, Empty) {}
2551
2552
0
  size_t numTrailingObjects(OverloadToken<TypeSourceInfo *>) const {
2553
0
    return getNumArgs();
2554
0
  }
2555
2556
public:
2557
  friend class ASTStmtReader;
2558
  friend class ASTStmtWriter;
2559
  friend TrailingObjects;
2560
2561
  /// Create a new type trait expression.
2562
  static TypeTraitExpr *Create(const ASTContext &C, QualType T,
2563
                               SourceLocation Loc, TypeTrait Kind,
2564
                               ArrayRef<TypeSourceInfo *> Args,
2565
                               SourceLocation RParenLoc,
2566
                               bool Value);
2567
2568
  static TypeTraitExpr *CreateDeserialized(const ASTContext &C,
2569
                                           unsigned NumArgs);
2570
2571
  /// Determine which type trait this expression uses.
2572
512k
  TypeTrait getTrait() const {
2573
512k
    return static_cast<TypeTrait>(TypeTraitExprBits.Kind);
2574
512k
  }
2575
2576
174k
  bool getValue() const {
2577
174k
    assert(!isValueDependent());
2578
174k
    return TypeTraitExprBits.Value;
2579
174k
  }
2580
2581
  /// Determine the number of arguments to this type trait.
2582
1.67M
  unsigned getNumArgs() const { return TypeTraitExprBits.NumArgs; }
2583
2584
  /// Retrieve the Ith argument.
2585
876k
  TypeSourceInfo *getArg(unsigned I) const {
2586
876k
    assert(I < getNumArgs() && "Argument out-of-range");
2587
876k
    return getArgs()[I];
2588
876k
  }
2589
2590
  /// Retrieve the argument types.
2591
876k
  ArrayRef<TypeSourceInfo *> getArgs() const {
2592
876k
    return llvm::makeArrayRef(getTrailingObjects<TypeSourceInfo *>(),
2593
876k
                              getNumArgs());
2594
876k
  }
2595
2596
844k
  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
2597
223k
  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
2598
2599
0
  static bool classof(const Stmt *T) {
2600
0
    return T->getStmtClass() == TypeTraitExprClass;
2601
0
  }
2602
2603
  // Iterators
2604
294k
  child_range children() {
2605
294k
    return child_range(child_iterator(), child_iterator());
2606
294k
  }
2607
2608
0
  const_child_range children() const {
2609
0
    return const_child_range(const_child_iterator(), const_child_iterator());
2610
0
  }
2611
};
2612
2613
/// An Embarcadero array type trait, as used in the implementation of
2614
/// __array_rank and __array_extent.
2615
///
2616
/// Example:
2617
/// \code
2618
///   __array_rank(int[10][20]) == 2
2619
///   __array_extent(int, 1)    == 20
2620
/// \endcode
2621
class ArrayTypeTraitExpr : public Expr {
2622
  /// The trait. An ArrayTypeTrait enum in MSVC compat unsigned.
2623
  unsigned ATT : 2;
2624
2625
  /// The value of the type trait. Unspecified if dependent.
2626
  uint64_t Value = 0;
2627
2628
  /// The array dimension being queried, or -1 if not used.
2629
  Expr *Dimension;
2630
2631
  /// The location of the type trait keyword.
2632
  SourceLocation Loc;
2633
2634
  /// The location of the closing paren.
2635
  SourceLocation RParen;
2636
2637
  /// The type being queried.
2638
  TypeSourceInfo *QueriedType = nullptr;
2639
2640
public:
2641
  friend class ASTStmtReader;
2642
2643
  ArrayTypeTraitExpr(SourceLocation loc, ArrayTypeTrait att,
2644
                     TypeSourceInfo *queried, uint64_t value,
2645
                     Expr *dimension, SourceLocation rparen, QualType ty)
2646
      : Expr(ArrayTypeTraitExprClass, ty, VK_RValue, OK_Ordinary,
2647
             false, queried->getType()->isDependentType(),
2648
             (queried->getType()->isInstantiationDependentType() ||
2649
              (dimension && dimension->isInstantiationDependent())),
2650
             queried->getType()->containsUnexpandedParameterPack()),
2651
        ATT(att), Value(value), Dimension(dimension),
2652
19
        Loc(loc), RParen(rparen), QueriedType(queried) {}
2653
2654
  explicit ArrayTypeTraitExpr(EmptyShell Empty)
2655
2
      : Expr(ArrayTypeTraitExprClass, Empty), ATT(0) {}
2656
2657
33
  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
2658
4
  SourceLocation getEndLoc() const LLVM_READONLY { return RParen; }
2659
2660
4
  ArrayTypeTrait getTrait() const { return static_cast<ArrayTypeTrait>(ATT); }
2661
2662
0
  QualType getQueriedType() const { return QueriedType->getType(); }
2663
2664
4
  TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; }
2665
2666
25
  uint64_t getValue() const { assert(!isTypeDependent()); return Value; }
2667
2668
4
  Expr *getDimensionExpression() const { return Dimension; }
2669
2670
0
  static bool classof(const Stmt *T) {
2671
0
    return T->getStmtClass() == ArrayTypeTraitExprClass;
2672
0
  }
2673
2674
  // Iterators
2675
6
  child_range children() {
2676
6
    return child_range(child_iterator(), child_iterator());
2677
6
  }
2678
2679
0
  const_child_range children() const {
2680
0
    return const_child_range(const_child_iterator(), const_child_iterator());
2681
0
  }
2682
};
2683
2684
/// An expression trait intrinsic.
2685
///
2686
/// Example:
2687
/// \code
2688
///   __is_lvalue_expr(std::cout) == true
2689
///   __is_lvalue_expr(1) == false
2690
/// \endcode
2691
class ExpressionTraitExpr : public Expr {
2692
  /// The trait. A ExpressionTrait enum in MSVC compatible unsigned.
2693
  unsigned ET : 31;
2694
2695
  /// The value of the type trait. Unspecified if dependent.
2696
  unsigned Value : 1;
2697
2698
  /// The location of the type trait keyword.
2699
  SourceLocation Loc;
2700
2701
  /// The location of the closing paren.
2702
  SourceLocation RParen;
2703
2704
  /// The expression being queried.
2705
  Expr* QueriedExpression = nullptr;
2706
2707
public:
2708
  friend class ASTStmtReader;
2709
2710
  ExpressionTraitExpr(SourceLocation loc, ExpressionTrait et,
2711
                     Expr *queried, bool value,
2712
                     SourceLocation rparen, QualType resultType)
2713
      : Expr(ExpressionTraitExprClass, resultType, VK_RValue, OK_Ordinary,
2714
             false, // Not type-dependent
2715
             // Value-dependent if the argument is type-dependent.
2716
             queried->isTypeDependent(),
2717
             queried->isInstantiationDependent(),
2718
             queried->containsUnexpandedParameterPack()),
2719
        ET(et), Value(value), Loc(loc), RParen(rparen),
2720
430
        QueriedExpression(queried) {}
2721
2722
  explicit ExpressionTraitExpr(EmptyShell Empty)
2723
1
      : Expr(ExpressionTraitExprClass, Empty), ET(0), Value(false) {}
2724
2725
1.07k
  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
2726
2
  SourceLocation getEndLoc() const LLVM_READONLY { return RParen; }
2727
2728
2
  ExpressionTrait getTrait() const { return static_cast<ExpressionTrait>(ET); }
2729
2730
2
  Expr *getQueriedExpression() const { return QueriedExpression; }
2731
2732
428
  bool getValue() const { return Value; }
2733
2734
0
  static bool classof(const Stmt *T) {
2735
0
    return T->getStmtClass() == ExpressionTraitExprClass;
2736
0
  }
2737
2738
  // Iterators
2739
5
  child_range children() {
2740
5
    return child_range(child_iterator(), child_iterator());
2741
5
  }
2742
2743
0
  const_child_range children() const {
2744
0
    return const_child_range(const_child_iterator(), const_child_iterator());
2745
0
  }
2746
};
2747
2748
/// A reference to an overloaded function set, either an
2749
/// \c UnresolvedLookupExpr or an \c UnresolvedMemberExpr.
2750
class OverloadExpr : public Expr {
2751
  friend class ASTStmtReader;
2752
  friend class ASTStmtWriter;
2753
2754
  /// The common name of these declarations.
2755
  DeclarationNameInfo NameInfo;
2756
2757
  /// The nested-name-specifier that qualifies the name, if any.
2758
  NestedNameSpecifierLoc QualifierLoc;
2759
2760
protected:
2761
  OverloadExpr(StmtClass SC, const ASTContext &Context,
2762
               NestedNameSpecifierLoc QualifierLoc,
2763
               SourceLocation TemplateKWLoc,
2764
               const DeclarationNameInfo &NameInfo,
2765
               const TemplateArgumentListInfo *TemplateArgs,
2766
               UnresolvedSetIterator Begin, UnresolvedSetIterator End,
2767
               bool KnownDependent, bool KnownInstantiationDependent,
2768
               bool KnownContainsUnexpandedParameterPack);
2769
2770
  OverloadExpr(StmtClass SC, EmptyShell Empty, unsigned NumResults,
2771
               bool HasTemplateKWAndArgsInfo);
2772
2773
  /// Return the results. Defined after UnresolvedMemberExpr.
2774
  inline DeclAccessPair *getTrailingResults();
2775
3.59M
  const DeclAccessPair *getTrailingResults() const {
2776
3.59M
    return const_cast<OverloadExpr *>(this)->getTrailingResults();
2777
3.59M
  }
2778
2779
  /// Return the optional template keyword and arguments info.
2780
  /// Defined after UnresolvedMemberExpr.
2781
  inline ASTTemplateKWAndArgsInfo *getTrailingASTTemplateKWAndArgsInfo();
2782
5.44M
  const ASTTemplateKWAndArgsInfo *getTrailingASTTemplateKWAndArgsInfo() const {
2783
5.44M
    return const_cast<OverloadExpr *>(this)
2784
5.44M
        ->getTrailingASTTemplateKWAndArgsInfo();
2785
5.44M
  }
2786
2787
  /// Return the optional template arguments. Defined after
2788
  /// UnresolvedMemberExpr.
2789
  inline TemplateArgumentLoc *getTrailingTemplateArgumentLoc();
2790
0
  const TemplateArgumentLoc *getTrailingTemplateArgumentLoc() const {
2791
0
    return const_cast<OverloadExpr *>(this)->getTrailingTemplateArgumentLoc();
2792
0
  }
2793
2794
16.1M
  bool hasTemplateKWAndArgsInfo() const {
2795
16.1M
    return OverloadExprBits.HasTemplateKWAndArgsInfo;
2796
16.1M
  }
2797
2798
public:
2799
  struct FindResult {
2800
    OverloadExpr *Expression;
2801
    bool IsAddressOfOperand;
2802
    bool HasFormOfMemberPointer;
2803
  };
2804
2805
  /// Finds the overloaded expression in the given expression \p E of
2806
  /// OverloadTy.
2807
  ///
2808
  /// \return the expression (which must be there) and true if it has
2809
  /// the particular form of a member pointer expression
2810
1.00M
  static FindResult find(Expr *E) {
2811
1.00M
    assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload));
2812
1.00M
2813
1.00M
    FindResult Result;
2814
1.00M
2815
1.00M
    E = E->IgnoreParens();
2816
1.00M
    if (isa<UnaryOperator>(E)) {
2817
1.99k
      assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf);
2818
1.99k
      E = cast<UnaryOperator>(E)->getSubExpr();
2819
1.99k
      auto *Ovl = cast<OverloadExpr>(E->IgnoreParens());
2820
1.99k
2821
1.99k
      Result.HasFormOfMemberPointer = (E == Ovl && 
Ovl->getQualifier()1.96k
);
2822
1.99k
      Result.IsAddressOfOperand = true;
2823
1.99k
      Result.Expression = Ovl;
2824
999k
    } else {
2825
999k
      Result.HasFormOfMemberPointer = false;
2826
999k
      Result.IsAddressOfOperand = false;
2827
999k
      Result.Expression = cast<OverloadExpr>(E);
2828
999k
    }
2829
1.00M
2830
1.00M
    return Result;
2831
1.00M
  }
2832
2833
  /// Gets the naming class of this lookup, if any.
2834
  /// Defined after UnresolvedMemberExpr.
2835
  inline CXXRecordDecl *getNamingClass();
2836
0
  const CXXRecordDecl *getNamingClass() const {
2837
0
    return const_cast<OverloadExpr *>(this)->getNamingClass();
2838
0
  }
2839
2840
  using decls_iterator = UnresolvedSetImpl::iterator;
2841
2842
1.79M
  decls_iterator decls_begin() const {
2843
1.79M
    return UnresolvedSetIterator(getTrailingResults());
2844
1.79M
  }
2845
1.79M
  decls_iterator decls_end() const {
2846
1.79M
    return UnresolvedSetIterator(getTrailingResults() + getNumDecls());
2847
1.79M
  }
2848
407k
  llvm::iterator_range<decls_iterator> decls() const {
2849
407k
    return llvm::make_range(decls_begin(), decls_end());
2850
407k
  }
2851
2852
  /// Gets the number of declarations in the unresolved set.
2853
9.93M
  unsigned getNumDecls() const { return OverloadExprBits.NumResults; }
2854
2855
  /// Gets the full name info.
2856
5.12M
  const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
2857
2858
  /// Gets the name looked up.
2859
1.41M
  DeclarationName getName() const { return NameInfo.getName(); }
2860
2861
  /// Gets the location of the name.
2862
3.93M
  SourceLocation getNameLoc() const { return NameInfo.getLoc(); }
2863
2864
  /// Fetches the nested-name qualifier, if one was given.
2865
632k
  NestedNameSpecifier *getQualifier() const {
2866
632k
    return QualifierLoc.getNestedNameSpecifier();
2867
632k
  }
2868
2869
  /// Fetches the nested-name qualifier with source-location
2870
  /// information, if one was given.
2871
6.93M
  NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
2872
2873
  /// Retrieve the location of the template keyword preceding
2874
  /// this name, if any.
2875
1.44M
  SourceLocation getTemplateKeywordLoc() const {
2876
1.44M
    if (!hasTemplateKWAndArgsInfo())
2877
1.05M
      return SourceLocation();
2878
387k
    return getTrailingASTTemplateKWAndArgsInfo()->TemplateKWLoc;
2879
387k
  }
2880
2881
  /// Retrieve the location of the left angle bracket starting the
2882
  /// explicit template argument list following the name, if any.
2883
7.10M
  SourceLocation getLAngleLoc() const {
2884
7.10M
    if (!hasTemplateKWAndArgsInfo())
2885
3.32M
      return SourceLocation();
2886
3.77M
    return getTrailingASTTemplateKWAndArgsInfo()->LAngleLoc;
2887
3.77M
  }
2888
2889
  /// Retrieve the location of the right angle bracket ending the
2890
  /// explicit template argument list following the name, if any.
2891
383k
  SourceLocation getRAngleLoc() const {
2892
383k
    if (!hasTemplateKWAndArgsInfo())
2893
0
      return SourceLocation();
2894
383k
    return getTrailingASTTemplateKWAndArgsInfo()->RAngleLoc;
2895
383k
  }
2896
2897
  /// Determines whether the name was preceded by the template keyword.
2898
27
  bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); }
2899
2900
  /// Determines whether this expression had explicit template arguments.
2901
6.92M
  bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
2902
2903
897k
  TemplateArgumentLoc const *getTemplateArgs() const {
2904
897k
    if (!hasExplicitTemplateArgs())
2905
23
      return nullptr;
2906
897k
    return const_cast<OverloadExpr *>(this)->getTrailingTemplateArgumentLoc();
2907
897k
  }
2908
2909
477k
  unsigned getNumTemplateArgs() const {
2910
477k
    if (!hasExplicitTemplateArgs())
2911
23
      return 0;
2912
477k
2913
477k
    return getTrailingASTTemplateKWAndArgsInfo()->NumTemplateArgs;
2914
477k
  }
2915
2916
22
  ArrayRef<TemplateArgumentLoc> template_arguments() const {
2917
22
    return {getTemplateArgs(), getNumTemplateArgs()};
2918
22
  }
2919
2920
  /// Copies the template arguments into the given structure.
2921
419k
  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
2922
419k
    if (hasExplicitTemplateArgs())
2923
419k
      getTrailingASTTemplateKWAndArgsInfo()->copyInto(getTemplateArgs(), List);
2924
419k
  }
2925
2926
4.16k
  static bool classof(const Stmt *T) {
2927
4.16k
    return T->getStmtClass() == UnresolvedLookupExprClass ||
2928
4.16k
           
T->getStmtClass() == UnresolvedMemberExprClass3.31k
;
2929
4.16k
  }
2930
};
2931
2932
/// A reference to a name which we were able to look up during
2933
/// parsing but could not resolve to a specific declaration.
2934
///
2935
/// This arises in several ways:
2936
///   * we might be waiting for argument-dependent lookup;
2937
///   * the name might resolve to an overloaded function;
2938
/// and eventually:
2939
///   * the lookup might have included a function template.
2940
///
2941
/// These never include UnresolvedUsingValueDecls, which are always class
2942
/// members and therefore appear only in UnresolvedMemberLookupExprs.
2943
class UnresolvedLookupExpr final
2944
    : public OverloadExpr,
2945
      private llvm::TrailingObjects<UnresolvedLookupExpr, DeclAccessPair,
2946
                                    ASTTemplateKWAndArgsInfo,
2947
                                    TemplateArgumentLoc> {
2948
  friend class ASTStmtReader;
2949
  friend class OverloadExpr;
2950
  friend TrailingObjects;
2951
2952
  /// The naming class (C++ [class.access.base]p5) of the lookup, if
2953
  /// any.  This can generally be recalculated from the context chain,
2954
  /// but that can be fairly expensive for unqualified lookups.
2955
  CXXRecordDecl *NamingClass;
2956
2957
  // UnresolvedLookupExpr is followed by several trailing objects.
2958
  // They are in order:
2959
  //
2960
  // * An array of getNumResults() DeclAccessPair for the results. These are
2961
  //   undesugared, which is to say, they may include UsingShadowDecls.
2962
  //   Access is relative to the naming class.
2963
  //
2964
  // * An optional ASTTemplateKWAndArgsInfo for the explicitly specified
2965
  //   template keyword and arguments. Present if and only if
2966
  //   hasTemplateKWAndArgsInfo().
2967
  //
2968
  // * An array of getNumTemplateArgs() TemplateArgumentLoc containing
2969
  //   location information for the explicitly specified template arguments.
2970
2971
  UnresolvedLookupExpr(const ASTContext &Context, CXXRecordDecl *NamingClass,
2972
                       NestedNameSpecifierLoc QualifierLoc,
2973
                       SourceLocation TemplateKWLoc,
2974
                       const DeclarationNameInfo &NameInfo, bool RequiresADL,
2975
                       bool Overloaded,
2976
                       const TemplateArgumentListInfo *TemplateArgs,
2977
                       UnresolvedSetIterator Begin, UnresolvedSetIterator End);
2978
2979
  UnresolvedLookupExpr(EmptyShell Empty, unsigned NumResults,
2980
                       bool HasTemplateKWAndArgsInfo);
2981
2982
7.19M
  unsigned numTrailingObjects(OverloadToken<DeclAccessPair>) const {
2983
7.19M
    return getNumDecls();
2984
7.19M
  }
2985
2986
1.33M
  unsigned numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
2987
1.33M
    return hasTemplateKWAndArgsInfo();
2988
1.33M
  }
2989
2990
public:
2991
  static UnresolvedLookupExpr *
2992
  Create(const ASTContext &Context, CXXRecordDecl *NamingClass,
2993
         NestedNameSpecifierLoc QualifierLoc,
2994
         const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded,
2995
         UnresolvedSetIterator Begin, UnresolvedSetIterator End);
2996
2997
  static UnresolvedLookupExpr *
2998
  Create(const ASTContext &Context, CXXRecordDecl *NamingClass,
2999
         NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
3000
         const DeclarationNameInfo &NameInfo, bool RequiresADL,
3001
         const TemplateArgumentListInfo *Args, UnresolvedSetIterator Begin,
3002
         UnresolvedSetIterator End);
3003
3004
  static UnresolvedLookupExpr *CreateEmpty(const ASTContext &Context,
3005
                                           unsigned NumResults,
3006
                                           bool HasTemplateKWAndArgsInfo,
3007
                                           unsigned NumTemplateArgs);
3008
3009
  /// True if this declaration should be extended by
3010
  /// argument-dependent lookup.
3011
1.59M
  bool requiresADL() const { return UnresolvedLookupExprBits.RequiresADL; }
3012
3013
  /// True if this lookup is overloaded.
3014
16.5k
  bool isOverloaded() const { return UnresolvedLookupExprBits.Overloaded; }
3015
3016
  /// Gets the 'naming class' (in the sense of C++0x
3017
  /// [class.access.base]p5) of the lookup.  This is the scope
3018
  /// that was looked in to find these results.
3019
1.30M
  CXXRecordDecl *getNamingClass() { return NamingClass; }
3020
0
  const CXXRecordDecl *getNamingClass() const { return NamingClass; }
3021
3022
4.77M
  SourceLocation getBeginLoc() const LLVM_READONLY {
3023
4.77M
    if (NestedNameSpecifierLoc l = getQualifierLoc())
3024
1.45M
      return l.getBeginLoc();
3025
3.31M
    return getNameInfo().getBeginLoc();
3026
3.31M
  }
3027
3028
280k
  SourceLocation getEndLoc() const LLVM_READONLY {
3029
280k
    if (hasExplicitTemplateArgs())
3030
204k
      return getRAngleLoc();
3031
75.5k
    return getNameInfo().getEndLoc();
3032
75.5k
  }
3033
3034
413k
  child_range children() {
3035
413k
    return child_range(child_iterator(), child_iterator());
3036
413k
  }
3037
3038
0
  const_child_range children() const {
3039
0
    return const_child_range(const_child_iterator(), const_child_iterator());
3040
0
  }
3041
3042
21.2M
  static bool classof(const Stmt *T) {
3043
21.2M
    return T->getStmtClass() == UnresolvedLookupExprClass;
3044
21.2M
  }
3045
};
3046
3047
/// A qualified reference to a name whose declaration cannot
3048
/// yet be resolved.
3049
///
3050
/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that
3051
/// it expresses a reference to a declaration such as
3052
/// X<T>::value. The difference, however, is that an
3053
/// DependentScopeDeclRefExpr node is used only within C++ templates when
3054
/// the qualification (e.g., X<T>::) refers to a dependent type. In
3055
/// this case, X<T>::value cannot resolve to a declaration because the
3056
/// declaration will differ from one instantiation of X<T> to the
3057
/// next. Therefore, DependentScopeDeclRefExpr keeps track of the
3058
/// qualifier (X<T>::) and the name of the entity being referenced
3059
/// ("value"). Such expressions will instantiate to a DeclRefExpr once the
3060
/// declaration can be found.
3061
class DependentScopeDeclRefExpr final
3062
    : public Expr,
3063
      private llvm::TrailingObjects<DependentScopeDeclRefExpr,
3064
                                    ASTTemplateKWAndArgsInfo,
3065
                                    TemplateArgumentLoc> {
3066
  friend class ASTStmtReader;
3067
  friend class ASTStmtWriter;
3068
  friend TrailingObjects;
3069
3070
  /// The nested-name-specifier that qualifies this unresolved
3071
  /// declaration name.
3072
  NestedNameSpecifierLoc QualifierLoc;
3073
3074
  /// The name of the entity we will be referencing.
3075
  DeclarationNameInfo NameInfo;
3076
3077
  DependentScopeDeclRefExpr(QualType Ty, NestedNameSpecifierLoc QualifierLoc,
3078
                            SourceLocation TemplateKWLoc,
3079
                            const DeclarationNameInfo &NameInfo,
3080
                            const TemplateArgumentListInfo *Args);
3081
3082
149k
  size_t numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
3083
149k
    return hasTemplateKWAndArgsInfo();
3084
149k
  }
3085
3086
10.2M
  bool hasTemplateKWAndArgsInfo() const {
3087
10.2M
    return DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo;
3088
10.2M
  }
3089
3090
public:
3091
  static DependentScopeDeclRefExpr *
3092
  Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc,
3093
         SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo,
3094
         const TemplateArgumentListInfo *TemplateArgs);
3095
3096
  static DependentScopeDeclRefExpr *CreateEmpty(const ASTContext &Context,
3097
                                                bool HasTemplateKWAndArgsInfo,
3098
                                                unsigned NumTemplateArgs);
3099
3100
  /// Retrieve the name that this expression refers to.
3101
1.46M
  const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
3102
3103
  /// Retrieve the name that this expression refers to.
3104
3.36M
  DeclarationName getDeclName() const { return NameInfo.getName(); }
3105
3106
  /// Retrieve the location of the name within the expression.
3107
  ///
3108
  /// For example, in "X<T>::value" this is the location of "value".
3109
69.1k
  SourceLocation getLocation() const { return NameInfo.getLoc(); }
3110
3111
  /// Retrieve the nested-name-specifier that qualifies the
3112
  /// name, with source location information.
3113
2.87M
  NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3114
3115
  /// Retrieve the nested-name-specifier that qualifies this
3116
  /// declaration.
3117
3.36M
  NestedNameSpecifier *getQualifier() const {
3118
3.36M
    return QualifierLoc.getNestedNameSpecifier();
3119
3.36M
  }
3120
3121
  /// Retrieve the location of the template keyword preceding
3122
  /// this name, if any.
3123
1.46M
  SourceLocation getTemplateKeywordLoc() const {
3124
1.46M
    if (!hasTemplateKWAndArgsInfo())
3125
1.41M
      return SourceLocation();
3126
41.1k
    return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->TemplateKWLoc;
3127
41.1k
  }
3128
3129
  /// Retrieve the location of the left angle bracket starting the
3130
  /// explicit template argument list following the name, if any.
3131
8.56M
  SourceLocation getLAngleLoc() const {
3132
8.56M
    if (!hasTemplateKWAndArgsInfo())
3133
8.05M
      return SourceLocation();
3134
504k
    return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->LAngleLoc;
3135
504k
  }
3136
3137
  /// Retrieve the location of the right angle bracket ending the
3138
  /// explicit template argument list following the name, if any.
3139
62.0k
  SourceLocation getRAngleLoc() const {
3140
62.0k
    if (!hasTemplateKWAndArgsInfo())
3141
4
      return SourceLocation();
3142
62.0k
    return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->RAngleLoc;
3143
62.0k
  }
3144
3145
  /// Determines whether the name was preceded by the template keyword.
3146
140
  bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); }
3147
3148
  /// Determines whether this lookup had explicit template arguments.
3149
8.52M
  bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
3150
3151
  /// Copies the template arguments (if present) into the given
3152
  /// structure.
3153
0
  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
3154
0
    if (hasExplicitTemplateArgs())
3155
0
      getTrailingObjects<ASTTemplateKWAndArgsInfo>()->copyInto(
3156
0
          getTrailingObjects<TemplateArgumentLoc>(), List);
3157
0
  }
3158
3159
140k
  TemplateArgumentLoc const *getTemplateArgs() const {
3160
140k
    if (!hasExplicitTemplateArgs())
3161
19.4k
      return nullptr;
3162
120k
3163
120k
    return getTrailingObjects<TemplateArgumentLoc>();
3164
120k
  }
3165
3166
140k
  unsigned getNumTemplateArgs() const {
3167
140k
    if (!hasExplicitTemplateArgs())
3168
19.4k
      return 0;
3169
120k
3170
120k
    return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
3171
120k
  }
3172
3173
10
  ArrayRef<TemplateArgumentLoc> template_arguments() const {
3174
10
    return {getTemplateArgs(), getNumTemplateArgs()};
3175
10
  }
3176
3177
  /// Note: getBeginLoc() is the start of the whole DependentScopeDeclRefExpr,
3178
  /// and differs from getLocation().getStart().
3179
1.78M
  SourceLocation getBeginLoc() const LLVM_READONLY {
3180
1.78M
    return QualifierLoc.getBeginLoc();
3181
1.78M
  }
3182
3183
90.0k
  SourceLocation getEndLoc() const LLVM_READONLY {
3184
90.0k
    if (hasExplicitTemplateArgs())
3185
20.9k
      return getRAngleLoc();
3186
69.1k
    return getLocation();
3187
69.1k
  }
3188
3189
61.0k
  static bool classof(const Stmt *T) {
3190
61.0k
    return T->getStmtClass() == DependentScopeDeclRefExprClass;
3191
61.0k
  }
3192
3193
3.46M
  child_range children() {
3194
3.46M
    return child_range(child_iterator(), child_iterator());
3195
3.46M
  }
3196
3197
0
  const_child_range children() const {
3198
0
    return const_child_range(const_child_iterator(), const_child_iterator());
3199
0
  }
3200
};
3201
3202
/// Represents an expression -- generally a full-expression -- that
3203
/// introduces cleanups to be run at the end of the sub-expression's
3204
/// evaluation.  The most common source of expression-introduced
3205
/// cleanups is temporary objects in C++, but several other kinds of
3206
/// expressions can create cleanups, including basically every
3207
/// call in ARC that returns an Objective-C pointer.
3208
///
3209
/// This expression also tracks whether the sub-expression contains a
3210
/// potentially-evaluated block literal.  The lifetime of a block
3211
/// literal is the extent of the enclosing scope.
3212
class ExprWithCleanups final
3213
    : public FullExpr,
3214
      private llvm::TrailingObjects<ExprWithCleanups, BlockDecl *> {
3215
public:
3216
  /// The type of objects that are kept in the cleanup.
3217
  /// It's useful to remember the set of blocks;  we could also
3218
  /// remember the set of temporaries, but there's currently
3219
  /// no need.
3220
  using CleanupObject = BlockDecl *;
3221
3222
private:
3223
  friend class ASTStmtReader;
3224
  friend TrailingObjects;
3225
3226
  ExprWithCleanups(EmptyShell, unsigned NumObjects);
3227
  ExprWithCleanups(Expr *SubExpr, bool CleanupsHaveSideEffects,
3228
                   ArrayRef<CleanupObject> Objects);
3229
3230
public:
3231
  static ExprWithCleanups *Create(const ASTContext &C, EmptyShell empty,
3232
                                  unsigned numObjects);
3233
3234
  static ExprWithCleanups *Create(const ASTContext &C, Expr *subexpr,
3235
                                  bool CleanupsHaveSideEffects,
3236
                                  ArrayRef<CleanupObject> objects);
3237
3238
975
  ArrayRef<CleanupObject> getObjects() const {
3239
975
    return llvm::makeArrayRef(getTrailingObjects<CleanupObject>(),
3240
975
                              getNumObjects());
3241
975
  }
3242
3243
45.2k
  unsigned getNumObjects() const { return ExprWithCleanupsBits.NumObjects; }
3244
3245
32
  CleanupObject getObject(unsigned i) const {
3246
32
    assert(i < getNumObjects() && "Index out of range");
3247
32
    return getObjects()[i];
3248
32
  }
3249
3250
16.7k
  bool cleanupsHaveSideEffects() const {
3251
16.7k
    return ExprWithCleanupsBits.CleanupsHaveSideEffects;
3252
16.7k
  }
3253
3254
42.5k
  SourceLocation getBeginLoc() const LLVM_READONLY {
3255
42.5k
    return SubExpr->getBeginLoc();
3256
42.5k
  }
3257
3258
10.4k
  SourceLocation getEndLoc() const LLVM_READONLY {
3259
10.4k
    return SubExpr->getEndLoc();
3260
10.4k
  }
3261
3262
  // Implement isa/cast/dyncast/etc.
3263
2.52M
  static bool classof(const Stmt *T) {
3264
2.52M
    return T->getStmtClass() == ExprWithCleanupsClass;
3265
2.52M
  }
3266
3267
  // Iterators
3268
64.7k
  child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
3269
3270
0
  const_child_range children() const {
3271
0
    return const_child_range(&SubExpr, &SubExpr + 1);
3272
0
  }
3273
};
3274
3275
/// Describes an explicit type conversion that uses functional
3276
/// notion but could not be resolved because one or more arguments are
3277
/// type-dependent.
3278
///
3279
/// The explicit type conversions expressed by
3280
/// CXXUnresolvedConstructExpr have the form <tt>T(a1, a2, ..., aN)</tt>,
3281
/// where \c T is some type and \c a1, \c a2, ..., \c aN are values, and
3282
/// either \c T is a dependent type or one or more of the <tt>a</tt>'s is
3283
/// type-dependent. For example, this would occur in a template such
3284
/// as:
3285
///
3286
/// \code
3287
///   template<typename T, typename A1>
3288
///   inline T make_a(const A1& a1) {
3289
///     return T(a1);
3290
///   }
3291
/// \endcode
3292
///
3293
/// When the returned expression is instantiated, it may resolve to a
3294
/// constructor call, conversion function call, or some kind of type
3295
/// conversion.
3296
class CXXUnresolvedConstructExpr final
3297
    : public Expr,
3298
      private llvm::TrailingObjects<CXXUnresolvedConstructExpr, Expr *> {
3299
  friend class ASTStmtReader;
3300
  friend TrailingObjects;
3301
3302
  /// The type being constructed.
3303
  TypeSourceInfo *TSI;
3304
3305
  /// The location of the left parentheses ('(').
3306
  SourceLocation LParenLoc;
3307
3308
  /// The location of the right parentheses (')').
3309
  SourceLocation RParenLoc;
3310
3311
  CXXUnresolvedConstructExpr(TypeSourceInfo *TSI, SourceLocation LParenLoc,
3312
                             ArrayRef<Expr *> Args, SourceLocation RParenLoc);
3313
3314
  CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs)
3315
823
      : Expr(CXXUnresolvedConstructExprClass, Empty) {
3316
823
    CXXUnresolvedConstructExprBits.NumArgs = NumArgs;
3317
823
  }
3318
3319
public:
3320
  static CXXUnresolvedConstructExpr *Create(const ASTContext &Context,
3321
                                            TypeSourceInfo *Type,
3322
                                            SourceLocation LParenLoc,
3323
                                            ArrayRef<Expr *> Args,
3324
                                            SourceLocation RParenLoc);
3325
3326
  static CXXUnresolvedConstructExpr *CreateEmpty(const ASTContext &Context,
3327
                                                 unsigned NumArgs);
3328
3329
  /// Retrieve the type that is being constructed, as specified
3330
  /// in the source code.
3331
46.6k
  QualType getTypeAsWritten() const { return TSI->getType(); }
3332
3333
  /// Retrieve the type source information for the type being
3334
  /// constructed.
3335
112k
  TypeSourceInfo *getTypeSourceInfo() const { return TSI; }
3336
3337
  /// Retrieve the location of the left parentheses ('(') that
3338
  /// precedes the argument list.
3339
54.4k
  SourceLocation getLParenLoc() const { return LParenLoc; }
3340
823
  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
3341
3342
  /// Retrieve the location of the right parentheses (')') that
3343
  /// follows the argument list.
3344
54.4k
  SourceLocation getRParenLoc() const { return RParenLoc; }
3345
823
  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
3346
3347
  /// Determine whether this expression models list-initialization.
3348
  /// If so, there will be exactly one subexpression, which will be
3349
  /// an InitListExpr.
3350
150k
  bool isListInitialization() const { return LParenLoc.isInvalid(); }
3351
3352
  /// Retrieve the number of arguments.
3353
184k
  unsigned arg_size() const { return CXXUnresolvedConstructExprBits.NumArgs; }
3354
3355
  using arg_iterator = Expr **;
3356
  using arg_range = llvm::iterator_range<arg_iterator>;
3357
3358
126k
  arg_iterator arg_begin() { return getTrailingObjects<Expr *>(); }
3359
1.58k
  arg_iterator arg_end() { return arg_begin() + arg_size(); }
3360
0
  arg_range arguments() { return arg_range(arg_begin(), arg_end()); }
3361
3362
  using const_arg_iterator = const Expr* const *;
3363
  using const_arg_range = llvm::iterator_range<const_arg_iterator>;
3364
3365
2.30k
  const_arg_iterator arg_begin() const { return getTrailingObjects<Expr *>(); }
3366
7
  const_arg_iterator arg_end() const { return arg_begin() + arg_size(); }
3367
7
  const_arg_range arguments() const {
3368
7
    return const_arg_range(arg_begin(), arg_end());
3369
7
  }
3370
3371
0
  Expr *getArg(unsigned I) {
3372
0
    assert(I < arg_size() && "Argument index out-of-range");
3373
0
    return arg_begin()[I];
3374
0
  }
3375
3376
2.29k
  const Expr *getArg(unsigned I) const {
3377
2.29k
    assert(I < arg_size() && "Argument index out-of-range");
3378
2.29k
    return arg_begin()[I];
3379
2.29k
  }
3380
3381
68
  void setArg(unsigned I, Expr *E) {
3382
68
    assert(I < arg_size() && "Argument index out-of-range");
3383
68
    arg_begin()[I] = E;
3384
68
  }
3385
3386
  SourceLocation getBeginLoc() const LLVM_READONLY;
3387
9.42k
  SourceLocation getEndLoc() const LLVM_READONLY {
3388
9.42k
    if (!RParenLoc.isValid() && 
arg_size() > 02.26k
)
3389
2.26k
      return getArg(arg_size() - 1)->getEndLoc();
3390
7.16k
    return RParenLoc;
3391
7.16k
  }
3392
3393
3.61k
  static bool classof(const Stmt *T) {
3394
3.61k
    return T->getStmtClass() == CXXUnresolvedConstructExprClass;
3395
3.61k
  }
3396
3397
  // Iterators
3398
70.4k
  child_range children() {
3399
70.4k
    auto **begin = reinterpret_cast<Stmt **>(arg_begin());
3400
70.4k
    return child_range(begin, begin + arg_size());
3401
70.4k
  }
3402
3403
0
  const_child_range children() const {
3404
0
    auto **begin = reinterpret_cast<Stmt **>(
3405
0
        const_cast<CXXUnresolvedConstructExpr *>(this)->arg_begin());
3406
0
    return const_child_range(begin, begin + arg_size());
3407
0
  }
3408
};
3409
3410
/// Represents a C++ member access expression where the actual
3411
/// member referenced could not be resolved because the base
3412
/// expression or the member name was dependent.
3413
///
3414
/// Like UnresolvedMemberExprs, these can be either implicit or
3415
/// explicit accesses.  It is only possible to get one of these with
3416
/// an implicit access if a qualifier is provided.
3417
class CXXDependentScopeMemberExpr final
3418
    : public Expr,
3419
      private llvm::TrailingObjects<CXXDependentScopeMemberExpr,
3420
                                    ASTTemplateKWAndArgsInfo,
3421
                                    TemplateArgumentLoc, NamedDecl *> {
3422
  friend class ASTStmtReader;
3423
  friend class ASTStmtWriter;
3424
  friend TrailingObjects;
3425
3426
  /// The expression for the base pointer or class reference,
3427
  /// e.g., the \c x in x.f.  Can be null in implicit accesses.
3428
  Stmt *Base;
3429
3430
  /// The type of the base expression.  Never null, even for
3431
  /// implicit accesses.
3432
  QualType BaseType;
3433
3434
  /// The nested-name-specifier that precedes the member name, if any.
3435
  /// FIXME: This could be in principle store as a trailing object.
3436
  /// However the performance impact of doing so should be investigated first.
3437
  NestedNameSpecifierLoc QualifierLoc;
3438
3439
  /// The member to which this member expression refers, which
3440
  /// can be name, overloaded operator, or destructor.
3441
  ///
3442
  /// FIXME: could also be a template-id
3443
  DeclarationNameInfo MemberNameInfo;
3444
3445
  // CXXDependentScopeMemberExpr is followed by several trailing objects,
3446
  // some of which optional. They are in order:
3447
  //
3448
  // * An optional ASTTemplateKWAndArgsInfo for the explicitly specified
3449
  //   template keyword and arguments. Present if and only if
3450
  //   hasTemplateKWAndArgsInfo().
3451
  //
3452
  // * An array of getNumTemplateArgs() TemplateArgumentLoc containing location
3453
  //   information for the explicitly specified template arguments.
3454
  //
3455
  // * An optional NamedDecl *. In a qualified member access expression such
3456
  //   as t->Base::f, this member stores the resolves of name lookup in the
3457
  //   context of the member access expression, to be used at instantiation
3458
  //   time. Present if and only if hasFirstQualifierFoundInScope().
3459
3460
749k
  bool hasTemplateKWAndArgsInfo() const {
3461
749k
    return CXXDependentScopeMemberExprBits.HasTemplateKWAndArgsInfo;
3462
749k
  }
3463
3464
1.79M
  bool hasFirstQualifierFoundInScope() const {
3465
1.79M
    return CXXDependentScopeMemberExprBits.HasFirstQualifierFoundInScope;
3466
1.79M
  }
3467
3468
2.09k
  unsigned numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
3469
2.09k
    return hasTemplateKWAndArgsInfo();
3470
2.09k
  }
3471
3472
117
  unsigned numTrailingObjects(OverloadToken<TemplateArgumentLoc>) const {
3473
117
    return getNumTemplateArgs();
3474
117
  }
3475
3476
0
  unsigned numTrailingObjects(OverloadToken<NamedDecl *>) const {
3477
0
    return hasFirstQualifierFoundInScope();
3478
0
  }
3479
3480
  CXXDependentScopeMemberExpr(const ASTContext &Ctx, Expr *Base,
3481
                              QualType BaseType, bool IsArrow,
3482
                              SourceLocation OperatorLoc,
3483
                              NestedNameSpecifierLoc QualifierLoc,
3484
                              SourceLocation TemplateKWLoc,
3485
                              NamedDecl *FirstQualifierFoundInScope,
3486
                              DeclarationNameInfo MemberNameInfo,
3487
                              const TemplateArgumentListInfo *TemplateArgs);
3488
3489
  CXXDependentScopeMemberExpr(EmptyShell Empty, bool HasTemplateKWAndArgsInfo,
3490
                              bool HasFirstQualifierFoundInScope);
3491
3492
public:
3493
  static CXXDependentScopeMemberExpr *
3494
  Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow,
3495
         SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc,
3496
         SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope,
3497
         DeclarationNameInfo MemberNameInfo,
3498
         const TemplateArgumentListInfo *TemplateArgs);
3499
3500
  static CXXDependentScopeMemberExpr *
3501
  CreateEmpty(const ASTContext &Ctx, bool HasTemplateKWAndArgsInfo,
3502
              unsigned NumTemplateArgs, bool HasFirstQualifierFoundInScope);
3503
3504
  /// True if this is an implicit access, i.e. one in which the
3505
  /// member being accessed was not written in the source.  The source
3506
  /// location of the operator is invalid in this case.
3507
2.52M
  bool isImplicitAccess() const {
3508
2.52M
    if (!Base)
3509
381k
      return true;
3510
2.14M
    return cast<Expr>(Base)->isImplicitCXXThis();
3511
2.14M
  }
3512
3513
  /// Retrieve the base object of this member expressions,
3514
  /// e.g., the \c x in \c x.m.
3515
234k
  Expr *getBase() const {
3516
234k
    assert(!isImplicitAccess());
3517
234k
    return cast<Expr>(Base);
3518
234k
  }
3519
3520
72.7k
  QualType getBaseType() const { return BaseType; }
3521
3522
  /// Determine whether this member expression used the '->'
3523
  /// operator; otherwise, it used the '.' operator.
3524
553k
  bool isArrow() const { return CXXDependentScopeMemberExprBits.IsArrow; }
3525
3526
  /// Retrieve the location of the '->' or '.' operator.
3527
501k
  SourceLocation getOperatorLoc() const {
3528
501k
    return CXXDependentScopeMemberExprBits.OperatorLoc;
3529
501k
  }
3530
3531
  /// Retrieve the nested-name-specifier that qualifies the member name.
3532
645k
  NestedNameSpecifier *getQualifier() const {
3533
645k
    return QualifierLoc.getNestedNameSpecifier();
3534
645k
  }
3535
3536
  /// Retrieve the nested-name-specifier that qualifies the member
3537
  /// name, with source location information.
3538
619k
  NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3539
3540
  /// Retrieve the first part of the nested-name-specifier that was
3541
  /// found in the scope of the member access expression when the member access
3542
  /// was initially parsed.
3543
  ///
3544
  /// This function only returns a useful result when member access expression
3545
  /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration
3546
  /// returned by this function describes what was found by unqualified name
3547
  /// lookup for the identifier "Base" within the scope of the member access
3548
  /// expression itself. At template instantiation time, this information is
3549
  /// combined with the results of name lookup into the type of the object
3550
  /// expression itself (the class type of x).
3551
268k
  NamedDecl *getFirstQualifierFoundInScope() const {
3552
268k
    if (!hasFirstQualifierFoundInScope())
3553
268k
      return nullptr;
3554
59
    return *getTrailingObjects<NamedDecl *>();
3555
59
  }
3556
3557
  /// Retrieve the name of the member that this expression refers to.
3558
273k
  const DeclarationNameInfo &getMemberNameInfo() const {
3559
273k
    return MemberNameInfo;
3560
273k
  }
3561
3562
  /// Retrieve the name of the member that this expression refers to.
3563
65.9k
  DeclarationName getMember() const { return MemberNameInfo.getName(); }
3564
3565
  // Retrieve the location of the name of the member that this
3566
  // expression refers to.
3567
16
  SourceLocation getMemberLoc() const { return MemberNameInfo.getLoc(); }
3568
3569
  /// Retrieve the location of the template keyword preceding the
3570
  /// member name, if any.
3571
269k
  SourceLocation getTemplateKeywordLoc() const {
3572
269k
    if (!hasTemplateKWAndArgsInfo())
3573
269k
      return SourceLocation();
3574
231
    return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->TemplateKWLoc;
3575
231
  }
3576
3577
  /// Retrieve the location of the left angle bracket starting the
3578
  /// explicit template argument list following the member name, if any.
3579
475k
  SourceLocation getLAngleLoc() const {
3580
475k
    if (!hasTemplateKWAndArgsInfo())
3581
474k
      return SourceLocation();
3582
848
    return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->LAngleLoc;
3583
848
  }
3584
3585
  /// Retrieve the location of the right angle bracket ending the
3586
  /// explicit template argument list following the member name, if any.
3587
194
  SourceLocation getRAngleLoc() const {
3588
194
    if (!hasTemplateKWAndArgsInfo())
3589
0
      return SourceLocation();
3590
194
    return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->RAngleLoc;
3591
194
  }
3592
3593
  /// Determines whether the member name was preceded by the template keyword.
3594
1.30k
  bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); }
3595
3596
  /// Determines whether this member expression actually had a C++
3597
  /// template argument list explicitly specified, e.g., x.f<int>.
3598
475k
  bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
3599
3600
  /// Copies the template arguments (if present) into the given
3601
  /// structure.
3602
0
  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
3603
0
    if (hasExplicitTemplateArgs())
3604
0
      getTrailingObjects<ASTTemplateKWAndArgsInfo>()->copyInto(
3605
0
          getTrailingObjects<TemplateArgumentLoc>(), List);
3606
0
  }
3607
3608
  /// Retrieve the template arguments provided as part of this
3609
  /// template-id.
3610
678
  const TemplateArgumentLoc *getTemplateArgs() const {
3611
678
    if (!hasExplicitTemplateArgs())
3612
478
      return nullptr;
3613
200
3614
200
    return getTrailingObjects<TemplateArgumentLoc>();
3615
200
  }
3616
3617
  /// Retrieve the number of template arguments provided as part of this
3618
  /// template-id.
3619
1.70k
  unsigned getNumTemplateArgs() const {
3620
1.70k
    if (!hasExplicitTemplateArgs())
3621
1.49k
      return 0;
3622
209
3623
209
    return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
3624
209
  }
3625
3626
3
  ArrayRef<TemplateArgumentLoc> template_arguments() const {
3627
3
    return {getTemplateArgs(), getNumTemplateArgs()};
3628
3
  }
3629
3630
2.01M
  SourceLocation getBeginLoc() const LLVM_READONLY {
3631
2.01M
    if (!isImplicitAccess())
3632
1.70M
      return Base->getBeginLoc();
3633
309k
    if (getQualifier())
3634
309k
      return getQualifierLoc().getBeginLoc();
3635
3
    return MemberNameInfo.getBeginLoc();
3636
3
  }
3637
3638
63.8k
  SourceLocation getEndLoc() const LLVM_READONLY {
3639
63.8k
    if (hasExplicitTemplateArgs())
3640
5
      return getRAngleLoc();
3641
63.8k
    return MemberNameInfo.getEndLoc();
3642
63.8k
  }
3643
3644
7.97k
  static bool classof(const Stmt *T) {
3645
7.97k
    return T->getStmtClass() == CXXDependentScopeMemberExprClass;
3646
7.97k
  }
3647
3648
  // Iterators
3649
105k
  child_range children() {
3650
105k
    if (isImplicitAccess())
3651
5.53k
      return child_range(child_iterator(), child_iterator());
3652
99.9k
    return child_range(&Base, &Base + 1);
3653
99.9k
  }
3654
3655
0
  const_child_range children() const {
3656
0
    if (isImplicitAccess())
3657
0
      return const_child_range(const_child_iterator(), const_child_iterator());
3658
0
    return const_child_range(&Base, &Base + 1);
3659
0
  }
3660
};
3661
3662
/// Represents a C++ member access expression for which lookup
3663
/// produced a set of overloaded functions.
3664
///
3665
/// The member access may be explicit or implicit:
3666
/// \code
3667
///    struct A {
3668
///      int a, b;
3669
///      int explicitAccess() { return this->a + this->A::b; }
3670
///      int implicitAccess() { return a + A::b; }
3671
///    };
3672
/// \endcode
3673
///
3674
/// In the final AST, an explicit access always becomes a MemberExpr.
3675
/// An implicit access may become either a MemberExpr or a
3676
/// DeclRefExpr, depending on whether the member is static.
3677
class UnresolvedMemberExpr final
3678
    : public OverloadExpr,
3679
      private llvm::TrailingObjects<UnresolvedMemberExpr, DeclAccessPair,
3680
                                    ASTTemplateKWAndArgsInfo,
3681
                                    TemplateArgumentLoc> {
3682
  friend class ASTStmtReader;
3683
  friend class OverloadExpr;
3684
  friend TrailingObjects;
3685
3686
  /// The expression for the base pointer or class reference,
3687
  /// e.g., the \c x in x.f.
3688
  ///
3689
  /// This can be null if this is an 'unbased' member expression.
3690
  Stmt *Base;
3691
3692
  /// The type of the base expression; never null.
3693
  QualType BaseType;
3694
3695
  /// The location of the '->' or '.' operator.
3696
  SourceLocation OperatorLoc;
3697
3698
  // UnresolvedMemberExpr is followed by several trailing objects.
3699
  // They are in order:
3700
  //
3701
  // * An array of getNumResults() DeclAccessPair for the results. These are
3702
  //   undesugared, which is to say, they may include UsingShadowDecls.
3703
  //   Access is relative to the naming class.
3704
  //
3705
  // * An optional ASTTemplateKWAndArgsInfo for the explicitly specified
3706
  //   template keyword and arguments. Present if and only if
3707
  //   hasTemplateKWAndArgsInfo().
3708
  //
3709
  // * An array of getNumTemplateArgs() TemplateArgumentLoc containing
3710
  //   location information for the explicitly specified template arguments.
3711
3712
  UnresolvedMemberExpr(const ASTContext &Context, bool HasUnresolvedUsing,
3713
                       Expr *Base, QualType BaseType, bool IsArrow,
3714
                       SourceLocation OperatorLoc,
3715
                       NestedNameSpecifierLoc QualifierLoc,
3716
                       SourceLocation TemplateKWLoc,
3717
                       const DeclarationNameInfo &MemberNameInfo,
3718
                       const TemplateArgumentListInfo *TemplateArgs,
3719
                       UnresolvedSetIterator Begin, UnresolvedSetIterator End);
3720
3721
  UnresolvedMemberExpr(EmptyShell Empty, unsigned NumResults,
3722
                       bool HasTemplateKWAndArgsInfo);
3723
3724
30.2k
  unsigned numTrailingObjects(OverloadToken<DeclAccessPair>) const {
3725
30.2k
    return getNumDecls();
3726
30.2k
  }
3727
3728
7.29k
  unsigned numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
3729
7.29k
    return hasTemplateKWAndArgsInfo();
3730
7.29k
  }
3731
3732
public:
3733
  static UnresolvedMemberExpr *
3734
  Create(const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base,
3735
         QualType BaseType, bool IsArrow, SourceLocation OperatorLoc,
3736
         NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
3737
         const DeclarationNameInfo &MemberNameInfo,
3738
         const TemplateArgumentListInfo *TemplateArgs,
3739
         UnresolvedSetIterator Begin, UnresolvedSetIterator End);
3740
3741
  static UnresolvedMemberExpr *CreateEmpty(const ASTContext &Context,
3742
                                           unsigned NumResults,
3743
                                           bool HasTemplateKWAndArgsInfo,
3744
                                           unsigned NumTemplateArgs);
3745
3746
  /// True if this is an implicit access, i.e., one in which the
3747
  /// member being accessed was not written in the source.
3748
  ///
3749
  /// The source location of the operator is invalid in this case.
3750
  bool isImplicitAccess() const;
3751
3752
  /// Retrieve the base object of this member expressions,
3753
  /// e.g., the \c x in \c x.m.
3754
198k
  Expr *getBase() {
3755
198k
    assert(!isImplicitAccess());
3756
198k
    return cast<Expr>(Base);
3757
198k
  }
3758
10
  const Expr *getBase() const {
3759
10
    assert(!isImplicitAccess());
3760
10
    return cast<Expr>(Base);
3761
10
  }
3762
3763
391k
  QualType getBaseType() const { return BaseType; }
3764
3765
  /// Determine whether the lookup results contain an unresolved using
3766
  /// declaration.
3767
13
  bool hasUnresolvedUsing() const {
3768
13
    return UnresolvedMemberExprBits.HasUnresolvedUsing;
3769
13
  }
3770
3771
  /// Determine whether this member expression used the '->'
3772
  /// operator; otherwise, it used the '.' operator.
3773
497k
  bool isArrow() const { return UnresolvedMemberExprBits.IsArrow; }
3774
3775
  /// Retrieve the location of the '->' or '.' operator.
3776
194k
  SourceLocation getOperatorLoc() const { return OperatorLoc; }
3777
3778
  /// Retrieve the naming class of this lookup.
3779
  CXXRecordDecl *getNamingClass();
3780
66
  const CXXRecordDecl *getNamingClass() const {
3781
66
    return const_cast<UnresolvedMemberExpr *>(this)->getNamingClass();
3782
66
  }
3783
3784
  /// Retrieve the full name info for the member that this expression
3785
  /// refers to.
3786
822k
  const DeclarationNameInfo &getMemberNameInfo() const { return getNameInfo(); }
3787
3788
  /// Retrieve the name of the member that this expression refers to.
3789
163k
  DeclarationName getMemberName() const { return getName(); }
3790
3791
  /// Retrieve the location of the name of the member that this
3792
  /// expression refers to.
3793
446k
  SourceLocation getMemberLoc() const { return getNameLoc(); }
3794
3795
  /// Return the preferred location (the member name) for the arrow when
3796
  /// diagnosing a problem with this expression.
3797
163k
  SourceLocation getExprLoc() const LLVM_READONLY { return getMemberLoc(); }
3798
3799
701k
  SourceLocation getBeginLoc() const LLVM_READONLY {
3800
701k
    if (!isImplicitAccess())
3801
183k
      return Base->getBeginLoc();
3802
517k
    if (NestedNameSpecifierLoc l = getQualifierLoc())
3803
26.9k
      return l.getBeginLoc();
3804
490k
    return getMemberNameInfo().getBeginLoc();
3805
490k
  }
3806
3807
137k
  SourceLocation getEndLoc() const LLVM_READONLY {
3808
137k
    if (hasExplicitTemplateArgs())
3809
320
      return getRAngleLoc();
3810
136k
    return getMemberNameInfo().getEndLoc();
3811
136k
  }
3812
3813
2.47M
  static bool classof(const Stmt *T) {
3814
2.47M
    return T->getStmtClass() == UnresolvedMemberExprClass;
3815
2.47M
  }
3816
3817
  // Iterators
3818
8.53k
  child_range children() {
3819
8.53k
    if (isImplicitAccess())
3820
6.13k
      return child_range(child_iterator(), child_iterator());
3821
2.39k
    return child_range(&Base, &Base + 1);
3822
2.39k
  }
3823
3824
0
  const_child_range children() const {
3825
0
    if (isImplicitAccess())
3826
0
      return const_child_range(const_child_iterator(), const_child_iterator());
3827
0
    return const_child_range(&Base, &Base + 1);
3828
0
  }
3829
};
3830
3831
6.34M
DeclAccessPair *OverloadExpr::getTrailingResults() {
3832
6.34M
  if (auto *ULE = dyn_cast<UnresolvedLookupExpr>(this))
3833
5.55M
    return ULE->getTrailingObjects<DeclAccessPair>();
3834
795k
  return cast<UnresolvedMemberExpr>(this)->getTrailingObjects<DeclAccessPair>();
3835
795k
}
3836
3837
5.88M
ASTTemplateKWAndArgsInfo *OverloadExpr::getTrailingASTTemplateKWAndArgsInfo() {
3838
5.88M
  if (!hasTemplateKWAndArgsInfo())
3839
0
    return nullptr;
3840
5.88M
3841
5.88M
  if (auto *ULE = dyn_cast<UnresolvedLookupExpr>(this))
3842
5.86M
    return ULE->getTrailingObjects<ASTTemplateKWAndArgsInfo>();
3843
22.9k
  return cast<UnresolvedMemberExpr>(this)
3844
22.9k
      ->getTrailingObjects<ASTTemplateKWAndArgsInfo>();
3845
22.9k
}
3846
3847
1.33M
TemplateArgumentLoc *OverloadExpr::getTrailingTemplateArgumentLoc() {
3848
1.33M
  if (auto *ULE = dyn_cast<UnresolvedLookupExpr>(this))
3849
1.33M
    return ULE->getTrailingObjects<TemplateArgumentLoc>();
3850
7.29k
  return cast<UnresolvedMemberExpr>(this)
3851
7.29k
      ->getTrailingObjects<TemplateArgumentLoc>();
3852
7.29k
}
3853
3854
62
CXXRecordDecl *OverloadExpr::getNamingClass() {
3855
62
  if (auto *ULE = dyn_cast<UnresolvedLookupExpr>(this))
3856
62
    return ULE->getNamingClass();
3857
0
  return cast<UnresolvedMemberExpr>(this)->getNamingClass();
3858
0
}
3859
3860
/// Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
3861
///
3862
/// The noexcept expression tests whether a given expression might throw. Its
3863
/// result is a boolean constant.
3864
class CXXNoexceptExpr : public Expr {
3865
  friend class ASTStmtReader;
3866
3867
  Stmt *Operand;
3868
  SourceRange Range;
3869
3870
public:
3871
  CXXNoexceptExpr(QualType Ty, Expr *Operand, CanThrowResult Val,
3872
                  SourceLocation Keyword, SourceLocation RParen)
3873
      : Expr(CXXNoexceptExprClass, Ty, VK_RValue, OK_Ordinary,
3874
             /*TypeDependent*/ false,
3875
             /*ValueDependent*/ Val == CT_Dependent,
3876
             Val == CT_Dependent || Operand->isInstantiationDependent(),
3877
             Operand->containsUnexpandedParameterPack()),
3878
18.8k
        Operand(Operand), Range(Keyword, RParen) {
3879
18.8k
    CXXNoexceptExprBits.Value = Val == CT_Cannot;
3880
18.8k
  }
3881
3882
3
  CXXNoexceptExpr(EmptyShell Empty) : Expr(CXXNoexceptExprClass, Empty) {}
3883
3884
987
  Expr *getOperand() const { return static_cast<Expr *>(Operand); }
3885
3886
23.7k
  SourceLocation getBeginLoc() const { return Range.getBegin(); }
3887
11
  SourceLocation getEndLoc() const { return Range.getEnd(); }
3888
496
  SourceRange getSourceRange() const { return Range; }
3889
3890
1.20k
  bool getValue() const { return CXXNoexceptExprBits.Value; }
3891
3892
3.59k
  static bool classof(const Stmt *T) {
3893
3.59k
    return T->getStmtClass() == CXXNoexceptExprClass;
3894
3.59k
  }
3895
3896
  // Iterators
3897
140k
  child_range children() { return child_range(&Operand, &Operand + 1); }
3898
3899
0
  const_child_range children() const {
3900
0
    return const_child_range(&Operand, &Operand + 1);
3901
0
  }
3902
};
3903
3904
/// Represents a C++11 pack expansion that produces a sequence of
3905
/// expressions.
3906
///
3907
/// A pack expansion expression contains a pattern (which itself is an
3908
/// expression) followed by an ellipsis. For example:
3909
///
3910
/// \code
3911
/// template<typename F, typename ...Types>
3912
/// void forward(F f, Types &&...args) {
3913
///   f(static_cast<Types&&>(args)...);
3914
/// }
3915
/// \endcode
3916
///
3917
/// Here, the argument to the function object \c f is a pack expansion whose
3918
/// pattern is \c static_cast<Types&&>(args). When the \c forward function
3919
/// template is instantiated, the pack expansion will instantiate to zero or
3920
/// or more function arguments to the function object \c f.
3921
class PackExpansionExpr : public Expr {
3922
  friend class ASTStmtReader;
3923
  friend class ASTStmtWriter;
3924
3925
  SourceLocation EllipsisLoc;
3926
3927
  /// The number of expansions that will be produced by this pack
3928
  /// expansion expression, if known.
3929
  ///
3930
  /// When zero, the number of expansions is not known. Otherwise, this value
3931
  /// is the number of expansions + 1.
3932
  unsigned NumExpansions;
3933
3934
  Stmt *Pattern;
3935
3936
public:
3937
  PackExpansionExpr(QualType T, Expr *Pattern, SourceLocation EllipsisLoc,
3938
                    Optional<unsigned> NumExpansions)
3939
      : Expr(PackExpansionExprClass, T, Pattern->getValueKind(),
3940
             Pattern->getObjectKind(), /*TypeDependent=*/true,
3941
             /*ValueDependent=*/true, /*InstantiationDependent=*/true,
3942
             /*ContainsUnexpandedParameterPack=*/false),
3943
        EllipsisLoc(EllipsisLoc),
3944
        NumExpansions(NumExpansions ? *NumExpansions + 1 : 0),
3945
137k
        Pattern(Pattern) {}
3946
3947
38
  PackExpansionExpr(EmptyShell Empty) : Expr(PackExpansionExprClass, Empty) {}
3948
3949
  /// Retrieve the pattern of the pack expansion.
3950
115k
  Expr *getPattern() { return reinterpret_cast<Expr *>(Pattern); }
3951
3952
  /// Retrieve the pattern of the pack expansion.
3953
6.98k
  const Expr *getPattern() const { return reinterpret_cast<Expr *>(Pattern); }
3954
3955
  /// Retrieve the location of the ellipsis that describes this pack
3956
  /// expansion.
3957
94.4k
  SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
3958
3959
  /// Determine the number of expansions that will be produced when
3960
  /// this pack expansion is instantiated, if already known.
3961
93.9k
  Optional<unsigned> getNumExpansions() const {
3962
93.9k
    if (NumExpansions)
3963
15
      return NumExpansions - 1;
3964
93.8k
3965
93.8k
    return None;
3966
93.8k
  }
3967
3968
45.0k
  SourceLocation getBeginLoc() const LLVM_READONLY {
3969
45.0k
    return Pattern->getBeginLoc();
3970
45.0k
  }
3971
3972
2
  SourceLocation getEndLoc() const LLVM_READONLY { return EllipsisLoc; }
3973
3974
7.45M
  static bool classof(const Stmt *T) {
3975
7.45M
    return T->getStmtClass() == PackExpansionExprClass;
3976
7.45M
  }
3977
3978
  // Iterators
3979
213k
  child_range children() {
3980
213k
    return child_range(&Pattern, &Pattern + 1);
3981
213k
  }
3982
3983
0
  const_child_range children() const {
3984
0
    return const_child_range(&Pattern, &Pattern + 1);
3985
0
  }
3986
};
3987
3988
/// Represents an expression that computes the length of a parameter
3989
/// pack.
3990
///
3991
/// \code
3992
/// template<typename ...Types>
3993
/// struct count {
3994
///   static const unsigned value = sizeof...(Types);
3995
/// };
3996
/// \endcode
3997
class SizeOfPackExpr final
3998
    : public Expr,
3999
      private llvm::TrailingObjects<SizeOfPackExpr, TemplateArgument> {
4000
  friend class ASTStmtReader;
4001
  friend class ASTStmtWriter;
4002
  friend TrailingObjects;
4003
4004
  /// The location of the \c sizeof keyword.
4005
  SourceLocation OperatorLoc;
4006
4007
  /// The location of the name of the parameter pack.
4008
  SourceLocation PackLoc;
4009
4010
  /// The location of the closing parenthesis.
4011
  SourceLocation RParenLoc;
4012
4013
  /// The length of the parameter pack, if known.
4014
  ///
4015
  /// When this expression is not value-dependent, this is the length of
4016
  /// the pack. When the expression was parsed rather than instantiated
4017
  /// (and thus is value-dependent), this is zero.
4018
  ///
4019
  /// After partial substitution into a sizeof...(X) expression (for instance,
4020
  /// within an alias template or during function template argument deduction),
4021
  /// we store a trailing array of partially-substituted TemplateArguments,
4022
  /// and this is the length of that array.
4023
  unsigned Length;
4024
4025
  /// The parameter pack.
4026
  NamedDecl *Pack = nullptr;
4027
4028
  /// Create an expression that computes the length of
4029
  /// the given parameter pack.
4030
  SizeOfPackExpr(QualType SizeType, SourceLocation OperatorLoc, NamedDecl *Pack,
4031
                 SourceLocation PackLoc, SourceLocation RParenLoc,
4032
                 Optional<unsigned> Length, ArrayRef<TemplateArgument> PartialArgs)
4033
      : Expr(SizeOfPackExprClass, SizeType, VK_RValue, OK_Ordinary,
4034
             /*TypeDependent=*/false, /*ValueDependent=*/!Length,
4035
             /*InstantiationDependent=*/!Length,
4036
             /*ContainsUnexpandedParameterPack=*/false),
4037
        OperatorLoc(OperatorLoc), PackLoc(PackLoc), RParenLoc(RParenLoc),
4038
90.7k
        Length(Length ? *Length : PartialArgs.size()), Pack(Pack) {
4039
90.7k
    assert((!Length || PartialArgs.empty()) &&
4040
90.7k
           "have partial args for non-dependent sizeof... expression");
4041
90.7k
    auto *Args = getTrailingObjects<TemplateArgument>();
4042
90.7k
    std::uninitialized_copy(PartialArgs.begin(), PartialArgs.end(), Args);
4043
90.7k
  }
4044
4045
  /// Create an empty expression.
4046
  SizeOfPackExpr(EmptyShell Empty, unsigned NumPartialArgs)
4047
0
      : Expr(SizeOfPackExprClass, Empty), Length(NumPartialArgs) {}
4048
4049
public:
4050
  static SizeOfPackExpr *Create(ASTContext &Context, SourceLocation OperatorLoc,
4051
                                NamedDecl *Pack, SourceLocation PackLoc,
4052
                                SourceLocation RParenLoc,
4053
                                Optional<unsigned> Length = None,
4054
                                ArrayRef<TemplateArgument> PartialArgs = None);
4055
  static SizeOfPackExpr *CreateDeserialized(ASTContext &Context,
4056
                                            unsigned NumPartialArgs);
4057
4058
  /// Determine the location of the 'sizeof' keyword.
4059
108k
  SourceLocation getOperatorLoc() const { return OperatorLoc; }
4060
4061
  /// Determine the location of the parameter pack.
4062
176k
  SourceLocation getPackLoc() const { return PackLoc; }
4063
4064
  /// Determine the location of the right parenthesis.
4065
54.0k
  SourceLocation getRParenLoc() const { return RParenLoc; }
4066
4067
  /// Retrieve the parameter pack.
4068
360k
  NamedDecl *getPack() const { return Pack; }
4069
4070
  /// Retrieve the length of the parameter pack.
4071
  ///
4072
  /// This routine may only be invoked when the expression is not
4073
  /// value-dependent.
4074
41.0k
  unsigned getPackLength() const {
4075
41.0k
    assert(!isValueDependent() &&
4076
41.0k
           "Cannot get the length of a value-dependent pack size expression");
4077
41.0k
    return Length;
4078
41.0k
  }
4079
4080
  /// Determine whether this represents a partially-substituted sizeof...
4081
  /// expression, such as is produced for:
4082
  ///
4083
  ///   template<typename ...Ts> using X = int[sizeof...(Ts)];
4084
  ///   template<typename ...Us> void f(X<Us..., 1, 2, 3, Us...>);
4085
264k
  bool isPartiallySubstituted() const {
4086
264k
    return isValueDependent() && 
Length246k
;
4087
264k
  }
4088
4089
  /// Get
4090
1.23k
  ArrayRef<TemplateArgument> getPartialArguments() const {
4091
1.23k
    assert(isPartiallySubstituted());
4092
1.23k
    const auto *Args = getTrailingObjects<TemplateArgument>();
4093
1.23k
    return llvm::makeArrayRef(Args, Args + Length);
4094
1.23k
  }
4095
4096
221k
  SourceLocation getBeginLoc() const LLVM_READONLY { return OperatorLoc; }
4097
24.6k
  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
4098
4099
11.9k
  static bool classof(const Stmt *T) {
4100
11.9k
    return T->getStmtClass() == SizeOfPackExprClass;
4101
11.9k
  }
4102
4103
  // Iterators
4104
212k
  child_range children() {
4105
212k
    return child_range(child_iterator(), child_iterator());
4106
212k
  }
4107
4108
0
  const_child_range children() const {
4109
0
    return const_child_range(const_child_iterator(), const_child_iterator());
4110
0
  }
4111
};
4112
4113
/// Represents a reference to a non-type template parameter
4114
/// that has been substituted with a template argument.
4115
class SubstNonTypeTemplateParmExpr : public Expr {
4116
  friend class ASTReader;
4117
  friend class ASTStmtReader;
4118
4119
  /// The replaced parameter.
4120
  NonTypeTemplateParmDecl *Param;
4121
4122
  /// The replacement expression.
4123
  Stmt *Replacement;
4124
4125
  explicit SubstNonTypeTemplateParmExpr(EmptyShell Empty)
4126
346
      : Expr(SubstNonTypeTemplateParmExprClass, Empty) {}
4127
4128
public:
4129
  SubstNonTypeTemplateParmExpr(QualType Ty, ExprValueKind ValueKind,
4130
                               SourceLocation Loc,
4131
                               NonTypeTemplateParmDecl *Param,
4132
                               Expr *Replacement)
4133
      : Expr(SubstNonTypeTemplateParmExprClass, Ty, ValueKind, OK_Ordinary,
4134
             Replacement->isTypeDependent(), Replacement->isValueDependent(),
4135
             Replacement->isInstantiationDependent(),
4136
             Replacement->containsUnexpandedParameterPack()),
4137
515k
        Param(Param), Replacement(Replacement) {
4138
515k
    SubstNonTypeTemplateParmExprBits.NameLoc = Loc;
4139
515k
  }
4140
4141
1.41M
  SourceLocation getNameLoc() const {
4142
1.41M
    return SubstNonTypeTemplateParmExprBits.NameLoc;
4143
1.41M
  }
4144
1.35M
  SourceLocation getBeginLoc() const { return getNameLoc(); }
4145
53.5k
  SourceLocation getEndLoc() const { return getNameLoc(); }
4146
4147
1.74M
  Expr *getReplacement() const { return cast<Expr>(Replacement); }
4148
4149
339
  NonTypeTemplateParmDecl *getParameter() const { return Param; }
4150
4151
208M
  static bool classof(const Stmt *s) {
4152
208M
    return s->getStmtClass() == SubstNonTypeTemplateParmExprClass;
4153
208M
  }
4154
4155
  // Iterators
4156
216k
  child_range children() { return child_range(&Replacement, &Replacement + 1); }
4157
4158
0
  const_child_range children() const {
4159
0
    return const_child_range(&Replacement, &Replacement + 1);
4160
0
  }
4161
};
4162
4163
/// Represents a reference to a non-type template parameter pack that
4164
/// has been substituted with a non-template argument pack.
4165
///
4166
/// When a pack expansion in the source code contains multiple parameter packs
4167
/// and those parameter packs correspond to different levels of template
4168
/// parameter lists, this node is used to represent a non-type template
4169
/// parameter pack from an outer level, which has already had its argument pack
4170
/// substituted but that still lives within a pack expansion that itself
4171
/// could not be instantiated. When actually performing a substitution into
4172
/// that pack expansion (e.g., when all template parameters have corresponding
4173
/// arguments), this type will be replaced with the appropriate underlying
4174
/// expression at the current pack substitution index.
4175
class SubstNonTypeTemplateParmPackExpr : public Expr {
4176
  friend class ASTReader;
4177
  friend class ASTStmtReader;
4178
4179
  /// The non-type template parameter pack itself.
4180
  NonTypeTemplateParmDecl *Param;
4181
4182
  /// A pointer to the set of template arguments that this
4183
  /// parameter pack is instantiated with.
4184
  const TemplateArgument *Arguments;
4185
4186
  /// The number of template arguments in \c Arguments.
4187
  unsigned NumArguments;
4188
4189
  /// The location of the non-type template parameter pack reference.
4190
  SourceLocation NameLoc;
4191
4192
  explicit SubstNonTypeTemplateParmPackExpr(EmptyShell Empty)
4193
0
      : Expr(SubstNonTypeTemplateParmPackExprClass, Empty) {}
4194
4195
public:
4196
  SubstNonTypeTemplateParmPackExpr(QualType T,
4197
                                   ExprValueKind ValueKind,
4198
                                   NonTypeTemplateParmDecl *Param,
4199
                                   SourceLocation NameLoc,
4200
                                   const TemplateArgument &ArgPack);
4201
4202
  /// Retrieve the non-type template parameter pack being substituted.
4203
9
  NonTypeTemplateParmDecl *getParameterPack() const { return Param; }
4204
4205
  /// Retrieve the location of the parameter pack name.
4206
4
  SourceLocation getParameterPackLocation() const { return NameLoc; }
4207
4208
  /// Retrieve the template argument pack containing the substituted
4209
  /// template arguments.
4210
  TemplateArgument getArgumentPack() const;
4211
4212
6
  SourceLocation getBeginLoc() const LLVM_READONLY { return NameLoc; }
4213
0
  SourceLocation getEndLoc() const LLVM_READONLY { return NameLoc; }
4214
4215
5.45k
  static bool classof(const Stmt *T) {
4216
5.45k
    return T->getStmtClass() == SubstNonTypeTemplateParmPackExprClass;
4217
5.45k
  }
4218
4219
  // Iterators
4220
14
  child_range children() {
4221
14
    return child_range(child_iterator(), child_iterator());
4222
14
  }
4223
4224
0
  const_child_range children() const {
4225
0
    return const_child_range(const_child_iterator(), const_child_iterator());
4226
0
  }
4227
};
4228
4229
/// Represents a reference to a function parameter pack or init-capture pack
4230
/// that has been substituted but not yet expanded.
4231
///
4232
/// When a pack expansion contains multiple parameter packs at different levels,
4233
/// this node is used to represent a function parameter pack at an outer level
4234
/// which we have already substituted to refer to expanded parameters, but where
4235
/// the containing pack expansion cannot yet be expanded.
4236
///
4237
/// \code
4238
/// template<typename...Ts> struct S {
4239
///   template<typename...Us> auto f(Ts ...ts) -> decltype(g(Us(ts)...));
4240
/// };
4241
/// template struct S<int, int>;
4242
/// \endcode
4243
class FunctionParmPackExpr final
4244
    : public Expr,
4245
      private llvm::TrailingObjects<FunctionParmPackExpr, VarDecl *> {
4246
  friend class ASTReader;
4247
  friend class ASTStmtReader;
4248
  friend TrailingObjects;
4249
4250
  /// The function parameter pack which was referenced.
4251
  VarDecl *ParamPack;
4252
4253
  /// The location of the function parameter pack reference.
4254
  SourceLocation NameLoc;
4255
4256
  /// The number of expansions of this pack.
4257
  unsigned NumParameters;
4258
4259
  FunctionParmPackExpr(QualType T, VarDecl *ParamPack,
4260
                       SourceLocation NameLoc, unsigned NumParams,
4261
                       VarDecl *const *Params);
4262
4263
public:
4264
  static FunctionParmPackExpr *Create(const ASTContext &Context, QualType T,
4265
                                      VarDecl *ParamPack,
4266
                                      SourceLocation NameLoc,
4267
                                      ArrayRef<VarDecl *> Params);
4268
  static FunctionParmPackExpr *CreateEmpty(const ASTContext &Context,
4269
                                           unsigned NumParams);
4270
4271
  /// Get the parameter pack which this expression refers to.
4272
61
  VarDecl *getParameterPack() const { return ParamPack; }
4273
4274
  /// Get the location of the parameter pack.
4275
692
  SourceLocation getParameterPackLocation() const { return NameLoc; }
4276
4277
  /// Iterators over the parameters which the parameter pack expanded
4278
  /// into.
4279
  using iterator = VarDecl * const *;
4280
728
  iterator begin() const { return getTrailingObjects<VarDecl *>(); }
4281
343
  iterator end() const { return begin() + NumParameters; }
4282
4283
  /// Get the number of parameters in this parameter pack.
4284
133
  unsigned getNumExpansions() const { return NumParameters; }
4285
4286
  /// Get an expansion of the parameter pack by index.
4287
42
  VarDecl *getExpansion(unsigned I) const { return begin()[I]; }
4288
4289
139
  SourceLocation getBeginLoc() const LLVM_READONLY { return NameLoc; }
4290
0
  SourceLocation getEndLoc() const LLVM_READONLY { return NameLoc; }
4291
4292
85
  static bool classof(const Stmt *T) {
4293
85
    return T->getStmtClass() == FunctionParmPackExprClass;
4294
85
  }
4295
4296
69
  child_range children() {
4297
69
    return child_range(child_iterator(), child_iterator());
4298
69
  }
4299
4300
0
  const_child_range children() const {
4301
0
    return const_child_range(const_child_iterator(), const_child_iterator());
4302
0
  }
4303
};
4304
4305
/// Represents a prvalue temporary that is written into memory so that
4306
/// a reference can bind to it.
4307
///
4308
/// Prvalue expressions are materialized when they need to have an address
4309
/// in memory for a reference to bind to. This happens when binding a
4310
/// reference to the result of a conversion, e.g.,
4311
///
4312
/// \code
4313
/// const int &r = 1.0;
4314
/// \endcode
4315
///
4316
/// Here, 1.0 is implicitly converted to an \c int. That resulting \c int is
4317
/// then materialized via a \c MaterializeTemporaryExpr, and the reference
4318
/// binds to the temporary. \c MaterializeTemporaryExprs are always glvalues
4319
/// (either an lvalue or an xvalue, depending on the kind of reference binding
4320
/// to it), maintaining the invariant that references always bind to glvalues.
4321
///
4322
/// Reference binding and copy-elision can both extend the lifetime of a
4323
/// temporary. When either happens, the expression will also track the
4324
/// declaration which is responsible for the lifetime extension.
4325
class MaterializeTemporaryExpr : public Expr {
4326
private:
4327
  friend class ASTStmtReader;
4328
  friend class ASTStmtWriter;
4329
4330
  struct ExtraState {
4331
    /// The temporary-generating expression whose value will be
4332
    /// materialized.
4333
    Stmt *Temporary;
4334
4335
    /// The declaration which lifetime-extended this reference, if any.
4336
    /// Either a VarDecl, or (for a ctor-initializer) a FieldDecl.
4337
    const ValueDecl *ExtendingDecl;
4338
4339
    unsigned ManglingNumber;
4340
  };
4341
  llvm::PointerUnion<Stmt *, ExtraState *> State;
4342
4343
  void initializeExtraState(const ValueDecl *ExtendedBy,
4344
                            unsigned ManglingNumber);
4345
4346
public:
4347
  MaterializeTemporaryExpr(QualType T, Expr *Temporary,
4348
                           bool BoundToLvalueReference)
4349
      : Expr(MaterializeTemporaryExprClass, T,
4350
             BoundToLvalueReference? VK_LValue : VK_XValue, OK_Ordinary,
4351
             Temporary->isTypeDependent(), Temporary->isValueDependent(),
4352
             Temporary->isInstantiationDependent(),
4353
             Temporary->containsUnexpandedParameterPack()),
4354
194k
        State(Temporary) {}
4355
4356
  MaterializeTemporaryExpr(EmptyShell Empty)
4357
1.36k
      : Expr(MaterializeTemporaryExprClass, Empty) {}
4358
4359
1.14M
  Stmt *getTemporary() const {
4360
1.14M
    return State.is<Stmt *>() ? 
State.get<Stmt *>()1.12M
4361
1.14M
                              : 
State.get<ExtraState *>()->Temporary17.1k
;
4362
1.14M
  }
4363
4364
  /// Retrieve the temporary-generating subexpression whose value will
4365
  /// be materialized into a glvalue.
4366
830k
  Expr *GetTemporaryExpr() const { return static_cast<Expr *>(getTemporary()); }
4367
4368
  /// Retrieve the storage duration for the materialized temporary.
4369
301k
  StorageDuration getStorageDuration() const {
4370
301k
    const ValueDecl *ExtendingDecl = getExtendingDecl();
4371
301k
    if (!ExtendingDecl)
4372
295k
      return SD_FullExpression;
4373
6.23k
    // FIXME: This is not necessarily correct for a temporary materialized
4374
6.23k
    // within a default initializer.
4375
6.23k
    if (isa<FieldDecl>(ExtendingDecl))
4376
19
      return SD_Automatic;
4377
6.21k
    // FIXME: This only works because storage class specifiers are not allowed
4378
6.21k
    // on decomposition declarations.
4379
6.21k
    if (isa<BindingDecl>(ExtendingDecl))
4380
0
      return ExtendingDecl->getDeclContext()->isFunctionOrMethod()
4381
0
                 ? SD_Automatic
4382
0
                 : SD_Static;
4383
6.21k
    return cast<VarDecl>(ExtendingDecl)->getStorageDuration();
4384
6.21k
  }
4385
4386
  /// Get the declaration which triggered the lifetime-extension of this
4387
  /// temporary, if any.
4388
304k
  const ValueDecl *getExtendingDecl() const {
4389
304k
    return State.is<Stmt *>() ? 
nullptr298k
4390
304k
                              : 
State.get<ExtraState *>()->ExtendingDecl6.78k
;
4391
304k
  }
4392
4393
  void setExtendingDecl(const ValueDecl *ExtendedBy, unsigned ManglingNumber);
4394
4395
1.65k
  unsigned getManglingNumber() const {
4396
1.65k
    return State.is<Stmt *>() ? 
01.41k
:
State.get<ExtraState *>()->ManglingNumber237
;
4397
1.65k
  }
4398
4399
  /// Determine whether this materialized temporary is bound to an
4400
  /// lvalue reference; otherwise, it's bound to an rvalue reference.
4401
6.52k
  bool isBoundToLvalueReference() const {
4402
6.52k
    return getValueKind() == VK_LValue;
4403
6.52k
  }
4404
4405
237k
  SourceLocation getBeginLoc() const LLVM_READONLY {
4406
237k
    return getTemporary()->getBeginLoc();
4407
237k
  }
4408
4409
49.7k
  SourceLocation getEndLoc() const LLVM_READONLY {
4410
49.7k
    return getTemporary()->getEndLoc();
4411
49.7k
  }
4412
4413
226M
  static bool classof(const Stmt *T) {
4414
226M
    return T->getStmtClass() == MaterializeTemporaryExprClass;
4415
226M
  }
4416
4417
  // Iterators
4418
313k
  child_range children() {
4419
313k
    if (State.is<Stmt *>())
4420
308k
      return child_range(State.getAddrOfPtr1(), State.getAddrOfPtr1() + 1);
4421
5.17k
4422
5.17k
    auto ES = State.get<ExtraState *>();
4423
5.17k
    return child_range(&ES->Temporary, &ES->Temporary + 1);
4424
5.17k
  }
4425
4426
0
  const_child_range children() const {
4427
0
    if (State.is<Stmt *>())
4428
0
      return const_child_range(State.getAddrOfPtr1(),
4429
0
                               State.getAddrOfPtr1() + 1);
4430
0
4431
0
    auto ES = State.get<ExtraState *>();
4432
0
    return const_child_range(&ES->Temporary, &ES->Temporary + 1);
4433
0
  }
4434
};
4435
4436
/// Represents a folding of a pack over an operator.
4437
///
4438
/// This expression is always dependent and represents a pack expansion of the
4439
/// forms:
4440
///
4441
///    ( expr op ... )
4442
///    ( ... op expr )
4443
///    ( expr op ... op expr )
4444
class CXXFoldExpr : public Expr {
4445
  friend class ASTStmtReader;
4446
  friend class ASTStmtWriter;
4447
4448
  SourceLocation LParenLoc;
4449
  SourceLocation EllipsisLoc;
4450
  SourceLocation RParenLoc;
4451
  // When 0, the number of expansions is not known. Otherwise, this is one more
4452
  // than the number of expansions.
4453
  unsigned NumExpansions;
4454
  Stmt *SubExprs[2];
4455
  BinaryOperatorKind Opcode;
4456
4457
public:
4458
  CXXFoldExpr(QualType T, SourceLocation LParenLoc, Expr *LHS,
4459
              BinaryOperatorKind Opcode, SourceLocation EllipsisLoc, Expr *RHS,
4460
              SourceLocation RParenLoc, Optional<unsigned> NumExpansions)
4461
      : Expr(CXXFoldExprClass, T, VK_RValue, OK_Ordinary,
4462
             /*Dependent*/ true, true, true,
4463
             /*ContainsUnexpandedParameterPack*/ false),
4464
        LParenLoc(LParenLoc), EllipsisLoc(EllipsisLoc), RParenLoc(RParenLoc),
4465
151
        NumExpansions(NumExpansions ? *NumExpansions + 1 : 0), Opcode(Opcode) {
4466
151
    SubExprs[0] = LHS;
4467
151
    SubExprs[1] = RHS;
4468
151
  }
4469
4470
0
  CXXFoldExpr(EmptyShell Empty) : Expr(CXXFoldExprClass, Empty) {}
4471
4472
945
  Expr *getLHS() const { return static_cast<Expr*>(SubExprs[0]); }
4473
160
  Expr *getRHS() const { return static_cast<Expr*>(SubExprs[1]); }
4474
4475
  /// Does this produce a right-associated sequence of operators?
4476
397
  bool isRightFold() const {
4477
397
    return getLHS() && 
getLHS()->containsUnexpandedParameterPack()365
;
4478
397
  }
4479
4480
  /// Does this produce a left-associated sequence of operators?
4481
397
  bool isLeftFold() const { return !isRightFold(); }
4482
4483
  /// Get the pattern, that is, the operand that contains an unexpanded pack.
4484
131
  Expr *getPattern() const { return isLeftFold() ? 
getRHS()36
:
getLHS()95
; }
4485
4486
  /// Get the operand that doesn't contain a pack, for a binary fold.
4487
133
  Expr *getInit() const { return isLeftFold() ? 
getLHS()42
:
getRHS()91
; }
4488
4489
405
  SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
4490
363
  BinaryOperatorKind getOperator() const { return Opcode; }
4491
4492
131
  Optional<unsigned> getNumExpansions() const {
4493
131
    if (NumExpansions)
4494
5
      return NumExpansions - 1;
4495
126
    return None;
4496
126
  }
4497
4498
213
  SourceLocation getBeginLoc() const LLVM_READONLY { return LParenLoc; }
4499
4500
53
  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
4501
4502
0
  static bool classof(const Stmt *T) {
4503
0
    return T->getStmtClass() == CXXFoldExprClass;
4504
0
  }
4505
4506
  // Iterators
4507
75
  child_range children() { return child_range(SubExprs, SubExprs + 2); }
4508
4509
0
  const_child_range children() const {
4510
0
    return const_child_range(SubExprs, SubExprs + 2);
4511
0
  }
4512
};
4513
4514
/// Represents an expression that might suspend coroutine execution;
4515
/// either a co_await or co_yield expression.
4516
///
4517
/// Evaluation of this expression first evaluates its 'ready' expression. If
4518
/// that returns 'false':
4519
///  -- execution of the coroutine is suspended
4520
///  -- the 'suspend' expression is evaluated
4521
///     -- if the 'suspend' expression returns 'false', the coroutine is
4522
///        resumed
4523
///     -- otherwise, control passes back to the resumer.
4524
/// If the coroutine is not suspended, or when it is resumed, the 'resume'
4525
/// expression is evaluated, and its result is the result of the overall
4526
/// expression.
4527
class CoroutineSuspendExpr : public Expr {
4528
  friend class ASTStmtReader;
4529
4530
  SourceLocation KeywordLoc;
4531
4532
  enum SubExpr { Common, Ready, Suspend, Resume, Count };
4533
4534
  Stmt *SubExprs[SubExpr::Count];
4535
  OpaqueValueExpr *OpaqueValue = nullptr;
4536
4537
public:
4538
  CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, Expr *Common,
4539
                       Expr *Ready, Expr *Suspend, Expr *Resume,
4540
                       OpaqueValueExpr *OpaqueValue)
4541
      : Expr(SC, Resume->getType(), Resume->getValueKind(),
4542
             Resume->getObjectKind(), Resume->isTypeDependent(),
4543
             Resume->isValueDependent(), Common->isInstantiationDependent(),
4544
             Common->containsUnexpandedParameterPack()),
4545
524
        KeywordLoc(KeywordLoc), OpaqueValue(OpaqueValue) {
4546
524
    SubExprs[SubExpr::Common] = Common;
4547
524
    SubExprs[SubExpr::Ready] = Ready;
4548
524
    SubExprs[SubExpr::Suspend] = Suspend;
4549
524
    SubExprs[SubExpr::Resume] = Resume;
4550
524
  }
4551
4552
  CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, QualType Ty,
4553
                       Expr *Common)
4554
      : Expr(SC, Ty, VK_RValue, OK_Ordinary, true, true, true,
4555
             Common->containsUnexpandedParameterPack()),
4556
123
        KeywordLoc(KeywordLoc) {
4557
123
    assert(Common->isTypeDependent() && Ty->isDependentType() &&
4558
123
           "wrong constructor for non-dependent co_await/co_yield expression");
4559
123
    SubExprs[SubExpr::Common] = Common;
4560
123
    SubExprs[SubExpr::Ready] = nullptr;
4561
123
    SubExprs[SubExpr::Suspend] = nullptr;
4562
123
    SubExprs[SubExpr::Resume] = nullptr;
4563
123
  }
4564
4565
5
  CoroutineSuspendExpr(StmtClass SC, EmptyShell Empty) : Expr(SC, Empty) {
4566
5
    SubExprs[SubExpr::Common] = nullptr;
4567
5
    SubExprs[SubExpr::Ready] = nullptr;
4568
5
    SubExprs[SubExpr::Suspend] = nullptr;
4569
5
    SubExprs[SubExpr::Resume] = nullptr;
4570
5
  }
4571
4572
135
  SourceLocation getKeywordLoc() const { return KeywordLoc; }
4573
4574
263
  Expr *getCommonExpr() const {
4575
263
    return static_cast<Expr*>(SubExprs[SubExpr::Common]);
4576
263
  }
4577
4578
  /// getOpaqueValue - Return the opaque value placeholder.
4579
110
  OpaqueValueExpr *getOpaqueValue() const { return OpaqueValue; }
4580
4581
103
  Expr *getReadyExpr() const {
4582
103
    return static_cast<Expr*>(SubExprs[SubExpr::Ready]);
4583
103
  }
4584
4585
103
  Expr *getSuspendExpr() const {
4586
103
    return static_cast<Expr*>(SubExprs[SubExpr::Suspend]);
4587
103
  }
4588
4589
457
  Expr *getResumeExpr() const {
4590
457
    return static_cast<Expr*>(SubExprs[SubExpr::Resume]);
4591
457
  }
4592
4593
1.90k
  SourceLocation getBeginLoc() const LLVM_READONLY { return KeywordLoc; }
4594
4595
28
  SourceLocation getEndLoc() const LLVM_READONLY {
4596
28
    return getCommonExpr()->getEndLoc();
4597
28
  }
4598
4599
1.11k
  child_range children() {
4600
1.11k
    return child_range(SubExprs, SubExprs + SubExpr::Count);
4601
1.11k
  }
4602
4603
0
  const_child_range children() const {
4604
0
    return const_child_range(SubExprs, SubExprs + SubExpr::Count);
4605
0
  }
4606
4607
0
  static bool classof(const Stmt *T) {
4608
0
    return T->getStmtClass() == CoawaitExprClass ||
4609
0
           T->getStmtClass() == CoyieldExprClass;
4610
0
  }
4611
};
4612
4613
/// Represents a 'co_await' expression.
4614
class CoawaitExpr : public CoroutineSuspendExpr {
4615
  friend class ASTStmtReader;
4616
4617
public:
4618
  CoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, Expr *Ready,
4619
              Expr *Suspend, Expr *Resume, OpaqueValueExpr *OpaqueValue,
4620
              bool IsImplicit = false)
4621
      : CoroutineSuspendExpr(CoawaitExprClass, CoawaitLoc, Operand, Ready,
4622
469
                             Suspend, Resume, OpaqueValue) {
4623
469
    CoawaitBits.IsImplicit = IsImplicit;
4624
469
  }
4625
4626
  CoawaitExpr(SourceLocation CoawaitLoc, QualType Ty, Expr *Operand,
4627
              bool IsImplicit = false)
4628
103
      : CoroutineSuspendExpr(CoawaitExprClass, CoawaitLoc, Ty, Operand) {
4629
103
    CoawaitBits.IsImplicit = IsImplicit;
4630
103
  }
4631
4632
  CoawaitExpr(EmptyShell Empty)
4633
4
      : CoroutineSuspendExpr(CoawaitExprClass, Empty) {}
4634
4635
109
  Expr *getOperand() const {
4636
109
    // FIXME: Dig out the actual operand or store it.
4637
109
    return getCommonExpr();
4638
109
  }
4639
4640
115
  bool isImplicit() const { return CoawaitBits.IsImplicit; }
4641
4
  void setIsImplicit(bool value = true) { CoawaitBits.IsImplicit = value; }
4642
4643
0
  static bool classof(const Stmt *T) {
4644
0
    return T->getStmtClass() == CoawaitExprClass;
4645
0
  }
4646
};
4647
4648
/// Represents a 'co_await' expression while the type of the promise
4649
/// is dependent.
4650
class DependentCoawaitExpr : public Expr {
4651
  friend class ASTStmtReader;
4652
4653
  SourceLocation KeywordLoc;
4654
  Stmt *SubExprs[2];
4655
4656
public:
4657
  DependentCoawaitExpr(SourceLocation KeywordLoc, QualType Ty, Expr *Op,
4658
                       UnresolvedLookupExpr *OpCoawait)
4659
      : Expr(DependentCoawaitExprClass, Ty, VK_RValue, OK_Ordinary,
4660
             /*TypeDependent*/ true, /*ValueDependent*/ true,
4661
             /*InstantiationDependent*/ true,
4662
             Op->containsUnexpandedParameterPack()),
4663
24
        KeywordLoc(KeywordLoc) {
4664
24
    // NOTE: A co_await expression is dependent on the coroutines promise
4665
24
    // type and may be dependent even when the `Op` expression is not.
4666
24
    assert(Ty->isDependentType() &&
4667
24
           "wrong constructor for non-dependent co_await/co_yield expression");
4668
24
    SubExprs[0] = Op;
4669
24
    SubExprs[1] = OpCoawait;
4670
24
  }
4671
4672
  DependentCoawaitExpr(EmptyShell Empty)
4673
1
      : Expr(DependentCoawaitExprClass, Empty) {}
4674
4675
23
  Expr *getOperand() const { return cast<Expr>(SubExprs[0]); }
4676
4677
23
  UnresolvedLookupExpr *getOperatorCoawaitLookup() const {
4678
23
    return cast<UnresolvedLookupExpr>(SubExprs[1]);
4679
23
  }
4680
4681
25
  SourceLocation getKeywordLoc() const { return KeywordLoc; }
4682
4683
43
  SourceLocation getBeginLoc() const LLVM_READONLY { return KeywordLoc; }
4684
4685
0
  SourceLocation getEndLoc() const LLVM_READONLY {
4686
0
    return getOperand()->getEndLoc();
4687
0
  }
4688
4689
4
  child_range children() { return child_range(SubExprs, SubExprs + 2); }
4690
4691
0
  const_child_range children() const {
4692
0
    return const_child_range(SubExprs, SubExprs + 2);
4693
0
  }
4694
4695
0
  static bool classof(const Stmt *T) {
4696
0
    return T->getStmtClass() == DependentCoawaitExprClass;
4697
0
  }
4698
};
4699
4700
/// Represents a 'co_yield' expression.
4701
class CoyieldExpr : public CoroutineSuspendExpr {
4702
  friend class ASTStmtReader;
4703
4704
public:
4705
  CoyieldExpr(SourceLocation CoyieldLoc, Expr *Operand, Expr *Ready,
4706
              Expr *Suspend, Expr *Resume, OpaqueValueExpr *OpaqueValue)
4707
      : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Operand, Ready,
4708
55
                             Suspend, Resume, OpaqueValue) {}
4709
  CoyieldExpr(SourceLocation CoyieldLoc, QualType Ty, Expr *Operand)
4710
20
      : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Ty, Operand) {}
4711
  CoyieldExpr(EmptyShell Empty)
4712
1
      : CoroutineSuspendExpr(CoyieldExprClass, Empty) {}
4713
4714
23
  Expr *getOperand() const {
4715
23
    // FIXME: Dig out the actual operand or store it.
4716
23
    return getCommonExpr();
4717
23
  }
4718
4719
0
  static bool classof(const Stmt *T) {
4720
0
    return T->getStmtClass() == CoyieldExprClass;
4721
0
  }
4722
};
4723
4724
/// Represents a C++2a __builtin_bit_cast(T, v) expression. Used to implement
4725
/// std::bit_cast. These can sometimes be evaluated as part of a constant
4726
/// expression, but otherwise CodeGen to a simple memcpy in general.
4727
class BuiltinBitCastExpr final
4728
    : public ExplicitCastExpr,
4729
      private llvm::TrailingObjects<BuiltinBitCastExpr, CXXBaseSpecifier *> {
4730
  friend class ASTStmtReader;
4731
  friend class CastExpr;
4732
  friend class TrailingObjects;
4733
4734
  SourceLocation KWLoc;
4735
  SourceLocation RParenLoc;
4736
4737
public:
4738
  BuiltinBitCastExpr(QualType T, ExprValueKind VK, CastKind CK, Expr *SrcExpr,
4739
                     TypeSourceInfo *DstType, SourceLocation KWLoc,
4740
                     SourceLocation RParenLoc)
4741
      : ExplicitCastExpr(BuiltinBitCastExprClass, T, VK, CK, SrcExpr, 0,
4742
                         DstType),
4743
137
        KWLoc(KWLoc), RParenLoc(RParenLoc) {}
4744
4745
1.13k
  SourceLocation getBeginLoc() const LLVM_READONLY { return KWLoc; }
4746
110
  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
4747
4748
0
  static bool classof(const Stmt *T) {
4749
0
    return T->getStmtClass() == BuiltinBitCastExprClass;
4750
0
  }
4751
};
4752
4753
} // namespace clang
4754
4755
#endif // LLVM_CLANG_AST_EXPRCXX_H