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