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