clang  10.0.0svn
ExprCXX.cpp
Go to the documentation of this file.
1 //===- ExprCXX.cpp - (C++) Expression AST Node Implementation -------------===//
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 // This file implements the subclesses of Expr class declared in ExprCXX.h
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "clang/AST/ExprCXX.h"
14 #include "clang/AST/ASTContext.h"
15 #include "clang/AST/Attr.h"
16 #include "clang/AST/Decl.h"
18 #include "clang/AST/DeclBase.h"
19 #include "clang/AST/DeclCXX.h"
21 #include "clang/AST/Expr.h"
24 #include "clang/AST/TemplateBase.h"
25 #include "clang/AST/Type.h"
26 #include "clang/AST/TypeLoc.h"
27 #include "clang/Basic/LLVM.h"
30 #include "clang/Basic/Specifiers.h"
31 #include "llvm/ADT/ArrayRef.h"
32 #include "llvm/Support/Casting.h"
33 #include "llvm/Support/ErrorHandling.h"
34 #include <cassert>
35 #include <cstddef>
36 #include <cstring>
37 #include <memory>
38 
39 using namespace clang;
40 
41 //===----------------------------------------------------------------------===//
42 // Child Iterators for iterating over subexpressions/substatements
43 //===----------------------------------------------------------------------===//
44 
46  // An infix binary operator is any operator with two arguments other than
47  // operator() and operator[]. Note that none of these operators can have
48  // default arguments, so it suffices to check the number of argument
49  // expressions.
50  if (getNumArgs() != 2)
51  return false;
52 
53  switch (getOperator()) {
54  case OO_Call: case OO_Subscript:
55  return false;
56  default:
57  return true;
58  }
59 }
60 
62  if (isTypeOperand())
63  return false;
64 
65  // C++11 [expr.typeid]p3:
66  // When typeid is applied to an expression other than a glvalue of
67  // polymorphic class type, [...] the expression is an unevaluated operand.
68  const Expr *E = getExprOperand();
69  if (const CXXRecordDecl *RD = E->getType()->getAsCXXRecordDecl())
70  if (RD->isPolymorphic() && E->isGLValue())
71  return true;
72 
73  return false;
74 }
75 
77  assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
78  Qualifiers Quals;
79  return Context.getUnqualifiedArrayType(
80  Operand.get<TypeSourceInfo *>()->getType().getNonReferenceType(), Quals);
81 }
82 
84  assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
85  Qualifiers Quals;
86  return Context.getUnqualifiedArrayType(
87  Operand.get<TypeSourceInfo *>()->getType().getNonReferenceType(), Quals);
88 }
89 
90 // CXXScalarValueInitExpr
92  return TypeInfo ? TypeInfo->getTypeLoc().getBeginLoc() : getRParenLoc();
93 }
94 
95 // CXXNewExpr
96 CXXNewExpr::CXXNewExpr(bool IsGlobalNew, FunctionDecl *OperatorNew,
97  FunctionDecl *OperatorDelete, bool ShouldPassAlignment,
98  bool UsualArrayDeleteWantsSize,
99  ArrayRef<Expr *> PlacementArgs, SourceRange TypeIdParens,
100  Optional<Expr *> ArraySize,
101  InitializationStyle InitializationStyle,
103  TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
104  SourceRange DirectInitRange)
105  : Expr(CXXNewExprClass, Ty, VK_RValue, OK_Ordinary, Ty->isDependentType(),
108  OperatorNew(OperatorNew), OperatorDelete(OperatorDelete),
109  AllocatedTypeInfo(AllocatedTypeInfo), Range(Range),
110  DirectInitRange(DirectInitRange) {
111 
112  assert((Initializer != nullptr || InitializationStyle == NoInit) &&
113  "Only NoInit can have no initializer!");
114 
115  CXXNewExprBits.IsGlobalNew = IsGlobalNew;
116  CXXNewExprBits.IsArray = ArraySize.hasValue();
117  CXXNewExprBits.ShouldPassAlignment = ShouldPassAlignment;
118  CXXNewExprBits.UsualArrayDeleteWantsSize = UsualArrayDeleteWantsSize;
119  CXXNewExprBits.StoredInitializationStyle =
120  Initializer ? InitializationStyle + 1 : 0;
121  bool IsParenTypeId = TypeIdParens.isValid();
122  CXXNewExprBits.IsParenTypeId = IsParenTypeId;
123  CXXNewExprBits.NumPlacementArgs = PlacementArgs.size();
124 
125  if (ArraySize) {
126  if (Expr *SizeExpr = *ArraySize) {
127  if (SizeExpr->isInstantiationDependent())
128  ExprBits.InstantiationDependent = true;
129  if (SizeExpr->containsUnexpandedParameterPack())
130  ExprBits.ContainsUnexpandedParameterPack = true;
131  }
132 
133  getTrailingObjects<Stmt *>()[arraySizeOffset()] = *ArraySize;
134  }
135 
136  if (Initializer) {
137  if (Initializer->isInstantiationDependent())
138  ExprBits.InstantiationDependent = true;
139  if (Initializer->containsUnexpandedParameterPack())
140  ExprBits.ContainsUnexpandedParameterPack = true;
141 
142  getTrailingObjects<Stmt *>()[initExprOffset()] = Initializer;
143  }
144 
145  for (unsigned I = 0; I != PlacementArgs.size(); ++I) {
146  if (PlacementArgs[I]->isInstantiationDependent())
147  ExprBits.InstantiationDependent = true;
148  if (PlacementArgs[I]->containsUnexpandedParameterPack())
149  ExprBits.ContainsUnexpandedParameterPack = true;
150 
151  getTrailingObjects<Stmt *>()[placementNewArgsOffset() + I] =
152  PlacementArgs[I];
153  }
154 
155  if (IsParenTypeId)
156  getTrailingObjects<SourceRange>()[0] = TypeIdParens;
157 
158  switch (getInitializationStyle()) {
159  case CallInit:
160  this->Range.setEnd(DirectInitRange.getEnd());
161  break;
162  case ListInit:
163  this->Range.setEnd(getInitializer()->getSourceRange().getEnd());
164  break;
165  default:
166  if (IsParenTypeId)
167  this->Range.setEnd(TypeIdParens.getEnd());
168  break;
169  }
170 }
171 
172 CXXNewExpr::CXXNewExpr(EmptyShell Empty, bool IsArray,
173  unsigned NumPlacementArgs, bool IsParenTypeId)
174  : Expr(CXXNewExprClass, Empty) {
175  CXXNewExprBits.IsArray = IsArray;
176  CXXNewExprBits.NumPlacementArgs = NumPlacementArgs;
177  CXXNewExprBits.IsParenTypeId = IsParenTypeId;
178 }
179 
180 CXXNewExpr *
181 CXXNewExpr::Create(const ASTContext &Ctx, bool IsGlobalNew,
182  FunctionDecl *OperatorNew, FunctionDecl *OperatorDelete,
183  bool ShouldPassAlignment, bool UsualArrayDeleteWantsSize,
184  ArrayRef<Expr *> PlacementArgs, SourceRange TypeIdParens,
185  Optional<Expr *> ArraySize,
187  QualType Ty, TypeSourceInfo *AllocatedTypeInfo,
188  SourceRange Range, SourceRange DirectInitRange) {
189  bool IsArray = ArraySize.hasValue();
190  bool HasInit = Initializer != nullptr;
191  unsigned NumPlacementArgs = PlacementArgs.size();
192  bool IsParenTypeId = TypeIdParens.isValid();
193  void *Mem =
194  Ctx.Allocate(totalSizeToAlloc<Stmt *, SourceRange>(
195  IsArray + HasInit + NumPlacementArgs, IsParenTypeId),
196  alignof(CXXNewExpr));
197  return new (Mem)
198  CXXNewExpr(IsGlobalNew, OperatorNew, OperatorDelete, ShouldPassAlignment,
199  UsualArrayDeleteWantsSize, PlacementArgs, TypeIdParens,
200  ArraySize, InitializationStyle, Initializer, Ty,
201  AllocatedTypeInfo, Range, DirectInitRange);
202 }
203 
205  bool HasInit, unsigned NumPlacementArgs,
206  bool IsParenTypeId) {
207  void *Mem =
208  Ctx.Allocate(totalSizeToAlloc<Stmt *, SourceRange>(
209  IsArray + HasInit + NumPlacementArgs, IsParenTypeId),
210  alignof(CXXNewExpr));
211  return new (Mem)
212  CXXNewExpr(EmptyShell(), IsArray, NumPlacementArgs, IsParenTypeId);
213 }
214 
216  return getOperatorNew()
217  ->getType()
218  ->castAs<FunctionProtoType>()
219  ->isNothrow() &&
220  !getOperatorNew()->isReservedGlobalPlacementOperator();
221 }
222 
223 // CXXDeleteExpr
225  const Expr *Arg = getArgument();
226 
227  // For a destroying operator delete, we may have implicitly converted the
228  // pointer type to the type of the parameter of the 'operator delete'
229  // function.
230  while (const auto *ICE = dyn_cast<ImplicitCastExpr>(Arg)) {
231  if (ICE->getCastKind() == CK_DerivedToBase ||
232  ICE->getCastKind() == CK_UncheckedDerivedToBase ||
233  ICE->getCastKind() == CK_NoOp) {
234  assert((ICE->getCastKind() == CK_NoOp ||
235  getOperatorDelete()->isDestroyingOperatorDelete()) &&
236  "only a destroying operator delete can have a converted arg");
237  Arg = ICE->getSubExpr();
238  } else
239  break;
240  }
241 
242  // The type-to-delete may not be a pointer if it's a dependent type.
243  const QualType ArgType = Arg->getType();
244 
245  if (ArgType->isDependentType() && !ArgType->isPointerType())
246  return QualType();
247 
248  return ArgType->getAs<PointerType>()->getPointeeType();
249 }
250 
251 // CXXPseudoDestructorExpr
253  : Type(Info) {
254  Location = Info->getTypeLoc().getLocalSourceRange().getBegin();
255 }
256 
258  Expr *Base, bool isArrow, SourceLocation OperatorLoc,
259  NestedNameSpecifierLoc QualifierLoc, TypeSourceInfo *ScopeType,
260  SourceLocation ColonColonLoc, SourceLocation TildeLoc,
261  PseudoDestructorTypeStorage DestroyedType)
262  : Expr(CXXPseudoDestructorExprClass,
263  Context.BoundMemberTy,
265  /*isTypeDependent=*/(Base->isTypeDependent() ||
266  (DestroyedType.getTypeSourceInfo() &&
267  DestroyedType.getTypeSourceInfo()->getType()->isDependentType())),
268  /*isValueDependent=*/Base->isValueDependent(),
269  (Base->isInstantiationDependent() ||
270  (QualifierLoc &&
271  QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent()) ||
272  (ScopeType &&
273  ScopeType->getType()->isInstantiationDependentType()) ||
274  (DestroyedType.getTypeSourceInfo() &&
275  DestroyedType.getTypeSourceInfo()->getType()
276  ->isInstantiationDependentType())),
277  // ContainsUnexpandedParameterPack
278  (Base->containsUnexpandedParameterPack() ||
279  (QualifierLoc &&
280  QualifierLoc.getNestedNameSpecifier()
281  ->containsUnexpandedParameterPack()) ||
282  (ScopeType &&
283  ScopeType->getType()->containsUnexpandedParameterPack()) ||
284  (DestroyedType.getTypeSourceInfo() &&
285  DestroyedType.getTypeSourceInfo()->getType()
286  ->containsUnexpandedParameterPack()))),
287  Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
288  OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc),
289  ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc),
290  DestroyedType(DestroyedType) {}
291 
293  if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo())
294  return TInfo->getType();
295 
296  return QualType();
297 }
298 
300  SourceLocation End = DestroyedType.getLocation();
301  if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo())
302  End = TInfo->getTypeLoc().getLocalSourceRange().getEnd();
303  return End;
304 }
305 
306 // UnresolvedLookupExpr
307 UnresolvedLookupExpr::UnresolvedLookupExpr(
308  const ASTContext &Context, CXXRecordDecl *NamingClass,
309  NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
310  const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded,
313  : OverloadExpr(UnresolvedLookupExprClass, Context, QualifierLoc,
314  TemplateKWLoc, NameInfo, TemplateArgs, Begin, End, false,
315  false, false),
316  NamingClass(NamingClass) {
317  UnresolvedLookupExprBits.RequiresADL = RequiresADL;
318  UnresolvedLookupExprBits.Overloaded = Overloaded;
319 }
320 
321 UnresolvedLookupExpr::UnresolvedLookupExpr(EmptyShell Empty,
322  unsigned NumResults,
323  bool HasTemplateKWAndArgsInfo)
324  : OverloadExpr(UnresolvedLookupExprClass, Empty, NumResults,
325  HasTemplateKWAndArgsInfo) {}
326 
328  const ASTContext &Context, CXXRecordDecl *NamingClass,
329  NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
330  bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin,
331  UnresolvedSetIterator End) {
332  unsigned NumResults = End - Begin;
333  unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
334  TemplateArgumentLoc>(NumResults, 0, 0);
335  void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
336  return new (Mem) UnresolvedLookupExpr(Context, NamingClass, QualifierLoc,
337  SourceLocation(), NameInfo, RequiresADL,
338  Overloaded, nullptr, Begin, End);
339 }
340 
342  const ASTContext &Context, CXXRecordDecl *NamingClass,
343  NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
344  const DeclarationNameInfo &NameInfo, bool RequiresADL,
346  UnresolvedSetIterator End) {
347  assert(Args || TemplateKWLoc.isValid());
348  unsigned NumResults = End - Begin;
349  unsigned NumTemplateArgs = Args ? Args->size() : 0;
350  unsigned Size =
351  totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
352  TemplateArgumentLoc>(NumResults, 1, NumTemplateArgs);
353  void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
354  return new (Mem) UnresolvedLookupExpr(Context, NamingClass, QualifierLoc,
355  TemplateKWLoc, NameInfo, RequiresADL,
356  /*Overloaded*/ true, Args, Begin, End);
357 }
358 
360  const ASTContext &Context, unsigned NumResults,
361  bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs) {
362  assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
363  unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
365  NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
366  void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
367  return new (Mem)
368  UnresolvedLookupExpr(EmptyShell(), NumResults, HasTemplateKWAndArgsInfo);
369 }
370 
372  NestedNameSpecifierLoc QualifierLoc,
373  SourceLocation TemplateKWLoc,
374  const DeclarationNameInfo &NameInfo,
375  const TemplateArgumentListInfo *TemplateArgs,
376  UnresolvedSetIterator Begin,
377  UnresolvedSetIterator End, bool KnownDependent,
378  bool KnownInstantiationDependent,
379  bool KnownContainsUnexpandedParameterPack)
380  : Expr(
381  SC, Context.OverloadTy, VK_LValue, OK_Ordinary, KnownDependent,
382  KnownDependent,
383  (KnownInstantiationDependent || NameInfo.isInstantiationDependent() ||
384  (QualifierLoc &&
385  QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())),
386  (KnownContainsUnexpandedParameterPack ||
387  NameInfo.containsUnexpandedParameterPack() ||
388  (QualifierLoc && QualifierLoc.getNestedNameSpecifier()
390  NameInfo(NameInfo), QualifierLoc(QualifierLoc) {
391  unsigned NumResults = End - Begin;
392  OverloadExprBits.NumResults = NumResults;
393  OverloadExprBits.HasTemplateKWAndArgsInfo =
394  (TemplateArgs != nullptr ) || TemplateKWLoc.isValid();
395 
396  if (NumResults) {
397  // Determine whether this expression is type-dependent.
398  for (UnresolvedSetImpl::const_iterator I = Begin; I != End; ++I) {
399  if ((*I)->getDeclContext()->isDependentContext() ||
400  isa<UnresolvedUsingValueDecl>(*I)) {
401  ExprBits.TypeDependent = true;
402  ExprBits.ValueDependent = true;
403  ExprBits.InstantiationDependent = true;
404  }
405  }
406 
407  // Copy the results to the trailing array past UnresolvedLookupExpr
408  // or UnresolvedMemberExpr.
409  DeclAccessPair *Results = getTrailingResults();
410  memcpy(Results, Begin.I, NumResults * sizeof(DeclAccessPair));
411  }
412 
413  // If we have explicit template arguments, check for dependent
414  // template arguments and whether they contain any unexpanded pack
415  // expansions.
416  if (TemplateArgs) {
417  bool Dependent = false;
418  bool InstantiationDependent = false;
419  bool ContainsUnexpandedParameterPack = false;
421  TemplateKWLoc, *TemplateArgs, getTrailingTemplateArgumentLoc(),
422  Dependent, InstantiationDependent, ContainsUnexpandedParameterPack);
423 
424  if (Dependent) {
425  ExprBits.TypeDependent = true;
426  ExprBits.ValueDependent = true;
427  }
428  if (InstantiationDependent)
429  ExprBits.InstantiationDependent = true;
430  if (ContainsUnexpandedParameterPack)
431  ExprBits.ContainsUnexpandedParameterPack = true;
432  } else if (TemplateKWLoc.isValid()) {
434  }
435 
436  if (isTypeDependent())
437  setType(Context.DependentTy);
438 }
439 
440 OverloadExpr::OverloadExpr(StmtClass SC, EmptyShell Empty, unsigned NumResults,
441  bool HasTemplateKWAndArgsInfo)
442  : Expr(SC, Empty) {
443  OverloadExprBits.NumResults = NumResults;
444  OverloadExprBits.HasTemplateKWAndArgsInfo = HasTemplateKWAndArgsInfo;
445 }
446 
447 // DependentScopeDeclRefExpr
448 DependentScopeDeclRefExpr::DependentScopeDeclRefExpr(
449  QualType Ty, NestedNameSpecifierLoc QualifierLoc,
450  SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo,
451  const TemplateArgumentListInfo *Args)
452  : Expr(
453  DependentScopeDeclRefExprClass, Ty, VK_LValue, OK_Ordinary, true,
454  true,
455  (NameInfo.isInstantiationDependent() ||
456  (QualifierLoc &&
458  (NameInfo.containsUnexpandedParameterPack() ||
459  (QualifierLoc && QualifierLoc.getNestedNameSpecifier()
461  QualifierLoc(QualifierLoc), NameInfo(NameInfo) {
462  DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo =
463  (Args != nullptr) || TemplateKWLoc.isValid();
464  if (Args) {
465  bool Dependent = true;
466  bool InstantiationDependent = true;
467  bool ContainsUnexpandedParameterPack
468  = ExprBits.ContainsUnexpandedParameterPack;
469  getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
470  TemplateKWLoc, *Args, getTrailingObjects<TemplateArgumentLoc>(),
471  Dependent, InstantiationDependent, ContainsUnexpandedParameterPack);
472  ExprBits.ContainsUnexpandedParameterPack = ContainsUnexpandedParameterPack;
473  } else if (TemplateKWLoc.isValid()) {
474  getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
475  TemplateKWLoc);
476  }
477 }
478 
480  const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc,
481  SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo,
482  const TemplateArgumentListInfo *Args) {
483  assert(QualifierLoc && "should be created for dependent qualifiers");
484  bool HasTemplateKWAndArgsInfo = Args || TemplateKWLoc.isValid();
485  std::size_t Size =
486  totalSizeToAlloc<ASTTemplateKWAndArgsInfo, TemplateArgumentLoc>(
487  HasTemplateKWAndArgsInfo, Args ? Args->size() : 0);
488  void *Mem = Context.Allocate(Size);
489  return new (Mem) DependentScopeDeclRefExpr(Context.DependentTy, QualifierLoc,
490  TemplateKWLoc, NameInfo, Args);
491 }
492 
495  bool HasTemplateKWAndArgsInfo,
496  unsigned NumTemplateArgs) {
497  assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
498  std::size_t Size =
499  totalSizeToAlloc<ASTTemplateKWAndArgsInfo, TemplateArgumentLoc>(
500  HasTemplateKWAndArgsInfo, NumTemplateArgs);
501  void *Mem = Context.Allocate(Size);
502  auto *E = new (Mem) DependentScopeDeclRefExpr(
504  DeclarationNameInfo(), nullptr);
505  E->DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo =
506  HasTemplateKWAndArgsInfo;
507  return E;
508 }
509 
511  if (isa<CXXTemporaryObjectExpr>(this))
512  return cast<CXXTemporaryObjectExpr>(this)->getBeginLoc();
513  return getLocation();
514 }
515 
517  if (isa<CXXTemporaryObjectExpr>(this))
518  return cast<CXXTemporaryObjectExpr>(this)->getEndLoc();
519 
520  if (ParenOrBraceRange.isValid())
521  return ParenOrBraceRange.getEnd();
522 
523  SourceLocation End = getLocation();
524  for (unsigned I = getNumArgs(); I > 0; --I) {
525  const Expr *Arg = getArg(I-1);
526  if (!Arg->isDefaultArgument()) {
527  SourceLocation NewEnd = Arg->getEndLoc();
528  if (NewEnd.isValid()) {
529  End = NewEnd;
530  break;
531  }
532  }
533  }
534 
535  return End;
536 }
537 
538 CXXOperatorCallExpr::CXXOperatorCallExpr(OverloadedOperatorKind OpKind,
539  Expr *Fn, ArrayRef<Expr *> Args,
540  QualType Ty, ExprValueKind VK,
541  SourceLocation OperatorLoc,
542  FPOptions FPFeatures,
543  ADLCallKind UsesADL)
544  : CallExpr(CXXOperatorCallExprClass, Fn, /*PreArgs=*/{}, Args, Ty, VK,
545  OperatorLoc, /*MinNumArgs=*/0, UsesADL) {
546  CXXOperatorCallExprBits.OperatorKind = OpKind;
547  CXXOperatorCallExprBits.FPFeatures = FPFeatures.getInt();
548  assert(
549  (CXXOperatorCallExprBits.OperatorKind == static_cast<unsigned>(OpKind)) &&
550  "OperatorKind overflow!");
551  assert((CXXOperatorCallExprBits.FPFeatures == FPFeatures.getInt()) &&
552  "FPFeatures overflow!");
553  Range = getSourceRangeImpl();
554 }
555 
556 CXXOperatorCallExpr::CXXOperatorCallExpr(unsigned NumArgs, EmptyShell Empty)
557  : CallExpr(CXXOperatorCallExprClass, /*NumPreArgs=*/0, NumArgs, Empty) {}
558 
560  const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn,
562  SourceLocation OperatorLoc, FPOptions FPFeatures, ADLCallKind UsesADL) {
563  // Allocate storage for the trailing objects of CallExpr.
564  unsigned NumArgs = Args.size();
565  unsigned SizeOfTrailingObjects =
566  CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs);
567  void *Mem = Ctx.Allocate(sizeof(CXXOperatorCallExpr) + SizeOfTrailingObjects,
568  alignof(CXXOperatorCallExpr));
569  return new (Mem) CXXOperatorCallExpr(OpKind, Fn, Args, Ty, VK, OperatorLoc,
570  FPFeatures, UsesADL);
571 }
572 
574  unsigned NumArgs,
575  EmptyShell Empty) {
576  // Allocate storage for the trailing objects of CallExpr.
577  unsigned SizeOfTrailingObjects =
578  CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs);
579  void *Mem = Ctx.Allocate(sizeof(CXXOperatorCallExpr) + SizeOfTrailingObjects,
580  alignof(CXXOperatorCallExpr));
581  return new (Mem) CXXOperatorCallExpr(NumArgs, Empty);
582 }
583 
584 SourceRange CXXOperatorCallExpr::getSourceRangeImpl() const {
585  OverloadedOperatorKind Kind = getOperator();
586  if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
587  if (getNumArgs() == 1)
588  // Prefix operator
589  return SourceRange(getOperatorLoc(), getArg(0)->getEndLoc());
590  else
591  // Postfix operator
592  return SourceRange(getArg(0)->getBeginLoc(), getOperatorLoc());
593  } else if (Kind == OO_Arrow) {
594  return getArg(0)->getSourceRange();
595  } else if (Kind == OO_Call) {
596  return SourceRange(getArg(0)->getBeginLoc(), getRParenLoc());
597  } else if (Kind == OO_Subscript) {
598  return SourceRange(getArg(0)->getBeginLoc(), getRParenLoc());
599  } else if (getNumArgs() == 1) {
600  return SourceRange(getOperatorLoc(), getArg(0)->getEndLoc());
601  } else if (getNumArgs() == 2) {
602  return SourceRange(getArg(0)->getBeginLoc(), getArg(1)->getEndLoc());
603  } else {
604  return getOperatorLoc();
605  }
606 }
607 
608 CXXMemberCallExpr::CXXMemberCallExpr(Expr *Fn, ArrayRef<Expr *> Args,
609  QualType Ty, ExprValueKind VK,
610  SourceLocation RP, unsigned MinNumArgs)
611  : CallExpr(CXXMemberCallExprClass, Fn, /*PreArgs=*/{}, Args, Ty, VK, RP,
612  MinNumArgs, NotADL) {}
613 
614 CXXMemberCallExpr::CXXMemberCallExpr(unsigned NumArgs, EmptyShell Empty)
615  : CallExpr(CXXMemberCallExprClass, /*NumPreArgs=*/0, NumArgs, Empty) {}
616 
618  ArrayRef<Expr *> Args, QualType Ty,
619  ExprValueKind VK,
620  SourceLocation RP,
621  unsigned MinNumArgs) {
622  // Allocate storage for the trailing objects of CallExpr.
623  unsigned NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
624  unsigned SizeOfTrailingObjects =
625  CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs);
626  void *Mem = Ctx.Allocate(sizeof(CXXMemberCallExpr) + SizeOfTrailingObjects,
627  alignof(CXXMemberCallExpr));
628  return new (Mem) CXXMemberCallExpr(Fn, Args, Ty, VK, RP, MinNumArgs);
629 }
630 
632  unsigned NumArgs,
633  EmptyShell Empty) {
634  // Allocate storage for the trailing objects of CallExpr.
635  unsigned SizeOfTrailingObjects =
636  CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs);
637  void *Mem = Ctx.Allocate(sizeof(CXXMemberCallExpr) + SizeOfTrailingObjects,
638  alignof(CXXMemberCallExpr));
639  return new (Mem) CXXMemberCallExpr(NumArgs, Empty);
640 }
641 
643  const Expr *Callee = getCallee()->IgnoreParens();
644  if (const auto *MemExpr = dyn_cast<MemberExpr>(Callee))
645  return MemExpr->getBase();
646  if (const auto *BO = dyn_cast<BinaryOperator>(Callee))
647  if (BO->getOpcode() == BO_PtrMemD || BO->getOpcode() == BO_PtrMemI)
648  return BO->getLHS();
649 
650  // FIXME: Will eventually need to cope with member pointers.
651  return nullptr;
652 }
653 
655  QualType Ty = getImplicitObjectArgument()->getType();
656  if (Ty->isPointerType())
657  Ty = Ty->getPointeeType();
658  return Ty;
659 }
660 
662  if (const auto *MemExpr = dyn_cast<MemberExpr>(getCallee()->IgnoreParens()))
663  return cast<CXXMethodDecl>(MemExpr->getMemberDecl());
664 
665  // FIXME: Will eventually need to cope with member pointers.
666  return nullptr;
667 }
668 
670  Expr* ThisArg = getImplicitObjectArgument();
671  if (!ThisArg)
672  return nullptr;
673 
674  if (ThisArg->getType()->isAnyPointerType())
675  return ThisArg->getType()->getPointeeType()->getAsCXXRecordDecl();
676 
677  return ThisArg->getType()->getAsCXXRecordDecl();
678 }
679 
680 //===----------------------------------------------------------------------===//
681 // Named casts
682 //===----------------------------------------------------------------------===//
683 
684 /// getCastName - Get the name of the C++ cast being used, e.g.,
685 /// "static_cast", "dynamic_cast", "reinterpret_cast", or
686 /// "const_cast". The returned pointer must not be freed.
687 const char *CXXNamedCastExpr::getCastName() const {
688  switch (getStmtClass()) {
689  case CXXStaticCastExprClass: return "static_cast";
690  case CXXDynamicCastExprClass: return "dynamic_cast";
691  case CXXReinterpretCastExprClass: return "reinterpret_cast";
692  case CXXConstCastExprClass: return "const_cast";
693  default: return "<invalid cast>";
694  }
695 }
696 
698  ExprValueKind VK,
699  CastKind K, Expr *Op,
700  const CXXCastPath *BasePath,
701  TypeSourceInfo *WrittenTy,
702  SourceLocation L,
703  SourceLocation RParenLoc,
704  SourceRange AngleBrackets) {
705  unsigned PathSize = (BasePath ? BasePath->size() : 0);
706  void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
707  auto *E =
708  new (Buffer) CXXStaticCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
709  RParenLoc, AngleBrackets);
710  if (PathSize)
711  std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
712  E->getTrailingObjects<CXXBaseSpecifier *>());
713  return E;
714 }
715 
717  unsigned PathSize) {
718  void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
719  return new (Buffer) CXXStaticCastExpr(EmptyShell(), PathSize);
720 }
721 
723  ExprValueKind VK,
724  CastKind K, Expr *Op,
725  const CXXCastPath *BasePath,
726  TypeSourceInfo *WrittenTy,
727  SourceLocation L,
728  SourceLocation RParenLoc,
729  SourceRange AngleBrackets) {
730  unsigned PathSize = (BasePath ? BasePath->size() : 0);
731  void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
732  auto *E =
733  new (Buffer) CXXDynamicCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
734  RParenLoc, AngleBrackets);
735  if (PathSize)
736  std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
737  E->getTrailingObjects<CXXBaseSpecifier *>());
738  return E;
739 }
740 
742  unsigned PathSize) {
743  void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
744  return new (Buffer) CXXDynamicCastExpr(EmptyShell(), PathSize);
745 }
746 
747 /// isAlwaysNull - Return whether the result of the dynamic_cast is proven
748 /// to always be null. For example:
749 ///
750 /// struct A { };
751 /// struct B final : A { };
752 /// struct C { };
753 ///
754 /// C *f(B* b) { return dynamic_cast<C*>(b); }
756 {
757  QualType SrcType = getSubExpr()->getType();
758  QualType DestType = getType();
759 
760  if (const auto *SrcPTy = SrcType->getAs<PointerType>()) {
761  SrcType = SrcPTy->getPointeeType();
762  DestType = DestType->castAs<PointerType>()->getPointeeType();
763  }
764 
765  if (DestType->isVoidType())
766  return false;
767 
768  const auto *SrcRD =
769  cast<CXXRecordDecl>(SrcType->castAs<RecordType>()->getDecl());
770 
771  if (!SrcRD->hasAttr<FinalAttr>())
772  return false;
773 
774  const auto *DestRD =
775  cast<CXXRecordDecl>(DestType->castAs<RecordType>()->getDecl());
776 
777  return !DestRD->isDerivedFrom(SrcRD);
778 }
779 
782  ExprValueKind VK, CastKind K, Expr *Op,
783  const CXXCastPath *BasePath,
784  TypeSourceInfo *WrittenTy, SourceLocation L,
785  SourceLocation RParenLoc,
786  SourceRange AngleBrackets) {
787  unsigned PathSize = (BasePath ? BasePath->size() : 0);
788  void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
789  auto *E =
790  new (Buffer) CXXReinterpretCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
791  RParenLoc, AngleBrackets);
792  if (PathSize)
793  std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
794  E->getTrailingObjects<CXXBaseSpecifier *>());
795  return E;
796 }
797 
800  void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
801  return new (Buffer) CXXReinterpretCastExpr(EmptyShell(), PathSize);
802 }
803 
805  ExprValueKind VK, Expr *Op,
806  TypeSourceInfo *WrittenTy,
807  SourceLocation L,
808  SourceLocation RParenLoc,
809  SourceRange AngleBrackets) {
810  return new (C) CXXConstCastExpr(T, VK, Op, WrittenTy, L, RParenLoc, AngleBrackets);
811 }
812 
814  return new (C) CXXConstCastExpr(EmptyShell());
815 }
816 
819  TypeSourceInfo *Written, CastKind K, Expr *Op,
820  const CXXCastPath *BasePath,
822  unsigned PathSize = (BasePath ? BasePath->size() : 0);
823  void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
824  auto *E =
825  new (Buffer) CXXFunctionalCastExpr(T, VK, Written, K, Op, PathSize, L, R);
826  if (PathSize)
827  std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
828  E->getTrailingObjects<CXXBaseSpecifier *>());
829  return E;
830 }
831 
833 CXXFunctionalCastExpr::CreateEmpty(const ASTContext &C, unsigned PathSize) {
834  void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
835  return new (Buffer) CXXFunctionalCastExpr(EmptyShell(), PathSize);
836 }
837 
839  return getTypeInfoAsWritten()->getTypeLoc().getBeginLoc();
840 }
841 
843  return RParenLoc.isValid() ? RParenLoc : getSubExpr()->getEndLoc();
844 }
845 
846 UserDefinedLiteral::UserDefinedLiteral(Expr *Fn, ArrayRef<Expr *> Args,
847  QualType Ty, ExprValueKind VK,
848  SourceLocation LitEndLoc,
849  SourceLocation SuffixLoc)
850  : CallExpr(UserDefinedLiteralClass, Fn, /*PreArgs=*/{}, Args, Ty, VK,
851  LitEndLoc, /*MinNumArgs=*/0, NotADL),
852  UDSuffixLoc(SuffixLoc) {}
853 
854 UserDefinedLiteral::UserDefinedLiteral(unsigned NumArgs, EmptyShell Empty)
855  : CallExpr(UserDefinedLiteralClass, /*NumPreArgs=*/0, NumArgs, Empty) {}
856 
858  ArrayRef<Expr *> Args,
859  QualType Ty, ExprValueKind VK,
860  SourceLocation LitEndLoc,
861  SourceLocation SuffixLoc) {
862  // Allocate storage for the trailing objects of CallExpr.
863  unsigned NumArgs = Args.size();
864  unsigned SizeOfTrailingObjects =
865  CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs);
866  void *Mem = Ctx.Allocate(sizeof(UserDefinedLiteral) + SizeOfTrailingObjects,
867  alignof(UserDefinedLiteral));
868  return new (Mem) UserDefinedLiteral(Fn, Args, Ty, VK, LitEndLoc, SuffixLoc);
869 }
870 
872  unsigned NumArgs,
873  EmptyShell Empty) {
874  // Allocate storage for the trailing objects of CallExpr.
875  unsigned SizeOfTrailingObjects =
876  CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs);
877  void *Mem = Ctx.Allocate(sizeof(UserDefinedLiteral) + SizeOfTrailingObjects,
878  alignof(UserDefinedLiteral));
879  return new (Mem) UserDefinedLiteral(NumArgs, Empty);
880 }
881 
884  if (getNumArgs() == 0)
885  return LOK_Template;
886  if (getNumArgs() == 2)
887  return LOK_String;
888 
889  assert(getNumArgs() == 1 && "unexpected #args in literal operator call");
890  QualType ParamTy =
891  cast<FunctionDecl>(getCalleeDecl())->getParamDecl(0)->getType();
892  if (ParamTy->isPointerType())
893  return LOK_Raw;
894  if (ParamTy->isAnyCharacterType())
895  return LOK_Character;
896  if (ParamTy->isIntegerType())
897  return LOK_Integer;
898  if (ParamTy->isFloatingType())
899  return LOK_Floating;
900 
901  llvm_unreachable("unknown kind of literal operator");
902 }
903 
905 #ifndef NDEBUG
906  LiteralOperatorKind LOK = getLiteralOperatorKind();
907  assert(LOK != LOK_Template && LOK != LOK_Raw && "not a cooked literal");
908 #endif
909  return getArg(0);
910 }
911 
913  return cast<FunctionDecl>(getCalleeDecl())->getLiteralIdentifier();
914 }
915 
916 CXXDefaultInitExpr::CXXDefaultInitExpr(const ASTContext &Ctx, SourceLocation Loc,
917  FieldDecl *Field, QualType Ty,
918  DeclContext *UsedContext)
919  : Expr(CXXDefaultInitExprClass, Ty.getNonLValueExprType(Ctx),
921  ? VK_XValue
922  : VK_RValue,
923  /*FIXME*/ OK_Ordinary, false, false, false, false),
924  Field(Field), UsedContext(UsedContext) {
925  CXXDefaultInitExprBits.Loc = Loc;
926  assert(Field->hasInClassInitializer());
927 }
928 
930  const CXXDestructorDecl *Destructor) {
931  return new (C) CXXTemporary(Destructor);
932 }
933 
935  CXXTemporary *Temp,
936  Expr* SubExpr) {
937  assert((SubExpr->getType()->isRecordType() ||
938  SubExpr->getType()->isArrayType()) &&
939  "Expression bound to a temporary must have record or array type!");
940 
941  return new (C) CXXBindTemporaryExpr(Temp, SubExpr);
942 }
943 
944 CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(
946  ArrayRef<Expr *> Args, SourceRange ParenOrBraceRange,
947  bool HadMultipleCandidates, bool ListInitialization,
948  bool StdInitListInitialization, bool ZeroInitialization)
950  CXXTemporaryObjectExprClass, Ty, TSI->getTypeLoc().getBeginLoc(),
951  Cons, /* Elidable=*/false, Args, HadMultipleCandidates,
952  ListInitialization, StdInitListInitialization, ZeroInitialization,
953  CXXConstructExpr::CK_Complete, ParenOrBraceRange),
954  TSI(TSI) {}
955 
956 CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(EmptyShell Empty,
957  unsigned NumArgs)
958  : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty, NumArgs) {}
959 
961  const ASTContext &Ctx, CXXConstructorDecl *Cons, QualType Ty,
962  TypeSourceInfo *TSI, ArrayRef<Expr *> Args, SourceRange ParenOrBraceRange,
963  bool HadMultipleCandidates, bool ListInitialization,
964  bool StdInitListInitialization, bool ZeroInitialization) {
965  unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(Args.size());
966  void *Mem =
967  Ctx.Allocate(sizeof(CXXTemporaryObjectExpr) + SizeOfTrailingObjects,
968  alignof(CXXTemporaryObjectExpr));
969  return new (Mem) CXXTemporaryObjectExpr(
970  Cons, Ty, TSI, Args, ParenOrBraceRange, HadMultipleCandidates,
971  ListInitialization, StdInitListInitialization, ZeroInitialization);
972 }
973 
975 CXXTemporaryObjectExpr::CreateEmpty(const ASTContext &Ctx, unsigned NumArgs) {
976  unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(NumArgs);
977  void *Mem =
978  Ctx.Allocate(sizeof(CXXTemporaryObjectExpr) + SizeOfTrailingObjects,
979  alignof(CXXTemporaryObjectExpr));
980  return new (Mem) CXXTemporaryObjectExpr(EmptyShell(), NumArgs);
981 }
982 
984  return getTypeSourceInfo()->getTypeLoc().getBeginLoc();
985 }
986 
988  SourceLocation Loc = getParenOrBraceRange().getEnd();
989  if (Loc.isInvalid() && getNumArgs())
990  Loc = getArg(getNumArgs() - 1)->getEndLoc();
991  return Loc;
992 }
993 
995  const ASTContext &Ctx, QualType Ty, SourceLocation Loc,
996  CXXConstructorDecl *Ctor, bool Elidable, ArrayRef<Expr *> Args,
997  bool HadMultipleCandidates, bool ListInitialization,
998  bool StdInitListInitialization, bool ZeroInitialization,
999  ConstructionKind ConstructKind, SourceRange ParenOrBraceRange) {
1000  unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(Args.size());
1001  void *Mem = Ctx.Allocate(sizeof(CXXConstructExpr) + SizeOfTrailingObjects,
1002  alignof(CXXConstructExpr));
1003  return new (Mem) CXXConstructExpr(
1004  CXXConstructExprClass, Ty, Loc, Ctor, Elidable, Args,
1005  HadMultipleCandidates, ListInitialization, StdInitListInitialization,
1006  ZeroInitialization, ConstructKind, ParenOrBraceRange);
1007 }
1008 
1010  unsigned NumArgs) {
1011  unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(NumArgs);
1012  void *Mem = Ctx.Allocate(sizeof(CXXConstructExpr) + SizeOfTrailingObjects,
1013  alignof(CXXConstructExpr));
1014  return new (Mem)
1015  CXXConstructExpr(CXXConstructExprClass, EmptyShell(), NumArgs);
1016 }
1017 
1020  bool Elidable, ArrayRef<Expr *> Args, bool HadMultipleCandidates,
1021  bool ListInitialization, bool StdInitListInitialization,
1022  bool ZeroInitialization, ConstructionKind ConstructKind,
1023  SourceRange ParenOrBraceRange)
1024  : Expr(SC, Ty, VK_RValue, OK_Ordinary, Ty->isDependentType(),
1025  Ty->isDependentType(), Ty->isInstantiationDependentType(),
1027  Constructor(Ctor), ParenOrBraceRange(ParenOrBraceRange),
1028  NumArgs(Args.size()) {
1029  CXXConstructExprBits.Elidable = Elidable;
1030  CXXConstructExprBits.HadMultipleCandidates = HadMultipleCandidates;
1031  CXXConstructExprBits.ListInitialization = ListInitialization;
1032  CXXConstructExprBits.StdInitListInitialization = StdInitListInitialization;
1033  CXXConstructExprBits.ZeroInitialization = ZeroInitialization;
1034  CXXConstructExprBits.ConstructionKind = ConstructKind;
1035  CXXConstructExprBits.Loc = Loc;
1036 
1037  Stmt **TrailingArgs = getTrailingArgs();
1038  for (unsigned I = 0, N = Args.size(); I != N; ++I) {
1039  assert(Args[I] && "NULL argument in CXXConstructExpr!");
1040 
1041  if (Args[I]->isValueDependent())
1042  ExprBits.ValueDependent = true;
1043  if (Args[I]->isInstantiationDependent())
1044  ExprBits.InstantiationDependent = true;
1045  if (Args[I]->containsUnexpandedParameterPack())
1046  ExprBits.ContainsUnexpandedParameterPack = true;
1047 
1048  TrailingArgs[I] = Args[I];
1049  }
1050 }
1051 
1053  unsigned NumArgs)
1054  : Expr(SC, Empty), NumArgs(NumArgs) {}
1055 
1058  SourceLocation EllipsisLoc)
1059  : DeclAndBits(Var, 0), Loc(Loc), EllipsisLoc(EllipsisLoc) {
1060  unsigned Bits = 0;
1061  if (Implicit)
1062  Bits |= Capture_Implicit;
1063 
1064  switch (Kind) {
1065  case LCK_StarThis:
1066  Bits |= Capture_ByCopy;
1067  LLVM_FALLTHROUGH;
1068  case LCK_This:
1069  assert(!Var && "'this' capture cannot have a variable!");
1070  Bits |= Capture_This;
1071  break;
1072 
1073  case LCK_ByCopy:
1074  Bits |= Capture_ByCopy;
1075  LLVM_FALLTHROUGH;
1076  case LCK_ByRef:
1077  assert(Var && "capture must have a variable!");
1078  break;
1079  case LCK_VLAType:
1080  assert(!Var && "VLA type capture cannot have a variable!");
1081  break;
1082  }
1083  DeclAndBits.setInt(Bits);
1084 }
1085 
1087  if (capturesVLAType())
1088  return LCK_VLAType;
1089  bool CapByCopy = DeclAndBits.getInt() & Capture_ByCopy;
1090  if (capturesThis())
1091  return CapByCopy ? LCK_StarThis : LCK_This;
1092  return CapByCopy ? LCK_ByCopy : LCK_ByRef;
1093 }
1094 
1095 LambdaExpr::LambdaExpr(QualType T, SourceRange IntroducerRange,
1096  LambdaCaptureDefault CaptureDefault,
1097  SourceLocation CaptureDefaultLoc,
1098  ArrayRef<LambdaCapture> Captures, bool ExplicitParams,
1099  bool ExplicitResultType, ArrayRef<Expr *> CaptureInits,
1100  SourceLocation ClosingBrace,
1101  bool ContainsUnexpandedParameterPack)
1102  : Expr(LambdaExprClass, T, VK_RValue, OK_Ordinary, T->isDependentType(),
1103  T->isDependentType(), T->isDependentType(),
1104  ContainsUnexpandedParameterPack),
1105  IntroducerRange(IntroducerRange), CaptureDefaultLoc(CaptureDefaultLoc),
1106  NumCaptures(Captures.size()), CaptureDefault(CaptureDefault),
1107  ExplicitParams(ExplicitParams), ExplicitResultType(ExplicitResultType),
1108  ClosingBrace(ClosingBrace) {
1109  assert(CaptureInits.size() == Captures.size() && "Wrong number of arguments");
1110  CXXRecordDecl *Class = getLambdaClass();
1111  CXXRecordDecl::LambdaDefinitionData &Data = Class->getLambdaData();
1112 
1113  // FIXME: Propagate "has unexpanded parameter pack" bit.
1114 
1115  // Copy captures.
1116  const ASTContext &Context = Class->getASTContext();
1117  Data.NumCaptures = NumCaptures;
1118  Data.NumExplicitCaptures = 0;
1119  Data.Captures =
1120  (LambdaCapture *)Context.Allocate(sizeof(LambdaCapture) * NumCaptures);
1121  LambdaCapture *ToCapture = Data.Captures;
1122  for (unsigned I = 0, N = Captures.size(); I != N; ++I) {
1123  if (Captures[I].isExplicit())
1124  ++Data.NumExplicitCaptures;
1125 
1126  *ToCapture++ = Captures[I];
1127  }
1128 
1129  // Copy initialization expressions for the non-static data members.
1130  Stmt **Stored = getStoredStmts();
1131  for (unsigned I = 0, N = CaptureInits.size(); I != N; ++I)
1132  *Stored++ = CaptureInits[I];
1133 
1134  // Copy the body of the lambda.
1135  *Stored++ = getCallOperator()->getBody();
1136 }
1137 
1139  const ASTContext &Context, CXXRecordDecl *Class,
1140  SourceRange IntroducerRange, LambdaCaptureDefault CaptureDefault,
1141  SourceLocation CaptureDefaultLoc, ArrayRef<LambdaCapture> Captures,
1142  bool ExplicitParams, bool ExplicitResultType, ArrayRef<Expr *> CaptureInits,
1143  SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack) {
1144  // Determine the type of the expression (i.e., the type of the
1145  // function object we're creating).
1146  QualType T = Context.getTypeDeclType(Class);
1147 
1148  unsigned Size = totalSizeToAlloc<Stmt *>(Captures.size() + 1);
1149  void *Mem = Context.Allocate(Size);
1150  return new (Mem)
1151  LambdaExpr(T, IntroducerRange, CaptureDefault, CaptureDefaultLoc,
1152  Captures, ExplicitParams, ExplicitResultType, CaptureInits,
1153  ClosingBrace, ContainsUnexpandedParameterPack);
1154 }
1155 
1157  unsigned NumCaptures) {
1158  unsigned Size = totalSizeToAlloc<Stmt *>(NumCaptures + 1);
1159  void *Mem = C.Allocate(Size);
1160  return new (Mem) LambdaExpr(EmptyShell(), NumCaptures);
1161 }
1162 
1164  return (C->capturesVariable() && C->getCapturedVar()->isInitCapture() &&
1165  (getCallOperator() == C->getCapturedVar()->getDeclContext()));
1166 }
1167 
1169  return getLambdaClass()->getLambdaData().Captures;
1170 }
1171 
1173  return capture_begin() + NumCaptures;
1174 }
1175 
1177  return capture_range(capture_begin(), capture_end());
1178 }
1179 
1181  return capture_begin();
1182 }
1183 
1185  struct CXXRecordDecl::LambdaDefinitionData &Data
1186  = getLambdaClass()->getLambdaData();
1187  return Data.Captures + Data.NumExplicitCaptures;
1188 }
1189 
1191  return capture_range(explicit_capture_begin(), explicit_capture_end());
1192 }
1193 
1195  return explicit_capture_end();
1196 }
1197 
1199  return capture_end();
1200 }
1201 
1203  return capture_range(implicit_capture_begin(), implicit_capture_end());
1204 }
1205 
1207  return getType()->getAsCXXRecordDecl();
1208 }
1209 
1211  CXXRecordDecl *Record = getLambdaClass();
1212  return Record->getLambdaCallOperator();
1213 }
1214 
1216  CXXRecordDecl *Record = getLambdaClass();
1217  return Record->getGenericLambdaTemplateParameterList();
1218 }
1219 
1221  const CXXRecordDecl *Record = getLambdaClass();
1222  return Record->getLambdaExplicitTemplateParameters();
1223 }
1224 
1226  // FIXME: this mutation in getBody is bogus. It should be
1227  // initialized in ASTStmtReader::VisitLambdaExpr, but for reasons I
1228  // don't understand, that doesn't work.
1229  if (!getStoredStmts()[NumCaptures])
1230  *const_cast<Stmt **>(&getStoredStmts()[NumCaptures]) =
1231  getCallOperator()->getBody();
1232 
1233  return static_cast<CompoundStmt *>(getStoredStmts()[NumCaptures]);
1234 }
1235 
1237  return !getCallOperator()->isConst();
1238 }
1239 
1240 ExprWithCleanups::ExprWithCleanups(Expr *subexpr,
1241  bool CleanupsHaveSideEffects,
1242  ArrayRef<CleanupObject> objects)
1243  : FullExpr(ExprWithCleanupsClass, subexpr) {
1244  ExprWithCleanupsBits.CleanupsHaveSideEffects = CleanupsHaveSideEffects;
1245  ExprWithCleanupsBits.NumObjects = objects.size();
1246  for (unsigned i = 0, e = objects.size(); i != e; ++i)
1247  getTrailingObjects<CleanupObject>()[i] = objects[i];
1248 }
1249 
1251  bool CleanupsHaveSideEffects,
1252  ArrayRef<CleanupObject> objects) {
1253  void *buffer = C.Allocate(totalSizeToAlloc<CleanupObject>(objects.size()),
1254  alignof(ExprWithCleanups));
1255  return new (buffer)
1256  ExprWithCleanups(subexpr, CleanupsHaveSideEffects, objects);
1257 }
1258 
1259 ExprWithCleanups::ExprWithCleanups(EmptyShell empty, unsigned numObjects)
1260  : FullExpr(ExprWithCleanupsClass, empty) {
1261  ExprWithCleanupsBits.NumObjects = numObjects;
1262 }
1263 
1265  EmptyShell empty,
1266  unsigned numObjects) {
1267  void *buffer = C.Allocate(totalSizeToAlloc<CleanupObject>(numObjects),
1268  alignof(ExprWithCleanups));
1269  return new (buffer) ExprWithCleanups(empty, numObjects);
1270 }
1271 
1272 CXXUnresolvedConstructExpr::CXXUnresolvedConstructExpr(TypeSourceInfo *TSI,
1273  SourceLocation LParenLoc,
1274  ArrayRef<Expr *> Args,
1275  SourceLocation RParenLoc)
1276  : Expr(CXXUnresolvedConstructExprClass,
1277  TSI->getType().getNonReferenceType(),
1278  (TSI->getType()->isLValueReferenceType()
1279  ? VK_LValue
1281  : VK_RValue),
1282  OK_Ordinary,
1283  TSI->getType()->isDependentType() ||
1284  TSI->getType()->getContainedDeducedType(),
1285  true, true, TSI->getType()->containsUnexpandedParameterPack()),
1286  TSI(TSI), LParenLoc(LParenLoc), RParenLoc(RParenLoc) {
1287  CXXUnresolvedConstructExprBits.NumArgs = Args.size();
1288  auto **StoredArgs = getTrailingObjects<Expr *>();
1289  for (unsigned I = 0; I != Args.size(); ++I) {
1290  if (Args[I]->containsUnexpandedParameterPack())
1291  ExprBits.ContainsUnexpandedParameterPack = true;
1292 
1293  StoredArgs[I] = Args[I];
1294  }
1295 }
1296 
1298  const ASTContext &Context, TypeSourceInfo *TSI, SourceLocation LParenLoc,
1299  ArrayRef<Expr *> Args, SourceLocation RParenLoc) {
1300  void *Mem = Context.Allocate(totalSizeToAlloc<Expr *>(Args.size()));
1301  return new (Mem) CXXUnresolvedConstructExpr(TSI, LParenLoc, Args, RParenLoc);
1302 }
1303 
1306  unsigned NumArgs) {
1307  void *Mem = Context.Allocate(totalSizeToAlloc<Expr *>(NumArgs));
1308  return new (Mem) CXXUnresolvedConstructExpr(EmptyShell(), NumArgs);
1309 }
1310 
1312  return TSI->getTypeLoc().getBeginLoc();
1313 }
1314 
1315 CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(
1316  const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow,
1317  SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc,
1318  SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope,
1319  DeclarationNameInfo MemberNameInfo,
1320  const TemplateArgumentListInfo *TemplateArgs)
1321  : Expr(CXXDependentScopeMemberExprClass, Ctx.DependentTy, VK_LValue,
1322  OK_Ordinary, true, true, true,
1323  ((Base && Base->containsUnexpandedParameterPack()) ||
1324  (QualifierLoc && QualifierLoc.getNestedNameSpecifier()
1326  MemberNameInfo.containsUnexpandedParameterPack())),
1327  Base(Base), BaseType(BaseType), QualifierLoc(QualifierLoc),
1328  MemberNameInfo(MemberNameInfo) {
1329  CXXDependentScopeMemberExprBits.IsArrow = IsArrow;
1330  CXXDependentScopeMemberExprBits.HasTemplateKWAndArgsInfo =
1331  (TemplateArgs != nullptr) || TemplateKWLoc.isValid();
1332  CXXDependentScopeMemberExprBits.HasFirstQualifierFoundInScope =
1333  FirstQualifierFoundInScope != nullptr;
1334  CXXDependentScopeMemberExprBits.OperatorLoc = OperatorLoc;
1335 
1336  if (TemplateArgs) {
1337  bool Dependent = true;
1338  bool InstantiationDependent = true;
1339  bool ContainsUnexpandedParameterPack = false;
1340  getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1341  TemplateKWLoc, *TemplateArgs, getTrailingObjects<TemplateArgumentLoc>(),
1342  Dependent, InstantiationDependent, ContainsUnexpandedParameterPack);
1343  if (ContainsUnexpandedParameterPack)
1344  ExprBits.ContainsUnexpandedParameterPack = true;
1345  } else if (TemplateKWLoc.isValid()) {
1346  getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1347  TemplateKWLoc);
1348  }
1349 
1350  if (hasFirstQualifierFoundInScope())
1351  *getTrailingObjects<NamedDecl *>() = FirstQualifierFoundInScope;
1352 }
1353 
1354 CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(
1355  EmptyShell Empty, bool HasTemplateKWAndArgsInfo,
1356  bool HasFirstQualifierFoundInScope)
1357  : Expr(CXXDependentScopeMemberExprClass, Empty) {
1358  CXXDependentScopeMemberExprBits.HasTemplateKWAndArgsInfo =
1359  HasTemplateKWAndArgsInfo;
1360  CXXDependentScopeMemberExprBits.HasFirstQualifierFoundInScope =
1361  HasFirstQualifierFoundInScope;
1362 }
1363 
1365  const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow,
1366  SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc,
1367  SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope,
1368  DeclarationNameInfo MemberNameInfo,
1369  const TemplateArgumentListInfo *TemplateArgs) {
1370  bool HasTemplateKWAndArgsInfo =
1371  (TemplateArgs != nullptr) || TemplateKWLoc.isValid();
1372  unsigned NumTemplateArgs = TemplateArgs ? TemplateArgs->size() : 0;
1373  bool HasFirstQualifierFoundInScope = FirstQualifierFoundInScope != nullptr;
1374 
1375  unsigned Size = totalSizeToAlloc<ASTTemplateKWAndArgsInfo,
1377  HasTemplateKWAndArgsInfo, NumTemplateArgs, HasFirstQualifierFoundInScope);
1378 
1379  void *Mem = Ctx.Allocate(Size, alignof(CXXDependentScopeMemberExpr));
1380  return new (Mem) CXXDependentScopeMemberExpr(
1381  Ctx, Base, BaseType, IsArrow, OperatorLoc, QualifierLoc, TemplateKWLoc,
1382  FirstQualifierFoundInScope, MemberNameInfo, TemplateArgs);
1383 }
1384 
1386  const ASTContext &Ctx, bool HasTemplateKWAndArgsInfo,
1387  unsigned NumTemplateArgs, bool HasFirstQualifierFoundInScope) {
1388  assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
1389 
1390  unsigned Size = totalSizeToAlloc<ASTTemplateKWAndArgsInfo,
1392  HasTemplateKWAndArgsInfo, NumTemplateArgs, HasFirstQualifierFoundInScope);
1393 
1394  void *Mem = Ctx.Allocate(Size, alignof(CXXDependentScopeMemberExpr));
1395  return new (Mem) CXXDependentScopeMemberExpr(
1396  EmptyShell(), HasTemplateKWAndArgsInfo, HasFirstQualifierFoundInScope);
1397 }
1398 
1400  UnresolvedSetIterator end) {
1401  do {
1402  NamedDecl *decl = *begin;
1403  if (isa<UnresolvedUsingValueDecl>(decl))
1404  return false;
1405 
1406  // Unresolved member expressions should only contain methods and
1407  // method templates.
1408  if (cast<CXXMethodDecl>(decl->getUnderlyingDecl()->getAsFunction())
1409  ->isStatic())
1410  return false;
1411  } while (++begin != end);
1412 
1413  return true;
1414 }
1415 
1416 UnresolvedMemberExpr::UnresolvedMemberExpr(
1417  const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base,
1418  QualType BaseType, bool IsArrow, SourceLocation OperatorLoc,
1419  NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
1420  const DeclarationNameInfo &MemberNameInfo,
1421  const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin,
1423  : OverloadExpr(
1424  UnresolvedMemberExprClass, Context, QualifierLoc, TemplateKWLoc,
1425  MemberNameInfo, TemplateArgs, Begin, End,
1426  // Dependent
1427  ((Base && Base->isTypeDependent()) || BaseType->isDependentType()),
1428  ((Base && Base->isInstantiationDependent()) ||
1429  BaseType->isInstantiationDependentType()),
1430  // Contains unexpanded parameter pack
1431  ((Base && Base->containsUnexpandedParameterPack()) ||
1432  BaseType->containsUnexpandedParameterPack())),
1433  Base(Base), BaseType(BaseType), OperatorLoc(OperatorLoc) {
1434  UnresolvedMemberExprBits.IsArrow = IsArrow;
1435  UnresolvedMemberExprBits.HasUnresolvedUsing = HasUnresolvedUsing;
1436 
1437  // Check whether all of the members are non-static member functions,
1438  // and if so, mark give this bound-member type instead of overload type.
1439  if (hasOnlyNonStaticMemberFunctions(Begin, End))
1440  setType(Context.BoundMemberTy);
1441 }
1442 
1443 UnresolvedMemberExpr::UnresolvedMemberExpr(EmptyShell Empty,
1444  unsigned NumResults,
1445  bool HasTemplateKWAndArgsInfo)
1446  : OverloadExpr(UnresolvedMemberExprClass, Empty, NumResults,
1447  HasTemplateKWAndArgsInfo) {}
1448 
1450  if (!Base)
1451  return true;
1452 
1453  return cast<Expr>(Base)->isImplicitCXXThis();
1454 }
1455 
1457  const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base,
1458  QualType BaseType, bool IsArrow, SourceLocation OperatorLoc,
1459  NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
1460  const DeclarationNameInfo &MemberNameInfo,
1461  const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin,
1462  UnresolvedSetIterator End) {
1463  unsigned NumResults = End - Begin;
1464  bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.isValid();
1465  unsigned NumTemplateArgs = TemplateArgs ? TemplateArgs->size() : 0;
1466  unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
1468  NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
1469  void *Mem = Context.Allocate(Size, alignof(UnresolvedMemberExpr));
1470  return new (Mem) UnresolvedMemberExpr(
1471  Context, HasUnresolvedUsing, Base, BaseType, IsArrow, OperatorLoc,
1472  QualifierLoc, TemplateKWLoc, MemberNameInfo, TemplateArgs, Begin, End);
1473 }
1474 
1476  const ASTContext &Context, unsigned NumResults,
1477  bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs) {
1478  assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
1479  unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
1481  NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
1482  void *Mem = Context.Allocate(Size, alignof(UnresolvedMemberExpr));
1483  return new (Mem)
1484  UnresolvedMemberExpr(EmptyShell(), NumResults, HasTemplateKWAndArgsInfo);
1485 }
1486 
1488  // Unlike for UnresolvedLookupExpr, it is very easy to re-derive this.
1489 
1490  // If there was a nested name specifier, it names the naming class.
1491  // It can't be dependent: after all, we were actually able to do the
1492  // lookup.
1493  CXXRecordDecl *Record = nullptr;
1494  auto *NNS = getQualifier();
1495  if (NNS && NNS->getKind() != NestedNameSpecifier::Super) {
1496  const Type *T = getQualifier()->getAsType();
1497  assert(T && "qualifier in member expression does not name type");
1498  Record = T->getAsCXXRecordDecl();
1499  assert(Record && "qualifier in member expression does not name record");
1500  }
1501  // Otherwise the naming class must have been the base class.
1502  else {
1503  QualType BaseType = getBaseType().getNonReferenceType();
1504  if (isArrow()) {
1505  const auto *PT = BaseType->getAs<PointerType>();
1506  assert(PT && "base of arrow member access is not pointer");
1507  BaseType = PT->getPointeeType();
1508  }
1509 
1510  Record = BaseType->getAsCXXRecordDecl();
1511  assert(Record && "base of member expression does not name record");
1512  }
1513 
1514  return Record;
1515 }
1516 
1519  NamedDecl *Pack, SourceLocation PackLoc,
1520  SourceLocation RParenLoc,
1521  Optional<unsigned> Length,
1522  ArrayRef<TemplateArgument> PartialArgs) {
1523  void *Storage =
1524  Context.Allocate(totalSizeToAlloc<TemplateArgument>(PartialArgs.size()));
1525  return new (Storage) SizeOfPackExpr(Context.getSizeType(), OperatorLoc, Pack,
1526  PackLoc, RParenLoc, Length, PartialArgs);
1527 }
1528 
1530  unsigned NumPartialArgs) {
1531  void *Storage =
1532  Context.Allocate(totalSizeToAlloc<TemplateArgument>(NumPartialArgs));
1533  return new (Storage) SizeOfPackExpr(EmptyShell(), NumPartialArgs);
1534 }
1535 
1536 SubstNonTypeTemplateParmPackExpr::
1537 SubstNonTypeTemplateParmPackExpr(QualType T,
1538  ExprValueKind ValueKind,
1539  NonTypeTemplateParmDecl *Param,
1540  SourceLocation NameLoc,
1541  const TemplateArgument &ArgPack)
1542  : Expr(SubstNonTypeTemplateParmPackExprClass, T, ValueKind, OK_Ordinary,
1543  true, true, true, true),
1544  Param(Param), Arguments(ArgPack.pack_begin()),
1545  NumArguments(ArgPack.pack_size()), NameLoc(NameLoc) {}
1546 
1548  return TemplateArgument(llvm::makeArrayRef(Arguments, NumArguments));
1549 }
1550 
1551 FunctionParmPackExpr::FunctionParmPackExpr(QualType T, VarDecl *ParamPack,
1552  SourceLocation NameLoc,
1553  unsigned NumParams,
1554  VarDecl *const *Params)
1555  : Expr(FunctionParmPackExprClass, T, VK_LValue, OK_Ordinary, true, true,
1556  true, true),
1557  ParamPack(ParamPack), NameLoc(NameLoc), NumParameters(NumParams) {
1558  if (Params)
1559  std::uninitialized_copy(Params, Params + NumParams,
1560  getTrailingObjects<VarDecl *>());
1561 }
1562 
1565  VarDecl *ParamPack, SourceLocation NameLoc,
1566  ArrayRef<VarDecl *> Params) {
1567  return new (Context.Allocate(totalSizeToAlloc<VarDecl *>(Params.size())))
1568  FunctionParmPackExpr(T, ParamPack, NameLoc, Params.size(), Params.data());
1569 }
1570 
1573  unsigned NumParams) {
1574  return new (Context.Allocate(totalSizeToAlloc<VarDecl *>(NumParams)))
1575  FunctionParmPackExpr(QualType(), nullptr, SourceLocation(), 0, nullptr);
1576 }
1577 
1579  unsigned ManglingNumber) {
1580  // We only need extra state if we have to remember more than just the Stmt.
1581  if (!ExtendedBy)
1582  return;
1583 
1584  // We may need to allocate extra storage for the mangling number and the
1585  // extended-by ValueDecl.
1586  if (!State.is<ExtraState *>()) {
1587  auto *ES = new (ExtendedBy->getASTContext()) ExtraState;
1588  ES->Temporary = State.get<Stmt *>();
1589  State = ES;
1590  }
1591 
1592  auto ES = State.get<ExtraState *>();
1593  ES->ExtendingDecl = ExtendedBy;
1594  ES->ManglingNumber = ManglingNumber;
1595 }
1596 
1597 TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind,
1599  SourceLocation RParenLoc,
1600  bool Value)
1601  : Expr(TypeTraitExprClass, T, VK_RValue, OK_Ordinary,
1602  /*TypeDependent=*/false,
1603  /*ValueDependent=*/false,
1604  /*InstantiationDependent=*/false,
1605  /*ContainsUnexpandedParameterPack=*/false),
1606  Loc(Loc), RParenLoc(RParenLoc) {
1607  TypeTraitExprBits.Kind = Kind;
1608  TypeTraitExprBits.Value = Value;
1609  TypeTraitExprBits.NumArgs = Args.size();
1610 
1611  auto **ToArgs = getTrailingObjects<TypeSourceInfo *>();
1612 
1613  for (unsigned I = 0, N = Args.size(); I != N; ++I) {
1614  if (Args[I]->getType()->isDependentType())
1615  setValueDependent(true);
1616  if (Args[I]->getType()->isInstantiationDependentType())
1618  if (Args[I]->getType()->containsUnexpandedParameterPack())
1620 
1621  ToArgs[I] = Args[I];
1622  }
1623 }
1624 
1626  SourceLocation Loc,
1627  TypeTrait Kind,
1629  SourceLocation RParenLoc,
1630  bool Value) {
1631  void *Mem = C.Allocate(totalSizeToAlloc<TypeSourceInfo *>(Args.size()));
1632  return new (Mem) TypeTraitExpr(T, Loc, Kind, Args, RParenLoc, Value);
1633 }
1634 
1636  unsigned NumArgs) {
1637  void *Mem = C.Allocate(totalSizeToAlloc<TypeSourceInfo *>(NumArgs));
1638  return new (Mem) TypeTraitExpr(EmptyShell());
1639 }
1640 
1641 CUDAKernelCallExpr::CUDAKernelCallExpr(Expr *Fn, CallExpr *Config,
1642  ArrayRef<Expr *> Args, QualType Ty,
1644  unsigned MinNumArgs)
1645  : CallExpr(CUDAKernelCallExprClass, Fn, /*PreArgs=*/Config, Args, Ty, VK,
1646  RP, MinNumArgs, NotADL) {}
1647 
1648 CUDAKernelCallExpr::CUDAKernelCallExpr(unsigned NumArgs, EmptyShell Empty)
1649  : CallExpr(CUDAKernelCallExprClass, /*NumPreArgs=*/END_PREARG, NumArgs,
1650  Empty) {}
1651 
1655  SourceLocation RP, unsigned MinNumArgs) {
1656  // Allocate storage for the trailing objects of CallExpr.
1657  unsigned NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1658  unsigned SizeOfTrailingObjects =
1659  CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/END_PREARG, NumArgs);
1660  void *Mem = Ctx.Allocate(sizeof(CUDAKernelCallExpr) + SizeOfTrailingObjects,
1661  alignof(CUDAKernelCallExpr));
1662  return new (Mem) CUDAKernelCallExpr(Fn, Config, Args, Ty, VK, RP, MinNumArgs);
1663 }
1664 
1666  unsigned NumArgs,
1667  EmptyShell Empty) {
1668  // Allocate storage for the trailing objects of CallExpr.
1669  unsigned SizeOfTrailingObjects =
1670  CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/END_PREARG, NumArgs);
1671  void *Mem = Ctx.Allocate(sizeof(CUDAKernelCallExpr) + SizeOfTrailingObjects,
1672  alignof(CUDAKernelCallExpr));
1673  return new (Mem) CUDAKernelCallExpr(NumArgs, Empty);
1674 }
A call to an overloaded operator written using operator syntax.
Definition: ExprCXX.h:77
static DependentScopeDeclRefExpr * CreateEmpty(const ASTContext &Context, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition: ExprCXX.cpp:494
void setValueDependent(bool VD)
Set whether this expression is value-dependent or not.
Definition: Expr.h:161
Defines the clang::ASTContext interface.
LiteralOperatorKind
The kind of literal operator which is invoked.
Definition: ExprCXX.h:499
VarDecl * getCapturedVar() const
Retrieve the declaration of the local variable being captured.
capture_iterator explicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
Definition: ExprCXX.cpp:1184
static CXXConstructExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs)
Create an empty C++ construction expression.
Definition: ExprCXX.cpp:1009
Represents a function declaration or definition.
Definition: Decl.h:1748
SourceLocation getRParenLoc() const
Definition: Expr.h:2759
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this __uuidof() expression after various required adjustments (removing...
Definition: ExprCXX.cpp:83
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2557
Stores the type being destroyed by a pseudo-destructor expression.
Definition: ExprCXX.h:2334
A (possibly-)qualified type.
Definition: Type.h:643
bool isArrayType() const
Definition: Type.h:6410
static const TemplateArgument & getArgument(const TemplateArgument &A)
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition: ExprCXX.cpp:1172
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2533
Stmt - This represents one statement.
Definition: Stmt.h:66
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Definition: Expr.h:2659
LambdaCapture(SourceLocation Loc, bool Implicit, LambdaCaptureKind Kind, VarDecl *Var=nullptr, SourceLocation EllipsisLoc=SourceLocation())
Create a new capture of a variable or of this.
Definition: ExprCXX.cpp:1056
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Definition: Type.cpp:505
static CXXDynamicCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Definition: ExprCXX.cpp:722
static UnresolvedMemberExpr * Create(const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
Definition: ExprCXX.cpp:1456
C Language Family Type Representation.
Microsoft&#39;s &#39;__super&#39; specifier, stored as a CXXRecordDecl* of the class it appeared in...
bool isRecordType() const
Definition: Type.h:6434
static unsigned sizeOfTrailingObjects(unsigned NumPreArgs, unsigned NumArgs)
Return the size in bytes needed for the trailing objects.
Definition: Expr.h:2580
Expr * getImplicitObjectArgument() const
Retrieve the implicit object argument for the member call.
Definition: ExprCXX.cpp:642
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
Definition: Lambda.h:22
void setType(QualType t)
Definition: Expr.h:138
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:2943
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
Definition: Type.h:6303
The base class of the type hierarchy.
Definition: Type.h:1418
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:516
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1331
ArrayRef< NamedDecl * > getLambdaExplicitTemplateParameters() const
Retrieve the lambda template parameters that were specified explicitly.
Definition: DeclCXX.cpp:1445
A container of type source information.
Definition: Decl.h:86
Floating point control options.
Definition: LangOptions.h:307
bool isInstantiationDependent() const
Determine whether this name involves a template parameter.
static CXXFunctionalCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, TypeSourceInfo *Written, CastKind Kind, Expr *Op, const CXXCastPath *Path, SourceLocation LPLoc, SourceLocation RPLoc)
Definition: ExprCXX.cpp:818
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:25
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2574
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
Definition: Decl.h:2747
static CXXOperatorCallExpr * Create(const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation OperatorLoc, FPOptions FPFeatures, ADLCallKind UsesADL=NotADL)
Definition: ExprCXX.cpp:559
capture_range implicit_captures() const
Retrieve this lambda&#39;s implicit captures.
Definition: ExprCXX.cpp:1202
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:510
static CXXConstructExpr * Create(const ASTContext &Ctx, QualType Ty, SourceLocation Loc, CXXConstructorDecl *Ctor, bool Elidable, ArrayRef< Expr *> Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, ConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
Create a C++ construction expression.
Definition: ExprCXX.cpp:994
CXXRecordDecl * getRecordDecl() const
Retrieve the CXXRecordDecl for the underlying type of the implicit object argument.
Definition: ExprCXX.cpp:669
Represents a variable declaration or definition.
Definition: Decl.h:812
const T * getAs() const
Member-template getAs<specific type>&#39;.
Definition: Type.h:6821
static FunctionParmPackExpr * CreateEmpty(const ASTContext &Context, unsigned NumParams)
Definition: ExprCXX.cpp:1572
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Definition: Decl.h:431
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:299
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:67
void setContainsUnexpandedParameterPack(bool PP=true)
Set the bit that describes whether this expression contains an unexpanded parameter pack...
Definition: Expr.h:229
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
Definition: ExprCXX.h:3212
static CXXTemporaryObjectExpr * Create(const ASTContext &Ctx, CXXConstructorDecl *Cons, QualType Ty, TypeSourceInfo *TSI, ArrayRef< Expr *> Args, SourceRange ParenOrBraceRange, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization)
Definition: ExprCXX.cpp:960
TemplateParameterList * getGenericLambdaTemplateParameterList() const
Retrieve the generic lambda&#39;s template parameter list.
Definition: DeclCXX.cpp:1436
Defines the clang::Expr interface and subclasses for C++ expressions.
The collection of all-type qualifiers we support.
Definition: Type.h:137
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Definition: ExprCXX.cpp:1206
A C++ static_cast expression (C++ [expr.static.cast]).
Definition: ExprCXX.h:318
static CXXUnresolvedConstructExpr * Create(const ASTContext &Context, TypeSourceInfo *Type, SourceLocation LParenLoc, ArrayRef< Expr *> Args, SourceLocation RParenLoc)
Definition: ExprCXX.cpp:1297
One of these records is kept for each identifier that is lexed.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:154
A C++ nested-name-specifier augmented with source location information.
LineState State
FullExpr - Represents a "full-expression" node.
Definition: Expr.h:920
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.cpp:263
LambdaCaptureKind
The different capture forms in a lambda introducer.
Definition: Lambda.h:33
Represents a member of a struct/union/class.
Definition: Decl.h:2607
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:987
CompoundStmt * getBody() const
Retrieve the body of the lambda.
Definition: ExprCXX.cpp:1225
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:838
The iterator over UnresolvedSets.
Definition: UnresolvedSet.h:31
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition: ExprCXX.cpp:292
capture_iterator implicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of implicit lambda captures.
Definition: ExprCXX.cpp:1198
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
Definition: opencl-c-base.h:40
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
Definition: ExprCXX.h:3677
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:124
bool isGLValue() const
Definition: Expr.h:261
TemplateArgument getArgumentPack() const
Retrieve the template argument pack containing the substituted template arguments.
Definition: ExprCXX.cpp:1547
CXXConstructExpr(StmtClass SC, QualType Ty, SourceLocation Loc, CXXConstructorDecl *Ctor, bool Elidable, ArrayRef< Expr *> Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, ConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
Build a C++ construction expression.
Definition: ExprCXX.cpp:1018
< Capturing the *this object by copy
Definition: Lambda.h:36
bool capturesThis() const
Determine whether this capture handles the C++ this pointer.
Definition: LambdaCapture.h:82
A convenient class for passing around template argument information.
Definition: TemplateBase.h:554
SourceLocation getLocation() const
Definition: ExprCXX.h:2358
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
An x-value expression is a reference to an object with independent storage but which can be "moved"...
Definition: Specifiers.h:133
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition: Type.h:1844
bool isRValueReferenceType() const
Definition: Type.h:6374
unsigned getInt() const
Used to serialize this.
Definition: LangOptions.h:352
QualType getObjectType() const
Retrieve the type of the object argument.
Definition: ExprCXX.cpp:654
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1282
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1727
DeclAccessPair * getTrailingResults()
Return the results. Defined after UnresolvedMemberExpr.
Definition: ExprCXX.h:3831
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
Definition: Expr.h:176
An ordinary object is located at an address in memory.
Definition: Specifiers.h:140
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3417
bool containsUnexpandedParameterPack() const
Determine whether this name contains an unexpanded parameter pack.
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda&#39;s captures is an init-capture.
Definition: ExprCXX.cpp:1163
StmtClass
Definition: Stmt.h:68
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
Definition: ExprCXX.cpp:327
const IdentifierInfo * getUDSuffix() const
Returns the ud-suffix specified for this literal.
Definition: ExprCXX.cpp:912
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:650
TypeTrait
Names for traits that operate specifically on types.
Definition: TypeTraits.h:20
bool isInstantiationDependent() const
Whether this nested name specifier involves a template parameter.
Expr()=delete
ASTTemplateKWAndArgsInfo * getTrailingASTTemplateKWAndArgsInfo()
Return the optional template keyword and arguments info.
Definition: ExprCXX.h:3837
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1310
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition: Type.cpp:1636
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3707
CastKind
CastKind - The kind of operation required for a conversion.
SourceRange getLocalSourceRange() const
Get the local source range.
Definition: TypeLoc.h:156
static FunctionParmPackExpr * Create(const ASTContext &Context, QualType T, VarDecl *ParamPack, SourceLocation NameLoc, ArrayRef< VarDecl *> Params)
Definition: ExprCXX.cpp:1564
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:189
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:983
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:636
This represents one expression.
Definition: Expr.h:108
SourceLocation End
static TypeTraitExpr * Create(const ASTContext &C, QualType T, SourceLocation Loc, TypeTrait Kind, ArrayRef< TypeSourceInfo *> Args, SourceLocation RParenLoc, bool Value)
Create a new type trait expression.
Definition: ExprCXX.cpp:1625
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:121
static CXXMemberCallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, EmptyShell Empty)
Definition: ExprCXX.cpp:631
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
Definition: ExprCXX.cpp:1449
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:6886
Represents a C++ functional cast expression that builds a temporary object.
Definition: ExprCXX.h:1659
A C++ const_cast expression (C++ [expr.const.cast]).
Definition: ExprCXX.h:436
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2838
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
Defines an enumeration for C++ overloaded operators.
static CXXStaticCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Definition: ExprCXX.cpp:697
static CXXReinterpretCastExpr * CreateEmpty(const ASTContext &Context, unsigned pathSize)
Definition: ExprCXX.cpp:799
DeclContext * getDeclContext()
Definition: DeclBase.h:438
ExprBitfields ExprBits
Definition: Stmt.h:959
static UserDefinedLiteral * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, EmptyShell Empty)
Definition: ExprCXX.cpp:871
static CXXDependentScopeMemberExpr * Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
Definition: ExprCXX.cpp:1364
SourceLocation Begin
Represents an expression that computes the length of a parameter pack.
Definition: ExprCXX.h:3997
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
CXXDefaultInitExprBitfields CXXDefaultInitExprBits
Definition: Stmt.h:986
Defines the clang::TypeLoc interface and its subclasses.
QualType getType() const
Definition: Expr.h:137
static LambdaExpr * Create(const ASTContext &C, CXXRecordDecl *Class, SourceRange IntroducerRange, LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc, ArrayRef< LambdaCapture > Captures, bool ExplicitParams, bool ExplicitResultType, ArrayRef< Expr *> CaptureInits, SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack)
Construct a new lambda expression.
Definition: ExprCXX.cpp:1138
SourceLocation getEnd() const
CXXMethodDecl * getMethodDecl() const
Retrieve the declaration of the called method.
Definition: ExprCXX.cpp:661
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this typeid() expression after various required adjustments (removing r...
Definition: ExprCXX.cpp:76
static UnresolvedLookupExpr * CreateEmpty(const ASTContext &Context, unsigned NumResults, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition: ExprCXX.cpp:359
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Definition: ASTContext.h:1389
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition: ExprCXX.cpp:224
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
Definition: ExprCXX.cpp:1210
SourceRange getSourceRange() const
Definition: ExprCXX.h:140
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.cpp:276
bool capturesVariable() const
Determine whether this capture handles a variable.
Definition: LambdaCapture.h:88
LiteralOperatorKind getLiteralOperatorKind() const
Returns the kind of literal operator invocation which this expression represents. ...
Definition: ExprCXX.cpp:883
bool containsUnexpandedParameterPack() const
Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic template...
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition: ExprCXX.h:354
static CXXConstCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, Expr *Op, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Definition: ExprCXX.cpp:804
Kind
static CXXBindTemporaryExpr * Create(const ASTContext &C, CXXTemporary *Temp, Expr *SubExpr)
Definition: ExprCXX.cpp:934
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
Definition: ExprCXX.h:2750
capture_iterator implicit_capture_begin() const
Retrieve an iterator pointing to the first implicit lambda capture.
Definition: ExprCXX.cpp:1194
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
Definition: Expr.h:200
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
Definition: DeclBase.cpp:217
static CXXDynamicCastExpr * CreateEmpty(const ASTContext &Context, unsigned pathSize)
Definition: ExprCXX.cpp:741
Encodes a location in the source.
capture_iterator explicit_capture_begin() const
Retrieve an iterator pointing to the first explicit lambda capture.
Definition: ExprCXX.cpp:1180
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:842
static DependentScopeDeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
Definition: ExprCXX.cpp:479
static CXXOperatorCallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, EmptyShell Empty)
Definition: ExprCXX.cpp:573
UnresolvedLookupExprBitfields UnresolvedLookupExprBits
Definition: Stmt.h:997
Represents a C++ temporary.
Definition: ExprCXX.h:1250
bool shouldNullCheckAllocation() const
True if the allocation result needs to be null-checked.
Definition: ExprCXX.cpp:215
static CXXConstCastExpr * CreateEmpty(const ASTContext &Context)
Definition: ExprCXX.cpp:813
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Definition: ExprCXX.h:2005
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit...
Definition: ExprCXX.h:473
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, Optional< unsigned > Length=None, ArrayRef< TemplateArgument > PartialArgs=None)
Definition: ExprCXX.cpp:1518
Represents a call to a member function that may be written either with member call syntax (e...
Definition: ExprCXX.h:170
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:376
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2114
static ExprWithCleanups * Create(const ASTContext &C, EmptyShell empty, unsigned numObjects)
Definition: ExprCXX.cpp:1264
ArrayRef< NamedDecl * > getExplicitTemplateParameters() const
Get the template parameters were explicitly specified (as opposed to being invented by use of an auto...
Definition: ExprCXX.cpp:1220
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
Definition: Expr.h:158
bool isAnyPointerType() const
Definition: Type.h:6358
bool isInfixBinaryOp() const
Is this written as an infix binary operator?
Definition: ExprCXX.cpp:45
bool isExplicit() const
Determine whether this was an explicit capture (written between the square brackets introducing the l...
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
Definition: Type.cpp:1854
static CXXDependentScopeMemberExpr * CreateEmpty(const ASTContext &Ctx, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs, bool HasFirstQualifierFoundInScope)
Definition: ExprCXX.cpp:1385
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
static SizeOfPackExpr * CreateDeserialized(ASTContext &Context, unsigned NumPartialArgs)
Definition: ExprCXX.cpp:1529
CXXRecordDecl * getNamingClass()
Retrieve the naming class of this lookup.
Definition: ExprCXX.cpp:1487
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:91
static CXXTemporaryObjectExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs)
Definition: ExprCXX.cpp:975
static CXXReinterpretCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Definition: ExprCXX.cpp:781
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
Definition: Type.h:2099
A placeholder type used to construct an empty shell of a type, that will be filled in later (e...
Definition: Stmt.h:1034
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:3061
static bool hasOnlyNonStaticMemberFunctions(UnresolvedSetIterator begin, UnresolvedSetIterator end)
Definition: ExprCXX.cpp:1399
Defines various enumerations that describe declaration and type specifiers.
A POD class for pairing a NamedDecl* with an access specifier.
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:672
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Definition: ExprCXX.h:4243
Represents a template argument.
Definition: TemplateBase.h:50
static CXXUnresolvedConstructExpr * CreateEmpty(const ASTContext &Context, unsigned NumArgs)
Definition: ExprCXX.cpp:1305
bool isMutable() const
Determine whether the lambda is mutable, meaning that any captures values can be modified.
Definition: ExprCXX.cpp:1236
Dataflow Directional Tag Classes.
void setExtendingDecl(const ValueDecl *ExtendedBy, unsigned ManglingNumber)
Definition: ExprCXX.cpp:1578
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
bool isValid() const
Return true if this is a valid SourceLocation object.
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
Definition: DeclCXX.cpp:1385
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
Definition: Type.cpp:1754
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1271
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
Definition: ExprCXX.h:106
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition: ExprCXX.h:396
LambdaCaptureKind getCaptureKind() const
Determine the kind of capture.
Definition: ExprCXX.cpp:1086
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:2350
bool capturesVLAType() const
Determine whether this captures a variable length array bound expression.
Definition: LambdaCapture.h:94
StmtClass getStmtClass() const
Definition: Stmt.h:1087
static LambdaExpr * CreateDeserialized(const ASTContext &C, unsigned NumCaptures)
Construct a new lambda expression that will be deserialized from an external source.
Definition: ExprCXX.cpp:1156
void setInstantiationDependent(bool ID)
Set whether this expression is instantiation-dependent or not.
Definition: Expr.h:205
DependentScopeDeclRefExprBitfields DependentScopeDeclRefExprBits
Definition: Stmt.h:991
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
Definition: Decl.h:1395
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it...
Definition: ExprCXX.cpp:1215
CXXNewExprBitfields CXXNewExprBits
Definition: Stmt.h:988
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:1311
OverloadExpr(StmtClass SC, const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent, bool KnownContainsUnexpandedParameterPack)
Definition: ExprCXX.cpp:371
Capturing variable-length array type.
Definition: Lambda.h:38
CXXConstructExprBitfields CXXConstructExprBits
Definition: Stmt.h:992
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4426
TemplateArgumentLoc * getTrailingTemplateArgumentLoc()
Return the optional template arguments.
Definition: ExprCXX.h:3847
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:449
static CUDAKernelCallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, EmptyShell Empty)
Definition: ExprCXX.cpp:1665
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
Definition: Type.h:6647
CanQualType DependentTy
Definition: ASTContext.h:1031
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:223
TypeTraitExprBitfields TypeTraitExprBits
Definition: Stmt.h:990
CanQualType BoundMemberTy
Definition: ASTContext.h:1031
static CXXFunctionalCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize)
Definition: ExprCXX.cpp:833
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
Definition: Type.cpp:2897
Capturing the *this object by reference.
Definition: Lambda.h:34
Represents a base class of a C++ class.
Definition: DeclCXX.h:192
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3296
bool isLValueReferenceType() const
Definition: Type.h:6370
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:240
OverloadExprBitfields OverloadExprBits
Definition: Stmt.h:996
static CXXMemberCallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation RP, unsigned MinNumArgs=0)
Definition: ExprCXX.cpp:617
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Defines the clang::SourceLocation class and associated facilities.
void setEnd(SourceLocation e)
Represents a C++ struct/union/class.
Definition: DeclCXX.h:300
static CXXStaticCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize)
Definition: ExprCXX.cpp:716
bool isValid() const
bool isVoidType() const
Definition: Type.h:6613
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
Definition: ExprCXX.cpp:929
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
Definition: ExprCXX.h:1597
static TypeTraitExpr * CreateDeserialized(const ASTContext &C, unsigned NumArgs)
Definition: ExprCXX.cpp:1635
CXXOperatorCallExprBitfields CXXOperatorCallExprBits
Definition: Stmt.h:980
Capturing by reference.
Definition: Lambda.h:37
void initializeFrom(SourceLocation TemplateKWLoc, const TemplateArgumentListInfo &List, TemplateArgumentLoc *OutArgArray)
static CXXNewExpr * CreateEmpty(const ASTContext &Ctx, bool IsArray, bool HasInit, unsigned NumPlacementArgs, bool IsParenTypeId)
Create an empty c++ new expression.
Definition: ExprCXX.cpp:204
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
Definition: Expr.h:223
capture_range captures() const
Retrieve this lambda&#39;s captures.
Definition: ExprCXX.cpp:1176
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2516
CXXPseudoDestructorExpr(const ASTContext &Context, Expr *Base, bool isArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, TypeSourceInfo *ScopeType, SourceLocation ColonColonLoc, SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType)
Definition: ExprCXX.cpp:257
static CUDAKernelCallExpr * Create(const ASTContext &Ctx, Expr *Fn, CallExpr *Config, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation RP, unsigned MinNumArgs=0)
Definition: ExprCXX.cpp:1653
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Definition: ExprCXX.cpp:1168
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2093
bool isAlwaysNull() const
isAlwaysNull - Return whether the result of the dynamic_cast is proven to always be null...
Definition: ExprCXX.cpp:755
bool isPointerType() const
Definition: Type.h:6354
const char * getCastName() const
getCastName - Get the name of the C++ cast being used, e.g., "static_cast", "dynamic_cast", "reinterpret_cast", or "const_cast".
Definition: ExprCXX.cpp:687
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition: Expr.cpp:2993
#define true
Definition: stdbool.h:16
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:128
bool isFloatingType() const
Definition: Type.cpp:1952
A trivial tuple used to represent a source range.
This represents a decl that may have a name.
Definition: Decl.h:248
bool isPotentiallyEvaluated() const
Determine whether this typeid has a type operand which is potentially evaluated, per C++11 [expr...
Definition: ExprCXX.cpp:61
static UserDefinedLiteral * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation LitEndLoc, SourceLocation SuffixLoc)
Definition: ExprCXX.cpp:857
capture_range explicit_captures() const
Retrieve this lambda&#39;s explicit captures.
Definition: ExprCXX.cpp:1190
SourceLocation getBegin() const
llvm::iterator_range< capture_iterator > capture_range
An iterator over a range of lambda captures.
Definition: ExprCXX.h:1815
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals...
QualType getType() const
Return the type wrapped by this type source info.
Definition: Decl.h:97
Defines the LambdaCapture class.
Expr * getCookedLiteral()
If this is not a raw user-defined literal, get the underlying cooked literal (representing the litera...
Definition: ExprCXX.cpp:904
static CXXNewExpr * Create(const ASTContext &Ctx, bool IsGlobalNew, FunctionDecl *OperatorNew, FunctionDecl *OperatorDelete, bool ShouldPassAlignment, bool UsualArrayDeleteWantsSize, ArrayRef< Expr *> PlacementArgs, SourceRange TypeIdParens, Optional< Expr *> ArraySize, InitializationStyle InitializationStyle, Expr *Initializer, QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range, SourceRange DirectInitRange)
Create a c++ new expression.
Definition: ExprCXX.cpp:181
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point...
Definition: Expr.cpp:2956
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
static UnresolvedMemberExpr * CreateEmpty(const ASTContext &Context, unsigned NumResults, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition: ExprCXX.cpp:1475