clang 23.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/ErrorHandling.h"
36#include <cassert>
37#include <cstddef>
38#include <cstring>
39#include <memory>
40#include <optional>
41
42using namespace clang;
43
44//===----------------------------------------------------------------------===//
45// Child Iterators for iterating over subexpressions/substatements
46//===----------------------------------------------------------------------===//
47
49 // An infix binary operator is any operator with two arguments other than
50 // operator() and operator[]. Note that none of these operators can have
51 // default arguments, so it suffices to check the number of argument
52 // expressions.
53 if (getNumArgs() != 2)
54 return false;
55
56 switch (getOperator()) {
57 case OO_Call: case OO_Subscript:
58 return false;
59 default:
60 return true;
61 }
62}
63
67 const Expr *E = getSemanticForm()->IgnoreImplicit();
68
69 // Remove an outer '!' if it exists (only happens for a '!=' rewrite).
70 bool SkippedNot = false;
71 if (auto *NotEq = dyn_cast<UnaryOperator>(E)) {
72 assert(NotEq->getOpcode() == UO_LNot);
73 E = NotEq->getSubExpr()->IgnoreImplicit();
74 SkippedNot = true;
75 }
76
77 // Decompose the outer binary operator.
78 if (auto *BO = dyn_cast<BinaryOperator>(E)) {
79 assert(!SkippedNot || BO->getOpcode() == BO_EQ);
80 Result.Opcode = SkippedNot ? BO_NE : BO->getOpcode();
81 Result.LHS = BO->getLHS();
82 Result.RHS = BO->getRHS();
83 Result.InnerBinOp = BO;
84 } else if (auto *BO = dyn_cast<CXXOperatorCallExpr>(E)) {
85 assert(!SkippedNot || BO->getOperator() == OO_EqualEqual);
86 assert(BO->isInfixBinaryOp());
87 switch (BO->getOperator()) {
88 case OO_Less: Result.Opcode = BO_LT; break;
89 case OO_LessEqual: Result.Opcode = BO_LE; break;
90 case OO_Greater: Result.Opcode = BO_GT; break;
91 case OO_GreaterEqual: Result.Opcode = BO_GE; break;
92 case OO_Spaceship: Result.Opcode = BO_Cmp; break;
93 case OO_EqualEqual: Result.Opcode = SkippedNot ? BO_NE : BO_EQ; break;
94 default: llvm_unreachable("unexpected binop in rewritten operator expr");
95 }
96 Result.LHS = BO->getArg(0);
97 Result.RHS = BO->getArg(1);
98 Result.InnerBinOp = BO;
99 } else {
100 llvm_unreachable("unexpected rewritten operator form");
101 }
102
103 // Put the operands in the right order for == and !=, and canonicalize the
104 // <=> subexpression onto the LHS for all other forms.
105 if (isReversed())
106 std::swap(Result.LHS, Result.RHS);
107
108 // If this isn't a spaceship rewrite, we're done.
109 if (Result.Opcode == BO_EQ || Result.Opcode == BO_NE)
110 return Result;
111
112 // Otherwise, we expect a <=> to now be on the LHS.
113 E = Result.LHS->IgnoreUnlessSpelledInSource();
114 if (auto *BO = dyn_cast<BinaryOperator>(E)) {
115 assert(BO->getOpcode() == BO_Cmp);
116 Result.LHS = BO->getLHS();
117 Result.RHS = BO->getRHS();
118 Result.InnerBinOp = BO;
119 } else if (auto *BO = dyn_cast<CXXOperatorCallExpr>(E)) {
120 assert(BO->getOperator() == OO_Spaceship);
121 Result.LHS = BO->getArg(0);
122 Result.RHS = BO->getArg(1);
123 Result.InnerBinOp = BO;
124 } else {
125 llvm_unreachable("unexpected rewritten operator form");
126 }
127
128 // Put the comparison operands in the right order.
129 if (isReversed())
130 std::swap(Result.LHS, Result.RHS);
131 return Result;
132}
133
135 if (isTypeOperand())
136 return false;
137
138 // C++11 [expr.typeid]p3:
139 // When typeid is applied to an expression other than a glvalue of
140 // polymorphic class type, [...] the expression is an unevaluated operand.
141 const Expr *E = getExprOperand();
142 if (const CXXRecordDecl *RD = E->getType()->getAsCXXRecordDecl())
143 if (RD->isPolymorphic() && E->isGLValue())
144 return true;
145
146 return false;
147}
148
149bool CXXTypeidExpr::isMostDerived(const ASTContext &Context) const {
150 assert(!isTypeOperand() && "Cannot call isMostDerived for typeid(type)");
151 const Expr *E = getExprOperand()->IgnoreParenNoopCasts(Context);
152 if (const auto *DRE = dyn_cast<DeclRefExpr>(E)) {
153 QualType Ty = DRE->getDecl()->getType();
154 if (!Ty->isPointerOrReferenceType())
155 return true;
156 }
157
158 return false;
159}
160
162 assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
163 Qualifiers Quals;
164 return Context.getUnqualifiedArrayType(
165 cast<TypeSourceInfo *>(Operand)->getType().getNonReferenceType(), Quals);
166}
167
168static bool isGLValueFromPointerDeref(const Expr *E) {
169 E = E->IgnoreParens();
170
171 if (const auto *CE = dyn_cast<CastExpr>(E)) {
172 if (!CE->getSubExpr()->isGLValue())
173 return false;
174 return isGLValueFromPointerDeref(CE->getSubExpr());
175 }
176
177 if (const auto *OVE = dyn_cast<OpaqueValueExpr>(E))
178 return isGLValueFromPointerDeref(OVE->getSourceExpr());
179
180 if (const auto *BO = dyn_cast<BinaryOperator>(E))
181 if (BO->getOpcode() == BO_Comma)
182 return isGLValueFromPointerDeref(BO->getRHS());
183
184 if (const auto *ACO = dyn_cast<AbstractConditionalOperator>(E))
185 return isGLValueFromPointerDeref(ACO->getTrueExpr()) ||
186 isGLValueFromPointerDeref(ACO->getFalseExpr());
187
188 // C++11 [expr.sub]p1:
189 // The expression E1[E2] is identical (by definition) to *((E1)+(E2))
191 return true;
192
193 if (const auto *UO = dyn_cast<UnaryOperator>(E))
194 if (UO->getOpcode() == UO_Deref)
195 return true;
196
197 return false;
198}
199
202 return false;
203
204 // C++ [expr.typeid]p2:
205 // If the glvalue expression is obtained by applying the unary * operator to
206 // a pointer and the pointer is a null pointer value, the typeid expression
207 // throws the std::bad_typeid exception.
208 //
209 // However, this paragraph's intent is not clear. We choose a very generous
210 // interpretation which implores us to consider comma operators, conditional
211 // operators, parentheses and other such constructs.
213}
214
216 assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
217 Qualifiers Quals;
218 return Context.getUnqualifiedArrayType(
219 cast<TypeSourceInfo *>(Operand)->getType().getNonReferenceType(), Quals);
220}
221
222// CXXScalarValueInitExpr
224 return TypeInfo ? TypeInfo->getTypeLoc().getBeginLoc() : getRParenLoc();
225}
226
227// CXXNewExpr
228CXXNewExpr::CXXNewExpr(bool IsGlobalNew, FunctionDecl *OperatorNew,
229 FunctionDecl *OperatorDelete,
231 bool UsualArrayDeleteWantsSize,
232 ArrayRef<Expr *> PlacementArgs, SourceRange TypeIdParens,
233 std::optional<Expr *> ArraySize,
234 CXXNewInitializationStyle InitializationStyle,
236 TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
237 SourceRange DirectInitRange)
238 : Expr(CXXNewExprClass, Ty, VK_PRValue, OK_Ordinary),
239 OperatorNew(OperatorNew), OperatorDelete(OperatorDelete),
240 AllocatedTypeInfo(AllocatedTypeInfo), Range(Range),
241 DirectInitRange(DirectInitRange) {
242
243 assert((Initializer != nullptr ||
244 InitializationStyle == CXXNewInitializationStyle::None) &&
245 "Only CXXNewInitializationStyle::None can have no initializer!");
246
247 CXXNewExprBits.IsGlobalNew = IsGlobalNew;
248 CXXNewExprBits.IsArray = ArraySize.has_value();
249 CXXNewExprBits.ShouldPassAlignment = isAlignedAllocation(IAP.PassAlignment);
250 CXXNewExprBits.ShouldPassTypeIdentity =
252 CXXNewExprBits.UsualArrayDeleteWantsSize = UsualArrayDeleteWantsSize;
253 CXXNewExprBits.HasInitializer = Initializer != nullptr;
254 CXXNewExprBits.StoredInitializationStyle =
255 llvm::to_underlying(InitializationStyle);
256 bool IsParenTypeId = TypeIdParens.isValid();
257 CXXNewExprBits.IsParenTypeId = IsParenTypeId;
258 CXXNewExprBits.NumPlacementArgs = PlacementArgs.size();
259
260 if (ArraySize)
261 getTrailingObjects<Stmt *>()[arraySizeOffset()] = *ArraySize;
262 if (Initializer)
263 getTrailingObjects<Stmt *>()[initExprOffset()] = Initializer;
264 llvm::copy(PlacementArgs,
265 getTrailingObjects<Stmt *>() + placementNewArgsOffset());
266 if (IsParenTypeId)
267 getTrailingObjects<SourceRange>()[0] = TypeIdParens;
268
269 switch (getInitializationStyle()) {
271 this->Range.setEnd(DirectInitRange.getEnd());
272 break;
274 this->Range.setEnd(getInitializer()->getSourceRange().getEnd());
275 break;
276 default:
277 if (IsParenTypeId)
278 this->Range.setEnd(TypeIdParens.getEnd());
279 break;
280 }
281
283}
284
285CXXNewExpr::CXXNewExpr(EmptyShell Empty, bool IsArray,
286 unsigned NumPlacementArgs, bool IsParenTypeId)
287 : Expr(CXXNewExprClass, Empty) {
288 CXXNewExprBits.IsArray = IsArray;
289 CXXNewExprBits.NumPlacementArgs = NumPlacementArgs;
290 CXXNewExprBits.IsParenTypeId = IsParenTypeId;
291}
292
294 const ASTContext &Ctx, bool IsGlobalNew, FunctionDecl *OperatorNew,
295 FunctionDecl *OperatorDelete, const ImplicitAllocationParameters &IAP,
296 bool UsualArrayDeleteWantsSize, ArrayRef<Expr *> PlacementArgs,
297 SourceRange TypeIdParens, std::optional<Expr *> ArraySize,
298 CXXNewInitializationStyle InitializationStyle, Expr *Initializer,
299 QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
300 SourceRange DirectInitRange) {
301 bool IsArray = ArraySize.has_value();
302 bool HasInit = Initializer != nullptr;
303 unsigned NumPlacementArgs = PlacementArgs.size();
304 bool IsParenTypeId = TypeIdParens.isValid();
305 void *Mem =
306 Ctx.Allocate(totalSizeToAlloc<Stmt *, SourceRange>(
307 IsArray + HasInit + NumPlacementArgs, IsParenTypeId),
308 alignof(CXXNewExpr));
309 return new (Mem) CXXNewExpr(
310 IsGlobalNew, OperatorNew, OperatorDelete, IAP, UsualArrayDeleteWantsSize,
311 PlacementArgs, TypeIdParens, ArraySize, InitializationStyle, Initializer,
312 Ty, AllocatedTypeInfo, Range, DirectInitRange);
313}
314
315CXXNewExpr *CXXNewExpr::CreateEmpty(const ASTContext &Ctx, bool IsArray,
316 bool HasInit, unsigned NumPlacementArgs,
317 bool IsParenTypeId) {
318 void *Mem =
319 Ctx.Allocate(totalSizeToAlloc<Stmt *, SourceRange>(
320 IsArray + HasInit + NumPlacementArgs, IsParenTypeId),
321 alignof(CXXNewExpr));
322 return new (Mem)
323 CXXNewExpr(EmptyShell(), IsArray, NumPlacementArgs, IsParenTypeId);
324}
325
327 if (getOperatorNew()->getLangOpts().CheckNew)
328 return true;
329 return !getOperatorNew()->hasAttr<ReturnsNonNullAttr>() &&
331 ->getType()
333 ->isNothrow() &&
335}
336
337// CXXDeleteExpr
339 const Expr *Arg = getArgument();
340
341 // For a destroying operator delete, we may have implicitly converted the
342 // pointer type to the type of the parameter of the 'operator delete'
343 // function.
344 while (const auto *ICE = dyn_cast<ImplicitCastExpr>(Arg)) {
345 if (ICE->getCastKind() == CK_DerivedToBase ||
346 ICE->getCastKind() == CK_UncheckedDerivedToBase ||
347 ICE->getCastKind() == CK_NoOp) {
348 assert((ICE->getCastKind() == CK_NoOp ||
349 getOperatorDelete()->isDestroyingOperatorDelete()) &&
350 "only a destroying operator delete can have a converted arg");
351 Arg = ICE->getSubExpr();
352 } else
353 break;
354 }
355
356 // The type-to-delete may not be a pointer if it's a dependent type.
357 const QualType ArgType = Arg->getType();
358
359 if (ArgType->isDependentType() && !ArgType->isPointerType())
360 return QualType();
361
362 return ArgType->castAs<PointerType>()->getPointeeType();
363}
364
365// CXXPseudoDestructorExpr
367 : Type(Info) {
368 Location = Info->getTypeLoc().getBeginLoc();
369}
370
372 const ASTContext &Context, Expr *Base, bool isArrow,
373 SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc,
374 TypeSourceInfo *ScopeType, SourceLocation ColonColonLoc,
375 SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType)
376 : Expr(CXXPseudoDestructorExprClass, Context.BoundMemberTy, VK_PRValue,
378 Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
379 OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc),
380 ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc),
381 DestroyedType(DestroyedType) {
383}
384
386 if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo())
387 return TInfo->getType();
388
389 return QualType();
390}
391
393 SourceLocation End = DestroyedType.getLocation();
394 if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo())
395 End = TInfo->getTypeLoc().getSourceRange().getEnd();
396 return End;
397}
398
401 if (std::distance(Begin, End) != 1)
402 return false;
403 NamedDecl *ND = *Begin;
404 if (const auto *TTP = llvm::dyn_cast<TemplateTemplateParmDecl>(ND))
405 return TTP->isParameterPack();
406 return false;
407}
408
409// UnresolvedLookupExpr
410UnresolvedLookupExpr::UnresolvedLookupExpr(
411 const ASTContext &Context, CXXRecordDecl *NamingClass,
412 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
413 const DeclarationNameInfo &NameInfo, bool RequiresADL,
414 const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin,
415 UnresolvedSetIterator End, bool KnownDependent,
416 bool KnownInstantiationDependent)
417 : OverloadExpr(
418 UnresolvedLookupExprClass, Context, QualifierLoc, TemplateKWLoc,
419 NameInfo, TemplateArgs, Begin, End, KnownDependent,
420 KnownInstantiationDependent,
422 NamingClass(NamingClass) {
423 UnresolvedLookupExprBits.RequiresADL = RequiresADL;
424}
425
426UnresolvedLookupExpr::UnresolvedLookupExpr(EmptyShell Empty,
427 unsigned NumResults,
428 bool HasTemplateKWAndArgsInfo)
429 : OverloadExpr(UnresolvedLookupExprClass, Empty, NumResults,
430 HasTemplateKWAndArgsInfo) {}
431
432UnresolvedLookupExpr *UnresolvedLookupExpr::Create(
433 const ASTContext &Context, CXXRecordDecl *NamingClass,
434 NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
435 bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End,
436 bool KnownDependent, bool KnownInstantiationDependent) {
437 unsigned NumResults = End - Begin;
438 unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
439 TemplateArgumentLoc>(NumResults, 0, 0);
440 void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
441 return new (Mem) UnresolvedLookupExpr(
442 Context, NamingClass, QualifierLoc,
443 /*TemplateKWLoc=*/SourceLocation(), NameInfo, RequiresADL,
444 /*TemplateArgs=*/nullptr, Begin, End, KnownDependent,
445 KnownInstantiationDependent);
446}
447
448UnresolvedLookupExpr *UnresolvedLookupExpr::Create(
449 const ASTContext &Context, CXXRecordDecl *NamingClass,
450 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
451 const DeclarationNameInfo &NameInfo, bool RequiresADL,
453 UnresolvedSetIterator End, bool KnownDependent,
454 bool KnownInstantiationDependent) {
455 unsigned NumResults = End - Begin;
456 bool HasTemplateKWAndArgsInfo = Args || TemplateKWLoc.isValid();
457 unsigned NumTemplateArgs = Args ? Args->size() : 0;
458 unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
460 NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
461 void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
462 return new (Mem) UnresolvedLookupExpr(
463 Context, NamingClass, QualifierLoc, TemplateKWLoc, NameInfo, RequiresADL,
464 Args, Begin, End, KnownDependent, KnownInstantiationDependent);
465}
466
468 const ASTContext &Context, unsigned NumResults,
469 bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs) {
470 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
471 unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
473 NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
474 void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
475 return new (Mem)
476 UnresolvedLookupExpr(EmptyShell(), NumResults, HasTemplateKWAndArgsInfo);
477}
478
480 NestedNameSpecifierLoc QualifierLoc,
481 SourceLocation TemplateKWLoc,
482 const DeclarationNameInfo &NameInfo,
483 const TemplateArgumentListInfo *TemplateArgs,
485 UnresolvedSetIterator End, bool KnownDependent,
486 bool KnownInstantiationDependent,
487 bool KnownContainsUnexpandedParameterPack)
488 : Expr(SC, Context.OverloadTy, VK_LValue, OK_Ordinary), NameInfo(NameInfo),
489 QualifierLoc(QualifierLoc) {
490 unsigned NumResults = End - Begin;
491 OverloadExprBits.NumResults = NumResults;
492 OverloadExprBits.HasTemplateKWAndArgsInfo =
493 (TemplateArgs != nullptr ) || TemplateKWLoc.isValid();
494
495 if (NumResults) {
496 // Copy the results to the trailing array past UnresolvedLookupExpr
497 // or UnresolvedMemberExpr.
499 memcpy(Results, Begin.I, NumResults * sizeof(DeclAccessPair));
500 }
501
502 if (TemplateArgs) {
503 auto Deps = TemplateArgumentDependence::None;
505 TemplateKWLoc, *TemplateArgs, getTrailingTemplateArgumentLoc(), Deps);
506 } else if (TemplateKWLoc.isValid()) {
507 getTrailingASTTemplateKWAndArgsInfo()->initializeFrom(TemplateKWLoc);
508 }
509
510 setDependence(computeDependence(this, KnownDependent,
511 KnownInstantiationDependent,
512 KnownContainsUnexpandedParameterPack));
513 if (isTypeDependent())
514 setType(Context.DependentTy);
515}
516
518 bool HasTemplateKWAndArgsInfo)
519 : Expr(SC, Empty) {
520 OverloadExprBits.NumResults = NumResults;
521 OverloadExprBits.HasTemplateKWAndArgsInfo = HasTemplateKWAndArgsInfo;
522}
523
524// DependentScopeDeclRefExpr
525DependentScopeDeclRefExpr::DependentScopeDeclRefExpr(
526 QualType Ty, NestedNameSpecifierLoc QualifierLoc,
527 SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo,
528 const TemplateArgumentListInfo *Args)
529 : Expr(DependentScopeDeclRefExprClass, Ty, VK_LValue, OK_Ordinary),
530 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {
531 DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo =
532 (Args != nullptr) || TemplateKWLoc.isValid();
533 if (Args) {
534 auto Deps = TemplateArgumentDependence::None;
535 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
536 TemplateKWLoc, *Args, getTrailingObjects<TemplateArgumentLoc>(), Deps);
537 } else if (TemplateKWLoc.isValid()) {
538 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
539 TemplateKWLoc);
540 }
542}
543
544DependentScopeDeclRefExpr *DependentScopeDeclRefExpr::Create(
545 const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc,
546 SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo,
547 const TemplateArgumentListInfo *Args) {
548 assert(QualifierLoc && "should be created for dependent qualifiers");
549 bool HasTemplateKWAndArgsInfo = Args || TemplateKWLoc.isValid();
550 std::size_t Size =
551 totalSizeToAlloc<ASTTemplateKWAndArgsInfo, TemplateArgumentLoc>(
552 HasTemplateKWAndArgsInfo, Args ? Args->size() : 0);
553 void *Mem = Context.Allocate(Size);
554 return new (Mem) DependentScopeDeclRefExpr(Context.DependentTy, QualifierLoc,
555 TemplateKWLoc, NameInfo, Args);
556}
557
560 bool HasTemplateKWAndArgsInfo,
561 unsigned NumTemplateArgs) {
562 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
563 std::size_t Size =
564 totalSizeToAlloc<ASTTemplateKWAndArgsInfo, TemplateArgumentLoc>(
565 HasTemplateKWAndArgsInfo, NumTemplateArgs);
566 void *Mem = Context.Allocate(Size);
567 auto *E = new (Mem) DependentScopeDeclRefExpr(
569 DeclarationNameInfo(), nullptr);
570 E->DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo =
571 HasTemplateKWAndArgsInfo;
572 return E;
573}
574
576 if (const auto *TOE = dyn_cast<CXXTemporaryObjectExpr>(this))
577 return TOE->getBeginLoc();
578 return getLocation();
579}
580
582 if (const auto *TOE = dyn_cast<CXXTemporaryObjectExpr>(this))
583 return TOE->getEndLoc();
584
585 if (ParenOrBraceRange.isValid())
586 return ParenOrBraceRange.getEnd();
587
589 for (unsigned I = getNumArgs(); I > 0; --I) {
590 const Expr *Arg = getArg(I-1);
591 if (!Arg->isDefaultArgument()) {
592 SourceLocation NewEnd = Arg->getEndLoc();
593 if (NewEnd.isValid()) {
594 End = NewEnd;
595 break;
596 }
597 }
598 }
599
600 return End;
601}
602
603CXXOperatorCallExpr::CXXOperatorCallExpr(OverloadedOperatorKind OpKind,
604 Expr *Fn, ArrayRef<Expr *> Args,
606 SourceLocation OperatorLoc,
607 FPOptionsOverride FPFeatures,
608 ADLCallKind UsesADL, bool IsReversed)
609 : CallExpr(CXXOperatorCallExprClass, Fn, /*PreArgs=*/{}, Args, Ty, VK,
610 OperatorLoc, FPFeatures, /*MinNumArgs=*/0, UsesADL) {
611 CXXOperatorCallExprBits.OperatorKind = OpKind;
612 CXXOperatorCallExprBits.IsReversed = IsReversed;
613 assert(
614 (CXXOperatorCallExprBits.OperatorKind == static_cast<unsigned>(OpKind)) &&
615 "OperatorKind overflow!");
616 BeginLoc = getSourceRangeImpl().getBegin();
617}
618
619CXXOperatorCallExpr::CXXOperatorCallExpr(unsigned NumArgs, bool HasFPFeatures,
620 EmptyShell Empty)
621 : CallExpr(CXXOperatorCallExprClass, /*NumPreArgs=*/0, NumArgs,
622 HasFPFeatures, Empty) {}
623
624CXXOperatorCallExpr *CXXOperatorCallExpr::Create(
625 const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn,
627 SourceLocation OperatorLoc, FPOptionsOverride FPFeatures,
628 ADLCallKind UsesADL, bool IsReversed) {
629 // Allocate storage for the trailing objects of CallExpr.
630 unsigned NumArgs = Args.size();
631 unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
632 /*NumPreArgs=*/0, NumArgs, FPFeatures.requiresTrailingStorage());
633 void *Mem =
635 SizeOfTrailingObjects),
636 alignof(CXXOperatorCallExpr));
637 return new (Mem) CXXOperatorCallExpr(OpKind, Fn, Args, Ty, VK, OperatorLoc,
638 FPFeatures, UsesADL, IsReversed);
639}
640
641CXXOperatorCallExpr *CXXOperatorCallExpr::CreateEmpty(const ASTContext &Ctx,
642 unsigned NumArgs,
643 bool HasFPFeatures,
645 // Allocate storage for the trailing objects of CallExpr.
646 unsigned SizeOfTrailingObjects =
647 CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs, HasFPFeatures);
648 void *Mem =
650 SizeOfTrailingObjects),
651 alignof(CXXOperatorCallExpr));
652 return new (Mem) CXXOperatorCallExpr(NumArgs, HasFPFeatures, Empty);
653}
654
655SourceRange CXXOperatorCallExpr::getSourceRangeImpl() const {
657 if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
658 if (getNumArgs() == 1)
659 // Prefix operator
661 else
662 // Postfix operator
664 } else if (Kind == OO_Arrow) {
666 } else if (Kind == OO_Call) {
667 return SourceRange(getArg(0)->getBeginLoc(), getRParenLoc());
668 } else if (Kind == OO_Subscript) {
669 return SourceRange(getArg(0)->getBeginLoc(), getRParenLoc());
670 } else if (getNumArgs() == 1) {
671 return SourceRange(getOperatorLoc(), getArg(0)->getEndLoc());
672 } else if (getNumArgs() == 2) {
673 if (CXXOperatorCallExprBits.IsReversed)
674 return SourceRange(getArg(1)->getBeginLoc(), getArg(0)->getEndLoc());
675 return SourceRange(getArg(0)->getBeginLoc(), getArg(1)->getEndLoc());
676 } else {
677 return getOperatorLoc();
678 }
679}
680
681CXXMemberCallExpr::CXXMemberCallExpr(Expr *Fn, ArrayRef<Expr *> Args,
682 QualType Ty, ExprValueKind VK,
685 unsigned MinNumArgs)
686 : CallExpr(CXXMemberCallExprClass, Fn, /*PreArgs=*/{}, Args, Ty, VK, RP,
687 FPOptions, MinNumArgs, NotADL) {}
688
689CXXMemberCallExpr::CXXMemberCallExpr(unsigned NumArgs, bool HasFPFeatures,
690 EmptyShell Empty)
691 : CallExpr(CXXMemberCallExprClass, /*NumPreArgs=*/0, NumArgs, HasFPFeatures,
692 Empty) {}
693
694CXXMemberCallExpr *CXXMemberCallExpr::Create(const ASTContext &Ctx, Expr *Fn,
695 ArrayRef<Expr *> Args, QualType Ty,
698 FPOptionsOverride FPFeatures,
699 unsigned MinNumArgs) {
700 // Allocate storage for the trailing objects of CallExpr.
701 unsigned NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
702 unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
703 /*NumPreArgs=*/0, NumArgs, FPFeatures.requiresTrailingStorage());
705 SizeOfTrailingObjects),
706 alignof(CXXMemberCallExpr));
707 return new (Mem)
708 CXXMemberCallExpr(Fn, Args, Ty, VK, RP, FPFeatures, MinNumArgs);
709}
710
711CXXMemberCallExpr *CXXMemberCallExpr::CreateEmpty(const ASTContext &Ctx,
712 unsigned NumArgs,
713 bool HasFPFeatures,
715 // Allocate storage for the trailing objects of CallExpr.
716 unsigned SizeOfTrailingObjects =
717 CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs, HasFPFeatures);
719 SizeOfTrailingObjects),
720 alignof(CXXMemberCallExpr));
721 return new (Mem) CXXMemberCallExpr(NumArgs, HasFPFeatures, Empty);
722}
723
725 const Expr *Callee = getCallee()->IgnoreParens();
726 if (const auto *MemExpr = dyn_cast<MemberExpr>(Callee))
727 return MemExpr->getBase();
728 if (const auto *BO = dyn_cast<BinaryOperator>(Callee))
729 if (BO->getOpcode() == BO_PtrMemD || BO->getOpcode() == BO_PtrMemI)
730 return BO->getLHS();
731
732 // FIXME: Will eventually need to cope with member pointers.
733 return nullptr;
734}
735
738 if (Ty->isPointerType())
739 Ty = Ty->getPointeeType();
740 return Ty;
741}
742
744 if (const auto *MemExpr = dyn_cast<MemberExpr>(getCallee()->IgnoreParens()))
745 return cast<CXXMethodDecl>(MemExpr->getMemberDecl());
746
747 // FIXME: Will eventually need to cope with member pointers.
748 // NOTE: Update makeTailCallIfSwiftAsync on fixing this.
749 return nullptr;
750}
751
753 Expr* ThisArg = getImplicitObjectArgument();
754 if (!ThisArg)
755 return nullptr;
756
757 if (ThisArg->getType()->isAnyPointerType())
758 return ThisArg->getType()->getPointeeType()->getAsCXXRecordDecl();
759
760 return ThisArg->getType()->getAsCXXRecordDecl();
761}
762
763//===----------------------------------------------------------------------===//
764// Named casts
765//===----------------------------------------------------------------------===//
766
767/// getCastName - Get the name of the C++ cast being used, e.g.,
768/// "static_cast", "dynamic_cast", "reinterpret_cast", or
769/// "const_cast". The returned pointer must not be freed.
770const char *CXXNamedCastExpr::getCastName() const {
771 switch (getStmtClass()) {
772 case CXXStaticCastExprClass: return "static_cast";
773 case CXXDynamicCastExprClass: return "dynamic_cast";
774 case CXXReinterpretCastExprClass: return "reinterpret_cast";
775 case CXXConstCastExprClass: return "const_cast";
776 case CXXAddrspaceCastExprClass: return "addrspace_cast";
777 default: return "<invalid cast>";
778 }
779}
780
783 CastKind K, Expr *Op, const CXXCastPath *BasePath,
784 TypeSourceInfo *WrittenTy, FPOptionsOverride FPO,
785 SourceLocation L, SourceLocation RParenLoc,
786 SourceRange AngleBrackets) {
787 unsigned PathSize = (BasePath ? BasePath->size() : 0);
788 void *Buffer =
789 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
790 PathSize, FPO.requiresTrailingStorage()));
791 auto *E = new (Buffer) CXXStaticCastExpr(T, VK, K, Op, PathSize, WrittenTy,
792 FPO, L, RParenLoc, AngleBrackets);
793 if (PathSize)
794 llvm::uninitialized_copy(*BasePath,
795 E->getTrailingObjects<CXXBaseSpecifier *>());
796 return E;
797}
798
800 unsigned PathSize,
801 bool HasFPFeatures) {
802 void *Buffer =
803 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
804 PathSize, HasFPFeatures));
805 return new (Buffer) CXXStaticCastExpr(EmptyShell(), PathSize, HasFPFeatures);
806}
807
808CXXDynamicCastExpr *CXXDynamicCastExpr::Create(const ASTContext &C, QualType T,
810 CastKind K, Expr *Op,
811 const CXXCastPath *BasePath,
812 TypeSourceInfo *WrittenTy,
814 SourceLocation RParenLoc,
815 SourceRange AngleBrackets) {
816 unsigned PathSize = (BasePath ? BasePath->size() : 0);
817 void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
818 auto *E =
819 new (Buffer) CXXDynamicCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
820 RParenLoc, AngleBrackets);
821 if (PathSize)
822 llvm::uninitialized_copy(*BasePath, E->getTrailingObjects());
823 return E;
824}
825
827 unsigned PathSize) {
828 void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
829 return new (Buffer) CXXDynamicCastExpr(EmptyShell(), PathSize);
830}
831
832/// isAlwaysNull - Return whether the result of the dynamic_cast is proven
833/// to always be null. For example:
834///
835/// struct A { };
836/// struct B final : A { };
837/// struct C { };
838///
839/// C *f(B* b) { return dynamic_cast<C*>(b); }
841 if (isValueDependent() || getCastKind() != CK_Dynamic)
842 return false;
843
844 QualType SrcType = getSubExpr()->getType();
845 QualType DestType = getType();
846
847 if (DestType->isVoidPointerType())
848 return false;
849
850 if (DestType->isPointerType()) {
851 SrcType = SrcType->getPointeeType();
852 DestType = DestType->getPointeeType();
853 }
854
855 const auto *SrcRD = SrcType->getAsCXXRecordDecl();
856 const auto *DestRD = DestType->getAsCXXRecordDecl();
857 assert(SrcRD && DestRD);
858
859 if (SrcRD->isEffectivelyFinal()) {
860 assert(!SrcRD->isDerivedFrom(DestRD) &&
861 "upcasts should not use CK_Dynamic");
862 return true;
863 }
864
865 if (DestRD->isEffectivelyFinal() && !DestRD->isDerivedFrom(SrcRD))
866 return true;
867
868 return false;
869}
870
874 const CXXCastPath *BasePath,
875 TypeSourceInfo *WrittenTy, SourceLocation L,
876 SourceLocation RParenLoc,
877 SourceRange AngleBrackets) {
878 unsigned PathSize = (BasePath ? BasePath->size() : 0);
879 void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
880 auto *E =
881 new (Buffer) CXXReinterpretCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
882 RParenLoc, AngleBrackets);
883 if (PathSize)
884 llvm::uninitialized_copy(*BasePath, E->getTrailingObjects());
885 return E;
886}
887
890 void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
891 return new (Buffer) CXXReinterpretCastExpr(EmptyShell(), PathSize);
892}
893
894CXXConstCastExpr *CXXConstCastExpr::Create(const ASTContext &C, QualType T,
895 ExprValueKind VK, Expr *Op,
896 TypeSourceInfo *WrittenTy,
898 SourceLocation RParenLoc,
899 SourceRange AngleBrackets) {
900 return new (C) CXXConstCastExpr(T, VK, Op, WrittenTy, L, RParenLoc, AngleBrackets);
901}
902
903CXXConstCastExpr *CXXConstCastExpr::CreateEmpty(const ASTContext &C) {
904 return new (C) CXXConstCastExpr(EmptyShell());
905}
906
909 CastKind K, Expr *Op, TypeSourceInfo *WrittenTy,
910 SourceLocation L, SourceLocation RParenLoc,
911 SourceRange AngleBrackets) {
912 return new (C) CXXAddrspaceCastExpr(T, VK, K, Op, WrittenTy, L, RParenLoc,
913 AngleBrackets);
914}
915
916CXXAddrspaceCastExpr *CXXAddrspaceCastExpr::CreateEmpty(const ASTContext &C) {
917 return new (C) CXXAddrspaceCastExpr(EmptyShell());
918}
919
920CXXFunctionalCastExpr *CXXFunctionalCastExpr::Create(
921 const ASTContext &C, QualType T, ExprValueKind VK, TypeSourceInfo *Written,
922 CastKind K, Expr *Op, const CXXCastPath *BasePath, FPOptionsOverride FPO,
924 unsigned PathSize = (BasePath ? BasePath->size() : 0);
925 void *Buffer =
926 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
927 PathSize, FPO.requiresTrailingStorage()));
928 auto *E = new (Buffer)
929 CXXFunctionalCastExpr(T, VK, Written, K, Op, PathSize, FPO, L, R);
930 if (PathSize)
931 llvm::uninitialized_copy(*BasePath,
932 E->getTrailingObjects<CXXBaseSpecifier *>());
933 return E;
934}
935
936CXXFunctionalCastExpr *CXXFunctionalCastExpr::CreateEmpty(const ASTContext &C,
937 unsigned PathSize,
938 bool HasFPFeatures) {
939 void *Buffer =
940 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
941 PathSize, HasFPFeatures));
942 return new (Buffer)
943 CXXFunctionalCastExpr(EmptyShell(), PathSize, HasFPFeatures);
944}
945
949
951 return RParenLoc.isValid() ? RParenLoc : getSubExpr()->getEndLoc();
952}
953
954UserDefinedLiteral::UserDefinedLiteral(Expr *Fn, ArrayRef<Expr *> Args,
956 SourceLocation LitEndLoc,
957 SourceLocation SuffixLoc,
958 FPOptionsOverride FPFeatures)
959 : CallExpr(UserDefinedLiteralClass, Fn, /*PreArgs=*/{}, Args, Ty, VK,
960 LitEndLoc, FPFeatures, /*MinNumArgs=*/0, NotADL),
961 UDSuffixLoc(SuffixLoc) {}
962
963UserDefinedLiteral::UserDefinedLiteral(unsigned NumArgs, bool HasFPFeatures,
964 EmptyShell Empty)
965 : CallExpr(UserDefinedLiteralClass, /*NumPreArgs=*/0, NumArgs,
966 HasFPFeatures, Empty) {}
967
968UserDefinedLiteral *UserDefinedLiteral::Create(const ASTContext &Ctx, Expr *Fn,
969 ArrayRef<Expr *> Args,
971 SourceLocation LitEndLoc,
972 SourceLocation SuffixLoc,
973 FPOptionsOverride FPFeatures) {
974 // Allocate storage for the trailing objects of CallExpr.
975 unsigned NumArgs = Args.size();
976 unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
977 /*NumPreArgs=*/0, NumArgs, FPFeatures.requiresTrailingStorage());
978 void *Mem =
980 SizeOfTrailingObjects),
981 alignof(UserDefinedLiteral));
982 return new (Mem)
983 UserDefinedLiteral(Fn, Args, Ty, VK, LitEndLoc, SuffixLoc, FPFeatures);
984}
985
986UserDefinedLiteral *UserDefinedLiteral::CreateEmpty(const ASTContext &Ctx,
987 unsigned NumArgs,
988 bool HasFPOptions,
990 // Allocate storage for the trailing objects of CallExpr.
991 unsigned SizeOfTrailingObjects =
992 CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs, HasFPOptions);
993 void *Mem =
995 SizeOfTrailingObjects),
996 alignof(UserDefinedLiteral));
997 return new (Mem) UserDefinedLiteral(NumArgs, HasFPOptions, Empty);
998}
999
1002 if (getNumArgs() == 0)
1003 return LOK_Template;
1004 if (getNumArgs() == 2)
1005 return LOK_String;
1006
1007 assert(getNumArgs() == 1 && "unexpected #args in literal operator call");
1008 QualType ParamTy =
1009 cast<FunctionDecl>(getCalleeDecl())->getParamDecl(0)->getType();
1010 if (ParamTy->isPointerType())
1011 return LOK_Raw;
1012 if (ParamTy->isAnyCharacterType())
1013 return LOK_Character;
1014 if (ParamTy->isIntegerType())
1015 return LOK_Integer;
1016 if (ParamTy->isFloatingType())
1017 return LOK_Floating;
1018
1019 llvm_unreachable("unknown kind of literal operator");
1020}
1021
1023#ifndef NDEBUG
1025 assert(LOK != LOK_Template && LOK != LOK_Raw && "not a cooked literal");
1026#endif
1027 return getArg(0);
1028}
1029
1031 return cast<FunctionDecl>(getCalleeDecl())->getLiteralIdentifier();
1032}
1033
1035 bool HasRewrittenInit) {
1036 size_t Size = totalSizeToAlloc<Expr *>(HasRewrittenInit);
1037 auto *Mem = C.Allocate(Size, alignof(CXXDefaultArgExpr));
1038 return new (Mem) CXXDefaultArgExpr(EmptyShell(), HasRewrittenInit);
1039}
1040
1041CXXDefaultArgExpr *CXXDefaultArgExpr::Create(const ASTContext &C,
1042 SourceLocation Loc,
1043 ParmVarDecl *Param,
1044 Expr *RewrittenExpr,
1045 DeclContext *UsedContext) {
1046 size_t Size = totalSizeToAlloc<Expr *>(RewrittenExpr != nullptr);
1047 auto *Mem = C.Allocate(Size, alignof(CXXDefaultArgExpr));
1048 return new (Mem) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param,
1049 RewrittenExpr, UsedContext);
1050}
1051
1056
1058 assert(hasRewrittenInit() &&
1059 "expected this CXXDefaultArgExpr to have a rewritten init.");
1061 if (auto *E = dyn_cast_if_present<FullExpr>(Init))
1062 if (!isa<ConstantExpr>(E))
1063 return E->getSubExpr();
1064 return Init;
1065}
1066
1067CXXDefaultInitExpr::CXXDefaultInitExpr(const ASTContext &Ctx,
1068 SourceLocation Loc, FieldDecl *Field,
1069 QualType Ty, DeclContext *UsedContext,
1070 Expr *RewrittenInitExpr)
1071 : Expr(CXXDefaultInitExprClass, Ty.getNonLValueExprType(Ctx),
1072 Ty->isLValueReferenceType() ? VK_LValue
1073 : Ty->isRValueReferenceType() ? VK_XValue
1074 : VK_PRValue,
1075 /*FIXME*/ OK_Ordinary),
1076 Field(Field), UsedContext(UsedContext) {
1077 CXXDefaultInitExprBits.Loc = Loc;
1078 CXXDefaultInitExprBits.HasRewrittenInit = RewrittenInitExpr != nullptr;
1079
1080 if (CXXDefaultInitExprBits.HasRewrittenInit)
1081 *getTrailingObjects() = RewrittenInitExpr;
1082
1083 assert(Field->hasInClassInitializer());
1084
1086}
1087
1089 bool HasRewrittenInit) {
1090 size_t Size = totalSizeToAlloc<Expr *>(HasRewrittenInit);
1091 auto *Mem = C.Allocate(Size, alignof(CXXDefaultInitExpr));
1092 return new (Mem) CXXDefaultInitExpr(EmptyShell(), HasRewrittenInit);
1093}
1094
1095CXXDefaultInitExpr *CXXDefaultInitExpr::Create(const ASTContext &Ctx,
1096 SourceLocation Loc,
1097 FieldDecl *Field,
1098 DeclContext *UsedContext,
1099 Expr *RewrittenInitExpr) {
1100
1101 size_t Size = totalSizeToAlloc<Expr *>(RewrittenInitExpr != nullptr);
1102 auto *Mem = Ctx.Allocate(Size, alignof(CXXDefaultInitExpr));
1103 return new (Mem) CXXDefaultInitExpr(Ctx, Loc, Field, Field->getType(),
1104 UsedContext, RewrittenInitExpr);
1105}
1106
1108 assert(Field->getInClassInitializer() && "initializer hasn't been parsed");
1109 if (hasRewrittenInit())
1110 return getRewrittenExpr();
1111
1112 return Field->getInClassInitializer();
1113}
1114
1115CXXTemporary *CXXTemporary::Create(const ASTContext &C,
1116 const CXXDestructorDecl *Destructor) {
1117 return new (C) CXXTemporary(Destructor);
1118}
1119
1120CXXBindTemporaryExpr *CXXBindTemporaryExpr::Create(const ASTContext &C,
1121 CXXTemporary *Temp,
1122 Expr* SubExpr) {
1123 assert((SubExpr->getType()->isRecordType() ||
1124 SubExpr->getType()->isArrayType()) &&
1125 "Expression bound to a temporary must have record or array type!");
1126
1127 return new (C) CXXBindTemporaryExpr(Temp, SubExpr);
1128}
1129
1130CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(
1132 ArrayRef<Expr *> Args, SourceRange ParenOrBraceRange,
1133 bool HadMultipleCandidates, bool ListInitialization,
1134 bool StdInitListInitialization, bool ZeroInitialization)
1136 CXXTemporaryObjectExprClass, Ty, TSI->getTypeLoc().getBeginLoc(),
1137 Cons, /* Elidable=*/false, Args, HadMultipleCandidates,
1138 ListInitialization, StdInitListInitialization, ZeroInitialization,
1139 CXXConstructionKind::Complete, ParenOrBraceRange),
1140 TSI(TSI) {
1142}
1143
1144CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(EmptyShell Empty,
1145 unsigned NumArgs)
1146 : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty, NumArgs) {}
1147
1148CXXTemporaryObjectExpr *CXXTemporaryObjectExpr::Create(
1149 const ASTContext &Ctx, CXXConstructorDecl *Cons, QualType Ty,
1150 TypeSourceInfo *TSI, ArrayRef<Expr *> Args, SourceRange ParenOrBraceRange,
1151 bool HadMultipleCandidates, bool ListInitialization,
1152 bool StdInitListInitialization, bool ZeroInitialization) {
1153 unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(Args.size());
1154 void *Mem =
1155 Ctx.Allocate(sizeof(CXXTemporaryObjectExpr) + SizeOfTrailingObjects,
1156 alignof(CXXTemporaryObjectExpr));
1157 return new (Mem) CXXTemporaryObjectExpr(
1158 Cons, Ty, TSI, Args, ParenOrBraceRange, HadMultipleCandidates,
1159 ListInitialization, StdInitListInitialization, ZeroInitialization);
1160}
1161
1164 unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(NumArgs);
1165 void *Mem =
1166 Ctx.Allocate(sizeof(CXXTemporaryObjectExpr) + SizeOfTrailingObjects,
1167 alignof(CXXTemporaryObjectExpr));
1168 return new (Mem) CXXTemporaryObjectExpr(EmptyShell(), NumArgs);
1169}
1170
1174
1177 if (Loc.isInvalid() && getNumArgs())
1178 Loc = getArg(getNumArgs() - 1)->getEndLoc();
1179 return Loc;
1180}
1181
1183 const ASTContext &Ctx, QualType Ty, SourceLocation Loc,
1184 CXXConstructorDecl *Ctor, bool Elidable, ArrayRef<Expr *> Args,
1185 bool HadMultipleCandidates, bool ListInitialization,
1186 bool StdInitListInitialization, bool ZeroInitialization,
1187 CXXConstructionKind ConstructKind, SourceRange ParenOrBraceRange) {
1188 unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(Args.size());
1189 void *Mem = Ctx.Allocate(sizeof(CXXConstructExpr) + SizeOfTrailingObjects,
1190 alignof(CXXConstructExpr));
1191 return new (Mem) CXXConstructExpr(
1192 CXXConstructExprClass, Ty, Loc, Ctor, Elidable, Args,
1193 HadMultipleCandidates, ListInitialization, StdInitListInitialization,
1194 ZeroInitialization, ConstructKind, ParenOrBraceRange);
1195}
1196
1198 unsigned NumArgs) {
1199 unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(NumArgs);
1200 void *Mem = Ctx.Allocate(sizeof(CXXConstructExpr) + SizeOfTrailingObjects,
1201 alignof(CXXConstructExpr));
1202 return new (Mem)
1203 CXXConstructExpr(CXXConstructExprClass, EmptyShell(), NumArgs);
1204}
1205
1208 bool Elidable, ArrayRef<Expr *> Args, bool HadMultipleCandidates,
1209 bool ListInitialization, bool StdInitListInitialization,
1210 bool ZeroInitialization, CXXConstructionKind ConstructKind,
1211 SourceRange ParenOrBraceRange)
1212 : Expr(SC, Ty, VK_PRValue, OK_Ordinary), Constructor(Ctor),
1213 ParenOrBraceRange(ParenOrBraceRange), NumArgs(Args.size()) {
1214 CXXConstructExprBits.Elidable = Elidable;
1215 CXXConstructExprBits.HadMultipleCandidates = HadMultipleCandidates;
1216 CXXConstructExprBits.ListInitialization = ListInitialization;
1217 CXXConstructExprBits.StdInitListInitialization = StdInitListInitialization;
1218 CXXConstructExprBits.ZeroInitialization = ZeroInitialization;
1219 CXXConstructExprBits.ConstructionKind = llvm::to_underlying(ConstructKind);
1220 CXXConstructExprBits.IsImmediateEscalating = false;
1221 CXXConstructExprBits.Loc = Loc;
1222
1223 Stmt **TrailingArgs = getTrailingArgs();
1224 llvm::copy(Args, TrailingArgs);
1225 assert(!llvm::is_contained(Args, nullptr));
1226
1227 // CXXTemporaryObjectExpr does this itself after setting its TypeSourceInfo.
1228 if (SC == CXXConstructExprClass)
1230}
1231
1233 unsigned NumArgs)
1234 : Expr(SC, Empty), NumArgs(NumArgs) {}
1235
1237 LambdaCaptureKind Kind, ValueDecl *Var,
1238 SourceLocation EllipsisLoc)
1239 : DeclAndBits(Var, 0), Loc(Loc), EllipsisLoc(EllipsisLoc) {
1240 unsigned Bits = 0;
1241 if (Implicit)
1242 Bits |= Capture_Implicit;
1243
1244 switch (Kind) {
1245 case LCK_StarThis:
1246 Bits |= Capture_ByCopy;
1247 [[fallthrough]];
1248 case LCK_This:
1249 assert(!Var && "'this' capture cannot have a variable!");
1250 Bits |= Capture_This;
1251 break;
1252
1253 case LCK_ByCopy:
1254 Bits |= Capture_ByCopy;
1255 [[fallthrough]];
1256 case LCK_ByRef:
1257 assert(Var && "capture must have a variable!");
1258 break;
1259 case LCK_VLAType:
1260 assert(!Var && "VLA type capture cannot have a variable!");
1261 break;
1262 }
1263 DeclAndBits.setInt(Bits);
1264}
1265
1267 if (capturesVLAType())
1268 return LCK_VLAType;
1269 bool CapByCopy = DeclAndBits.getInt() & Capture_ByCopy;
1270 if (capturesThis())
1271 return CapByCopy ? LCK_StarThis : LCK_This;
1272 return CapByCopy ? LCK_ByCopy : LCK_ByRef;
1273}
1274
1275LambdaExpr::LambdaExpr(QualType T, SourceRange IntroducerRange,
1276 LambdaCaptureDefault CaptureDefault,
1277 SourceLocation CaptureDefaultLoc, bool ExplicitParams,
1278 bool ExplicitResultType, ArrayRef<Expr *> CaptureInits,
1279 SourceLocation ClosingBrace,
1280 bool ContainsUnexpandedParameterPack)
1281 : Expr(LambdaExprClass, T, VK_PRValue, OK_Ordinary),
1282 IntroducerRange(IntroducerRange), CaptureDefaultLoc(CaptureDefaultLoc),
1283 ClosingBrace(ClosingBrace) {
1284 LambdaExprBits.NumCaptures = CaptureInits.size();
1285 LambdaExprBits.CaptureDefault = CaptureDefault;
1286 LambdaExprBits.ExplicitParams = ExplicitParams;
1287 LambdaExprBits.ExplicitResultType = ExplicitResultType;
1288
1289 CXXRecordDecl *Class = getLambdaClass();
1290 (void)Class;
1291 assert(capture_size() == Class->capture_size() && "Wrong number of captures");
1292 assert(getCaptureDefault() == Class->getLambdaCaptureDefault());
1293
1294 // Copy initialization expressions for the non-static data members.
1295 Stmt **Stored = getStoredStmts();
1296 for (unsigned I = 0, N = CaptureInits.size(); I != N; ++I)
1297 *Stored++ = CaptureInits[I];
1298
1299 // Copy the body of the lambda.
1300 *Stored++ = getCallOperator()->getBody();
1301
1302 setDependence(computeDependence(this, ContainsUnexpandedParameterPack));
1303}
1304
1305LambdaExpr::LambdaExpr(EmptyShell Empty, unsigned NumCaptures)
1306 : Expr(LambdaExprClass, Empty) {
1307 LambdaExprBits.NumCaptures = NumCaptures;
1308
1309 // Initially don't initialize the body of the LambdaExpr. The body will
1310 // be lazily deserialized when needed.
1311 getStoredStmts()[NumCaptures] = nullptr; // Not one past the end.
1312}
1313
1315 SourceRange IntroducerRange,
1316 LambdaCaptureDefault CaptureDefault,
1317 SourceLocation CaptureDefaultLoc,
1318 bool ExplicitParams, bool ExplicitResultType,
1319 ArrayRef<Expr *> CaptureInits,
1320 SourceLocation ClosingBrace,
1321 bool ContainsUnexpandedParameterPack) {
1322 // Determine the type of the expression (i.e., the type of the
1323 // function object we're creating).
1324 CanQualType T = Context.getCanonicalTagType(Class);
1325
1326 unsigned Size = totalSizeToAlloc<Stmt *>(CaptureInits.size() + 1);
1327 void *Mem = Context.Allocate(Size);
1328 return new (Mem)
1329 LambdaExpr(T, IntroducerRange, CaptureDefault, CaptureDefaultLoc,
1330 ExplicitParams, ExplicitResultType, CaptureInits, ClosingBrace,
1331 ContainsUnexpandedParameterPack);
1332}
1333
1335 unsigned NumCaptures) {
1336 unsigned Size = totalSizeToAlloc<Stmt *>(NumCaptures + 1);
1337 void *Mem = C.Allocate(Size);
1338 return new (Mem) LambdaExpr(EmptyShell(), NumCaptures);
1339}
1340
1341void LambdaExpr::initBodyIfNeeded() const {
1342 if (!getStoredStmts()[capture_size()]) {
1343 auto *This = const_cast<LambdaExpr *>(this);
1344 This->getStoredStmts()[capture_size()] = getCallOperator()->getBody();
1345 }
1346}
1347
1349 initBodyIfNeeded();
1350 return getStoredStmts()[capture_size()];
1351}
1352
1354 Stmt *Body = getBody();
1355 if (const auto *CoroBody = dyn_cast<CoroutineBodyStmt>(Body))
1356 return cast<CompoundStmt>(CoroBody->getBody());
1357 return cast<CompoundStmt>(Body);
1358}
1359
1361 return C->capturesVariable() && C->getCapturedVar()->isInitCapture() &&
1362 getCallOperator() == C->getCapturedVar()->getDeclContext();
1363}
1364
1368
1372
1376
1380
1382 return capture_begin() +
1383 getLambdaClass()->getLambdaData().NumExplicitCaptures;
1384}
1385
1389
1393
1397
1401
1405
1408 return Record->getLambdaCallOperator();
1409}
1410
1413 return Record->getDependentLambdaCallOperator();
1414}
1415
1418 return Record->getGenericLambdaTemplateParameterList();
1419}
1420
1423 return Record->getLambdaExplicitTemplateParameters();
1424}
1425
1429
1430bool LambdaExpr::isMutable() const { return !getCallOperator()->isConst(); }
1431
1433 initBodyIfNeeded();
1434 return child_range(getStoredStmts(), getStoredStmts() + capture_size() + 1);
1435}
1436
1438 initBodyIfNeeded();
1439 return const_child_range(getStoredStmts(),
1440 getStoredStmts() + capture_size() + 1);
1441}
1442
1443ExprWithCleanups::ExprWithCleanups(Expr *subexpr,
1444 bool CleanupsHaveSideEffects,
1446 : FullExpr(ExprWithCleanupsClass, subexpr) {
1447 ExprWithCleanupsBits.CleanupsHaveSideEffects = CleanupsHaveSideEffects;
1448 ExprWithCleanupsBits.NumObjects = objects.size();
1449 llvm::copy(objects, getTrailingObjects());
1450}
1451
1452ExprWithCleanups *ExprWithCleanups::Create(const ASTContext &C, Expr *subexpr,
1453 bool CleanupsHaveSideEffects,
1454 ArrayRef<CleanupObject> objects) {
1455 void *buffer = C.Allocate(totalSizeToAlloc<CleanupObject>(objects.size()),
1456 alignof(ExprWithCleanups));
1457 return new (buffer)
1458 ExprWithCleanups(subexpr, CleanupsHaveSideEffects, objects);
1459}
1460
1461ExprWithCleanups::ExprWithCleanups(EmptyShell empty, unsigned numObjects)
1462 : FullExpr(ExprWithCleanupsClass, empty) {
1463 ExprWithCleanupsBits.NumObjects = numObjects;
1464}
1465
1466ExprWithCleanups *ExprWithCleanups::Create(const ASTContext &C,
1467 EmptyShell empty,
1468 unsigned numObjects) {
1469 void *buffer = C.Allocate(totalSizeToAlloc<CleanupObject>(numObjects),
1470 alignof(ExprWithCleanups));
1471 return new (buffer) ExprWithCleanups(empty, numObjects);
1472}
1473
1474CXXUnresolvedConstructExpr::CXXUnresolvedConstructExpr(
1475 QualType T, TypeSourceInfo *TSI, SourceLocation LParenLoc,
1476 ArrayRef<Expr *> Args, SourceLocation RParenLoc, bool IsListInit)
1477 : Expr(CXXUnresolvedConstructExprClass, T,
1478 (TSI->getType()->isLValueReferenceType() ? VK_LValue
1479 : TSI->getType()->isRValueReferenceType() ? VK_XValue
1480 : VK_PRValue),
1481 OK_Ordinary),
1482 TypeAndInitForm(TSI, IsListInit), LParenLoc(LParenLoc),
1483 RParenLoc(RParenLoc) {
1484 CXXUnresolvedConstructExprBits.NumArgs = Args.size();
1485 auto **StoredArgs = getTrailingObjects();
1486 llvm::copy(Args, StoredArgs);
1488}
1489
1490CXXUnresolvedConstructExpr *CXXUnresolvedConstructExpr::Create(
1491 const ASTContext &Context, QualType T, TypeSourceInfo *TSI,
1492 SourceLocation LParenLoc, ArrayRef<Expr *> Args, SourceLocation RParenLoc,
1493 bool IsListInit) {
1494 void *Mem = Context.Allocate(totalSizeToAlloc<Expr *>(Args.size()));
1495 return new (Mem) CXXUnresolvedConstructExpr(T, TSI, LParenLoc, Args,
1496 RParenLoc, IsListInit);
1497}
1498
1501 unsigned NumArgs) {
1502 void *Mem = Context.Allocate(totalSizeToAlloc<Expr *>(NumArgs));
1503 return new (Mem) CXXUnresolvedConstructExpr(EmptyShell(), NumArgs);
1504}
1505
1507 return TypeAndInitForm.getPointer()->getTypeLoc().getBeginLoc();
1508}
1509
1510CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(
1511 const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow,
1512 SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc,
1513 SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope,
1514 DeclarationNameInfo MemberNameInfo,
1515 const TemplateArgumentListInfo *TemplateArgs)
1516 : Expr(CXXDependentScopeMemberExprClass, Ctx.DependentTy, VK_LValue,
1517 OK_Ordinary),
1518 Base(Base), BaseType(BaseType), QualifierLoc(QualifierLoc),
1519 MemberNameInfo(MemberNameInfo) {
1520 CXXDependentScopeMemberExprBits.IsArrow = IsArrow;
1521 CXXDependentScopeMemberExprBits.HasTemplateKWAndArgsInfo =
1522 (TemplateArgs != nullptr) || TemplateKWLoc.isValid();
1523 CXXDependentScopeMemberExprBits.HasFirstQualifierFoundInScope =
1524 FirstQualifierFoundInScope != nullptr;
1525 CXXDependentScopeMemberExprBits.OperatorLoc = OperatorLoc;
1526
1527 if (TemplateArgs) {
1528 auto Deps = TemplateArgumentDependence::None;
1529 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1530 TemplateKWLoc, *TemplateArgs, getTrailingObjects<TemplateArgumentLoc>(),
1531 Deps);
1532 } else if (TemplateKWLoc.isValid()) {
1533 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1534 TemplateKWLoc);
1535 }
1536
1537 if (hasFirstQualifierFoundInScope())
1538 *getTrailingObjects<NamedDecl *>() = FirstQualifierFoundInScope;
1540}
1541
1542CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(
1543 EmptyShell Empty, bool HasTemplateKWAndArgsInfo,
1544 bool HasFirstQualifierFoundInScope)
1545 : Expr(CXXDependentScopeMemberExprClass, Empty) {
1546 CXXDependentScopeMemberExprBits.HasTemplateKWAndArgsInfo =
1547 HasTemplateKWAndArgsInfo;
1548 CXXDependentScopeMemberExprBits.HasFirstQualifierFoundInScope =
1549 HasFirstQualifierFoundInScope;
1550}
1551
1552CXXDependentScopeMemberExpr *CXXDependentScopeMemberExpr::Create(
1553 const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow,
1554 SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc,
1555 SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope,
1556 DeclarationNameInfo MemberNameInfo,
1557 const TemplateArgumentListInfo *TemplateArgs) {
1558 bool HasTemplateKWAndArgsInfo =
1559 (TemplateArgs != nullptr) || TemplateKWLoc.isValid();
1560 unsigned NumTemplateArgs = TemplateArgs ? TemplateArgs->size() : 0;
1561 bool HasFirstQualifierFoundInScope = FirstQualifierFoundInScope != nullptr;
1562
1563 unsigned Size = totalSizeToAlloc<ASTTemplateKWAndArgsInfo,
1565 HasTemplateKWAndArgsInfo, NumTemplateArgs, HasFirstQualifierFoundInScope);
1566
1567 void *Mem = Ctx.Allocate(Size, alignof(CXXDependentScopeMemberExpr));
1568 return new (Mem) CXXDependentScopeMemberExpr(
1569 Ctx, Base, BaseType, IsArrow, OperatorLoc, QualifierLoc, TemplateKWLoc,
1570 FirstQualifierFoundInScope, MemberNameInfo, TemplateArgs);
1571}
1572
1573CXXDependentScopeMemberExpr *CXXDependentScopeMemberExpr::CreateEmpty(
1574 const ASTContext &Ctx, bool HasTemplateKWAndArgsInfo,
1575 unsigned NumTemplateArgs, bool HasFirstQualifierFoundInScope) {
1576 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
1577
1578 unsigned Size = totalSizeToAlloc<ASTTemplateKWAndArgsInfo,
1580 HasTemplateKWAndArgsInfo, NumTemplateArgs, HasFirstQualifierFoundInScope);
1581
1582 void *Mem = Ctx.Allocate(Size, alignof(CXXDependentScopeMemberExpr));
1583 return new (Mem) CXXDependentScopeMemberExpr(
1584 EmptyShell(), HasTemplateKWAndArgsInfo, HasFirstQualifierFoundInScope);
1585}
1586
1588 QualType Ty, bool IsImplicit) {
1589 return new (Ctx) CXXThisExpr(L, Ty, IsImplicit,
1590 Ctx.getLangOpts().HLSL ? VK_LValue : VK_PRValue);
1591}
1592
1593CXXThisExpr *CXXThisExpr::CreateEmpty(const ASTContext &Ctx) {
1594 return new (Ctx) CXXThisExpr(EmptyShell());
1595}
1596
1599 do {
1600 NamedDecl *decl = *begin;
1602 return false;
1603
1604 // Unresolved member expressions should only contain methods and
1605 // method templates.
1606 if (cast<CXXMethodDecl>(decl->getUnderlyingDecl()->getAsFunction())
1607 ->isStatic())
1608 return false;
1609 } while (++begin != end);
1610
1611 return true;
1612}
1613
1614UnresolvedMemberExpr::UnresolvedMemberExpr(
1615 const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base,
1616 QualType BaseType, bool IsArrow, SourceLocation OperatorLoc,
1617 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
1618 const DeclarationNameInfo &MemberNameInfo,
1619 const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin,
1621 : OverloadExpr(
1622 UnresolvedMemberExprClass, Context, QualifierLoc, TemplateKWLoc,
1623 MemberNameInfo, TemplateArgs, Begin, End,
1624 // Dependent
1625 ((Base && Base->isTypeDependent()) || BaseType->isDependentType()),
1626 ((Base && Base->isInstantiationDependent()) ||
1627 BaseType->isInstantiationDependentType()),
1628 // Contains unexpanded parameter pack
1629 ((Base && Base->containsUnexpandedParameterPack()) ||
1630 BaseType->containsUnexpandedParameterPack())),
1631 Base(Base), BaseType(BaseType), OperatorLoc(OperatorLoc) {
1632 UnresolvedMemberExprBits.IsArrow = IsArrow;
1633 UnresolvedMemberExprBits.HasUnresolvedUsing = HasUnresolvedUsing;
1634
1635 // Check whether all of the members are non-static member functions,
1636 // and if so, mark give this bound-member type instead of overload type.
1637 if (hasOnlyNonStaticMemberFunctions(Begin, End))
1638 setType(Context.BoundMemberTy);
1639}
1640
1641UnresolvedMemberExpr::UnresolvedMemberExpr(EmptyShell Empty,
1642 unsigned NumResults,
1643 bool HasTemplateKWAndArgsInfo)
1644 : OverloadExpr(UnresolvedMemberExprClass, Empty, NumResults,
1645 HasTemplateKWAndArgsInfo) {}
1646
1648 if (!Base)
1649 return true;
1650
1651 return cast<Expr>(Base)->isImplicitCXXThis();
1652}
1653
1654UnresolvedMemberExpr *UnresolvedMemberExpr::Create(
1655 const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base,
1656 QualType BaseType, bool IsArrow, SourceLocation OperatorLoc,
1657 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
1658 const DeclarationNameInfo &MemberNameInfo,
1659 const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin,
1661 unsigned NumResults = End - Begin;
1662 bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.isValid();
1663 unsigned NumTemplateArgs = TemplateArgs ? TemplateArgs->size() : 0;
1664 unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
1666 NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
1667 void *Mem = Context.Allocate(Size, alignof(UnresolvedMemberExpr));
1668 return new (Mem) UnresolvedMemberExpr(
1669 Context, HasUnresolvedUsing, Base, BaseType, IsArrow, OperatorLoc,
1670 QualifierLoc, TemplateKWLoc, MemberNameInfo, TemplateArgs, Begin, End);
1671}
1672
1674 const ASTContext &Context, unsigned NumResults,
1675 bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs) {
1676 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
1677 unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
1679 NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
1680 void *Mem = Context.Allocate(Size, alignof(UnresolvedMemberExpr));
1681 return new (Mem)
1682 UnresolvedMemberExpr(EmptyShell(), NumResults, HasTemplateKWAndArgsInfo);
1683}
1684
1686 // Unlike for UnresolvedLookupExpr, it is very easy to re-derive this.
1687
1688 // If there was a nested name specifier, it names the naming class.
1689 // It can't be dependent: after all, we were actually able to do the
1690 // lookup.
1691 CXXRecordDecl *Record = nullptr;
1692 if (NestedNameSpecifier Qualifier = getQualifier();
1693 Qualifier.getKind() == NestedNameSpecifier::Kind::Type) {
1694 const Type *T = getQualifier().getAsType();
1695 Record = T->getAsCXXRecordDecl();
1696 assert(Record && "qualifier in member expression does not name record");
1697 }
1698 // Otherwise the naming class must have been the base class.
1699 else {
1701 if (isArrow())
1702 BaseType = BaseType->castAs<PointerType>()->getPointeeType();
1703
1704 Record = BaseType->getAsCXXRecordDecl();
1705 assert(Record && "base of member expression does not name record");
1706 }
1707
1708 return Record;
1709}
1710
1711SizeOfPackExpr *SizeOfPackExpr::Create(ASTContext &Context,
1712 SourceLocation OperatorLoc,
1713 NamedDecl *Pack, SourceLocation PackLoc,
1714 SourceLocation RParenLoc,
1715 UnsignedOrNone Length,
1716 ArrayRef<TemplateArgument> PartialArgs) {
1717 void *Storage =
1718 Context.Allocate(totalSizeToAlloc<TemplateArgument>(PartialArgs.size()));
1719 return new (Storage) SizeOfPackExpr(Context.getSizeType(), OperatorLoc, Pack,
1720 PackLoc, RParenLoc, Length, PartialArgs);
1721}
1722
1724 unsigned NumPartialArgs) {
1725 void *Storage =
1726 Context.Allocate(totalSizeToAlloc<TemplateArgument>(NumPartialArgs));
1727 return new (Storage) SizeOfPackExpr(EmptyShell(), NumPartialArgs);
1728}
1729
1734
1736 ASTContext &Context, SourceLocation EllipsisLoc, SourceLocation RSquareLoc,
1737 Expr *PackIdExpr, Expr *IndexExpr, std::optional<int64_t> Index,
1738 ArrayRef<Expr *> SubstitutedExprs, bool FullySubstituted) {
1739 QualType Type;
1740 if (Index && FullySubstituted && !SubstitutedExprs.empty())
1741 Type = SubstitutedExprs[*Index]->getType();
1742 else
1743 Type = PackIdExpr->getType();
1744
1745 void *Storage =
1746 Context.Allocate(totalSizeToAlloc<Expr *>(SubstitutedExprs.size()));
1747 return new (Storage)
1748 PackIndexingExpr(Type, EllipsisLoc, RSquareLoc, PackIdExpr, IndexExpr,
1749 SubstitutedExprs, FullySubstituted);
1750}
1751
1753 if (auto *D = dyn_cast<DeclRefExpr>(getPackIdExpression()); D) {
1754 return D->getDecl();
1755 }
1756 assert(false && "invalid declaration kind in pack indexing expression");
1757 return nullptr;
1758}
1759
1762 unsigned NumTransformedExprs) {
1763 void *Storage =
1764 Context.Allocate(totalSizeToAlloc<Expr *>(NumTransformedExprs));
1765 return new (Storage) PackIndexingExpr(EmptyShell{});
1766}
1767
1769 const ASTContext &Context) const {
1770 // Note that, for a class type NTTP, we will have an lvalue of type 'const
1771 // T', so we can't just compute this from the type and value category.
1772
1773 QualType Type = getType();
1774
1776 return Context.getLValueReferenceType(Type);
1777 return Type.getUnqualifiedType();
1778}
1779
1780SubstNonTypeTemplateParmPackExpr::SubstNonTypeTemplateParmPackExpr(
1781 QualType T, ExprValueKind ValueKind, SourceLocation NameLoc,
1782 const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index,
1783 bool Final)
1784 : Expr(SubstNonTypeTemplateParmPackExprClass, T, ValueKind, OK_Ordinary),
1785 AssociatedDecl(AssociatedDecl), Arguments(ArgPack.pack_begin()),
1786 NumArguments(ArgPack.pack_size()), Final(Final), Index(Index),
1787 NameLoc(NameLoc) {
1788 assert(AssociatedDecl != nullptr);
1789 setDependence(ExprDependence::TypeValueInstantiation |
1790 ExprDependence::UnexpandedPack);
1791}
1792
1798
1802
1803FunctionParmPackExpr::FunctionParmPackExpr(QualType T, ValueDecl *ParamPack,
1804 SourceLocation NameLoc,
1805 unsigned NumParams,
1806 ValueDecl *const *Params)
1807 : Expr(FunctionParmPackExprClass, T, VK_LValue, OK_Ordinary),
1808 ParamPack(ParamPack), NameLoc(NameLoc), NumParameters(NumParams) {
1809 if (Params)
1810 std::uninitialized_copy(Params, Params + NumParams, getTrailingObjects());
1811 setDependence(ExprDependence::TypeValueInstantiation |
1812 ExprDependence::UnexpandedPack);
1813}
1814
1817 ValueDecl *ParamPack, SourceLocation NameLoc,
1818 ArrayRef<ValueDecl *> Params) {
1819 return new (Context.Allocate(totalSizeToAlloc<ValueDecl *>(Params.size())))
1820 FunctionParmPackExpr(T, ParamPack, NameLoc, Params.size(), Params.data());
1821}
1822
1825 unsigned NumParams) {
1826 return new (Context.Allocate(totalSizeToAlloc<ValueDecl *>(NumParams)))
1827 FunctionParmPackExpr(QualType(), nullptr, SourceLocation(), 0, nullptr);
1828}
1829
1831 QualType T, Expr *Temporary, bool BoundToLvalueReference,
1833 : Expr(MaterializeTemporaryExprClass, T,
1834 BoundToLvalueReference ? VK_LValue : VK_XValue, OK_Ordinary) {
1835 if (MTD) {
1836 State = MTD;
1837 MTD->ExprWithTemporary = Temporary;
1838 return;
1839 }
1840 State = Temporary;
1842}
1843
1845 unsigned ManglingNumber) {
1846 // We only need extra state if we have to remember more than just the Stmt.
1847 if (!ExtendedBy)
1848 return;
1849
1850 // We may need to allocate extra storage for the mangling number and the
1851 // extended-by ValueDecl.
1854 cast<Expr>(cast<Stmt *>(State)), ExtendedBy, ManglingNumber);
1855
1857 ES->ExtendingDecl = ExtendedBy;
1858 ES->ManglingNumber = ManglingNumber;
1859}
1860
1862 const ASTContext &Context) const {
1863 // C++20 [expr.const]p4:
1864 // An object or reference is usable in constant expressions if it is [...]
1865 // a temporary object of non-volatile const-qualified literal type
1866 // whose lifetime is extended to that of a variable that is usable
1867 // in constant expressions
1868 auto *VD = dyn_cast_or_null<VarDecl>(getExtendingDecl());
1869 return VD && getType().isConstant(Context) &&
1871 getType()->isLiteralType(Context) &&
1872 VD->isUsableInConstantExpressions(Context);
1873}
1874
1875TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind,
1877 SourceLocation RParenLoc,
1878 std::variant<bool, APValue> Value)
1879 : Expr(TypeTraitExprClass, T, VK_PRValue, OK_Ordinary), Loc(Loc),
1880 RParenLoc(RParenLoc) {
1881 assert(Kind <= TT_Last && "invalid enum value!");
1882
1883 TypeTraitExprBits.Kind = Kind;
1884 assert(static_cast<unsigned>(Kind) == TypeTraitExprBits.Kind &&
1885 "TypeTraitExprBits.Kind overflow!");
1886
1887 TypeTraitExprBits.IsBooleanTypeTrait = std::holds_alternative<bool>(Value);
1888 if (TypeTraitExprBits.IsBooleanTypeTrait)
1889 TypeTraitExprBits.Value = std::get<bool>(Value);
1890 else
1891 ::new (getTrailingObjects<APValue>())
1892 APValue(std::get<APValue>(std::move(Value)));
1893
1894 TypeTraitExprBits.NumArgs = Args.size();
1895 assert(Args.size() == TypeTraitExprBits.NumArgs &&
1896 "TypeTraitExprBits.NumArgs overflow!");
1897 auto **ToArgs = getTrailingObjects<TypeSourceInfo *>();
1898 llvm::copy(Args, ToArgs);
1899
1901
1902 assert((TypeTraitExprBits.IsBooleanTypeTrait || isValueDependent() ||
1903 getAPValue().isInt() || getAPValue().isAbsent()) &&
1904 "Only int values are supported by clang");
1905}
1906
1907TypeTraitExpr::TypeTraitExpr(EmptyShell Empty, bool IsStoredAsBool)
1908 : Expr(TypeTraitExprClass, Empty) {
1909 TypeTraitExprBits.IsBooleanTypeTrait = IsStoredAsBool;
1910 if (!IsStoredAsBool)
1911 ::new (getTrailingObjects<APValue>()) APValue();
1912}
1913
1915 SourceLocation Loc,
1916 TypeTrait Kind,
1918 SourceLocation RParenLoc,
1919 bool Value) {
1920 void *Mem =
1921 C.Allocate(totalSizeToAlloc<APValue, TypeSourceInfo *>(0, Args.size()));
1922 return new (Mem) TypeTraitExpr(T, Loc, Kind, Args, RParenLoc, Value);
1923}
1924
1926 SourceLocation Loc, TypeTrait Kind,
1928 SourceLocation RParenLoc, APValue Value) {
1929 void *Mem =
1930 C.Allocate(totalSizeToAlloc<APValue, TypeSourceInfo *>(1, Args.size()));
1931 return new (Mem) TypeTraitExpr(T, Loc, Kind, Args, RParenLoc, Value);
1932}
1933
1935 bool IsStoredAsBool,
1936 unsigned NumArgs) {
1937 void *Mem = C.Allocate(totalSizeToAlloc<APValue, TypeSourceInfo *>(
1938 IsStoredAsBool ? 0 : 1, NumArgs));
1939 return new (Mem) TypeTraitExpr(EmptyShell(), IsStoredAsBool);
1940}
1941
1942CXXReflectExpr::CXXReflectExpr(EmptyShell Empty)
1943 : Expr(CXXReflectExprClass, Empty) {}
1944
1945CXXReflectExpr::CXXReflectExpr(SourceLocation CaretCaretLoc,
1946 const TypeSourceInfo *TSI)
1947 : Expr(CXXReflectExprClass, TSI->getType(), VK_PRValue, OK_Ordinary),
1948 CaretCaretLoc(CaretCaretLoc), Operand(TSI) {}
1949
1951 SourceLocation CaretCaretLoc,
1952 TypeSourceInfo *TSI) {
1953 return new (C) CXXReflectExpr(CaretCaretLoc, TSI);
1954}
1955
1957 return new (C) CXXReflectExpr(EmptyShell());
1958}
1959
1960CUDAKernelCallExpr::CUDAKernelCallExpr(Expr *Fn, CallExpr *Config,
1961 ArrayRef<Expr *> Args, QualType Ty,
1963 FPOptionsOverride FPFeatures,
1964 unsigned MinNumArgs)
1965 : CallExpr(CUDAKernelCallExprClass, Fn, /*PreArgs=*/Config, Args, Ty, VK,
1966 RP, FPFeatures, MinNumArgs, NotADL) {}
1967
1968CUDAKernelCallExpr::CUDAKernelCallExpr(unsigned NumArgs, bool HasFPFeatures,
1969 EmptyShell Empty)
1970 : CallExpr(CUDAKernelCallExprClass, /*NumPreArgs=*/END_PREARG, NumArgs,
1971 HasFPFeatures, Empty) {}
1972
1976 SourceLocation RP, FPOptionsOverride FPFeatures,
1977 unsigned MinNumArgs) {
1978 // Allocate storage for the trailing objects of CallExpr.
1979 unsigned NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1980 unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
1981 /*NumPreArgs=*/END_PREARG, NumArgs, FPFeatures.requiresTrailingStorage());
1982 void *Mem =
1984 SizeOfTrailingObjects),
1985 alignof(CUDAKernelCallExpr));
1986 return new (Mem)
1987 CUDAKernelCallExpr(Fn, Config, Args, Ty, VK, RP, FPFeatures, MinNumArgs);
1988}
1989
1990CUDAKernelCallExpr *CUDAKernelCallExpr::CreateEmpty(const ASTContext &Ctx,
1991 unsigned NumArgs,
1992 bool HasFPFeatures,
1993 EmptyShell Empty) {
1994 // Allocate storage for the trailing objects of CallExpr.
1995 unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
1996 /*NumPreArgs=*/END_PREARG, NumArgs, HasFPFeatures);
1997 void *Mem =
1999 SizeOfTrailingObjects),
2000 alignof(CUDAKernelCallExpr));
2001 return new (Mem) CUDAKernelCallExpr(NumArgs, HasFPFeatures, Empty);
2002}
2003
2006 unsigned NumUserSpecifiedExprs,
2007 SourceLocation InitLoc, SourceLocation LParenLoc,
2008 SourceLocation RParenLoc) {
2009 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(Args.size()));
2010 return new (Mem) CXXParenListInitExpr(Args, T, NumUserSpecifiedExprs, InitLoc,
2011 LParenLoc, RParenLoc);
2012}
2013
2015 unsigned NumExprs,
2016 EmptyShell Empty) {
2017 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumExprs),
2018 alignof(CXXParenListInitExpr));
2019 return new (Mem) CXXParenListInitExpr(Empty, NumExprs);
2020}
2021
2023 SourceLocation LParenLoc, Expr *LHS,
2024 BinaryOperatorKind Opcode, SourceLocation EllipsisLoc,
2025 Expr *RHS, SourceLocation RParenLoc,
2026 UnsignedOrNone NumExpansions)
2027 : Expr(CXXFoldExprClass, T, VK_PRValue, OK_Ordinary), LParenLoc(LParenLoc),
2028 EllipsisLoc(EllipsisLoc), RParenLoc(RParenLoc),
2029 NumExpansions(NumExpansions) {
2030 CXXFoldExprBits.Opcode = Opcode;
2031 // We rely on asserted invariant to distinguish left and right folds.
2032 if (LHS && RHS)
2033 assert(LHS->containsUnexpandedParameterPack() !=
2034 RHS->containsUnexpandedParameterPack() &&
2035 "Exactly one of LHS or RHS should contain an unexpanded pack");
2036 SubExprs[SubExpr::Callee] = Callee;
2037 SubExprs[SubExpr::LHS] = LHS;
2038 SubExprs[SubExpr::RHS] = RHS;
2040}
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:1597
static bool isGLValueFromPointerDeref(const Expr *E)
Definition ExprCXX.cpp:168
static bool UnresolvedLookupExprIsVariableOrConceptParameterPack(UnresolvedSetIterator Begin, UnresolvedSetIterator End)
Definition ExprCXX.cpp:399
Defines the clang::Expr interface and subclasses for C++ expressions.
TokenType getType() const
Returns the token's type, e.g.
void setType(TokenType T)
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:31
Defines an enumeration for C++ overloaded operators.
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
a trap message and trap category.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition APValue.h:122
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:227
const LangOptions & getLangOpts() const
Definition ASTContext.h:959
void * Allocate(size_t Size, unsigned Align=8) const
Definition ASTContext.h:879
Represents a call to a CUDA kernel function.
Definition ExprCXX.h:238
static CUDAKernelCallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty)
Definition ExprCXX.cpp:1990
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:1974
A C++ addrspace_cast expression (currently only enabled for OpenCL).
Definition ExprCXX.h:608
static CXXAddrspaceCastExpr * CreateEmpty(const ASTContext &Context)
Definition ExprCXX.cpp:916
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:908
Represents a base class of a C++ class.
Definition DeclCXX.h:146
static CXXBindTemporaryExpr * Create(const ASTContext &C, CXXTemporary *Temp, Expr *SubExpr)
Definition ExprCXX.cpp:1120
static CXXConstCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, Expr *Op, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Definition ExprCXX.cpp:894
static CXXConstCastExpr * CreateEmpty(const ASTContext &Context)
Definition ExprCXX.cpp:903
Represents a call to a C++ constructor.
Definition ExprCXX.h:1552
SourceRange getParenOrBraceRange() const
Definition ExprCXX.h:1733
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:1182
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition ExprCXX.h:1695
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:1206
SourceLocation getLocation() const
Definition ExprCXX.h:1617
static unsigned sizeOfTrailingObjects(unsigned NumArgs)
Return the size in bytes of the trailing objects.
Definition ExprCXX.h:1598
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.cpp:581
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:575
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Definition ExprCXX.h:1692
static CXXConstructExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs)
Create an empty C++ construction expression.
Definition ExprCXX.cpp:1197
Represents a C++ constructor within a class.
Definition DeclCXX.h:2620
const ParmVarDecl * getParam() const
Definition ExprCXX.h:1316
Expr * getAdjustedRewrittenExpr()
Definition ExprCXX.cpp:1057
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
Definition ExprCXX.cpp:1041
static CXXDefaultArgExpr * CreateEmpty(const ASTContext &C, bool HasRewrittenInit)
Definition ExprCXX.cpp:1034
bool hasRewrittenInit() const
Definition ExprCXX.h:1319
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:1095
const Expr * getRewrittenExpr() const
Retrieve the initializing expression with evaluated immediate calls, if any.
Definition ExprCXX.h:1426
bool hasRewrittenInit() const
Definition ExprCXX.h:1410
Expr * getExpr()
Get the initialization expression that will be used.
Definition ExprCXX.cpp:1107
static CXXDefaultInitExpr * CreateEmpty(const ASTContext &C, bool HasRewrittenInit)
Definition ExprCXX.cpp:1088
FunctionDecl * getOperatorDelete() const
Definition ExprCXX.h:2669
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition ExprCXX.cpp:338
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:1552
static CXXDependentScopeMemberExpr * CreateEmpty(const ASTContext &Ctx, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs, bool HasFirstQualifierFoundInScope)
Definition ExprCXX.cpp:1573
Represents a C++ destructor within a class.
Definition DeclCXX.h:2882
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:808
static CXXDynamicCastExpr * CreateEmpty(const ASTContext &Context, unsigned pathSize)
Definition ExprCXX.cpp:826
bool isAlwaysNull() const
isAlwaysNull - Return whether the result of the dynamic_cast is proven to always be null.
Definition ExprCXX.cpp:840
CXXFoldExpr(QualType T, UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Opcode, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, UnsignedOrNone NumExpansions)
Definition ExprCXX.cpp:2022
static CXXFunctionalCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize, bool HasFPFeatures)
Definition ExprCXX.cpp:936
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:946
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.cpp:950
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:920
CXXMethodDecl * getMethodDecl() const
Retrieve the declaration of the called method.
Definition ExprCXX.cpp:743
Expr * getImplicitObjectArgument() const
Retrieve the implicit object argument for the member call.
Definition ExprCXX.cpp:724
static CXXMemberCallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty)
Definition ExprCXX.cpp:711
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:694
QualType getObjectType() const
Retrieve the type of the object argument.
Definition ExprCXX.cpp:736
CXXRecordDecl * getRecordDecl() const
Retrieve the CXXRecordDecl for the underlying type of the implicit object argument.
Definition ExprCXX.cpp:752
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2132
bool isConst() const
Definition DeclCXX.h:2184
const char * getCastName() const
getCastName - Get the name of the C++ cast being used, e.g., "static_cast", "dynamic_cast",...
Definition ExprCXX.cpp:770
static CXXNewExpr * Create(const ASTContext &Ctx, bool IsGlobalNew, FunctionDecl *OperatorNew, FunctionDecl *OperatorDelete, const ImplicitAllocationParameters &IAP, 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:293
static CXXNewExpr * CreateEmpty(const ASTContext &Ctx, bool IsArray, bool HasInit, unsigned NumPlacementArgs, bool IsParenTypeId)
Create an empty c++ new expression.
Definition ExprCXX.cpp:315
bool shouldNullCheckAllocation() const
True if the allocation result needs to be null-checked.
Definition ExprCXX.cpp:326
FunctionDecl * getOperatorNew() const
Definition ExprCXX.h:2463
bool isInfixBinaryOp() const
Is this written as an infix binary operator?
Definition ExprCXX.cpp:48
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
Definition ExprCXX.h:156
static CXXOperatorCallExpr * Create(const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation OperatorLoc, FPOptionsOverride FPFeatures, ADLCallKind UsesADL=NotADL, bool IsReversed=false)
Definition ExprCXX.cpp:624
SourceLocation getEndLoc() const
Definition ExprCXX.h:167
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
Definition ExprCXX.h:115
static CXXOperatorCallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty)
Definition ExprCXX.cpp:641
SourceLocation getBeginLoc() const
Definition ExprCXX.h:166
Represents a list-initialization with parenthesis.
Definition ExprCXX.h:5141
static CXXParenListInitExpr * Create(ASTContext &C, ArrayRef< Expr * > Args, QualType T, unsigned NumUserSpecifiedExprs, SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Definition ExprCXX.cpp:2005
static CXXParenListInitExpr * CreateEmpty(ASTContext &C, unsigned numExprs, EmptyShell Empty)
Definition ExprCXX.cpp:2014
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an '->' (otherwise,...
Definition ExprCXX.h:2813
CXXPseudoDestructorExpr(const ASTContext &Context, Expr *Base, bool isArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, TypeSourceInfo *ScopeType, SourceLocation ColonColonLoc, SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType)
Definition ExprCXX.cpp:371
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.cpp:392
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition ExprCXX.cpp:385
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
capture_const_iterator captures_end() const
Definition DeclCXX.h:1107
capture_const_iterator captures_begin() const
Definition DeclCXX.h:1101
static CXXReflectExpr * Create(ASTContext &C, SourceLocation OperatorLoc, TypeSourceInfo *TL)
Definition ExprCXX.cpp:1950
static CXXReflectExpr * CreateEmpty(ASTContext &C)
Definition ExprCXX.cpp:1956
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition ExprCXX.h:530
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:872
static CXXReinterpretCastExpr * CreateEmpty(const ASTContext &Context, unsigned pathSize)
Definition ExprCXX.cpp:889
Expr * getSemanticForm()
Get an equivalent semantic form for this expression.
Definition ExprCXX.h:308
bool isReversed() const
Determine whether this expression was rewritten in reverse form.
Definition ExprCXX.h:326
DecomposedForm getDecomposedForm() const LLVM_READONLY
Decompose this operator into its syntactic form.
Definition ExprCXX.cpp:65
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:223
SourceLocation getRParenLoc() const
Definition ExprCXX.h:2223
A C++ static_cast expression (C++ [expr.static.cast]).
Definition ExprCXX.h:440
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:782
static CXXStaticCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize, bool hasFPFeatures)
Definition ExprCXX.cpp:799
Represents a C++ functional cast expression that builds a temporary object.
Definition ExprCXX.h:1903
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:1148
TypeSourceInfo * getTypeSourceInfo() const
Definition ExprCXX.h:1932
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.cpp:1175
static CXXTemporaryObjectExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs)
Definition ExprCXX.cpp:1163
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:1171
Represents a C++ temporary.
Definition ExprCXX.h:1463
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
Definition ExprCXX.cpp:1115
static CXXThisExpr * CreateEmpty(const ASTContext &Ctx)
Definition ExprCXX.cpp:1593
static CXXThisExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType Ty, bool IsImplicit)
Definition ExprCXX.cpp:1587
bool isTypeOperand() const
Definition ExprCXX.h:888
QualType getTypeOperand(const ASTContext &Context) const
Retrieves the type operand of this typeid() expression after various required adjustments (removing r...
Definition ExprCXX.cpp:161
Expr * getExprOperand() const
Definition ExprCXX.h:899
bool isMostDerived(const ASTContext &Context) const
Best-effort check if the expression operand refers to a most derived object.
Definition ExprCXX.cpp:149
bool isPotentiallyEvaluated() const
Determine whether this typeid has a type operand which is potentially evaluated, per C++11 [expr....
Definition ExprCXX.cpp:134
bool hasNullCheck() const
Whether this is of a form like "typeid(*ptr)" that can throw a std::bad_typeid if a pointer is a null...
Definition ExprCXX.cpp:200
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition ExprCXX.h:3744
static CXXUnresolvedConstructExpr * Create(const ASTContext &Context, QualType T, TypeSourceInfo *TSI, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool IsListInit)
Definition ExprCXX.cpp:1490
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:1506
static CXXUnresolvedConstructExpr * CreateEmpty(const ASTContext &Context, unsigned NumArgs)
Definition ExprCXX.cpp:1500
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this __uuidof() expression after various required adjustments (removing...
Definition ExprCXX.cpp:215
bool isTypeOperand() const
Definition ExprCXX.h:1102
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:2946
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition Expr.h:3150
static unsigned sizeOfTrailingObjects(unsigned NumPreArgs, unsigned NumArgs, bool HasFPFeatures)
Return the size in bytes needed for the trailing objects.
Definition Expr.h:3029
Expr * getCallee()
Definition Expr.h:3093
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Definition Expr.h:3137
CallExpr(StmtClass SC, Expr *Fn, ArrayRef< Expr * > PreArgs, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs, ADLCallKind UsesADL)
Build a call expression, assuming that appropriate storage has been allocated for the trailing object...
Definition Expr.cpp:1473
static constexpr unsigned sizeToAllocateForCallExprSubclass(unsigned SizeOfTrailingObjects)
Definition Expr.h:2986
SourceLocation getRParenLoc() const
Definition Expr.h:3277
static constexpr ADLCallKind UsesADL
Definition Expr.h:3013
Decl * getCalleeDecl()
Definition Expr.h:3123
CastKind getCastKind() const
Definition Expr.h:3723
Expr * getSubExpr()
Definition Expr.h:3729
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition Stmt.h:1746
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:1462
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
bool isParameterPack() const
Whether this declaration is a parameter pack.
Definition DeclBase.cpp:266
bool hasAttr() const
Definition DeclBase.h:585
const AssociatedConstraint & getTrailingRequiresClause() const
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
Definition Decl.h:855
A qualified reference to a name whose declaration cannot yet be resolved.
Definition ExprCXX.h:3510
static DependentScopeDeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
Definition ExprCXX.cpp:544
static DependentScopeDeclRefExpr * CreateEmpty(const ASTContext &Context, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition ExprCXX.cpp:559
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to.
Definition Expr.h:3953
static ExprWithCleanups * Create(const ASTContext &C, EmptyShell empty, unsigned numObjects)
Definition ExprCXX.cpp:1466
This represents one expression.
Definition Expr.h:112
bool isGLValue() const
Definition Expr.h:287
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:3117
void setType(QualType t)
Definition Expr.h:145
bool isValueDependent() const
Determines whether the value of this expression depends on.
Definition Expr.h:177
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition Expr.h:194
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Definition Expr.cpp:3078
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
Definition Expr.cpp:3086
Expr()=delete
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition Expr.cpp:3214
QualType getType() const
Definition Expr.h:144
void setDependence(ExprDependence Deps)
Each concrete expr subclass is expected to compute its dependence and call this in the constructor.
Definition Expr.h:137
Represents difference between two FPOptions values.
bool requiresTrailingStorage() const
Represents a member of a struct/union/class.
Definition Decl.h:3178
FullExpr - Represents a "full-expression" node.
Definition Expr.h:1052
Represents a function declaration or definition.
Definition Decl.h:2018
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Definition Decl.cpp:3274
bool isReservedGlobalPlacementOperator() const
Determines whether this operator new or delete is one of the reserved global placement operators: voi...
Definition Decl.cpp:3398
Represents a reference to a function parameter pack, init-capture pack, or binding pack that has been...
Definition ExprCXX.h:4841
static FunctionParmPackExpr * Create(const ASTContext &Context, QualType T, ValueDecl *ParamPack, SourceLocation NameLoc, ArrayRef< ValueDecl * > Params)
Definition ExprCXX.cpp:1816
static FunctionParmPackExpr * CreateEmpty(const ASTContext &Context, unsigned NumParams)
Definition ExprCXX.cpp:1824
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5362
Declaration of a template function.
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.
bool capturesVLAType() const
Determine whether this captures a variable length array bound expression.
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:1236
LambdaCaptureKind getCaptureKind() const
Determine the kind of capture.
Definition ExprCXX.cpp:1266
bool capturesThis() const
Determine whether this capture handles the C++ this pointer.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition ExprCXX.h:1972
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Definition ExprCXX.cpp:1365
static LambdaExpr * CreateDeserialized(const ASTContext &C, unsigned NumCaptures)
Construct a new lambda expression that will be deserialized from an external source.
Definition ExprCXX.cpp:1334
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:1314
Stmt * getBody() const
Retrieve the body of the lambda.
Definition ExprCXX.cpp:1348
bool isMutable() const
Determine whether the lambda is mutable, meaning that any captures values can be modified.
Definition ExprCXX.cpp:1430
capture_iterator implicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of implicit lambda captures.
Definition ExprCXX.cpp:1394
unsigned capture_size() const
Determine the number of captures in this lambda.
Definition ExprCXX.h:2053
capture_range explicit_captures() const
Retrieve this lambda's explicit captures.
Definition ExprCXX.cpp:1386
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
Definition ExprCXX.cpp:1360
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
Definition ExprCXX.cpp:1406
const CompoundStmt * getCompoundStmtBody() const
Retrieve the CompoundStmt representing the body of the lambda.
Definition ExprCXX.cpp:1353
capture_range implicit_captures() const
Retrieve this lambda's implicit captures.
Definition ExprCXX.cpp:1398
const AssociatedConstraint & getTrailingRequiresClause() const
Get the trailing requires clause, if any.
Definition ExprCXX.cpp:1426
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it,...
Definition ExprCXX.cpp:1416
ArrayRef< NamedDecl * > getExplicitTemplateParameters() const
Get the template parameters were explicitly specified (as opposed to being invented by use of an auto...
Definition ExprCXX.cpp:1421
capture_iterator implicit_capture_begin() const
Retrieve an iterator pointing to the first implicit lambda capture.
Definition ExprCXX.cpp:1390
capture_iterator explicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
Definition ExprCXX.cpp:1381
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition ExprCXX.cpp:1369
llvm::iterator_range< capture_iterator > capture_range
An iterator over a range of lambda captures.
Definition ExprCXX.h:2040
const LambdaCapture * capture_iterator
An iterator that walks over the captures of the lambda, both implicit and explicit.
Definition ExprCXX.h:2037
capture_iterator explicit_capture_begin() const
Retrieve an iterator pointing to the first explicit lambda capture.
Definition ExprCXX.cpp:1377
child_range children()
Includes the captures and the body of the lambda.
Definition ExprCXX.cpp:1432
FunctionTemplateDecl * getDependentCallOperator() const
Retrieve the function template call operator associated with this lambda expression.
Definition ExprCXX.cpp:1411
capture_range captures() const
Retrieve this lambda's captures.
Definition ExprCXX.cpp:1373
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Definition ExprCXX.cpp:1402
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
Definition DeclCXX.h:3313
static LifetimeExtendedTemporaryDecl * Create(Expr *Temp, ValueDecl *EDec, unsigned Mangling)
Definition DeclCXX.h:3338
MaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference, LifetimeExtendedTemporaryDecl *MTD=nullptr)
Definition ExprCXX.cpp:1830
ValueDecl * getExtendingDecl()
Get the declaration which triggered the lifetime-extension of this temporary, if any.
Definition ExprCXX.h:4970
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:1861
void setExtendingDecl(ValueDecl *ExtendedBy, unsigned ManglingNumber)
Definition ExprCXX.cpp:1844
This represents a decl that may have a name.
Definition Decl.h:274
A C++ nested-name-specifier augmented with source location information.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
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:3132
ASTTemplateKWAndArgsInfo * getTrailingASTTemplateKWAndArgsInfo()
Return the optional template keyword and arguments info.
Definition ExprCXX.h:4282
NestedNameSpecifier getQualifier() const
Fetches the nested-name qualifier, if one was given.
Definition ExprCXX.h:3248
TemplateArgumentLoc * getTrailingTemplateArgumentLoc()
Return the optional template arguments.
Definition ExprCXX.h:4292
DeclAccessPair * getTrailingResults()
Return the results. Defined after UnresolvedMemberExpr.
Definition ExprCXX.h:4276
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:479
NamedDecl * getPackDecl() const
Definition ExprCXX.cpp:1752
static PackIndexingExpr * CreateDeserialized(ASTContext &Context, unsigned NumTransformedExprs)
Definition ExprCXX.cpp:1761
Expr * getPackIdExpression() const
Definition ExprCXX.h:4624
static PackIndexingExpr * Create(ASTContext &Context, SourceLocation EllipsisLoc, SourceLocation RSquareLoc, Expr *PackIdExpr, Expr *IndexExpr, std::optional< int64_t > Index, ArrayRef< Expr * > SubstitutedExprs={}, bool FullySubstituted=false)
Definition ExprCXX.cpp:1735
Represents a parameter to a function.
Definition Decl.h:1808
Expr * getDefaultArg()
Definition Decl.cpp:3005
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition TypeBase.h:3383
Stores the type being destroyed by a pseudo-destructor expression.
Definition ExprCXX.h:2698
A (possibly-)qualified type.
Definition TypeBase.h:937
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
Definition TypeBase.h:8520
bool isConstant(const ASTContext &Ctx) const
Definition TypeBase.h:1097
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
Definition TypeBase.h:8621
The collection of all-type qualifiers we support.
Definition TypeBase.h:331
static SizeOfPackExpr * CreateDeserialized(ASTContext &Context, unsigned NumPartialArgs)
Definition ExprCXX.cpp:1723
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs={})
Definition ExprCXX.cpp:1711
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
void setEnd(SourceLocation e)
Stmt - This represents one statement.
Definition Stmt.h:86
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.cpp:367
CXXUnresolvedConstructExprBitfields CXXUnresolvedConstructExprBits
Definition Stmt.h:1391
ExprWithCleanupsBitfields ExprWithCleanupsBits
Definition Stmt.h:1390
StmtClass getStmtClass() const
Definition Stmt.h:1499
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition Stmt.cpp:343
OverloadExprBitfields OverloadExprBits
Definition Stmt.h:1393
CXXConstructExprBitfields CXXConstructExprBits
Definition Stmt.h:1389
CXXDependentScopeMemberExprBitfields CXXDependentScopeMemberExprBits
Definition Stmt.h:1392
TypeTraitExprBitfields TypeTraitExprBits
Definition Stmt.h:1387
CXXNewExprBitfields CXXNewExprBits
Definition Stmt.h:1385
llvm::iterator_range< child_iterator > child_range
Definition Stmt.h:1588
CXXFoldExprBitfields CXXFoldExprBits
Definition Stmt.h:1402
CXXOperatorCallExprBitfields CXXOperatorCallExprBits
Definition Stmt.h:1376
CXXDefaultInitExprBitfields CXXDefaultInitExprBits
Definition Stmt.h:1383
DependentScopeDeclRefExprBitfields DependentScopeDeclRefExprBits
Definition Stmt.h:1388
llvm::iterator_range< const_child_iterator > const_child_range
Definition Stmt.h:1589
CXXDefaultArgExprBitfields CXXDefaultArgExprBits
Definition Stmt.h:1382
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
Definition ExprCXX.h:4709
QualType getParameterType(const ASTContext &Ctx) const
Determine the substituted type of the template parameter.
Definition ExprCXX.cpp:1768
NonTypeTemplateParmDecl * getParameter() const
Definition ExprCXX.cpp:1730
TemplateArgument getArgumentPack() const
Retrieve the template argument pack containing the substituted template arguments.
Definition ExprCXX.cpp:1799
NonTypeTemplateParmDecl * getParameterPack() const
Retrieve the non-type template parameter pack being substituted.
Definition ExprCXX.cpp:1794
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
Definition ExprCXX.h:4788
A convenient class for passing around template argument information.
Location wrapper for a TemplateArgument.
Represents a template argument.
Stores a list of template parameters for a TemplateDecl and its derived classes.
SourceLocation getBeginLoc() const
Get the begin source location.
Definition TypeLoc.cpp:193
A container of type source information.
Definition TypeBase.h:8407
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition TypeLoc.h:267
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition ExprCXX.h:2900
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:1914
static TypeTraitExpr * CreateDeserialized(const ASTContext &C, bool IsStoredAsBool, unsigned NumArgs)
Definition ExprCXX.cpp:1934
The base class of the type hierarchy.
Definition TypeBase.h:1871
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
Definition Type.cpp:3108
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition Type.h:26
bool isVoidPointerType() const
Definition Type.cpp:749
bool isPointerType() const
Definition TypeBase.h:8673
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
Definition TypeBase.h:9083
const T * castAs() const
Member-template castAs<specific type>.
Definition TypeBase.h:9333
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
Definition Type.cpp:789
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
Definition Type.cpp:2229
bool isPointerOrReferenceType() const
Definition TypeBase.h:8677
bool isFloatingType() const
Definition Type.cpp:2389
bool isAnyPointerType() const
Definition TypeBase.h:8681
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition ExprCXX.h:3390
static UnresolvedLookupExpr * CreateEmpty(const ASTContext &Context, unsigned NumResults, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition ExprCXX.cpp:467
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
Definition ExprCXX.cpp:432
QualType getBaseType() const
Definition ExprCXX.h:4208
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
Definition ExprCXX.h:4218
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:1654
CXXRecordDecl * getNamingClass()
Retrieve the naming class of this lookup.
Definition ExprCXX.cpp:1685
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:1647
static UnresolvedMemberExpr * CreateEmpty(const ASTContext &Context, unsigned NumResults, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition ExprCXX.cpp:1673
The iterator over UnresolvedSets.
LiteralOperatorKind getLiteralOperatorKind() const
Returns the kind of literal operator invocation which this expression represents.
Definition ExprCXX.cpp:1001
const IdentifierInfo * getUDSuffix() const
Returns the ud-suffix specified for this literal.
Definition ExprCXX.cpp:1030
static UserDefinedLiteral * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation LitEndLoc, SourceLocation SuffixLoc, FPOptionsOverride FPFeatures)
Definition ExprCXX.cpp:968
static UserDefinedLiteral * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPOptions, EmptyShell Empty)
Definition ExprCXX.cpp:986
Expr * getCookedLiteral()
If this is not a raw user-defined literal, get the underlying cooked literal (representing the litera...
Definition ExprCXX.cpp:1022
LiteralOperatorKind
The kind of literal operator which is invoked.
Definition ExprCXX.h:672
@ LOK_String
operator "" X (const CharT *, size_t)
Definition ExprCXX.h:686
@ LOK_Raw
Raw form: operator "" X (const char *)
Definition ExprCXX.h:674
@ LOK_Floating
operator "" X (long double)
Definition ExprCXX.h:683
@ LOK_Integer
operator "" X (unsigned long long)
Definition ExprCXX.h:680
@ LOK_Template
Raw form: operator "" X<cs...> ()
Definition ExprCXX.h:677
@ LOK_Character
operator "" X (CharT)
Definition ExprCXX.h:689
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:712
QualType getType() const
Definition Decl.h:723
Definition SPIR.cpp:47
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
bool isa(CodeGen::Address addr)
Definition Address.h:330
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
CXXConstructionKind
Definition ExprCXX.h:1544
@ OK_Ordinary
An ordinary object is located at an address in memory.
Definition Specifiers.h:152
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)
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
bool isAlignedAllocation(AlignedAllocationMode Mode)
Definition ExprCXX.h:2269
@ Result
The result type of a method or function.
Definition TypeBase.h:905
OptionalUnsigned< unsigned > UnsignedOrNone
bool isTypeAwareAllocation(TypeAwareAllocationMode Mode)
Definition ExprCXX.h:2257
CastKind
CastKind - The kind of operation required for a conversion.
std::tuple< NamedDecl *, TemplateArgument > getReplacedTemplateParameter(Decl *D, unsigned Index)
Internal helper used by Subst* nodes to retrieve a parameter from the AssociatedDecl,...
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:133
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition Specifiers.h:136
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
Definition Specifiers.h:145
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition Specifiers.h:140
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
Definition ASTContext.h:151
U cast(CodeGen::Address addr)
Definition Address.h:327
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5972
TypeTrait
Names for traits that operate specifically on types.
Definition TypeTraits.h:21
@ TT_Last
Definition TypeTraits.h:36
CXXNewInitializationStyle
Definition ExprCXX.h:2244
@ Parens
New-expression has a C++98 paren-delimited initializer.
Definition ExprCXX.h:2249
@ None
New-expression has no initializer as written.
Definition ExprCXX.h:2246
@ Braces
New-expression has a C++11 list-initializer.
Definition ExprCXX.h:2252
@ Implicit
An implicit conversion.
Definition Sema.h:440
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
#define false
Definition stdbool.h:26
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
void initializeFrom(SourceLocation TemplateKWLoc, const TemplateArgumentListInfo &List, TemplateArgumentLoc *OutArgArray)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
AlignedAllocationMode PassAlignment
Definition ExprCXX.h:2311
TypeAwareAllocationMode PassTypeIdentity
Definition ExprCXX.h:2310
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....
Definition Stmt.h:1439