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