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