clang  17.0.0git
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"
17 #include "clang/AST/Decl.h"
19 #include "clang/AST/DeclBase.h"
20 #include "clang/AST/DeclCXX.h"
21 #include "clang/AST/DeclTemplate.h"
24 #include "clang/AST/Expr.h"
27 #include "clang/AST/TemplateBase.h"
28 #include "clang/AST/Type.h"
29 #include "clang/AST/TypeLoc.h"
30 #include "clang/Basic/LLVM.h"
33 #include "clang/Basic/Specifiers.h"
34 #include "llvm/ADT/ArrayRef.h"
35 #include "llvm/Support/Casting.h"
36 #include "llvm/Support/ErrorHandling.h"
37 #include <cassert>
38 #include <cstddef>
39 #include <cstring>
40 #include <memory>
41 #include <optional>
42 
43 using namespace clang;
44 
45 //===----------------------------------------------------------------------===//
46 // Child Iterators for iterating over subexpressions/substatements
47 //===----------------------------------------------------------------------===//
48 
50  // An infix binary operator is any operator with two arguments other than
51  // operator() and operator[]. Note that none of these operators can have
52  // default arguments, so it suffices to check the number of argument
53  // expressions.
54  if (getNumArgs() != 2)
55  return false;
56 
57  switch (getOperator()) {
58  case OO_Call: case OO_Subscript:
59  return false;
60  default:
61  return true;
62  }
63 }
64 
67  DecomposedForm Result = {};
68  const Expr *E = getSemanticForm()->IgnoreImplicit();
69 
70  // Remove an outer '!' if it exists (only happens for a '!=' rewrite).
71  bool SkippedNot = false;
72  if (auto *NotEq = dyn_cast<UnaryOperator>(E)) {
73  assert(NotEq->getOpcode() == UO_LNot);
74  E = NotEq->getSubExpr()->IgnoreImplicit();
75  SkippedNot = true;
76  }
77 
78  // Decompose the outer binary operator.
79  if (auto *BO = dyn_cast<BinaryOperator>(E)) {
80  assert(!SkippedNot || BO->getOpcode() == BO_EQ);
81  Result.Opcode = SkippedNot ? BO_NE : BO->getOpcode();
82  Result.LHS = BO->getLHS();
83  Result.RHS = BO->getRHS();
84  Result.InnerBinOp = BO;
85  } else if (auto *BO = dyn_cast<CXXOperatorCallExpr>(E)) {
86  assert(!SkippedNot || BO->getOperator() == OO_EqualEqual);
87  assert(BO->isInfixBinaryOp());
88  switch (BO->getOperator()) {
89  case OO_Less: Result.Opcode = BO_LT; break;
90  case OO_LessEqual: Result.Opcode = BO_LE; break;
91  case OO_Greater: Result.Opcode = BO_GT; break;
92  case OO_GreaterEqual: Result.Opcode = BO_GE; break;
93  case OO_Spaceship: Result.Opcode = BO_Cmp; break;
94  case OO_EqualEqual: Result.Opcode = SkippedNot ? BO_NE : BO_EQ; break;
95  default: llvm_unreachable("unexpected binop in rewritten operator expr");
96  }
97  Result.LHS = BO->getArg(0);
98  Result.RHS = BO->getArg(1);
99  Result.InnerBinOp = BO;
100  } else {
101  llvm_unreachable("unexpected rewritten operator form");
102  }
103 
104  // Put the operands in the right order for == and !=, and canonicalize the
105  // <=> subexpression onto the LHS for all other forms.
106  if (isReversed())
107  std::swap(Result.LHS, Result.RHS);
108 
109  // If this isn't a spaceship rewrite, we're done.
110  if (Result.Opcode == BO_EQ || Result.Opcode == BO_NE)
111  return Result;
112 
113  // Otherwise, we expect a <=> to now be on the LHS.
114  E = Result.LHS->IgnoreImplicitAsWritten();
115  if (auto *BO = dyn_cast<BinaryOperator>(E)) {
116  assert(BO->getOpcode() == BO_Cmp);
117  Result.LHS = BO->getLHS();
118  Result.RHS = BO->getRHS();
119  Result.InnerBinOp = BO;
120  } else if (auto *BO = dyn_cast<CXXOperatorCallExpr>(E)) {
121  assert(BO->getOperator() == OO_Spaceship);
122  Result.LHS = BO->getArg(0);
123  Result.RHS = BO->getArg(1);
124  Result.InnerBinOp = BO;
125  } else {
126  llvm_unreachable("unexpected rewritten operator form");
127  }
128 
129  // Put the comparison operands in the right order.
130  if (isReversed())
131  std::swap(Result.LHS, Result.RHS);
132  return Result;
133 }
134 
136  if (isTypeOperand())
137  return false;
138 
139  // C++11 [expr.typeid]p3:
140  // When typeid is applied to an expression other than a glvalue of
141  // polymorphic class type, [...] the expression is an unevaluated operand.
142  const Expr *E = getExprOperand();
143  if (const CXXRecordDecl *RD = E->getType()->getAsCXXRecordDecl())
144  if (RD->isPolymorphic() && E->isGLValue())
145  return true;
146 
147  return false;
148 }
149 
151  assert(!isTypeOperand() && "Cannot call isMostDerived for typeid(type)");
152  const Expr *E = getExprOperand()->IgnoreParenNoopCasts(Context);
153  if (const auto *DRE = dyn_cast<DeclRefExpr>(E)) {
154  QualType Ty = DRE->getDecl()->getType();
155  if (!Ty->isPointerType() && !Ty->isReferenceType())
156  return true;
157  }
158 
159  return false;
160 }
161 
163  assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
164  Qualifiers Quals;
165  return Context.getUnqualifiedArrayType(
166  Operand.get<TypeSourceInfo *>()->getType().getNonReferenceType(), Quals);
167 }
168 
170  assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
171  Qualifiers Quals;
172  return Context.getUnqualifiedArrayType(
173  Operand.get<TypeSourceInfo *>()->getType().getNonReferenceType(), Quals);
174 }
175 
176 // CXXScalarValueInitExpr
178  return TypeInfo ? TypeInfo->getTypeLoc().getBeginLoc() : getRParenLoc();
179 }
180 
181 // CXXNewExpr
182 CXXNewExpr::CXXNewExpr(bool IsGlobalNew, FunctionDecl *OperatorNew,
183  FunctionDecl *OperatorDelete, bool ShouldPassAlignment,
184  bool UsualArrayDeleteWantsSize,
185  ArrayRef<Expr *> PlacementArgs, SourceRange TypeIdParens,
186  std::optional<Expr *> ArraySize,
187  InitializationStyle InitializationStyle,
188  Expr *Initializer, QualType Ty,
189  TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
190  SourceRange DirectInitRange)
191  : Expr(CXXNewExprClass, Ty, VK_PRValue, OK_Ordinary),
192  OperatorNew(OperatorNew), OperatorDelete(OperatorDelete),
193  AllocatedTypeInfo(AllocatedTypeInfo), Range(Range),
194  DirectInitRange(DirectInitRange) {
195 
196  assert((Initializer != nullptr || InitializationStyle == NoInit) &&
197  "Only NoInit can have no initializer!");
198 
199  CXXNewExprBits.IsGlobalNew = IsGlobalNew;
200  CXXNewExprBits.IsArray = ArraySize.has_value();
201  CXXNewExprBits.ShouldPassAlignment = ShouldPassAlignment;
202  CXXNewExprBits.UsualArrayDeleteWantsSize = UsualArrayDeleteWantsSize;
203  CXXNewExprBits.StoredInitializationStyle =
204  Initializer ? InitializationStyle + 1 : 0;
205  bool IsParenTypeId = TypeIdParens.isValid();
206  CXXNewExprBits.IsParenTypeId = IsParenTypeId;
207  CXXNewExprBits.NumPlacementArgs = PlacementArgs.size();
208 
209  if (ArraySize)
210  getTrailingObjects<Stmt *>()[arraySizeOffset()] = *ArraySize;
211  if (Initializer)
212  getTrailingObjects<Stmt *>()[initExprOffset()] = Initializer;
213  for (unsigned I = 0; I != PlacementArgs.size(); ++I)
214  getTrailingObjects<Stmt *>()[placementNewArgsOffset() + I] =
215  PlacementArgs[I];
216  if (IsParenTypeId)
217  getTrailingObjects<SourceRange>()[0] = TypeIdParens;
218 
219  switch (getInitializationStyle()) {
220  case CallInit:
221  this->Range.setEnd(DirectInitRange.getEnd());
222  break;
223  case ListInit:
224  this->Range.setEnd(getInitializer()->getSourceRange().getEnd());
225  break;
226  default:
227  if (IsParenTypeId)
228  this->Range.setEnd(TypeIdParens.getEnd());
229  break;
230  }
231 
233 }
234 
235 CXXNewExpr::CXXNewExpr(EmptyShell Empty, bool IsArray,
236  unsigned NumPlacementArgs, bool IsParenTypeId)
237  : Expr(CXXNewExprClass, Empty) {
238  CXXNewExprBits.IsArray = IsArray;
239  CXXNewExprBits.NumPlacementArgs = NumPlacementArgs;
240  CXXNewExprBits.IsParenTypeId = IsParenTypeId;
241 }
242 
243 CXXNewExpr *
244 CXXNewExpr::Create(const ASTContext &Ctx, bool IsGlobalNew,
245  FunctionDecl *OperatorNew, FunctionDecl *OperatorDelete,
246  bool ShouldPassAlignment, bool UsualArrayDeleteWantsSize,
247  ArrayRef<Expr *> PlacementArgs, SourceRange TypeIdParens,
248  std::optional<Expr *> ArraySize,
250  QualType Ty, TypeSourceInfo *AllocatedTypeInfo,
251  SourceRange Range, SourceRange DirectInitRange) {
252  bool IsArray = ArraySize.has_value();
253  bool HasInit = Initializer != nullptr;
254  unsigned NumPlacementArgs = PlacementArgs.size();
255  bool IsParenTypeId = TypeIdParens.isValid();
256  void *Mem =
257  Ctx.Allocate(totalSizeToAlloc<Stmt *, SourceRange>(
258  IsArray + HasInit + NumPlacementArgs, IsParenTypeId),
259  alignof(CXXNewExpr));
260  return new (Mem)
261  CXXNewExpr(IsGlobalNew, OperatorNew, OperatorDelete, ShouldPassAlignment,
262  UsualArrayDeleteWantsSize, PlacementArgs, TypeIdParens,
263  ArraySize, InitializationStyle, Initializer, Ty,
264  AllocatedTypeInfo, Range, DirectInitRange);
265 }
266 
268  bool HasInit, unsigned NumPlacementArgs,
269  bool IsParenTypeId) {
270  void *Mem =
271  Ctx.Allocate(totalSizeToAlloc<Stmt *, SourceRange>(
272  IsArray + HasInit + NumPlacementArgs, IsParenTypeId),
273  alignof(CXXNewExpr));
274  return new (Mem)
275  CXXNewExpr(EmptyShell(), IsArray, NumPlacementArgs, IsParenTypeId);
276 }
277 
279  return !getOperatorNew()->hasAttr<ReturnsNonNullAttr>() &&
281  ->getType()
283  ->isNothrow() &&
285 }
286 
287 // CXXDeleteExpr
289  const Expr *Arg = getArgument();
290 
291  // For a destroying operator delete, we may have implicitly converted the
292  // pointer type to the type of the parameter of the 'operator delete'
293  // function.
294  while (const auto *ICE = dyn_cast<ImplicitCastExpr>(Arg)) {
295  if (ICE->getCastKind() == CK_DerivedToBase ||
296  ICE->getCastKind() == CK_UncheckedDerivedToBase ||
297  ICE->getCastKind() == CK_NoOp) {
298  assert((ICE->getCastKind() == CK_NoOp ||
299  getOperatorDelete()->isDestroyingOperatorDelete()) &&
300  "only a destroying operator delete can have a converted arg");
301  Arg = ICE->getSubExpr();
302  } else
303  break;
304  }
305 
306  // The type-to-delete may not be a pointer if it's a dependent type.
307  const QualType ArgType = Arg->getType();
308 
309  if (ArgType->isDependentType() && !ArgType->isPointerType())
310  return QualType();
311 
312  return ArgType->castAs<PointerType>()->getPointeeType();
313 }
314 
315 // CXXPseudoDestructorExpr
317  : Type(Info) {
318  Location = Info->getTypeLoc().getBeginLoc();
319 }
320 
322  const ASTContext &Context, Expr *Base, bool isArrow,
323  SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc,
324  TypeSourceInfo *ScopeType, SourceLocation ColonColonLoc,
325  SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType)
326  : Expr(CXXPseudoDestructorExprClass, Context.BoundMemberTy, VK_PRValue,
327  OK_Ordinary),
328  Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
329  OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc),
330  ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc),
331  DestroyedType(DestroyedType) {
333 }
334 
336  if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo())
337  return TInfo->getType();
338 
339  return QualType();
340 }
341 
343  SourceLocation End = DestroyedType.getLocation();
344  if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo())
345  End = TInfo->getTypeLoc().getSourceRange().getEnd();
346  return End;
347 }
348 
349 // UnresolvedLookupExpr
350 UnresolvedLookupExpr::UnresolvedLookupExpr(
351  const ASTContext &Context, CXXRecordDecl *NamingClass,
352  NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
353  const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded,
356  : OverloadExpr(UnresolvedLookupExprClass, Context, QualifierLoc,
357  TemplateKWLoc, NameInfo, TemplateArgs, Begin, End, false,
358  false, false),
359  NamingClass(NamingClass) {
360  UnresolvedLookupExprBits.RequiresADL = RequiresADL;
361  UnresolvedLookupExprBits.Overloaded = Overloaded;
362 }
363 
364 UnresolvedLookupExpr::UnresolvedLookupExpr(EmptyShell Empty,
365  unsigned NumResults,
366  bool HasTemplateKWAndArgsInfo)
367  : OverloadExpr(UnresolvedLookupExprClass, Empty, NumResults,
368  HasTemplateKWAndArgsInfo) {}
369 
371  const ASTContext &Context, CXXRecordDecl *NamingClass,
372  NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
373  bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin,
375  unsigned NumResults = End - Begin;
376  unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
377  TemplateArgumentLoc>(NumResults, 0, 0);
378  void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
379  return new (Mem) UnresolvedLookupExpr(Context, NamingClass, QualifierLoc,
380  SourceLocation(), NameInfo, RequiresADL,
381  Overloaded, nullptr, Begin, End);
382 }
383 
385  const ASTContext &Context, CXXRecordDecl *NamingClass,
386  NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
387  const DeclarationNameInfo &NameInfo, bool RequiresADL,
390  assert(Args || TemplateKWLoc.isValid());
391  unsigned NumResults = End - Begin;
392  unsigned NumTemplateArgs = Args ? Args->size() : 0;
393  unsigned Size =
394  totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
395  TemplateArgumentLoc>(NumResults, 1, NumTemplateArgs);
396  void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
397  return new (Mem) UnresolvedLookupExpr(Context, NamingClass, QualifierLoc,
398  TemplateKWLoc, NameInfo, RequiresADL,
399  /*Overloaded*/ true, Args, Begin, End);
400 }
401 
403  const ASTContext &Context, unsigned NumResults,
404  bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs) {
405  assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
406  unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
408  NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
409  void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
410  return new (Mem)
411  UnresolvedLookupExpr(EmptyShell(), NumResults, HasTemplateKWAndArgsInfo);
412 }
413 
415  NestedNameSpecifierLoc QualifierLoc,
416  SourceLocation TemplateKWLoc,
417  const DeclarationNameInfo &NameInfo,
418  const TemplateArgumentListInfo *TemplateArgs,
420  UnresolvedSetIterator End, bool KnownDependent,
421  bool KnownInstantiationDependent,
422  bool KnownContainsUnexpandedParameterPack)
423  : Expr(SC, Context.OverloadTy, VK_LValue, OK_Ordinary), NameInfo(NameInfo),
424  QualifierLoc(QualifierLoc) {
425  unsigned NumResults = End - Begin;
426  OverloadExprBits.NumResults = NumResults;
427  OverloadExprBits.HasTemplateKWAndArgsInfo =
428  (TemplateArgs != nullptr ) || TemplateKWLoc.isValid();
429 
430  if (NumResults) {
431  // Copy the results to the trailing array past UnresolvedLookupExpr
432  // or UnresolvedMemberExpr.
433  DeclAccessPair *Results = getTrailingResults();
434  memcpy(Results, Begin.I, NumResults * sizeof(DeclAccessPair));
435  }
436 
437  if (TemplateArgs) {
440  TemplateKWLoc, *TemplateArgs, getTrailingTemplateArgumentLoc(), Deps);
441  } else if (TemplateKWLoc.isValid()) {
443  }
444 
445  setDependence(computeDependence(this, KnownDependent,
446  KnownInstantiationDependent,
447  KnownContainsUnexpandedParameterPack));
448  if (isTypeDependent())
449  setType(Context.DependentTy);
450 }
451 
452 OverloadExpr::OverloadExpr(StmtClass SC, EmptyShell Empty, unsigned NumResults,
453  bool HasTemplateKWAndArgsInfo)
454  : Expr(SC, Empty) {
455  OverloadExprBits.NumResults = NumResults;
456  OverloadExprBits.HasTemplateKWAndArgsInfo = HasTemplateKWAndArgsInfo;
457 }
458 
459 // DependentScopeDeclRefExpr
460 DependentScopeDeclRefExpr::DependentScopeDeclRefExpr(
461  QualType Ty, NestedNameSpecifierLoc QualifierLoc,
462  SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo,
463  const TemplateArgumentListInfo *Args)
464  : Expr(DependentScopeDeclRefExprClass, Ty, VK_LValue, OK_Ordinary),
465  QualifierLoc(QualifierLoc), NameInfo(NameInfo) {
466  DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo =
467  (Args != nullptr) || TemplateKWLoc.isValid();
468  if (Args) {
470  getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
471  TemplateKWLoc, *Args, getTrailingObjects<TemplateArgumentLoc>(), Deps);
472  } else if (TemplateKWLoc.isValid()) {
473  getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
474  TemplateKWLoc);
475  }
477 }
478 
480  const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc,
481  SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo,
482  const TemplateArgumentListInfo *Args) {
483  assert(QualifierLoc && "should be created for dependent qualifiers");
484  bool HasTemplateKWAndArgsInfo = Args || TemplateKWLoc.isValid();
485  std::size_t Size =
486  totalSizeToAlloc<ASTTemplateKWAndArgsInfo, TemplateArgumentLoc>(
487  HasTemplateKWAndArgsInfo, Args ? Args->size() : 0);
488  void *Mem = Context.Allocate(Size);
489  return new (Mem) DependentScopeDeclRefExpr(Context.DependentTy, QualifierLoc,
490  TemplateKWLoc, NameInfo, Args);
491 }
492 
495  bool HasTemplateKWAndArgsInfo,
496  unsigned NumTemplateArgs) {
497  assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
498  std::size_t Size =
499  totalSizeToAlloc<ASTTemplateKWAndArgsInfo, TemplateArgumentLoc>(
500  HasTemplateKWAndArgsInfo, NumTemplateArgs);
501  void *Mem = Context.Allocate(Size);
502  auto *E = new (Mem) DependentScopeDeclRefExpr(
504  DeclarationNameInfo(), nullptr);
505  E->DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo =
506  HasTemplateKWAndArgsInfo;
507  return E;
508 }
509 
511  if (isa<CXXTemporaryObjectExpr>(this))
512  return cast<CXXTemporaryObjectExpr>(this)->getBeginLoc();
513  return getLocation();
514 }
515 
517  if (isa<CXXTemporaryObjectExpr>(this))
518  return cast<CXXTemporaryObjectExpr>(this)->getEndLoc();
519 
520  if (ParenOrBraceRange.isValid())
521  return ParenOrBraceRange.getEnd();
522 
524  for (unsigned I = getNumArgs(); I > 0; --I) {
525  const Expr *Arg = getArg(I-1);
526  if (!Arg->isDefaultArgument()) {
527  SourceLocation NewEnd = Arg->getEndLoc();
528  if (NewEnd.isValid()) {
529  End = NewEnd;
530  break;
531  }
532  }
533  }
534 
535  return End;
536 }
537 
538 CXXOperatorCallExpr::CXXOperatorCallExpr(OverloadedOperatorKind OpKind,
539  Expr *Fn, ArrayRef<Expr *> Args,
540  QualType Ty, ExprValueKind VK,
541  SourceLocation OperatorLoc,
542  FPOptionsOverride FPFeatures,
543  ADLCallKind UsesADL)
544  : CallExpr(CXXOperatorCallExprClass, Fn, /*PreArgs=*/{}, Args, Ty, VK,
545  OperatorLoc, FPFeatures, /*MinNumArgs=*/0, UsesADL) {
546  CXXOperatorCallExprBits.OperatorKind = OpKind;
547  assert(
548  (CXXOperatorCallExprBits.OperatorKind == static_cast<unsigned>(OpKind)) &&
549  "OperatorKind overflow!");
550  Range = getSourceRangeImpl();
551 }
552 
553 CXXOperatorCallExpr::CXXOperatorCallExpr(unsigned NumArgs, bool HasFPFeatures,
554  EmptyShell Empty)
555  : CallExpr(CXXOperatorCallExprClass, /*NumPreArgs=*/0, NumArgs,
556  HasFPFeatures, Empty) {}
557 
560  OverloadedOperatorKind OpKind, Expr *Fn,
561  ArrayRef<Expr *> Args, QualType Ty,
562  ExprValueKind VK, SourceLocation OperatorLoc,
563  FPOptionsOverride FPFeatures, ADLCallKind UsesADL) {
564  // Allocate storage for the trailing objects of CallExpr.
565  unsigned NumArgs = Args.size();
566  unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
567  /*NumPreArgs=*/0, NumArgs, FPFeatures.requiresTrailingStorage());
568  void *Mem = Ctx.Allocate(sizeof(CXXOperatorCallExpr) + SizeOfTrailingObjects,
569  alignof(CXXOperatorCallExpr));
570  return new (Mem) CXXOperatorCallExpr(OpKind, Fn, Args, Ty, VK, OperatorLoc,
571  FPFeatures, UsesADL);
572 }
573 
575  unsigned NumArgs,
576  bool HasFPFeatures,
577  EmptyShell Empty) {
578  // Allocate storage for the trailing objects of CallExpr.
579  unsigned SizeOfTrailingObjects =
580  CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs, HasFPFeatures);
581  void *Mem = Ctx.Allocate(sizeof(CXXOperatorCallExpr) + SizeOfTrailingObjects,
582  alignof(CXXOperatorCallExpr));
583  return new (Mem) CXXOperatorCallExpr(NumArgs, HasFPFeatures, Empty);
584 }
585 
586 SourceRange CXXOperatorCallExpr::getSourceRangeImpl() const {
588  if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
589  if (getNumArgs() == 1)
590  // Prefix operator
591  return SourceRange(getOperatorLoc(), getArg(0)->getEndLoc());
592  else
593  // Postfix operator
594  return SourceRange(getArg(0)->getBeginLoc(), getOperatorLoc());
595  } else if (Kind == OO_Arrow) {
596  return SourceRange(getArg(0)->getBeginLoc(), getOperatorLoc());
597  } else if (Kind == OO_Call) {
598  return SourceRange(getArg(0)->getBeginLoc(), getRParenLoc());
599  } else if (Kind == OO_Subscript) {
600  return SourceRange(getArg(0)->getBeginLoc(), getRParenLoc());
601  } else if (getNumArgs() == 1) {
602  return SourceRange(getOperatorLoc(), getArg(0)->getEndLoc());
603  } else if (getNumArgs() == 2) {
604  return SourceRange(getArg(0)->getBeginLoc(), getArg(1)->getEndLoc());
605  } else {
606  return getOperatorLoc();
607  }
608 }
609 
610 CXXMemberCallExpr::CXXMemberCallExpr(Expr *Fn, ArrayRef<Expr *> Args,
611  QualType Ty, ExprValueKind VK,
612  SourceLocation RP,
614  unsigned MinNumArgs)
615  : CallExpr(CXXMemberCallExprClass, Fn, /*PreArgs=*/{}, Args, Ty, VK, RP,
616  FPOptions, MinNumArgs, NotADL) {}
617 
618 CXXMemberCallExpr::CXXMemberCallExpr(unsigned NumArgs, bool HasFPFeatures,
619  EmptyShell Empty)
620  : CallExpr(CXXMemberCallExprClass, /*NumPreArgs=*/0, NumArgs, HasFPFeatures,
621  Empty) {}
622 
624  ArrayRef<Expr *> Args, QualType Ty,
625  ExprValueKind VK,
626  SourceLocation RP,
627  FPOptionsOverride FPFeatures,
628  unsigned MinNumArgs) {
629  // Allocate storage for the trailing objects of CallExpr.
630  unsigned NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
631  unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
632  /*NumPreArgs=*/0, NumArgs, FPFeatures.requiresTrailingStorage());
633  void *Mem = Ctx.Allocate(sizeof(CXXMemberCallExpr) + SizeOfTrailingObjects,
634  alignof(CXXMemberCallExpr));
635  return new (Mem)
636  CXXMemberCallExpr(Fn, Args, Ty, VK, RP, FPFeatures, MinNumArgs);
637 }
638 
640  unsigned NumArgs,
641  bool HasFPFeatures,
642  EmptyShell Empty) {
643  // Allocate storage for the trailing objects of CallExpr.
644  unsigned SizeOfTrailingObjects =
645  CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs, HasFPFeatures);
646  void *Mem = Ctx.Allocate(sizeof(CXXMemberCallExpr) + SizeOfTrailingObjects,
647  alignof(CXXMemberCallExpr));
648  return new (Mem) CXXMemberCallExpr(NumArgs, HasFPFeatures, Empty);
649 }
650 
652  const Expr *Callee = getCallee()->IgnoreParens();
653  if (const auto *MemExpr = dyn_cast<MemberExpr>(Callee))
654  return MemExpr->getBase();
655  if (const auto *BO = dyn_cast<BinaryOperator>(Callee))
656  if (BO->getOpcode() == BO_PtrMemD || BO->getOpcode() == BO_PtrMemI)
657  return BO->getLHS();
658 
659  // FIXME: Will eventually need to cope with member pointers.
660  return nullptr;
661 }
662 
665  if (Ty->isPointerType())
666  Ty = Ty->getPointeeType();
667  return Ty;
668 }
669 
671  if (const auto *MemExpr = dyn_cast<MemberExpr>(getCallee()->IgnoreParens()))
672  return cast<CXXMethodDecl>(MemExpr->getMemberDecl());
673 
674  // FIXME: Will eventually need to cope with member pointers.
675  // NOTE: Update makeTailCallIfSwiftAsync on fixing this.
676  return nullptr;
677 }
678 
680  Expr* ThisArg = getImplicitObjectArgument();
681  if (!ThisArg)
682  return nullptr;
683 
684  if (ThisArg->getType()->isAnyPointerType())
685  return ThisArg->getType()->getPointeeType()->getAsCXXRecordDecl();
686 
687  return ThisArg->getType()->getAsCXXRecordDecl();
688 }
689 
690 //===----------------------------------------------------------------------===//
691 // Named casts
692 //===----------------------------------------------------------------------===//
693 
694 /// getCastName - Get the name of the C++ cast being used, e.g.,
695 /// "static_cast", "dynamic_cast", "reinterpret_cast", or
696 /// "const_cast". The returned pointer must not be freed.
697 const char *CXXNamedCastExpr::getCastName() const {
698  switch (getStmtClass()) {
699  case CXXStaticCastExprClass: return "static_cast";
700  case CXXDynamicCastExprClass: return "dynamic_cast";
701  case CXXReinterpretCastExprClass: return "reinterpret_cast";
702  case CXXConstCastExprClass: return "const_cast";
703  case CXXAddrspaceCastExprClass: return "addrspace_cast";
704  default: return "<invalid cast>";
705  }
706 }
707 
710  CastKind K, Expr *Op, const CXXCastPath *BasePath,
711  TypeSourceInfo *WrittenTy, FPOptionsOverride FPO,
712  SourceLocation L, SourceLocation RParenLoc,
713  SourceRange AngleBrackets) {
714  unsigned PathSize = (BasePath ? BasePath->size() : 0);
715  void *Buffer =
716  C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
717  PathSize, FPO.requiresTrailingStorage()));
718  auto *E = new (Buffer) CXXStaticCastExpr(T, VK, K, Op, PathSize, WrittenTy,
719  FPO, L, RParenLoc, AngleBrackets);
720  if (PathSize)
721  std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
722  E->getTrailingObjects<CXXBaseSpecifier *>());
723  return E;
724 }
725 
727  unsigned PathSize,
728  bool HasFPFeatures) {
729  void *Buffer =
730  C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
731  PathSize, HasFPFeatures));
732  return new (Buffer) CXXStaticCastExpr(EmptyShell(), PathSize, HasFPFeatures);
733 }
734 
736  ExprValueKind VK,
737  CastKind K, Expr *Op,
738  const CXXCastPath *BasePath,
739  TypeSourceInfo *WrittenTy,
740  SourceLocation L,
741  SourceLocation RParenLoc,
742  SourceRange AngleBrackets) {
743  unsigned PathSize = (BasePath ? BasePath->size() : 0);
744  void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
745  auto *E =
746  new (Buffer) CXXDynamicCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
747  RParenLoc, AngleBrackets);
748  if (PathSize)
749  std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
750  E->getTrailingObjects<CXXBaseSpecifier *>());
751  return E;
752 }
753 
755  unsigned PathSize) {
756  void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
757  return new (Buffer) CXXDynamicCastExpr(EmptyShell(), PathSize);
758 }
759 
760 /// isAlwaysNull - Return whether the result of the dynamic_cast is proven
761 /// to always be null. For example:
762 ///
763 /// struct A { };
764 /// struct B final : A { };
765 /// struct C { };
766 ///
767 /// C *f(B* b) { return dynamic_cast<C*>(b); }
769 {
770  QualType SrcType = getSubExpr()->getType();
771  QualType DestType = getType();
772 
773  if (const auto *SrcPTy = SrcType->getAs<PointerType>()) {
774  SrcType = SrcPTy->getPointeeType();
775  DestType = DestType->castAs<PointerType>()->getPointeeType();
776  }
777 
778  if (DestType->isVoidType())
779  return false;
780 
781  const auto *SrcRD =
782  cast<CXXRecordDecl>(SrcType->castAs<RecordType>()->getDecl());
783 
784  if (!SrcRD->hasAttr<FinalAttr>())
785  return false;
786 
787  const auto *DestRD =
788  cast<CXXRecordDecl>(DestType->castAs<RecordType>()->getDecl());
789 
790  return !DestRD->isDerivedFrom(SrcRD);
791 }
792 
795  ExprValueKind VK, CastKind K, Expr *Op,
796  const CXXCastPath *BasePath,
797  TypeSourceInfo *WrittenTy, SourceLocation L,
798  SourceLocation RParenLoc,
799  SourceRange AngleBrackets) {
800  unsigned PathSize = (BasePath ? BasePath->size() : 0);
801  void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
802  auto *E =
803  new (Buffer) CXXReinterpretCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
804  RParenLoc, AngleBrackets);
805  if (PathSize)
806  std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
807  E->getTrailingObjects<CXXBaseSpecifier *>());
808  return E;
809 }
810 
812 CXXReinterpretCastExpr::CreateEmpty(const ASTContext &C, unsigned PathSize) {
813  void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
814  return new (Buffer) CXXReinterpretCastExpr(EmptyShell(), PathSize);
815 }
816 
818  ExprValueKind VK, Expr *Op,
819  TypeSourceInfo *WrittenTy,
820  SourceLocation L,
821  SourceLocation RParenLoc,
822  SourceRange AngleBrackets) {
823  return new (C) CXXConstCastExpr(T, VK, Op, WrittenTy, L, RParenLoc, AngleBrackets);
824 }
825 
827  return new (C) CXXConstCastExpr(EmptyShell());
828 }
829 
832  CastKind K, Expr *Op, TypeSourceInfo *WrittenTy,
833  SourceLocation L, SourceLocation RParenLoc,
834  SourceRange AngleBrackets) {
835  return new (C) CXXAddrspaceCastExpr(T, VK, K, Op, WrittenTy, L, RParenLoc,
836  AngleBrackets);
837 }
838 
840  return new (C) CXXAddrspaceCastExpr(EmptyShell());
841 }
842 
844  const ASTContext &C, QualType T, ExprValueKind VK, TypeSourceInfo *Written,
845  CastKind K, Expr *Op, const CXXCastPath *BasePath, FPOptionsOverride FPO,
847  unsigned PathSize = (BasePath ? BasePath->size() : 0);
848  void *Buffer =
849  C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
850  PathSize, FPO.requiresTrailingStorage()));
851  auto *E = new (Buffer)
852  CXXFunctionalCastExpr(T, VK, Written, K, Op, PathSize, FPO, L, R);
853  if (PathSize)
854  std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
855  E->getTrailingObjects<CXXBaseSpecifier *>());
856  return E;
857 }
858 
860  unsigned PathSize,
861  bool HasFPFeatures) {
862  void *Buffer =
863  C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
864  PathSize, HasFPFeatures));
865  return new (Buffer)
866  CXXFunctionalCastExpr(EmptyShell(), PathSize, HasFPFeatures);
867 }
868 
871 }
872 
874  return RParenLoc.isValid() ? RParenLoc : getSubExpr()->getEndLoc();
875 }
876 
877 UserDefinedLiteral::UserDefinedLiteral(Expr *Fn, ArrayRef<Expr *> Args,
878  QualType Ty, ExprValueKind VK,
879  SourceLocation LitEndLoc,
880  SourceLocation SuffixLoc,
881  FPOptionsOverride FPFeatures)
882  : CallExpr(UserDefinedLiteralClass, Fn, /*PreArgs=*/{}, Args, Ty, VK,
883  LitEndLoc, FPFeatures, /*MinNumArgs=*/0, NotADL),
884  UDSuffixLoc(SuffixLoc) {}
885 
886 UserDefinedLiteral::UserDefinedLiteral(unsigned NumArgs, bool HasFPFeatures,
887  EmptyShell Empty)
888  : CallExpr(UserDefinedLiteralClass, /*NumPreArgs=*/0, NumArgs,
889  HasFPFeatures, Empty) {}
890 
892  ArrayRef<Expr *> Args,
893  QualType Ty, ExprValueKind VK,
894  SourceLocation LitEndLoc,
895  SourceLocation SuffixLoc,
896  FPOptionsOverride FPFeatures) {
897  // Allocate storage for the trailing objects of CallExpr.
898  unsigned NumArgs = Args.size();
899  unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
900  /*NumPreArgs=*/0, NumArgs, FPFeatures.requiresTrailingStorage());
901  void *Mem = Ctx.Allocate(sizeof(UserDefinedLiteral) + SizeOfTrailingObjects,
902  alignof(UserDefinedLiteral));
903  return new (Mem)
904  UserDefinedLiteral(Fn, Args, Ty, VK, LitEndLoc, SuffixLoc, FPFeatures);
905 }
906 
908  unsigned NumArgs,
909  bool HasFPOptions,
910  EmptyShell Empty) {
911  // Allocate storage for the trailing objects of CallExpr.
912  unsigned SizeOfTrailingObjects =
913  CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs, HasFPOptions);
914  void *Mem = Ctx.Allocate(sizeof(UserDefinedLiteral) + SizeOfTrailingObjects,
915  alignof(UserDefinedLiteral));
916  return new (Mem) UserDefinedLiteral(NumArgs, HasFPOptions, Empty);
917 }
918 
921  if (getNumArgs() == 0)
922  return LOK_Template;
923  if (getNumArgs() == 2)
924  return LOK_String;
925 
926  assert(getNumArgs() == 1 && "unexpected #args in literal operator call");
927  QualType ParamTy =
928  cast<FunctionDecl>(getCalleeDecl())->getParamDecl(0)->getType();
929  if (ParamTy->isPointerType())
930  return LOK_Raw;
931  if (ParamTy->isAnyCharacterType())
932  return LOK_Character;
933  if (ParamTy->isIntegerType())
934  return LOK_Integer;
935  if (ParamTy->isFloatingType())
936  return LOK_Floating;
937 
938  llvm_unreachable("unknown kind of literal operator");
939 }
940 
942 #ifndef NDEBUG
944  assert(LOK != LOK_Template && LOK != LOK_Raw && "not a cooked literal");
945 #endif
946  return getArg(0);
947 }
948 
950  return cast<FunctionDecl>(getCalleeDecl())->getLiteralIdentifier();
951 }
952 
954  bool HasRewrittenInit) {
955  size_t Size = totalSizeToAlloc<Expr *>(HasRewrittenInit);
956  auto *Mem = C.Allocate(Size, alignof(CXXDefaultArgExpr));
957  return new (Mem) CXXDefaultArgExpr(EmptyShell(), HasRewrittenInit);
958 }
959 
961  SourceLocation Loc,
962  ParmVarDecl *Param,
963  Expr *RewrittenExpr,
964  DeclContext *UsedContext) {
965  size_t Size = totalSizeToAlloc<Expr *>(RewrittenExpr != nullptr);
966  auto *Mem = C.Allocate(Size, alignof(CXXDefaultArgExpr));
967  return new (Mem) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param,
968  RewrittenExpr, UsedContext);
969 }
970 
972  return CXXDefaultArgExprBits.HasRewrittenInit ? getAdjustedRewrittenExpr()
973  : getParam()->getDefaultArg();
974 }
975 
977  assert(hasRewrittenInit() &&
978  "expected this CXXDefaultArgExpr to have a rewritten init.");
979  Expr *Init = getRewrittenExpr();
980  if (auto *E = dyn_cast_if_present<FullExpr>(Init))
981  if (!isa<ConstantExpr>(E))
982  return E->getSubExpr();
983  return Init;
984 }
985 
986 CXXDefaultInitExpr::CXXDefaultInitExpr(const ASTContext &Ctx,
987  SourceLocation Loc, FieldDecl *Field,
988  QualType Ty, DeclContext *UsedContext,
989  Expr *RewrittenInitExpr)
990  : Expr(CXXDefaultInitExprClass, Ty.getNonLValueExprType(Ctx),
991  Ty->isLValueReferenceType() ? VK_LValue
992  : Ty->isRValueReferenceType() ? VK_XValue
993  : VK_PRValue,
994  /*FIXME*/ OK_Ordinary),
995  Field(Field), UsedContext(UsedContext) {
996  CXXDefaultInitExprBits.Loc = Loc;
997  CXXDefaultInitExprBits.HasRewrittenInit = RewrittenInitExpr != nullptr;
998 
999  if (CXXDefaultInitExprBits.HasRewrittenInit)
1000  *getTrailingObjects<Expr *>() = RewrittenInitExpr;
1001 
1002  assert(Field->hasInClassInitializer());
1003 
1005 }
1006 
1008  bool HasRewrittenInit) {
1009  size_t Size = totalSizeToAlloc<Expr *>(HasRewrittenInit);
1010  auto *Mem = C.Allocate(Size, alignof(CXXDefaultInitExpr));
1011  return new (Mem) CXXDefaultInitExpr(EmptyShell(), HasRewrittenInit);
1012 }
1013 
1015  SourceLocation Loc,
1016  FieldDecl *Field,
1017  DeclContext *UsedContext,
1018  Expr *RewrittenInitExpr) {
1019 
1020  size_t Size = totalSizeToAlloc<Expr *>(RewrittenInitExpr != nullptr);
1021  auto *Mem = Ctx.Allocate(Size, alignof(CXXDefaultInitExpr));
1022  return new (Mem) CXXDefaultInitExpr(Ctx, Loc, Field, Field->getType(),
1023  UsedContext, RewrittenInitExpr);
1024 }
1025 
1027  assert(Field->getInClassInitializer() && "initializer hasn't been parsed");
1028  if (hasRewrittenInit())
1029  return getRewrittenExpr();
1030 
1031  return Field->getInClassInitializer();
1032 }
1033 
1035  const CXXDestructorDecl *Destructor) {
1036  return new (C) CXXTemporary(Destructor);
1037 }
1038 
1040  CXXTemporary *Temp,
1041  Expr* SubExpr) {
1042  assert((SubExpr->getType()->isRecordType() ||
1043  SubExpr->getType()->isArrayType()) &&
1044  "Expression bound to a temporary must have record or array type!");
1045 
1046  return new (C) CXXBindTemporaryExpr(Temp, SubExpr);
1047 }
1048 
1049 CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(
1050  CXXConstructorDecl *Cons, QualType Ty, TypeSourceInfo *TSI,
1051  ArrayRef<Expr *> Args, SourceRange ParenOrBraceRange,
1052  bool HadMultipleCandidates, bool ListInitialization,
1053  bool StdInitListInitialization, bool ZeroInitialization)
1054  : CXXConstructExpr(
1055  CXXTemporaryObjectExprClass, Ty, TSI->getTypeLoc().getBeginLoc(),
1056  Cons, /* Elidable=*/false, Args, HadMultipleCandidates,
1057  ListInitialization, StdInitListInitialization, ZeroInitialization,
1058  CXXConstructExpr::CK_Complete, ParenOrBraceRange),
1059  TSI(TSI) {
1061 }
1062 
1063 CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(EmptyShell Empty,
1064  unsigned NumArgs)
1065  : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty, NumArgs) {}
1066 
1068  const ASTContext &Ctx, CXXConstructorDecl *Cons, QualType Ty,
1069  TypeSourceInfo *TSI, ArrayRef<Expr *> Args, SourceRange ParenOrBraceRange,
1070  bool HadMultipleCandidates, bool ListInitialization,
1071  bool StdInitListInitialization, bool ZeroInitialization) {
1072  unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(Args.size());
1073  void *Mem =
1074  Ctx.Allocate(sizeof(CXXTemporaryObjectExpr) + SizeOfTrailingObjects,
1075  alignof(CXXTemporaryObjectExpr));
1076  return new (Mem) CXXTemporaryObjectExpr(
1077  Cons, Ty, TSI, Args, ParenOrBraceRange, HadMultipleCandidates,
1078  ListInitialization, StdInitListInitialization, ZeroInitialization);
1079 }
1080 
1082 CXXTemporaryObjectExpr::CreateEmpty(const ASTContext &Ctx, unsigned NumArgs) {
1083  unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(NumArgs);
1084  void *Mem =
1085  Ctx.Allocate(sizeof(CXXTemporaryObjectExpr) + SizeOfTrailingObjects,
1086  alignof(CXXTemporaryObjectExpr));
1087  return new (Mem) CXXTemporaryObjectExpr(EmptyShell(), NumArgs);
1088 }
1089 
1092 }
1093 
1096  if (Loc.isInvalid() && getNumArgs())
1097  Loc = getArg(getNumArgs() - 1)->getEndLoc();
1098  return Loc;
1099 }
1100 
1102  const ASTContext &Ctx, QualType Ty, SourceLocation Loc,
1103  CXXConstructorDecl *Ctor, bool Elidable, ArrayRef<Expr *> Args,
1104  bool HadMultipleCandidates, bool ListInitialization,
1105  bool StdInitListInitialization, bool ZeroInitialization,
1106  ConstructionKind ConstructKind, SourceRange ParenOrBraceRange) {
1107  unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(Args.size());
1108  void *Mem = Ctx.Allocate(sizeof(CXXConstructExpr) + SizeOfTrailingObjects,
1109  alignof(CXXConstructExpr));
1110  return new (Mem) CXXConstructExpr(
1111  CXXConstructExprClass, Ty, Loc, Ctor, Elidable, Args,
1112  HadMultipleCandidates, ListInitialization, StdInitListInitialization,
1113  ZeroInitialization, ConstructKind, ParenOrBraceRange);
1114 }
1115 
1117  unsigned NumArgs) {
1118  unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(NumArgs);
1119  void *Mem = Ctx.Allocate(sizeof(CXXConstructExpr) + SizeOfTrailingObjects,
1120  alignof(CXXConstructExpr));
1121  return new (Mem)
1122  CXXConstructExpr(CXXConstructExprClass, EmptyShell(), NumArgs);
1123 }
1124 
1127  bool Elidable, ArrayRef<Expr *> Args, bool HadMultipleCandidates,
1128  bool ListInitialization, bool StdInitListInitialization,
1129  bool ZeroInitialization, ConstructionKind ConstructKind,
1130  SourceRange ParenOrBraceRange)
1131  : Expr(SC, Ty, VK_PRValue, OK_Ordinary), Constructor(Ctor),
1132  ParenOrBraceRange(ParenOrBraceRange), NumArgs(Args.size()) {
1133  CXXConstructExprBits.Elidable = Elidable;
1134  CXXConstructExprBits.HadMultipleCandidates = HadMultipleCandidates;
1135  CXXConstructExprBits.ListInitialization = ListInitialization;
1136  CXXConstructExprBits.StdInitListInitialization = StdInitListInitialization;
1137  CXXConstructExprBits.ZeroInitialization = ZeroInitialization;
1138  CXXConstructExprBits.ConstructionKind = ConstructKind;
1139  CXXConstructExprBits.Loc = Loc;
1140 
1141  Stmt **TrailingArgs = getTrailingArgs();
1142  for (unsigned I = 0, N = Args.size(); I != N; ++I) {
1143  assert(Args[I] && "NULL argument in CXXConstructExpr!");
1144  TrailingArgs[I] = Args[I];
1145  }
1146 
1147  // CXXTemporaryObjectExpr does this itself after setting its TypeSourceInfo.
1148  if (SC == CXXConstructExprClass)
1150 }
1151 
1153  unsigned NumArgs)
1154  : Expr(SC, Empty), NumArgs(NumArgs) {}
1155 
1158  SourceLocation EllipsisLoc)
1159  : DeclAndBits(Var, 0), Loc(Loc), EllipsisLoc(EllipsisLoc) {
1160  unsigned Bits = 0;
1161  if (Implicit)
1162  Bits |= Capture_Implicit;
1163 
1164  switch (Kind) {
1165  case LCK_StarThis:
1166  Bits |= Capture_ByCopy;
1167  [[fallthrough]];
1168  case LCK_This:
1169  assert(!Var && "'this' capture cannot have a variable!");
1170  Bits |= Capture_This;
1171  break;
1172 
1173  case LCK_ByCopy:
1174  Bits |= Capture_ByCopy;
1175  [[fallthrough]];
1176  case LCK_ByRef:
1177  assert(Var && "capture must have a variable!");
1178  break;
1179  case LCK_VLAType:
1180  assert(!Var && "VLA type capture cannot have a variable!");
1181  break;
1182  }
1183  DeclAndBits.setInt(Bits);
1184 }
1185 
1187  if (capturesVLAType())
1188  return LCK_VLAType;
1189  bool CapByCopy = DeclAndBits.getInt() & Capture_ByCopy;
1190  if (capturesThis())
1191  return CapByCopy ? LCK_StarThis : LCK_This;
1192  return CapByCopy ? LCK_ByCopy : LCK_ByRef;
1193 }
1194 
1195 LambdaExpr::LambdaExpr(QualType T, SourceRange IntroducerRange,
1196  LambdaCaptureDefault CaptureDefault,
1197  SourceLocation CaptureDefaultLoc, bool ExplicitParams,
1198  bool ExplicitResultType, ArrayRef<Expr *> CaptureInits,
1199  SourceLocation ClosingBrace,
1200  bool ContainsUnexpandedParameterPack)
1201  : Expr(LambdaExprClass, T, VK_PRValue, OK_Ordinary),
1202  IntroducerRange(IntroducerRange), CaptureDefaultLoc(CaptureDefaultLoc),
1203  ClosingBrace(ClosingBrace) {
1204  LambdaExprBits.NumCaptures = CaptureInits.size();
1205  LambdaExprBits.CaptureDefault = CaptureDefault;
1206  LambdaExprBits.ExplicitParams = ExplicitParams;
1207  LambdaExprBits.ExplicitResultType = ExplicitResultType;
1208 
1209  CXXRecordDecl *Class = getLambdaClass();
1210  (void)Class;
1211  assert(capture_size() == Class->capture_size() && "Wrong number of captures");
1212  assert(getCaptureDefault() == Class->getLambdaCaptureDefault());
1213 
1214  // Copy initialization expressions for the non-static data members.
1215  Stmt **Stored = getStoredStmts();
1216  for (unsigned I = 0, N = CaptureInits.size(); I != N; ++I)
1217  *Stored++ = CaptureInits[I];
1218 
1219  // Copy the body of the lambda.
1220  *Stored++ = getCallOperator()->getBody();
1221 
1222  setDependence(computeDependence(this, ContainsUnexpandedParameterPack));
1223 }
1224 
1225 LambdaExpr::LambdaExpr(EmptyShell Empty, unsigned NumCaptures)
1226  : Expr(LambdaExprClass, Empty) {
1227  LambdaExprBits.NumCaptures = NumCaptures;
1228 
1229  // Initially don't initialize the body of the LambdaExpr. The body will
1230  // be lazily deserialized when needed.
1231  getStoredStmts()[NumCaptures] = nullptr; // Not one past the end.
1232 }
1233 
1235  SourceRange IntroducerRange,
1236  LambdaCaptureDefault CaptureDefault,
1237  SourceLocation CaptureDefaultLoc,
1238  bool ExplicitParams, bool ExplicitResultType,
1239  ArrayRef<Expr *> CaptureInits,
1240  SourceLocation ClosingBrace,
1241  bool ContainsUnexpandedParameterPack) {
1242  // Determine the type of the expression (i.e., the type of the
1243  // function object we're creating).
1244  QualType T = Context.getTypeDeclType(Class);
1245 
1246  unsigned Size = totalSizeToAlloc<Stmt *>(CaptureInits.size() + 1);
1247  void *Mem = Context.Allocate(Size);
1248  return new (Mem)
1249  LambdaExpr(T, IntroducerRange, CaptureDefault, CaptureDefaultLoc,
1250  ExplicitParams, ExplicitResultType, CaptureInits, ClosingBrace,
1251  ContainsUnexpandedParameterPack);
1252 }
1253 
1255  unsigned NumCaptures) {
1256  unsigned Size = totalSizeToAlloc<Stmt *>(NumCaptures + 1);
1257  void *Mem = C.Allocate(Size);
1258  return new (Mem) LambdaExpr(EmptyShell(), NumCaptures);
1259 }
1260 
1261 void LambdaExpr::initBodyIfNeeded() const {
1262  if (!getStoredStmts()[capture_size()]) {
1263  auto *This = const_cast<LambdaExpr *>(this);
1264  This->getStoredStmts()[capture_size()] = getCallOperator()->getBody();
1265  }
1266 }
1267 
1269  initBodyIfNeeded();
1270  return getStoredStmts()[capture_size()];
1271 }
1272 
1274  Stmt *Body = getBody();
1275  if (const auto *CoroBody = dyn_cast<CoroutineBodyStmt>(Body))
1276  return cast<CompoundStmt>(CoroBody->getBody());
1277  return cast<CompoundStmt>(Body);
1278 }
1279 
1281  return C->capturesVariable() && C->getCapturedVar()->isInitCapture() &&
1282  getCallOperator() == C->getCapturedVar()->getDeclContext();
1283 }
1284 
1286  return getLambdaClass()->captures_begin();
1287 }
1288 
1290  return getLambdaClass()->captures_end();
1291 }
1292 
1295 }
1296 
1298  return capture_begin();
1299 }
1300 
1302  return capture_begin() +
1303  getLambdaClass()->getLambdaData().NumExplicitCaptures;
1304 }
1305 
1308 }
1309 
1311  return explicit_capture_end();
1312 }
1313 
1315  return capture_end();
1316 }
1317 
1320 }
1321 
1323  return getType()->getAsCXXRecordDecl();
1324 }
1325 
1327  CXXRecordDecl *Record = getLambdaClass();
1328  return Record->getLambdaCallOperator();
1329 }
1330 
1332  CXXRecordDecl *Record = getLambdaClass();
1333  return Record->getDependentLambdaCallOperator();
1334 }
1335 
1337  CXXRecordDecl *Record = getLambdaClass();
1338  return Record->getGenericLambdaTemplateParameterList();
1339 }
1340 
1342  const CXXRecordDecl *Record = getLambdaClass();
1343  return Record->getLambdaExplicitTemplateParameters();
1344 }
1345 
1348 }
1349 
1350 bool LambdaExpr::isMutable() const { return !getCallOperator()->isConst(); }
1351 
1353  initBodyIfNeeded();
1354  return child_range(getStoredStmts(), getStoredStmts() + capture_size() + 1);
1355 }
1356 
1358  initBodyIfNeeded();
1359  return const_child_range(getStoredStmts(),
1360  getStoredStmts() + capture_size() + 1);
1361 }
1362 
1363 ExprWithCleanups::ExprWithCleanups(Expr *subexpr,
1364  bool CleanupsHaveSideEffects,
1365  ArrayRef<CleanupObject> objects)
1366  : FullExpr(ExprWithCleanupsClass, subexpr) {
1367  ExprWithCleanupsBits.CleanupsHaveSideEffects = CleanupsHaveSideEffects;
1368  ExprWithCleanupsBits.NumObjects = objects.size();
1369  for (unsigned i = 0, e = objects.size(); i != e; ++i)
1370  getTrailingObjects<CleanupObject>()[i] = objects[i];
1371 }
1372 
1374  bool CleanupsHaveSideEffects,
1375  ArrayRef<CleanupObject> objects) {
1376  void *buffer = C.Allocate(totalSizeToAlloc<CleanupObject>(objects.size()),
1377  alignof(ExprWithCleanups));
1378  return new (buffer)
1379  ExprWithCleanups(subexpr, CleanupsHaveSideEffects, objects);
1380 }
1381 
1382 ExprWithCleanups::ExprWithCleanups(EmptyShell empty, unsigned numObjects)
1383  : FullExpr(ExprWithCleanupsClass, empty) {
1384  ExprWithCleanupsBits.NumObjects = numObjects;
1385 }
1386 
1388  EmptyShell empty,
1389  unsigned numObjects) {
1390  void *buffer = C.Allocate(totalSizeToAlloc<CleanupObject>(numObjects),
1391  alignof(ExprWithCleanups));
1392  return new (buffer) ExprWithCleanups(empty, numObjects);
1393 }
1394 
1395 CXXUnresolvedConstructExpr::CXXUnresolvedConstructExpr(QualType T,
1396  TypeSourceInfo *TSI,
1397  SourceLocation LParenLoc,
1398  ArrayRef<Expr *> Args,
1399  SourceLocation RParenLoc)
1400  : Expr(CXXUnresolvedConstructExprClass, T,
1401  (TSI->getType()->isLValueReferenceType() ? VK_LValue
1402  : TSI->getType()->isRValueReferenceType() ? VK_XValue
1403  : VK_PRValue),
1404  OK_Ordinary),
1405  TSI(TSI), LParenLoc(LParenLoc), RParenLoc(RParenLoc) {
1406  CXXUnresolvedConstructExprBits.NumArgs = Args.size();
1407  auto **StoredArgs = getTrailingObjects<Expr *>();
1408  for (unsigned I = 0; I != Args.size(); ++I)
1409  StoredArgs[I] = Args[I];
1411 }
1412 
1414  const ASTContext &Context, QualType T, TypeSourceInfo *TSI, SourceLocation LParenLoc,
1415  ArrayRef<Expr *> Args, SourceLocation RParenLoc) {
1416  void *Mem = Context.Allocate(totalSizeToAlloc<Expr *>(Args.size()));
1417  return new (Mem)
1418  CXXUnresolvedConstructExpr(T, TSI, LParenLoc, Args, RParenLoc);
1419 }
1420 
1423  unsigned NumArgs) {
1424  void *Mem = Context.Allocate(totalSizeToAlloc<Expr *>(NumArgs));
1425  return new (Mem) CXXUnresolvedConstructExpr(EmptyShell(), NumArgs);
1426 }
1427 
1429  return TSI->getTypeLoc().getBeginLoc();
1430 }
1431 
1432 CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(
1433  const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow,
1434  SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc,
1435  SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope,
1436  DeclarationNameInfo MemberNameInfo,
1437  const TemplateArgumentListInfo *TemplateArgs)
1438  : Expr(CXXDependentScopeMemberExprClass, Ctx.DependentTy, VK_LValue,
1439  OK_Ordinary),
1440  Base(Base), BaseType(BaseType), QualifierLoc(QualifierLoc),
1441  MemberNameInfo(MemberNameInfo) {
1442  CXXDependentScopeMemberExprBits.IsArrow = IsArrow;
1443  CXXDependentScopeMemberExprBits.HasTemplateKWAndArgsInfo =
1444  (TemplateArgs != nullptr) || TemplateKWLoc.isValid();
1445  CXXDependentScopeMemberExprBits.HasFirstQualifierFoundInScope =
1446  FirstQualifierFoundInScope != nullptr;
1447  CXXDependentScopeMemberExprBits.OperatorLoc = OperatorLoc;
1448 
1449  if (TemplateArgs) {
1451  getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1452  TemplateKWLoc, *TemplateArgs, getTrailingObjects<TemplateArgumentLoc>(),
1453  Deps);
1454  } else if (TemplateKWLoc.isValid()) {
1455  getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1456  TemplateKWLoc);
1457  }
1458 
1459  if (hasFirstQualifierFoundInScope())
1460  *getTrailingObjects<NamedDecl *>() = FirstQualifierFoundInScope;
1462 }
1463 
1464 CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(
1465  EmptyShell Empty, bool HasTemplateKWAndArgsInfo,
1466  bool HasFirstQualifierFoundInScope)
1467  : Expr(CXXDependentScopeMemberExprClass, Empty) {
1468  CXXDependentScopeMemberExprBits.HasTemplateKWAndArgsInfo =
1469  HasTemplateKWAndArgsInfo;
1470  CXXDependentScopeMemberExprBits.HasFirstQualifierFoundInScope =
1471  HasFirstQualifierFoundInScope;
1472 }
1473 
1475  const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow,
1476  SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc,
1477  SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope,
1478  DeclarationNameInfo MemberNameInfo,
1479  const TemplateArgumentListInfo *TemplateArgs) {
1480  bool HasTemplateKWAndArgsInfo =
1481  (TemplateArgs != nullptr) || TemplateKWLoc.isValid();
1482  unsigned NumTemplateArgs = TemplateArgs ? TemplateArgs->size() : 0;
1483  bool HasFirstQualifierFoundInScope = FirstQualifierFoundInScope != nullptr;
1484 
1485  unsigned Size = totalSizeToAlloc<ASTTemplateKWAndArgsInfo,
1487  HasTemplateKWAndArgsInfo, NumTemplateArgs, HasFirstQualifierFoundInScope);
1488 
1489  void *Mem = Ctx.Allocate(Size, alignof(CXXDependentScopeMemberExpr));
1490  return new (Mem) CXXDependentScopeMemberExpr(
1491  Ctx, Base, BaseType, IsArrow, OperatorLoc, QualifierLoc, TemplateKWLoc,
1492  FirstQualifierFoundInScope, MemberNameInfo, TemplateArgs);
1493 }
1494 
1496  const ASTContext &Ctx, bool HasTemplateKWAndArgsInfo,
1497  unsigned NumTemplateArgs, bool HasFirstQualifierFoundInScope) {
1498  assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
1499 
1500  unsigned Size = totalSizeToAlloc<ASTTemplateKWAndArgsInfo,
1502  HasTemplateKWAndArgsInfo, NumTemplateArgs, HasFirstQualifierFoundInScope);
1503 
1504  void *Mem = Ctx.Allocate(Size, alignof(CXXDependentScopeMemberExpr));
1505  return new (Mem) CXXDependentScopeMemberExpr(
1506  EmptyShell(), HasTemplateKWAndArgsInfo, HasFirstQualifierFoundInScope);
1507 }
1508 
1510  UnresolvedSetIterator end) {
1511  do {
1512  NamedDecl *decl = *begin;
1513  if (isa<UnresolvedUsingValueDecl>(decl))
1514  return false;
1515 
1516  // Unresolved member expressions should only contain methods and
1517  // method templates.
1518  if (cast<CXXMethodDecl>(decl->getUnderlyingDecl()->getAsFunction())
1519  ->isStatic())
1520  return false;
1521  } while (++begin != end);
1522 
1523  return true;
1524 }
1525 
1526 UnresolvedMemberExpr::UnresolvedMemberExpr(
1527  const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base,
1528  QualType BaseType, bool IsArrow, SourceLocation OperatorLoc,
1529  NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
1530  const DeclarationNameInfo &MemberNameInfo,
1533  : OverloadExpr(
1534  UnresolvedMemberExprClass, Context, QualifierLoc, TemplateKWLoc,
1535  MemberNameInfo, TemplateArgs, Begin, End,
1536  // Dependent
1537  ((Base && Base->isTypeDependent()) || BaseType->isDependentType()),
1538  ((Base && Base->isInstantiationDependent()) ||
1539  BaseType->isInstantiationDependentType()),
1540  // Contains unexpanded parameter pack
1541  ((Base && Base->containsUnexpandedParameterPack()) ||
1542  BaseType->containsUnexpandedParameterPack())),
1543  Base(Base), BaseType(BaseType), OperatorLoc(OperatorLoc) {
1544  UnresolvedMemberExprBits.IsArrow = IsArrow;
1545  UnresolvedMemberExprBits.HasUnresolvedUsing = HasUnresolvedUsing;
1546 
1547  // Check whether all of the members are non-static member functions,
1548  // and if so, mark give this bound-member type instead of overload type.
1550  setType(Context.BoundMemberTy);
1551 }
1552 
1553 UnresolvedMemberExpr::UnresolvedMemberExpr(EmptyShell Empty,
1554  unsigned NumResults,
1555  bool HasTemplateKWAndArgsInfo)
1556  : OverloadExpr(UnresolvedMemberExprClass, Empty, NumResults,
1557  HasTemplateKWAndArgsInfo) {}
1558 
1559 bool UnresolvedMemberExpr::isImplicitAccess() const {
1560  if (!Base)
1561  return true;
1562 
1563  return cast<Expr>(Base)->isImplicitCXXThis();
1564 }
1565 
1567  const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base,
1568  QualType BaseType, bool IsArrow, SourceLocation OperatorLoc,
1569  NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
1570  const DeclarationNameInfo &MemberNameInfo,
1573  unsigned NumResults = End - Begin;
1574  bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.isValid();
1575  unsigned NumTemplateArgs = TemplateArgs ? TemplateArgs->size() : 0;
1576  unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
1578  NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
1579  void *Mem = Context.Allocate(Size, alignof(UnresolvedMemberExpr));
1580  return new (Mem) UnresolvedMemberExpr(
1581  Context, HasUnresolvedUsing, Base, BaseType, IsArrow, OperatorLoc,
1582  QualifierLoc, TemplateKWLoc, MemberNameInfo, TemplateArgs, Begin, End);
1583 }
1584 
1586  const ASTContext &Context, unsigned NumResults,
1587  bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs) {
1588  assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
1589  unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
1591  NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
1592  void *Mem = Context.Allocate(Size, alignof(UnresolvedMemberExpr));
1593  return new (Mem)
1594  UnresolvedMemberExpr(EmptyShell(), NumResults, HasTemplateKWAndArgsInfo);
1595 }
1596 
1598  // Unlike for UnresolvedLookupExpr, it is very easy to re-derive this.
1599 
1600  // If there was a nested name specifier, it names the naming class.
1601  // It can't be dependent: after all, we were actually able to do the
1602  // lookup.
1603  CXXRecordDecl *Record = nullptr;
1604  auto *NNS = getQualifier();
1605  if (NNS && NNS->getKind() != NestedNameSpecifier::Super) {
1606  const Type *T = getQualifier()->getAsType();
1607  assert(T && "qualifier in member expression does not name type");
1608  Record = T->getAsCXXRecordDecl();
1609  assert(Record && "qualifier in member expression does not name record");
1610  }
1611  // Otherwise the naming class must have been the base class.
1612  else {
1613  QualType BaseType = getBaseType().getNonReferenceType();
1614  if (isArrow())
1615  BaseType = BaseType->castAs<PointerType>()->getPointeeType();
1616 
1617  Record = BaseType->getAsCXXRecordDecl();
1618  assert(Record && "base of member expression does not name record");
1619  }
1620 
1621  return Record;
1622 }
1623 
1625  SourceLocation OperatorLoc,
1626  NamedDecl *Pack, SourceLocation PackLoc,
1627  SourceLocation RParenLoc,
1628  std::optional<unsigned> Length,
1629  ArrayRef<TemplateArgument> PartialArgs) {
1630  void *Storage =
1631  Context.Allocate(totalSizeToAlloc<TemplateArgument>(PartialArgs.size()));
1632  return new (Storage) SizeOfPackExpr(Context.getSizeType(), OperatorLoc, Pack,
1633  PackLoc, RParenLoc, Length, PartialArgs);
1634 }
1635 
1637  unsigned NumPartialArgs) {
1638  void *Storage =
1639  Context.Allocate(totalSizeToAlloc<TemplateArgument>(NumPartialArgs));
1640  return new (Storage) SizeOfPackExpr(EmptyShell(), NumPartialArgs);
1641 }
1642 
1644  return cast<NonTypeTemplateParmDecl>(
1646 }
1647 
1649  const ASTContext &Context) const {
1650  // Note that, for a class type NTTP, we will have an lvalue of type 'const
1651  // T', so we can't just compute this from the type and value category.
1652  if (isReferenceParameter())
1653  return Context.getLValueReferenceType(getType());
1654  return getType().getUnqualifiedType();
1655 }
1656 
1657 SubstNonTypeTemplateParmPackExpr::SubstNonTypeTemplateParmPackExpr(
1658  QualType T, ExprValueKind ValueKind, SourceLocation NameLoc,
1659  const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index)
1660  : Expr(SubstNonTypeTemplateParmPackExprClass, T, ValueKind, OK_Ordinary),
1661  AssociatedDecl(AssociatedDecl), Arguments(ArgPack.pack_begin()),
1662  NumArguments(ArgPack.pack_size()), Index(Index), NameLoc(NameLoc) {
1663  assert(AssociatedDecl != nullptr);
1664  setDependence(ExprDependence::TypeValueInstantiation |
1665  ExprDependence::UnexpandedPack);
1666 }
1667 
1670  return cast<NonTypeTemplateParmDecl>(
1672 }
1673 
1675  return TemplateArgument(llvm::ArrayRef(Arguments, NumArguments));
1676 }
1677 
1678 FunctionParmPackExpr::FunctionParmPackExpr(QualType T, VarDecl *ParamPack,
1679  SourceLocation NameLoc,
1680  unsigned NumParams,
1681  VarDecl *const *Params)
1682  : Expr(FunctionParmPackExprClass, T, VK_LValue, OK_Ordinary),
1683  ParamPack(ParamPack), NameLoc(NameLoc), NumParameters(NumParams) {
1684  if (Params)
1685  std::uninitialized_copy(Params, Params + NumParams,
1686  getTrailingObjects<VarDecl *>());
1687  setDependence(ExprDependence::TypeValueInstantiation |
1688  ExprDependence::UnexpandedPack);
1689 }
1690 
1693  VarDecl *ParamPack, SourceLocation NameLoc,
1694  ArrayRef<VarDecl *> Params) {
1695  return new (Context.Allocate(totalSizeToAlloc<VarDecl *>(Params.size())))
1696  FunctionParmPackExpr(T, ParamPack, NameLoc, Params.size(), Params.data());
1697 }
1698 
1701  unsigned NumParams) {
1702  return new (Context.Allocate(totalSizeToAlloc<VarDecl *>(NumParams)))
1703  FunctionParmPackExpr(QualType(), nullptr, SourceLocation(), 0, nullptr);
1704 }
1705 
1707  QualType T, Expr *Temporary, bool BoundToLvalueReference,
1709  : Expr(MaterializeTemporaryExprClass, T,
1710  BoundToLvalueReference ? VK_LValue : VK_XValue, OK_Ordinary) {
1711  if (MTD) {
1712  State = MTD;
1713  MTD->ExprWithTemporary = Temporary;
1714  return;
1715  }
1716  State = Temporary;
1718 }
1719 
1721  unsigned ManglingNumber) {
1722  // We only need extra state if we have to remember more than just the Stmt.
1723  if (!ExtendedBy)
1724  return;
1725 
1726  // We may need to allocate extra storage for the mangling number and the
1727  // extended-by ValueDecl.
1728  if (!State.is<LifetimeExtendedTemporaryDecl *>())
1730  cast<Expr>(State.get<Stmt *>()), ExtendedBy, ManglingNumber);
1731 
1732  auto ES = State.get<LifetimeExtendedTemporaryDecl *>();
1733  ES->ExtendingDecl = ExtendedBy;
1734  ES->ManglingNumber = ManglingNumber;
1735 }
1736 
1738  const ASTContext &Context) const {
1739  // C++20 [expr.const]p4:
1740  // An object or reference is usable in constant expressions if it is [...]
1741  // a temporary object of non-volatile const-qualified literal type
1742  // whose lifetime is extended to that of a variable that is usable
1743  // in constant expressions
1744  auto *VD = dyn_cast_or_null<VarDecl>(getExtendingDecl());
1745  return VD && getType().isConstant(Context) &&
1747  getType()->isLiteralType(Context) &&
1748  VD->isUsableInConstantExpressions(Context);
1749 }
1750 
1751 TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind,
1753  SourceLocation RParenLoc, bool Value)
1754  : Expr(TypeTraitExprClass, T, VK_PRValue, OK_Ordinary), Loc(Loc),
1755  RParenLoc(RParenLoc) {
1756  assert(Kind <= TT_Last && "invalid enum value!");
1757  TypeTraitExprBits.Kind = Kind;
1758  assert(static_cast<unsigned>(Kind) == TypeTraitExprBits.Kind &&
1759  "TypeTraitExprBits.Kind overflow!");
1760  TypeTraitExprBits.Value = Value;
1761  TypeTraitExprBits.NumArgs = Args.size();
1762  assert(Args.size() == TypeTraitExprBits.NumArgs &&
1763  "TypeTraitExprBits.NumArgs overflow!");
1764 
1765  auto **ToArgs = getTrailingObjects<TypeSourceInfo *>();
1766  for (unsigned I = 0, N = Args.size(); I != N; ++I)
1767  ToArgs[I] = Args[I];
1768 
1770 }
1771 
1773  SourceLocation Loc,
1774  TypeTrait Kind,
1776  SourceLocation RParenLoc,
1777  bool Value) {
1778  void *Mem = C.Allocate(totalSizeToAlloc<TypeSourceInfo *>(Args.size()));
1779  return new (Mem) TypeTraitExpr(T, Loc, Kind, Args, RParenLoc, Value);
1780 }
1781 
1783  unsigned NumArgs) {
1784  void *Mem = C.Allocate(totalSizeToAlloc<TypeSourceInfo *>(NumArgs));
1785  return new (Mem) TypeTraitExpr(EmptyShell());
1786 }
1787 
1788 CUDAKernelCallExpr::CUDAKernelCallExpr(Expr *Fn, CallExpr *Config,
1789  ArrayRef<Expr *> Args, QualType Ty,
1791  FPOptionsOverride FPFeatures,
1792  unsigned MinNumArgs)
1793  : CallExpr(CUDAKernelCallExprClass, Fn, /*PreArgs=*/Config, Args, Ty, VK,
1794  RP, FPFeatures, MinNumArgs, NotADL) {}
1795 
1796 CUDAKernelCallExpr::CUDAKernelCallExpr(unsigned NumArgs, bool HasFPFeatures,
1797  EmptyShell Empty)
1798  : CallExpr(CUDAKernelCallExprClass, /*NumPreArgs=*/END_PREARG, NumArgs,
1799  HasFPFeatures, Empty) {}
1800 
1804  SourceLocation RP, FPOptionsOverride FPFeatures,
1805  unsigned MinNumArgs) {
1806  // Allocate storage for the trailing objects of CallExpr.
1807  unsigned NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1808  unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
1809  /*NumPreArgs=*/END_PREARG, NumArgs, FPFeatures.requiresTrailingStorage());
1810  void *Mem = Ctx.Allocate(sizeof(CUDAKernelCallExpr) + SizeOfTrailingObjects,
1811  alignof(CUDAKernelCallExpr));
1812  return new (Mem)
1813  CUDAKernelCallExpr(Fn, Config, Args, Ty, VK, RP, FPFeatures, MinNumArgs);
1814 }
1815 
1817  unsigned NumArgs,
1818  bool HasFPFeatures,
1819  EmptyShell Empty) {
1820  // Allocate storage for the trailing objects of CallExpr.
1821  unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
1822  /*NumPreArgs=*/END_PREARG, NumArgs, HasFPFeatures);
1823  void *Mem = Ctx.Allocate(sizeof(CUDAKernelCallExpr) + SizeOfTrailingObjects,
1824  alignof(CUDAKernelCallExpr));
1825  return new (Mem) CUDAKernelCallExpr(NumArgs, HasFPFeatures, Empty);
1826 }
1827 
1830  unsigned NumUserSpecifiedExprs,
1831  SourceLocation InitLoc, SourceLocation LParenLoc,
1832  SourceLocation RParenLoc) {
1833  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(Args.size()));
1834  return new (Mem) CXXParenListInitExpr(Args, T, NumUserSpecifiedExprs, InitLoc,
1835  LParenLoc, RParenLoc);
1836 }
1837 
1839  unsigned NumExprs,
1840  EmptyShell Empty) {
1841  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumExprs),
1842  alignof(CXXParenListInitExpr));
1843  return new (Mem) CXXParenListInitExpr(Empty, NumExprs);
1844 }
clang::UserDefinedLiteral::Create
static UserDefinedLiteral * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation LitEndLoc, SourceLocation SuffixLoc, FPOptionsOverride FPFeatures)
Definition: ExprCXX.cpp:891
clang::CXXPseudoDestructorExpr::getDestroyedType
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition: ExprCXX.cpp:335
clang::Type::isRecordType
bool isRecordType() const
Definition: Type.h:6984
clang::CXXTemporary::Create
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
Definition: ExprCXX.cpp:1034
clang::UnresolvedMemberExpr::getBaseType
QualType getBaseType() const
Definition: ExprCXX.h:3969
clang::CXXConstructorDecl
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2448
clang::ASTContext::getTypeDeclType
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:1553
clang::OverloadExpr::getTrailingASTTemplateKWAndArgsInfo
ASTTemplateKWAndArgsInfo * getTrailingASTTemplateKWAndArgsInfo()
Return the optional template keyword and arguments info.
Definition: ExprCXX.h:4043
clang::CXXRecordDecl::getDependentLambdaCallOperator
FunctionTemplateDecl * getDependentLambdaCallOperator() const
Retrieve the dependent lambda call operator of the closure type if this is a templated closure type.
Definition: DeclCXX.cpp:1547
clang::NestedNameSpecifier::Super
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
Definition: NestedNameSpecifier.h:101
clang::LambdaExpr::capture_begin
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Definition: ExprCXX.cpp:1285
clang::CXXConstructExpr::CXXConstructExpr
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:1125
Specifiers.h
clang::LambdaCapture::capturesThis
bool capturesThis() const
Determine whether this capture handles the C++ this pointer.
Definition: LambdaCapture.h:82
clang::OK_Ordinary
@ OK_Ordinary
An ordinary object is located at an address in memory.
Definition: Specifiers.h:139
clang::CXXRewrittenBinaryOperator::getDecomposedForm
DecomposedForm getDecomposedForm() const LLVM_READONLY
Decompose this operator into its syntactic form.
Definition: ExprCXX.cpp:66
clang::TypeSourceInfo::getType
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6615
clang::CXXRewrittenBinaryOperator::DecomposedForm
Definition: ExprCXX.h:304
clang::CXXMemberCallExpr::getMethodDecl
CXXMethodDecl * getMethodDecl() const
Retrieve the declaration of the called method.
Definition: ExprCXX.cpp:670
clang::LambdaExpr::implicit_capture_begin
capture_iterator implicit_capture_begin() const
Retrieve an iterator pointing to the first implicit lambda capture.
Definition: ExprCXX.cpp:1310
clang::FPOptionsOverride::requiresTrailingStorage
bool requiresTrailingStorage() const
Definition: LangOptions.h:832
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:210
DeclAccessPair.h
clang::Stmt::CXXNewExprBits
CXXNewExprBitfields CXXNewExprBits
Definition: Stmt.h:1069
clang::CXXParenListInitExpr::Create
static CXXParenListInitExpr * Create(ASTContext &C, ArrayRef< Expr * > Args, QualType T, unsigned NumUserSpecifiedExprs, SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Definition: ExprCXX.cpp:1829
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1389
clang::LambdaCapture
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:25
clang::Decl::hasAttr
bool hasAttr() const
Definition: DeclBase.h:560
clang::CXXReinterpretCastExpr
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition: ExprCXX.h:520
clang::FunctionParmPackExpr::CreateEmpty
static FunctionParmPackExpr * CreateEmpty(const ASTContext &Context, unsigned NumParams)
Definition: ExprCXX.cpp:1700
clang::CXXConstructExpr::getNumArgs
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Definition: ExprCXX.h:1666
clang::LambdaExpr::capture_range
llvm::iterator_range< capture_iterator > capture_range
An iterator over a range of lambda captures.
Definition: ExprCXX.h:1992
clang::CXXConstructExpr::getParenOrBraceRange
SourceRange getParenOrBraceRange() const
Definition: ExprCXX.h:1686
DependenceFlags.h
clang::CXXFunctionalCastExpr::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:869
clang::LambdaExpr::getTrailingRequiresClause
Expr * getTrailingRequiresClause() const
Get the trailing requires clause, if any.
Definition: ExprCXX.cpp:1346
clang::Expr::IgnoreImplicit
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Definition: Expr.cpp:3024
clang::UnresolvedMemberExpr::CreateEmpty
static UnresolvedMemberExpr * CreateEmpty(const ASTContext &Context, unsigned NumResults, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition: ExprCXX.cpp:1585
clang::CXXConstCastExpr::CreateEmpty
static CXXConstCastExpr * CreateEmpty(const ASTContext &Context)
Definition: ExprCXX.cpp:826
clang::CXXNewExpr::CreateEmpty
static CXXNewExpr * CreateEmpty(const ASTContext &Ctx, bool IsArray, bool HasInit, unsigned NumPlacementArgs, bool IsParenTypeId)
Create an empty c++ new expression.
Definition: ExprCXX.cpp:267
llvm::SmallVector
Definition: LLVM.h:38
clang::CXXTypeidExpr::isPotentiallyEvaluated
bool isPotentiallyEvaluated() const
Determine whether this typeid has a type operand which is potentially evaluated, per C++11 [expr....
Definition: ExprCXX.cpp:135
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::CXXMemberCallExpr::Create
static CXXMemberCallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RP, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0)
Definition: ExprCXX.cpp:623
clang::CXXDefaultInitExpr::getExpr
Expr * getExpr()
Get the initialization expression that will be used.
Definition: ExprCXX.cpp:1026
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::Stmt::StmtClass
StmtClass
Definition: Stmt.h:74
clang::QualType::getNonReferenceType
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:6842
clang::CastExpr::getSubExpr
Expr * getSubExpr()
Definition: Expr.h:3532
clang::CXXNewExpr::getOperatorNew
FunctionDecl * getOperatorNew() const
Definition: ExprCXX.h:2315
clang::LambdaExpr::isMutable
bool isMutable() const
Determine whether the lambda is mutable, meaning that any captures values can be modified.
Definition: ExprCXX.cpp:1350
clang::CXXRewrittenBinaryOperator::getSemanticForm
Expr * getSemanticForm()
Get an equivalent semantic form for this expression.
Definition: ExprCXX.h:301
clang::DependentScopeDeclRefExpr::CreateEmpty
static DependentScopeDeclRefExpr * CreateEmpty(const ASTContext &Context, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition: ExprCXX.cpp:494
clang::Stmt::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:325
clang::UnresolvedMemberExpr
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition: ExprCXX.h:3883
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:736
clang::NonTypeTemplateParmDecl
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Definition: DeclTemplate.h:1407
Attr.h
clang::Stmt::TypeTraitExprBits
TypeTraitExprBitfields TypeTraitExprBits
Definition: Stmt.h:1071
clang::DynamicInitKind::Initializer
@ Initializer
clang::CXXStaticCastExpr::Create
static CXXStaticCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written, FPOptionsOverride FPO, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Definition: ExprCXX.cpp:709
clang::TypeTraitExpr
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2740
clang::UnresolvedSetIterator
The iterator over UnresolvedSets.
Definition: UnresolvedSet.h:32
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2943
clang::TypeTrait
TypeTrait
Names for traits that operate specifically on types.
Definition: TypeTraits.h:21
clang::Type::isFloatingType
bool isFloatingType() const
Definition: Type.cpp:2145
clang::Qualifiers
The collection of all-type qualifiers we support.
Definition: Type.h:146
clang::MaterializeTemporaryExpr::MaterializeTemporaryExpr
MaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference, LifetimeExtendedTemporaryDecl *MTD=nullptr)
Definition: ExprCXX.cpp:1706
clang::ParmVarDecl
Represents a parameter to a function.
Definition: Decl.h:1724
clang::ParmVarDecl::getDefaultArg
Expr * getDefaultArg()
Definition: Decl.cpp:2895
DeclCXX.h
memcpy
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Definition: __clang_cuda_device_functions.h:1549
clang::VK_XValue
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
Definition: Specifiers.h:132
clang::CXXNewExpr
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition: ExprCXX.h:2197
clang::SourceRange::isValid
bool isValid() const
Definition: SourceLocation.h:225
clang::Expr::IgnoreParenNoopCasts
Expr * IgnoreParenNoopCasts(const ASTContext &Ctx) LLVM_READONLY
Skip past any parenthese and casts which do not change the value (including ptr->int casts of the sam...
Definition: Expr.cpp:3063
clang::CXXUuidofExpr::getTypeOperand
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this __uuidof() expression after various required adjustments (removing...
Definition: ExprCXX.cpp:169
clang::LambdaExpr::capture_end
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition: ExprCXX.cpp:1289
clang::Type::isVoidType
bool isVoidType() const
Definition: Type.h:7191
clang::CXXDefaultInitExpr::getRewrittenExpr
const Expr * getRewrittenExpr() const
Retrieve the initializing expression with evaluated immediate calls, if any.
Definition: ExprCXX.h:1401
clang::CXXBindTemporaryExpr::Create
static CXXBindTemporaryExpr * Create(const ASTContext &C, CXXTemporary *Temp, Expr *SubExpr)
Definition: ExprCXX.cpp:1039
clang::CXXMemberCallExpr::CreateEmpty
static CXXMemberCallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty)
Definition: ExprCXX.cpp:639
clang::QualType::isVolatileQualified
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
Definition: Type.h:6716
clang::CXXTemporaryObjectExpr::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:1090
clang::CallExpr::getRParenLoc
SourceLocation getRParenLoc() const
Definition: Expr.h:3122
clang::CallExpr::getCalleeDecl
Decl * getCalleeDecl()
Definition: Expr.h:2976
clang::CXXStaticCastExpr
A C++ static_cast expression (C++ [expr.static.cast]).
Definition: ExprCXX.h:430
clang::FunctionParmPackExpr::Create
static FunctionParmPackExpr * Create(const ASTContext &Context, QualType T, VarDecl *ParamPack, SourceLocation NameLoc, ArrayRef< VarDecl * > Params)
Definition: ExprCXX.cpp:1692
clang::CXXPseudoDestructorExpr::CXXPseudoDestructorExpr
CXXPseudoDestructorExpr(const ASTContext &Context, Expr *Base, bool isArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, TypeSourceInfo *ScopeType, SourceLocation ColonColonLoc, SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType)
Definition: ExprCXX.cpp:321
clang::CXXTypeidExpr::isMostDerived
bool isMostDerived(ASTContext &Context) const
Best-effort check if the expression operand refers to a most derived object.
Definition: ExprCXX.cpp:150
clang::CXXScalarValueInitExpr::getRParenLoc
SourceLocation getRParenLoc() const
Definition: ExprCXX.h:2174
clang::CXXAddrspaceCastExpr::Create
static CXXAddrspaceCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind, Expr *Op, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Definition: ExprCXX.cpp:831
clang::CXXTypeidExpr::getExprOperand
Expr * getExprOperand() const
Definition: ExprCXX.h:892
clang::UserDefinedLiteral::getCookedLiteral
Expr * getCookedLiteral()
If this is not a raw user-defined literal, get the underlying cooked literal (representing the litera...
Definition: ExprCXX.cpp:941
End
SourceLocation End
Definition: USRLocFinder.cpp:167
clang::Expr::isGLValue
bool isGLValue() const
Definition: Expr.h:274
clang::CXXFunctionalCastExpr::Create
static CXXFunctionalCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, TypeSourceInfo *Written, CastKind Kind, Expr *Op, const CXXCastPath *Path, FPOptionsOverride FPO, SourceLocation LPLoc, SourceLocation RPLoc)
Definition: ExprCXX.cpp:843
clang::Stmt::ExprWithCleanupsBits
ExprWithCleanupsBitfields ExprWithCleanupsBits
Definition: Stmt.h:1074
clang::Stmt::EmptyShell
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....
Definition: Stmt.h:1117
clang::CXXRecordDecl::getLambdaCallOperator
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
Definition: DeclCXX.cpp:1552
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1566
clang::CUDAKernelCallExpr::CreateEmpty
static CUDAKernelCallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty)
Definition: ExprCXX.cpp:1816
clang::Stmt::CXXUnresolvedConstructExprBits
CXXUnresolvedConstructExprBitfields CXXUnresolvedConstructExprBits
Definition: Stmt.h:1075
Decl.h
clang::FullExpr
FullExpr - Represents a "full-expression" node.
Definition: Expr.h:1015
clang::UserDefinedLiteral::LOK_Template
@ LOK_Template
Raw form: operator "" X<cs...> ()
Definition: ExprCXX.h:670
clang::TypeLoc::getBeginLoc
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:191
clang::ASTContext::BoundMemberTy
CanQualType BoundMemberTy
Definition: ASTContext.h:1105
clang::CXXTemporaryObjectExpr
Represents a C++ functional cast expression that builds a temporary object.
Definition: ExprCXX.h:1855
clang::FunctionParmPackExpr
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Definition: ExprCXX.h:4480
size_t
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
Definition: opencl-c-base.h:137
clang::LambdaExpr::explicit_capture_begin
capture_iterator explicit_capture_begin() const
Retrieve an iterator pointing to the first explicit lambda capture.
Definition: ExprCXX.cpp:1297
clang::ASTContext::Allocate
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:704
clang::CXXMemberCallExpr::getImplicitObjectArgument
Expr * getImplicitObjectArgument() const
Retrieve the implicit object argument for the member call.
Definition: ExprCXX.cpp:651
clang::CUDAKernelCallExpr::Create
static CUDAKernelCallExpr * Create(const ASTContext &Ctx, Expr *Fn, CallExpr *Config, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RP, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0)
Definition: ExprCXX.cpp:1802
clang::Type::isLiteralType
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
Definition: Type.cpp:2622
clang::FunctionTemplateDecl
Declaration of a template function.
Definition: DeclTemplate.h:1005
clang::TypeInfo
Definition: ASTContext.h:152
clang::CXXOperatorCallExpr::getOperatorLoc
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
Definition: ExprCXX.h:149
clang::CXXDependentScopeMemberExpr::CreateEmpty
static CXXDependentScopeMemberExpr * CreateEmpty(const ASTContext &Ctx, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs, bool HasFirstQualifierFoundInScope)
Definition: ExprCXX.cpp:1495
clang::Type::isReferenceType
bool isReferenceType() const
Definition: Type.h:6906
clang::CallExpr::getCallee
Expr * getCallee()
Definition: Expr.h:2962
TemplateBase.h
clang::LambdaExpr::getDependentCallOperator
FunctionTemplateDecl * getDependentCallOperator() const
Retrieve the function template call operator associated with this lambda expression.
Definition: ExprCXX.cpp:1331
clang::UserDefinedLiteral::LiteralOperatorKind
LiteralOperatorKind
The kind of literal operator which is invoked.
Definition: ExprCXX.h:665
clang::CXXDefaultArgExpr::hasRewrittenInit
bool hasRewrittenInit() const
Definition: ExprCXX.h:1294
clang::Expr::isTypeDependent
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition: Expr.h:186
clang::RecordType
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4821
clang::CompoundStmt
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1418
DeclTemplate.h
clang::CXXAddrspaceCastExpr
A C++ addrspace_cast expression (currently only enabled for OpenCL).
Definition: ExprCXX.h:599
clang::UnresolvedLookupExpr
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:3147
clang::LambdaExpr::getCallOperator
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
Definition: ExprCXX.cpp:1326
clang::PseudoDestructorTypeStorage::getLocation
SourceLocation getLocation() const
Definition: ExprCXX.h:2565
clang::TemplateArgumentListInfo
A convenient class for passing around template argument information.
Definition: TemplateBase.h:590
clang::UserDefinedLiteral::LOK_Character
@ LOK_Character
operator "" X (CharT)
Definition: ExprCXX.h:682
clang::CXXConstructExpr::CreateEmpty
static CXXConstructExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs)
Create an empty C++ construction expression.
Definition: ExprCXX.cpp:1116
clang::SizeOfPackExpr
Represents an expression that computes the length of a parameter pack.
Definition: ExprCXX.h:4200
clang::CXXBindTemporaryExpr
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1470
clang::CXXConstructExpr::ConstructionKind
ConstructionKind
Definition: ExprCXX.h:1522
clang::DependentScopeDeclRefExpr::Create
static DependentScopeDeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
Definition: ExprCXX.cpp:479
clang::CXXReinterpretCastExpr::CreateEmpty
static CXXReinterpretCastExpr * CreateEmpty(const ASTContext &Context, unsigned pathSize)
Definition: ExprCXX.cpp:812
clang::ExplicitCastExpr::getTypeInfoAsWritten
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to.
Definition: Expr.h:3726
clang::OverloadExpr::getTrailingResults
DeclAccessPair * getTrailingResults()
Return the results. Defined after UnresolvedMemberExpr.
Definition: ExprCXX.h:4037
clang::LambdaExpr::capture_size
unsigned capture_size() const
Determine the number of captures in this lambda.
Definition: ExprCXX.h:2005
DeclBase.h
clang::SubstNonTypeTemplateParmExpr::isReferenceParameter
bool isReferenceParameter() const
Definition: ExprCXX.h:4374
clang::XRayInstrKind::None
constexpr XRayInstrMask None
Definition: XRayInstr.h:38
clang::LambdaExpr
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1923
clang::SubstNonTypeTemplateParmPackExpr::getAssociatedDecl
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
Definition: ExprCXX.h:4433
OperatorKinds.h
clang::LambdaExpr::getTemplateParameterList
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it,...
Definition: ExprCXX.cpp:1336
clang::SourceRange::getEnd
SourceLocation getEnd() const
Definition: SourceLocation.h:220
clang::UnresolvedMemberExpr::isArrow
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
Definition: ExprCXX.h:3979
clang::CXXTemporaryObjectExpr::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:1094
clang::Type::isAnyCharacterType
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
Definition: Type.cpp:2021
clang::CXXMemberCallExpr::getObjectType
QualType getObjectType() const
Retrieve the type of the object argument.
Definition: ExprCXX.cpp:663
clang::DeclAccessPair
A POD class for pairing a NamedDecl* with an access specifier.
Definition: DeclAccessPair.h:29
clang::Stmt::CXXDefaultInitExprBits
CXXDefaultInitExprBitfields CXXDefaultInitExprBits
Definition: Stmt.h:1067
clang::ASTContext::DependentTy
CanQualType DependentTy
Definition: ASTContext.h:1105
clang::MaterializeTemporaryExpr::getExtendingDecl
ValueDecl * getExtendingDecl()
Get the declaration which triggered the lifetime-extension of this temporary, if any.
Definition: ExprCXX.h:4612
clang::FPOptionsOverride
Represents difference between two FPOptions values.
Definition: LangOptions.h:806
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:182
clang::ASTContext::getSizeType
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Definition: ASTContext.cpp:5980
NestedNameSpecifier.h
clang::FunctionDecl::getBody
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Definition: Decl.cpp:3126
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7397
clang::PseudoDestructorTypeStorage
Stores the type being destroyed by a pseudo-destructor expression.
Definition: ExprCXX.h:2541
clang::Stmt::CXXConstructExprBits
CXXConstructExprBitfields CXXConstructExprBits
Definition: Stmt.h:1073
clang::CallExpr::getArg
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: Expr.h:3003
clang::TemplateArgument
Represents a template argument.
Definition: TemplateBase.h:60
clang::OverloadExpr::OverloadExpr
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:414
clang::FPOptions
Definition: LangOptions.h:657
clang::CXXNewExpr::InitializationStyle
InitializationStyle
Definition: ExprCXX.h:2249
clang::LambdaCaptureDefault
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
Definition: Lambda.h:22
clang::ASTTemplateKWAndArgsInfo::initializeFrom
void initializeFrom(SourceLocation TemplateKWLoc, const TemplateArgumentListInfo &List, TemplateArgumentLoc *OutArgArray)
Definition: TemplateBase.cpp:644
clang::MaterializeTemporaryExpr::isUsableInConstantExpressions
bool isUsableInConstantExpressions(const ASTContext &Context) const
Determine whether this temporary object is usable in constant expressions, as specified in C++20 [exp...
Definition: ExprCXX.cpp:1737
clang::LambdaExpr::getCompoundStmtBody
const CompoundStmt * getCompoundStmtBody() const
Retrieve the CompoundStmt representing the body of the lambda.
Definition: ExprCXX.cpp:1273
clang::Stmt::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.cpp:349
clang::CXXDestructorDecl
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2715
clang::UnresolvedLookupExpr::Create
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
Definition: ExprCXX.cpp:370
clang::CXXOperatorCallExpr::getBeginLoc
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:159
clang::TemplateArgumentLoc
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:484
Type.h
clang::CXXFunctionalCastExpr::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:873
clang::UserDefinedLiteral::LOK_Integer
@ LOK_Integer
operator "" X (unsigned long long)
Definition: ExprCXX.h:673
Expr.h
clang::CXXConstCastExpr::Create
static CXXConstCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, Expr *Op, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Definition: ExprCXX.cpp:817
ASTContext.h
clang::CXXDynamicCastExpr
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition: ExprCXX.h:476
clang::CallExpr::sizeOfTrailingObjects
static unsigned sizeOfTrailingObjects(unsigned NumPreArgs, unsigned NumArgs, bool HasFPFeatures)
Return the size in bytes needed for the trailing objects.
Definition: Expr.h:2886
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:915
ComputeDependence.h
clang::Type::getPointeeType
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
Definition: Type.cpp:629
clang::CXXDeleteExpr::getOperatorDelete
FunctionDecl * getOperatorDelete() const
Definition: ExprCXX.h:2512
clang::TemplateParameterList
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:71
clang::SourceRange::setEnd
void setEnd(SourceLocation e)
Definition: SourceLocation.h:223
clang::CXXTypeidExpr::getTypeOperand
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this typeid() expression after various required adjustments (removing r...
Definition: ExprCXX.cpp:162
clang::CXXRecordDecl::captures_begin
capture_const_iterator captures_begin() const
Definition: DeclCXX.h:1082
clang::ExprWithCleanups
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition: ExprCXX.h:3416
clang::DeclaratorDecl::getTrailingRequiresClause
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
Definition: Decl.h:843
clang::Type::getAsCXXRecordDecl
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition: Type.cpp:1783
clang::CXXTemporary
Represents a C++ temporary.
Definition: ExprCXX.h:1438
clang::CXXMemberCallExpr::getRecordDecl
CXXRecordDecl * getRecordDecl() const
Retrieve the CXXRecordDecl for the underlying type of the implicit object argument.
Definition: ExprCXX.cpp:679
clang::LambdaCapture::capturesVLAType
bool capturesVLAType() const
Determine whether this captures a variable length array bound expression.
Definition: LambdaCapture.h:94
clang::LambdaCapture::getCaptureKind
LambdaCaptureKind getCaptureKind() const
Determine the kind of capture.
Definition: ExprCXX.cpp:1186
clang::NestedNameSpecifierLoc
A C++ nested-name-specifier augmented with source location information.
Definition: NestedNameSpecifier.h:243
ExprCXX.h
Base
clang::Stmt::child_range
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:1266
clang::CXXDefaultArgExpr
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1247
clang::LambdaExpr::implicit_capture_end
capture_iterator implicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of implicit lambda captures.
Definition: ExprCXX.cpp:1314
clang::computeDependence
ExprDependence computeDependence(FullExpr *E)
Definition: ComputeDependence.cpp:24
clang::Stmt::DependentScopeDeclRefExprBits
DependentScopeDeclRefExprBitfields DependentScopeDeclRefExprBits
Definition: Stmt.h:1072
clang::CXXUnresolvedConstructExpr::Create
static CXXUnresolvedConstructExpr * Create(const ASTContext &Context, QualType T, TypeSourceInfo *TSI, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc)
Definition: ExprCXX.cpp:1413
clang::OverloadedOperatorKind
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
clang::MaterializeTemporaryExpr::setExtendingDecl
void setExtendingDecl(ValueDecl *ExtendedBy, unsigned ManglingNumber)
Definition: ExprCXX.cpp:1720
clang::CXXOperatorCallExpr::Create
static CXXOperatorCallExpr * Create(const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation OperatorLoc, FPOptionsOverride FPFeatures, ADLCallKind UsesADL=NotADL)
Definition: ExprCXX.cpp:559
clang::LambdaExpr::getExplicitTemplateParameters
ArrayRef< NamedDecl * > getExplicitTemplateParameters() const
Get the template parameters were explicitly specified (as opposed to being invented by use of an auto...
Definition: ExprCXX.cpp:1341
clang::QualType::getUnqualifiedType
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition: Type.h:6726
clang::Stmt::CXXDefaultArgExprBits
CXXDefaultArgExprBitfields CXXDefaultArgExprBits
Definition: Stmt.h:1066
clang::Stmt::const_child_range
llvm::iterator_range< const_child_iterator > const_child_range
Definition: Stmt.h:1267
clang::UserDefinedLiteral
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
Definition: ExprCXX.h:637
clang::VK_LValue
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:127
clang::CXXParenListInitExpr::CreateEmpty
static CXXParenListInitExpr * CreateEmpty(ASTContext &C, unsigned numExprs, EmptyShell Empty)
Definition: ExprCXX.cpp:1838
clang::Type::castAs
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:7464
hasOnlyNonStaticMemberFunctions
static bool hasOnlyNonStaticMemberFunctions(UnresolvedSetIterator begin, UnresolvedSetIterator end)
Definition: ExprCXX.cpp:1509
clang::Expr::isImplicitCXXThis
bool isImplicitCXXThis() const
Whether this expression is an implicit reference to 'this' in C++.
Definition: Expr.cpp:3212
clang::CallExpr::ADLCallKind
ADLCallKind
Definition: Expr.h:2868
clang::Stmt::CXXDependentScopeMemberExprBits
CXXDependentScopeMemberExprBitfields CXXDependentScopeMemberExprBits
Definition: Stmt.h:1076
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
SourceLocation.h
clang::LifetimeExtendedTemporaryDecl::Create
static LifetimeExtendedTemporaryDecl * Create(Expr *Temp, ValueDecl *EDec, unsigned Mangling)
Definition: DeclCXX.h:3168
clang::CXXOperatorCallExpr::getEndLoc
SourceLocation getEndLoc() const
Definition: ExprCXX.h:160
clang::CXXDefaultInitExpr::CreateEmpty
static CXXDefaultInitExpr * CreateEmpty(const ASTContext &C, bool HasRewrittenInit)
Definition: ExprCXX.cpp:1007
clang::UserDefinedLiteral::LOK_String
@ LOK_String
operator "" X (const CharT *, size_t)
Definition: ExprCXX.h:679
clang::ast_matchers::decl
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
Definition: ASTMatchersInternal.cpp:735
clang::Type::isDependentType
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2308
clang::VK_PRValue
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:123
clang::LambdaCaptureKind
LambdaCaptureKind
The different capture forms in a lambda introducer.
Definition: Lambda.h:33
clang::LambdaExpr::isInitCapture
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
Definition: ExprCXX.cpp:1280
clang::CXXOperatorCallExpr::getOperator
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
Definition: ExprCXX.h:111
clang::Stmt::getStmtClass
StmtClass getStmtClass() const
Definition: Stmt.h:1177
clang::Type::isPointerType
bool isPointerType() const
Definition: Type.h:6894
clang::LambdaCaptureInitKind::ListInit
@ ListInit
[a{b}]
clang::SubstNonTypeTemplateParmPackExpr::getParameterPack
NonTypeTemplateParmDecl * getParameterPack() const
Retrieve the non-type template parameter pack being substituted.
Definition: ExprCXX.cpp:1669
false
#define false
Definition: stdbool.h:22
clang::LCK_ByRef
@ LCK_ByRef
Capturing by reference.
Definition: Lambda.h:37
clang::ValueDecl
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:703
clang::ASTContext::getUnqualifiedArrayType
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
Definition: ASTContext.cpp:6063
clang::FunctionProtoType
Represents a prototype with parameter type info, e.g.
Definition: Type.h:4021
clang::TemplateArgumentListInfo::size
unsigned size() const
Definition: TemplateBase.h:612
clang::CallExpr::getNumArgs
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Definition: Expr.h:2990
clang::UserDefinedLiteral::CreateEmpty
static UserDefinedLiteral * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPOptions, EmptyShell Empty)
Definition: ExprCXX.cpp:907
clang::QualType::isConstant
bool isConstant(const ASTContext &Ctx) const
Definition: Type.h:876
clang::PseudoDestructorTypeStorage::getTypeSourceInfo
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:2557
clang::LambdaExpr::captures
capture_range captures() const
Retrieve this lambda's captures.
Definition: ExprCXX.cpp:1293
clang::CXXReinterpretCastExpr::Create
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:794
Begin
SourceLocation Begin
Definition: USRLocFinder.cpp:165
clang::CXXTemporaryObjectExpr::CreateEmpty
static CXXTemporaryObjectExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs)
Definition: ExprCXX.cpp:1082
clang::CXXAddrspaceCastExpr::CreateEmpty
static CXXAddrspaceCastExpr * CreateEmpty(const ASTContext &Context)
Definition: ExprCXX.cpp:839
llvm::ArrayRef
Definition: LLVM.h:34
clang::UnresolvedLookupExpr::CreateEmpty
static UnresolvedLookupExpr * CreateEmpty(const ASTContext &Context, unsigned NumResults, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition: ExprCXX.cpp:402
Value
Value
Definition: UninitializedValues.cpp:102
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
clang::CXXTypeidExpr::isTypeOperand
bool isTypeOperand() const
Definition: ExprCXX.h:881
clang::CXXNewExpr::shouldNullCheckAllocation
bool shouldNullCheckAllocation() const
True if the allocation result needs to be null-checked.
Definition: ExprCXX.cpp:278
clang::CXXFunctionalCastExpr
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr....
Definition: ExprCXX.h:1784
clang::CXXRecordDecl::getLambdaExplicitTemplateParameters
ArrayRef< NamedDecl * > getLambdaExplicitTemplateParameters() const
Retrieve the lambda template parameters that were specified explicitly.
Definition: DeclCXX.cpp:1629
clang::LCK_StarThis
@ LCK_StarThis
Capturing the *this object by copy.
Definition: Lambda.h:35
clang::DependentScopeDeclRefExpr
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:3265
clang::CXXUnresolvedConstructExpr::CreateEmpty
static CXXUnresolvedConstructExpr * CreateEmpty(const ASTContext &Context, unsigned NumArgs)
Definition: ExprCXX.cpp:1422
clang::PseudoDestructorTypeStorage::PseudoDestructorTypeStorage
PseudoDestructorTypeStorage()=default
LLVM.h
clang::CXXConstructExpr::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:516
clang::CXXNamedCastExpr::getCastName
const char * getCastName() const
getCastName - Get the name of the C++ cast being used, e.g., "static_cast", "dynamic_cast",...
Definition: ExprCXX.cpp:697
clang::OverloadExpr
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
Definition: ExprCXX.h:2954
clang::CXXDynamicCastExpr::Create
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:735
clang::CXXDeleteExpr::getDestroyedType
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition: ExprCXX.cpp:288
clang::UserDefinedLiteral::LOK_Raw
@ LOK_Raw
Raw form: operator "" X (const char *)
Definition: ExprCXX.h:667
clang::CXXDependentScopeMemberExpr
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3623
clang::TypeTraitExpr::Create
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:1772
clang::ExprValueKind
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:120
clang::CXXUnresolvedConstructExpr
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3501
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:85
clang::CXXDefaultArgExpr::getRewrittenExpr
Expr * getRewrittenExpr()
Definition: ExprCXX.h:1304
clang::LambdaExpr::getBody
Stmt * getBody() const
Retrieve the body of the lambda.
Definition: ExprCXX.cpp:1268
clang::CXXRecordDecl::getGenericLambdaTemplateParameterList
TemplateParameterList * getGenericLambdaTemplateParameterList() const
Retrieve the generic lambda's template parameter list.
Definition: DeclCXX.cpp:1620
clang::ASTContext::getLValueReferenceType
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
Definition: ASTContext.cpp:3513
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::LambdaExpr::explicit_captures
capture_range explicit_captures() const
Retrieve this lambda's explicit captures.
Definition: ExprCXX.cpp:1306
clang::CXXScalarValueInitExpr::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:177
clang::Expr::setDependence
void setDependence(ExprDependence Deps)
Each concrete expr subclass is expected to compute its dependence and call this in the constructor.
Definition: Expr.h:135
clang::LCK_ByCopy
@ LCK_ByCopy
Capturing by copy (a.k.a., by value)
Definition: Lambda.h:36
clang::Stmt::OverloadExprBits
OverloadExprBitfields OverloadExprBits
Definition: Stmt.h:1077
clang::LCK_VLAType
@ LCK_VLAType
Capturing variable-length array type.
Definition: Lambda.h:38
clang::CXXConstCastExpr
A C++ const_cast expression (C++ [expr.const.cast]).
Definition: ExprCXX.h:561
clang::UserDefinedLiteral::getLiteralOperatorKind
LiteralOperatorKind getLiteralOperatorKind() const
Returns the kind of literal operator invocation which this expression represents.
Definition: ExprCXX.cpp:920
DeclarationName.h
clang::PointerType
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2774
clang::CXXConstructExpr::getLocation
SourceLocation getLocation() const
Definition: ExprCXX.h:1592
clang::CUDAKernelCallExpr
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:231
clang::LambdaExpr::getLambdaClass
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Definition: ExprCXX.cpp:1322
clang::interp::This
bool This(InterpState &S, CodePtr OpPC)
Definition: Interp.h:1356
clang::CXXTemporaryObjectExpr::Create
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:1067
clang::FunctionDecl::isReservedGlobalPlacementOperator
bool isReservedGlobalPlacementOperator() const
Determines whether this operator new or delete is one of the reserved global placement operators: voi...
Definition: Decl.cpp:3193
clang::SizeOfPackExpr::Create
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, std::optional< unsigned > Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs=std::nullopt)
Definition: ExprCXX.cpp:1624
clang::SourceLocation::isInvalid
bool isInvalid() const
Definition: SourceLocation.h:111
clang::CXXMethodDecl::isConst
bool isConst() const
Definition: DeclCXX.h:2036
clang::Expr::setType
void setType(QualType t)
Definition: Expr.h:143
clang::UnresolvedMemberExpr::getNamingClass
CXXRecordDecl * getNamingClass()
Retrieve the naming class of this lookup.
Definition: ExprCXX.cpp:1597
clang::Expr::IgnoreParens
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
Definition: Expr.cpp:3032
clang
Definition: CalledOnceCheck.h:17
clang::Type::isAnyPointerType
bool isAnyPointerType() const
Definition: Type.h:6898
clang::CXXPseudoDestructorExpr::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:342
clang::CXXDynamicCastExpr::isAlwaysNull
bool isAlwaysNull() const
isAlwaysNull - Return whether the result of the dynamic_cast is proven to always be null.
Definition: ExprCXX.cpp:768
clang::Type::isArrayType
bool isArrayType() const
Definition: Type.h:6960
clang::Expr::isDefaultArgument
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition: Expr.cpp:3131
clang::CXXFunctionalCastExpr::CreateEmpty
static CXXFunctionalCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize, bool HasFPFeatures)
Definition: ExprCXX.cpp:859
clang::CXXDynamicCastExpr::CreateEmpty
static CXXDynamicCastExpr * CreateEmpty(const ASTContext &Context, unsigned pathSize)
Definition: ExprCXX.cpp:754
clang::NestedNameSpecifier::getAsType
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Definition: NestedNameSpecifier.h:196
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:72
clang::CXXUnresolvedConstructExpr::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:1428
clang::CXXTemporaryObjectExpr::getTypeSourceInfo
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:1884
clang::CXXDefaultArgExpr::CreateEmpty
static CXXDefaultArgExpr * CreateEmpty(const ASTContext &C, bool HasRewrittenInit)
Definition: ExprCXX.cpp:953
clang::CXXConstructExpr::sizeOfTrailingObjects
static unsigned sizeOfTrailingObjects(unsigned NumArgs)
Return the size in bytes of the trailing objects.
Definition: ExprCXX.h:1573
clang::Expr::getType
QualType getType() const
Definition: Expr.h:142
clang::SourceLocation::isValid
bool isValid() const
Return true if this is a valid SourceLocation object.
Definition: SourceLocation.h:110
clang::CXXBaseSpecifier
Represents a base class of a C++ class.
Definition: DeclCXX.h:146
clang::CXXDefaultArgExpr::getParam
const ParmVarDecl * getParam() const
Definition: ExprCXX.h:1291
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6604
clang::CXXUuidofExpr::isTypeOperand
bool isTypeOperand() const
Definition: ExprCXX.h:1092
clang::SizeOfPackExpr::CreateDeserialized
static SizeOfPackExpr * CreateDeserialized(ASTContext &Context, unsigned NumPartialArgs)
Definition: ExprCXX.cpp:1636
clang::OverloadExpr::getQualifier
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Definition: ExprCXX.h:3069
clang::getReplacedTemplateParameterList
TemplateParameterList * getReplacedTemplateParameterList(Decl *D)
Internal helper used by Subst* nodes to retrieve the parameter list for their AssociatedDecl.
Definition: DeclTemplate.cpp:1597
clang::CXXDeleteExpr::getArgument
Expr * getArgument()
Definition: ExprCXX.h:2514
clang::LCK_This
@ LCK_This
Capturing the *this object by reference.
Definition: Lambda.h:34
clang::CXXDefaultInitExpr::Create
static CXXDefaultInitExpr * Create(const ASTContext &Ctx, SourceLocation Loc, FieldDecl *Field, DeclContext *UsedContext, Expr *RewrittenInitExpr)
Field is the non-static data member whose default initializer is used by this expression.
Definition: ExprCXX.cpp:1014
clang::CXXRewrittenBinaryOperator::isReversed
bool isReversed() const
Determine whether this expression was rewritten in reverse form.
Definition: ExprCXX.h:319
clang::LambdaExpr::explicit_capture_end
capture_iterator explicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
Definition: ExprCXX.cpp:1301
LambdaCapture.h
clang::SubstNonTypeTemplateParmExpr::getParameter
NonTypeTemplateParmDecl * getParameter() const
Definition: ExprCXX.cpp:1643
clang::CXXNewExpr::Create
static CXXNewExpr * Create(const ASTContext &Ctx, bool IsGlobalNew, FunctionDecl *OperatorNew, FunctionDecl *OperatorDelete, bool ShouldPassAlignment, bool UsualArrayDeleteWantsSize, ArrayRef< Expr * > PlacementArgs, SourceRange TypeIdParens, std::optional< Expr * > ArraySize, InitializationStyle InitializationStyle, Expr *Initializer, QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range, SourceRange DirectInitRange)
Create a c++ new expression.
Definition: ExprCXX.cpp:244
clang::CXXDependentScopeMemberExpr::Create
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:1474
clang::CXXOperatorCallExpr::CreateEmpty
static CXXOperatorCallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty)
Definition: ExprCXX.cpp:574
clang::LifetimeExtendedTemporaryDecl
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
Definition: DeclCXX.h:3141
clang::RecordType::getDecl
RecordDecl * getDecl() const
Definition: Type.h:4831
clang::CXXParenListInitExpr
Represents a list-initialization with parenthesis.
Definition: ExprCXX.h:4794
clang::LambdaExpr::children
child_range children()
Includes the captures and the body of the lambda.
Definition: ExprCXX.cpp:1352
clang::UserDefinedLiteral::LOK_Floating
@ LOK_Floating
operator "" X (long double)
Definition: ExprCXX.h:676
clang::OverloadExpr::getTrailingTemplateArgumentLoc
TemplateArgumentLoc * getTrailingTemplateArgumentLoc()
Return the optional template arguments.
Definition: ExprCXX.h:4053
clang::CXXConstructExpr::getArg
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition: ExprCXX.h:1669
clang::SubstNonTypeTemplateParmPackExpr::getArgumentPack
TemplateArgument getArgumentPack() const
Retrieve the template argument pack containing the substituted template arguments.
Definition: ExprCXX.cpp:1674
clang::ValueDecl::getType
QualType getType() const
Definition: Decl.h:714
clang::CallExpr::UsesADL
static constexpr ADLCallKind UsesADL
Definition: Expr.h:2870
clang::CastKind
CastKind
CastKind - The kind of operation required for a conversion.
Definition: OperationKinds.h:20
clang::TypeTraitExpr::CreateDeserialized
static TypeTraitExpr * CreateDeserialized(const ASTContext &C, unsigned NumArgs)
Definition: ExprCXX.cpp:1782
clang::Type::isIntegerType
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
Definition: Type.h:7223
clang::Expr
This represents one expression.
Definition: Expr.h:110
clang::Stmt::UnresolvedLookupExprBits
UnresolvedLookupExprBitfields UnresolvedLookupExprBits
Definition: Stmt.h:1078
clang::UserDefinedLiteral::getUDSuffix
const IdentifierInfo * getUDSuffix() const
Returns the ud-suffix specified for this literal.
Definition: ExprCXX.cpp:949
clang::CXXConstructExpr::Create
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:1101
clang::CXXDefaultInitExpr
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1354
clang::SubstNonTypeTemplateParmExpr::getAssociatedDecl
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
Definition: ExprCXX.h:4360
clang::CXXDefaultArgExpr::Create
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
Definition: ExprCXX.cpp:960
clang::ASTTemplateKWAndArgsInfo
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:693
clang::DeclarationNameInfo
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Definition: DeclarationName.h:767
clang::CXXDefaultArgExpr::getAdjustedRewrittenExpr
Expr * getAdjustedRewrittenExpr()
Definition: ExprCXX.cpp:976
clang::UnresolvedMemberExpr::Create
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:1566
clang::CXXConstructExpr::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:510
clang::LambdaExpr::Create
static LambdaExpr * Create(const ASTContext &C, CXXRecordDecl *Class, SourceRange IntroducerRange, LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc, bool ExplicitParams, bool ExplicitResultType, ArrayRef< Expr * > CaptureInits, SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack)
Construct a new lambda expression.
Definition: ExprCXX.cpp:1234
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1917
clang::CallExpr
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2812
clang::CXXDefaultArgExpr::getExpr
Expr * getExpr()
Definition: ExprCXX.cpp:971
clang::SubstNonTypeTemplateParmExpr::getParameterType
QualType getParameterType(const ASTContext &Ctx) const
Determine the substituted type of the template parameter.
Definition: ExprCXX.cpp:1648
clang::CXXOperatorCallExpr
A call to an overloaded operator written using operator syntax.
Definition: ExprCXX.h:81
clang::ExprWithCleanups::Create
static ExprWithCleanups * Create(const ASTContext &C, EmptyShell empty, unsigned numObjects)
Definition: ExprCXX.cpp:1387
clang::CXXConstructExpr
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1518
clang::TT_Last
@ TT_Last
Definition: TypeTraits.h:36
clang::CXXMemberCallExpr
Represents a call to a member function that may be written either with member call syntax (e....
Definition: ExprCXX.h:176
clang::LambdaExpr::CreateDeserialized
static LambdaExpr * CreateDeserialized(const ASTContext &C, unsigned NumCaptures)
Construct a new lambda expression that will be deserialized from an external source.
Definition: ExprCXX.cpp:1254
clang::CXXDefaultInitExpr::hasRewrittenInit
bool hasRewrittenInit() const
Definition: ExprCXX.h:1385
TypeLoc.h
clang::TypeSourceInfo::getTypeLoc
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:244
clang::LambdaCapture::LambdaCapture
LambdaCapture(SourceLocation Loc, bool Implicit, LambdaCaptureKind Kind, ValueDecl *Var=nullptr, SourceLocation EllipsisLoc=SourceLocation())
Create a new capture of a variable or of this.
Definition: ExprCXX.cpp:1156
clang::CXXMethodDecl
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1995
clang::CXXRecordDecl::captures_end
capture_const_iterator captures_end() const
Definition: DeclCXX.h:1088
clang::CXXStaticCastExpr::CreateEmpty
static CXXStaticCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize, bool hasFPFeatures)
Definition: ExprCXX.cpp:726
clang::CXXOperatorCallExpr::isInfixBinaryOp
bool isInfixBinaryOp() const
Is this written as an infix binary operator?
Definition: ExprCXX.cpp:49
clang::LambdaExpr::implicit_captures
capture_range implicit_captures() const
Retrieve this lambda's implicit captures.
Definition: ExprCXX.cpp:1318