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