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