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
153 if (const CXXRecordDecl *RD = E->getType()->getAsCXXRecordDecl())
154 if (RD->isEffectivelyFinal())
155 return true;
156
157 if (const auto *DRE = dyn_cast<DeclRefExpr>(E)) {
158 QualType Ty = DRE->getDecl()->getType();
159 if (!Ty->isPointerOrReferenceType())
160 return true;
161 }
162
163 return false;
164}
165
167 assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
168 Qualifiers Quals;
169 return Context.getUnqualifiedArrayType(
170 cast<TypeSourceInfo *>(Operand)->getType().getNonReferenceType(), Quals);
171}
172
173static bool isGLValueFromPointerDeref(const Expr *E) {
174 E = E->IgnoreParens();
175
176 if (const auto *CE = dyn_cast<CastExpr>(E)) {
177 if (!CE->getSubExpr()->isGLValue())
178 return false;
179 return isGLValueFromPointerDeref(CE->getSubExpr());
180 }
181
182 if (const auto *OVE = dyn_cast<OpaqueValueExpr>(E))
183 return isGLValueFromPointerDeref(OVE->getSourceExpr());
184
185 if (const auto *BO = dyn_cast<BinaryOperator>(E))
186 if (BO->getOpcode() == BO_Comma)
187 return isGLValueFromPointerDeref(BO->getRHS());
188
189 if (const auto *ACO = dyn_cast<AbstractConditionalOperator>(E))
190 return isGLValueFromPointerDeref(ACO->getTrueExpr()) ||
191 isGLValueFromPointerDeref(ACO->getFalseExpr());
192
193 // C++11 [expr.sub]p1:
194 // The expression E1[E2] is identical (by definition) to *((E1)+(E2))
196 return true;
197
198 if (const auto *UO = dyn_cast<UnaryOperator>(E))
199 if (UO->getOpcode() == UO_Deref)
200 return true;
201
202 return false;
203}
204
207 return false;
208
209 // C++ [expr.typeid]p2:
210 // If the glvalue expression is obtained by applying the unary * operator to
211 // a pointer and the pointer is a null pointer value, the typeid expression
212 // throws the std::bad_typeid exception.
213 //
214 // However, this paragraph's intent is not clear. We choose a very generous
215 // interpretation which implores us to consider comma operators, conditional
216 // operators, parentheses and other such constructs.
218}
219
221 assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
222 Qualifiers Quals;
223 return Context.getUnqualifiedArrayType(
224 cast<TypeSourceInfo *>(Operand)->getType().getNonReferenceType(), Quals);
225}
226
227// CXXScalarValueInitExpr
229 return TypeInfo ? TypeInfo->getTypeLoc().getBeginLoc() : getRParenLoc();
230}
231
232// CXXNewExpr
233CXXNewExpr::CXXNewExpr(bool IsGlobalNew, FunctionDecl *OperatorNew,
234 FunctionDecl *OperatorDelete,
236 bool UsualArrayDeleteWantsSize,
237 ArrayRef<Expr *> PlacementArgs, SourceRange TypeIdParens,
238 std::optional<Expr *> ArraySize,
239 CXXNewInitializationStyle InitializationStyle,
241 TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
242 SourceRange DirectInitRange)
243 : Expr(CXXNewExprClass, Ty, VK_PRValue, OK_Ordinary),
244 OperatorNew(OperatorNew), OperatorDelete(OperatorDelete),
245 AllocatedTypeInfo(AllocatedTypeInfo), Range(Range),
246 DirectInitRange(DirectInitRange) {
247
248 assert((Initializer != nullptr ||
249 InitializationStyle == CXXNewInitializationStyle::None) &&
250 "Only CXXNewInitializationStyle::None can have no initializer!");
251
252 CXXNewExprBits.IsGlobalNew = IsGlobalNew;
253 CXXNewExprBits.IsArray = ArraySize.has_value();
254 CXXNewExprBits.ShouldPassAlignment = isAlignedAllocation(IAP.PassAlignment);
255 CXXNewExprBits.ShouldPassTypeIdentity =
257 CXXNewExprBits.UsualArrayDeleteWantsSize = UsualArrayDeleteWantsSize;
258 CXXNewExprBits.HasInitializer = Initializer != nullptr;
259 CXXNewExprBits.StoredInitializationStyle =
260 llvm::to_underlying(InitializationStyle);
261 bool IsParenTypeId = TypeIdParens.isValid();
262 CXXNewExprBits.IsParenTypeId = IsParenTypeId;
263 CXXNewExprBits.NumPlacementArgs = PlacementArgs.size();
264
265 if (ArraySize)
266 getTrailingObjects<Stmt *>()[arraySizeOffset()] = *ArraySize;
267 if (Initializer)
268 getTrailingObjects<Stmt *>()[initExprOffset()] = Initializer;
269 llvm::copy(PlacementArgs,
270 getTrailingObjects<Stmt *>() + placementNewArgsOffset());
271 if (IsParenTypeId)
272 getTrailingObjects<SourceRange>()[0] = TypeIdParens;
273
274 switch (getInitializationStyle()) {
276 this->Range.setEnd(DirectInitRange.getEnd());
277 break;
279 this->Range.setEnd(getInitializer()->getSourceRange().getEnd());
280 break;
281 default:
282 if (IsParenTypeId)
283 this->Range.setEnd(TypeIdParens.getEnd());
284 break;
285 }
286
288}
289
290CXXNewExpr::CXXNewExpr(EmptyShell Empty, bool IsArray,
291 unsigned NumPlacementArgs, bool IsParenTypeId)
292 : Expr(CXXNewExprClass, Empty) {
293 CXXNewExprBits.IsArray = IsArray;
294 CXXNewExprBits.NumPlacementArgs = NumPlacementArgs;
295 CXXNewExprBits.IsParenTypeId = IsParenTypeId;
296}
297
299 const ASTContext &Ctx, bool IsGlobalNew, FunctionDecl *OperatorNew,
300 FunctionDecl *OperatorDelete, const ImplicitAllocationParameters &IAP,
301 bool UsualArrayDeleteWantsSize, ArrayRef<Expr *> PlacementArgs,
302 SourceRange TypeIdParens, std::optional<Expr *> ArraySize,
303 CXXNewInitializationStyle InitializationStyle, Expr *Initializer,
304 QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
305 SourceRange DirectInitRange) {
306 bool IsArray = ArraySize.has_value();
307 bool HasInit = Initializer != nullptr;
308 unsigned NumPlacementArgs = PlacementArgs.size();
309 bool IsParenTypeId = TypeIdParens.isValid();
310 void *Mem =
311 Ctx.Allocate(totalSizeToAlloc<Stmt *, SourceRange>(
312 IsArray + HasInit + NumPlacementArgs, IsParenTypeId),
313 alignof(CXXNewExpr));
314 return new (Mem) CXXNewExpr(
315 IsGlobalNew, OperatorNew, OperatorDelete, IAP, UsualArrayDeleteWantsSize,
316 PlacementArgs, TypeIdParens, ArraySize, InitializationStyle, Initializer,
317 Ty, AllocatedTypeInfo, Range, DirectInitRange);
318}
319
320CXXNewExpr *CXXNewExpr::CreateEmpty(const ASTContext &Ctx, bool IsArray,
321 bool HasInit, unsigned NumPlacementArgs,
322 bool IsParenTypeId) {
323 void *Mem =
324 Ctx.Allocate(totalSizeToAlloc<Stmt *, SourceRange>(
325 IsArray + HasInit + NumPlacementArgs, IsParenTypeId),
326 alignof(CXXNewExpr));
327 return new (Mem)
328 CXXNewExpr(EmptyShell(), IsArray, NumPlacementArgs, IsParenTypeId);
329}
330
332 if (getOperatorNew()->getLangOpts().CheckNew)
333 return true;
334 return !getOperatorNew()->hasAttr<ReturnsNonNullAttr>() &&
336 ->getType()
338 ->isNothrow() &&
340}
341
342// CXXDeleteExpr
344 const Expr *Arg = getArgument();
345
346 // For a destroying operator delete, we may have implicitly converted the
347 // pointer type to the type of the parameter of the 'operator delete'
348 // function.
349 while (const auto *ICE = dyn_cast<ImplicitCastExpr>(Arg)) {
350 if (ICE->getCastKind() == CK_DerivedToBase ||
351 ICE->getCastKind() == CK_UncheckedDerivedToBase ||
352 ICE->getCastKind() == CK_NoOp) {
353 assert((ICE->getCastKind() == CK_NoOp ||
354 getOperatorDelete()->isDestroyingOperatorDelete()) &&
355 "only a destroying operator delete can have a converted arg");
356 Arg = ICE->getSubExpr();
357 } else
358 break;
359 }
360
361 // The type-to-delete may not be a pointer if it's a dependent type.
362 const QualType ArgType = Arg->getType();
363
364 if (ArgType->isDependentType() && !ArgType->isPointerType())
365 return QualType();
366
367 return ArgType->castAs<PointerType>()->getPointeeType();
368}
369
370// CXXPseudoDestructorExpr
372 : Type(Info) {
373 Location = Info->getTypeLoc().getBeginLoc();
374}
375
377 const ASTContext &Context, Expr *Base, bool isArrow,
378 SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc,
379 TypeSourceInfo *ScopeType, SourceLocation ColonColonLoc,
380 SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType)
381 : Expr(CXXPseudoDestructorExprClass, Context.BoundMemberTy, VK_PRValue,
383 Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
384 OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc),
385 ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc),
386 DestroyedType(DestroyedType) {
388}
389
391 if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo())
392 return TInfo->getType();
393
394 return QualType();
395}
396
398 SourceLocation End = DestroyedType.getLocation();
399 if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo())
400 End = TInfo->getTypeLoc().getSourceRange().getEnd();
401 return End;
402}
403
406 if (std::distance(Begin, End) != 1)
407 return false;
408 NamedDecl *ND = *Begin;
409 if (const auto *TTP = llvm::dyn_cast<TemplateTemplateParmDecl>(ND))
410 return TTP->isParameterPack();
411 return false;
412}
413
414// UnresolvedLookupExpr
415UnresolvedLookupExpr::UnresolvedLookupExpr(
416 const ASTContext &Context, CXXRecordDecl *NamingClass,
417 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
418 const DeclarationNameInfo &NameInfo, bool RequiresADL,
419 const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin,
420 UnresolvedSetIterator End, bool KnownDependent,
421 bool KnownInstantiationDependent)
422 : OverloadExpr(
423 UnresolvedLookupExprClass, Context, QualifierLoc, TemplateKWLoc,
424 NameInfo, TemplateArgs, Begin, End, KnownDependent,
425 KnownInstantiationDependent,
427 NamingClass(NamingClass) {
428 UnresolvedLookupExprBits.RequiresADL = RequiresADL;
429}
430
431UnresolvedLookupExpr::UnresolvedLookupExpr(EmptyShell Empty,
432 unsigned NumResults,
433 bool HasTemplateKWAndArgsInfo)
434 : OverloadExpr(UnresolvedLookupExprClass, Empty, NumResults,
435 HasTemplateKWAndArgsInfo) {}
436
437UnresolvedLookupExpr *UnresolvedLookupExpr::Create(
438 const ASTContext &Context, CXXRecordDecl *NamingClass,
439 NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
440 bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End,
441 bool KnownDependent, bool KnownInstantiationDependent) {
442 unsigned NumResults = End - Begin;
443 unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
444 TemplateArgumentLoc>(NumResults, 0, 0);
445 void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
446 return new (Mem) UnresolvedLookupExpr(
447 Context, NamingClass, QualifierLoc,
448 /*TemplateKWLoc=*/SourceLocation(), NameInfo, RequiresADL,
449 /*TemplateArgs=*/nullptr, Begin, End, KnownDependent,
450 KnownInstantiationDependent);
451}
452
453UnresolvedLookupExpr *UnresolvedLookupExpr::Create(
454 const ASTContext &Context, CXXRecordDecl *NamingClass,
455 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
456 const DeclarationNameInfo &NameInfo, bool RequiresADL,
458 UnresolvedSetIterator End, bool KnownDependent,
459 bool KnownInstantiationDependent) {
460 unsigned NumResults = End - Begin;
461 bool HasTemplateKWAndArgsInfo = Args || TemplateKWLoc.isValid();
462 unsigned NumTemplateArgs = Args ? Args->size() : 0;
463 unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
465 NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
466 void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
467 return new (Mem) UnresolvedLookupExpr(
468 Context, NamingClass, QualifierLoc, TemplateKWLoc, NameInfo, RequiresADL,
469 Args, Begin, End, KnownDependent, KnownInstantiationDependent);
470}
471
473 const ASTContext &Context, unsigned NumResults,
474 bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs) {
475 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
476 unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
478 NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
479 void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
480 return new (Mem)
481 UnresolvedLookupExpr(EmptyShell(), NumResults, HasTemplateKWAndArgsInfo);
482}
483
485 NestedNameSpecifierLoc QualifierLoc,
486 SourceLocation TemplateKWLoc,
487 const DeclarationNameInfo &NameInfo,
488 const TemplateArgumentListInfo *TemplateArgs,
490 UnresolvedSetIterator End, bool KnownDependent,
491 bool KnownInstantiationDependent,
492 bool KnownContainsUnexpandedParameterPack)
493 : Expr(SC, Context.OverloadTy, VK_LValue, OK_Ordinary), NameInfo(NameInfo),
494 QualifierLoc(QualifierLoc) {
495 unsigned NumResults = End - Begin;
496 OverloadExprBits.NumResults = NumResults;
497 OverloadExprBits.HasTemplateKWAndArgsInfo =
498 (TemplateArgs != nullptr ) || TemplateKWLoc.isValid();
499
500 if (NumResults) {
501 // Copy the results to the trailing array past UnresolvedLookupExpr
502 // or UnresolvedMemberExpr.
504 memcpy(Results, Begin.I, NumResults * sizeof(DeclAccessPair));
505 }
506
507 if (TemplateArgs) {
508 auto Deps = TemplateArgumentDependence::None;
510 TemplateKWLoc, *TemplateArgs, getTrailingTemplateArgumentLoc(), Deps);
511 } else if (TemplateKWLoc.isValid()) {
512 getTrailingASTTemplateKWAndArgsInfo()->initializeFrom(TemplateKWLoc);
513 }
514
515 setDependence(computeDependence(this, KnownDependent,
516 KnownInstantiationDependent,
517 KnownContainsUnexpandedParameterPack));
518 if (isTypeDependent())
519 setType(Context.DependentTy);
520}
521
523 bool HasTemplateKWAndArgsInfo)
524 : Expr(SC, Empty) {
525 OverloadExprBits.NumResults = NumResults;
526 OverloadExprBits.HasTemplateKWAndArgsInfo = HasTemplateKWAndArgsInfo;
527}
528
529// DependentScopeDeclRefExpr
530DependentScopeDeclRefExpr::DependentScopeDeclRefExpr(
531 QualType Ty, NestedNameSpecifierLoc QualifierLoc,
532 SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo,
533 const TemplateArgumentListInfo *Args)
534 : Expr(DependentScopeDeclRefExprClass, Ty, VK_LValue, OK_Ordinary),
535 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {
536 DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo =
537 (Args != nullptr) || TemplateKWLoc.isValid();
538 if (Args) {
539 auto Deps = TemplateArgumentDependence::None;
540 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
541 TemplateKWLoc, *Args, getTrailingObjects<TemplateArgumentLoc>(), Deps);
542 } else if (TemplateKWLoc.isValid()) {
543 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
544 TemplateKWLoc);
545 }
547}
548
549DependentScopeDeclRefExpr *DependentScopeDeclRefExpr::Create(
550 const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc,
551 SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo,
552 const TemplateArgumentListInfo *Args) {
553 assert(QualifierLoc && "should be created for dependent qualifiers");
554 bool HasTemplateKWAndArgsInfo = Args || TemplateKWLoc.isValid();
555 std::size_t Size =
556 totalSizeToAlloc<ASTTemplateKWAndArgsInfo, TemplateArgumentLoc>(
557 HasTemplateKWAndArgsInfo, Args ? Args->size() : 0);
558 void *Mem = Context.Allocate(Size);
559 return new (Mem) DependentScopeDeclRefExpr(Context.DependentTy, QualifierLoc,
560 TemplateKWLoc, NameInfo, Args);
561}
562
565 bool HasTemplateKWAndArgsInfo,
566 unsigned NumTemplateArgs) {
567 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
568 std::size_t Size =
569 totalSizeToAlloc<ASTTemplateKWAndArgsInfo, TemplateArgumentLoc>(
570 HasTemplateKWAndArgsInfo, NumTemplateArgs);
571 void *Mem = Context.Allocate(Size);
572 auto *E = new (Mem) DependentScopeDeclRefExpr(
574 DeclarationNameInfo(), nullptr);
575 E->DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo =
576 HasTemplateKWAndArgsInfo;
577 return E;
578}
579
581 if (const auto *TOE = dyn_cast<CXXTemporaryObjectExpr>(this))
582 return TOE->getBeginLoc();
583 return getLocation();
584}
585
587 if (const auto *TOE = dyn_cast<CXXTemporaryObjectExpr>(this))
588 return TOE->getEndLoc();
589
590 if (ParenOrBraceRange.isValid())
591 return ParenOrBraceRange.getEnd();
592
594 for (unsigned I = getNumArgs(); I > 0; --I) {
595 const Expr *Arg = getArg(I-1);
596 if (!Arg->isDefaultArgument()) {
597 SourceLocation NewEnd = Arg->getEndLoc();
598 if (NewEnd.isValid()) {
599 End = NewEnd;
600 break;
601 }
602 }
603 }
604
605 return End;
606}
607
608CXXOperatorCallExpr::CXXOperatorCallExpr(OverloadedOperatorKind OpKind,
609 Expr *Fn, ArrayRef<Expr *> Args,
611 SourceLocation OperatorLoc,
612 FPOptionsOverride FPFeatures,
613 ADLCallKind UsesADL, bool IsReversed)
614 : CallExpr(CXXOperatorCallExprClass, Fn, /*PreArgs=*/{}, Args, Ty, VK,
615 OperatorLoc, FPFeatures, /*MinNumArgs=*/0, UsesADL) {
616 CXXOperatorCallExprBits.OperatorKind = OpKind;
617 CXXOperatorCallExprBits.IsReversed = IsReversed;
618 assert(
619 (CXXOperatorCallExprBits.OperatorKind == static_cast<unsigned>(OpKind)) &&
620 "OperatorKind overflow!");
621 BeginLoc = getSourceRangeImpl().getBegin();
622}
623
624CXXOperatorCallExpr::CXXOperatorCallExpr(unsigned NumArgs, bool HasFPFeatures,
625 EmptyShell Empty)
626 : CallExpr(CXXOperatorCallExprClass, /*NumPreArgs=*/0, NumArgs,
627 HasFPFeatures, Empty) {}
628
629CXXOperatorCallExpr *CXXOperatorCallExpr::Create(
630 const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn,
632 SourceLocation OperatorLoc, FPOptionsOverride FPFeatures,
633 ADLCallKind UsesADL, bool IsReversed) {
634 // Allocate storage for the trailing objects of CallExpr.
635 unsigned NumArgs = Args.size();
636 unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
637 /*NumPreArgs=*/0, NumArgs, FPFeatures.requiresTrailingStorage());
638 void *Mem =
640 SizeOfTrailingObjects),
641 alignof(CXXOperatorCallExpr));
642 return new (Mem) CXXOperatorCallExpr(OpKind, Fn, Args, Ty, VK, OperatorLoc,
643 FPFeatures, UsesADL, IsReversed);
644}
645
646CXXOperatorCallExpr *CXXOperatorCallExpr::CreateEmpty(const ASTContext &Ctx,
647 unsigned NumArgs,
648 bool HasFPFeatures,
650 // Allocate storage for the trailing objects of CallExpr.
651 unsigned SizeOfTrailingObjects =
652 CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs, HasFPFeatures);
653 void *Mem =
655 SizeOfTrailingObjects),
656 alignof(CXXOperatorCallExpr));
657 return new (Mem) CXXOperatorCallExpr(NumArgs, HasFPFeatures, Empty);
658}
659
660SourceRange CXXOperatorCallExpr::getSourceRangeImpl() const {
662 if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
663 if (getNumArgs() == 1)
664 // Prefix operator
666 else
667 // Postfix operator
669 } else if (Kind == OO_Arrow) {
671 } else if (Kind == OO_Call) {
672 return SourceRange(getArg(0)->getBeginLoc(), getRParenLoc());
673 } else if (Kind == OO_Subscript) {
674 return SourceRange(getArg(0)->getBeginLoc(), getRParenLoc());
675 } else if (getNumArgs() == 1) {
676 return SourceRange(getOperatorLoc(), getArg(0)->getEndLoc());
677 } else if (getNumArgs() == 2) {
678 if (CXXOperatorCallExprBits.IsReversed)
679 return SourceRange(getArg(1)->getBeginLoc(), getArg(0)->getEndLoc());
680 return SourceRange(getArg(0)->getBeginLoc(), getArg(1)->getEndLoc());
681 } else {
682 return getOperatorLoc();
683 }
684}
685
686CXXMemberCallExpr::CXXMemberCallExpr(Expr *Fn, ArrayRef<Expr *> Args,
687 QualType Ty, ExprValueKind VK,
690 unsigned MinNumArgs)
691 : CallExpr(CXXMemberCallExprClass, Fn, /*PreArgs=*/{}, Args, Ty, VK, RP,
692 FPOptions, MinNumArgs, NotADL) {}
693
694CXXMemberCallExpr::CXXMemberCallExpr(unsigned NumArgs, bool HasFPFeatures,
695 EmptyShell Empty)
696 : CallExpr(CXXMemberCallExprClass, /*NumPreArgs=*/0, NumArgs, HasFPFeatures,
697 Empty) {}
698
699CXXMemberCallExpr *CXXMemberCallExpr::Create(const ASTContext &Ctx, Expr *Fn,
700 ArrayRef<Expr *> Args, QualType Ty,
703 FPOptionsOverride FPFeatures,
704 unsigned MinNumArgs) {
705 // Allocate storage for the trailing objects of CallExpr.
706 unsigned NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
707 unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
708 /*NumPreArgs=*/0, NumArgs, FPFeatures.requiresTrailingStorage());
710 SizeOfTrailingObjects),
711 alignof(CXXMemberCallExpr));
712 return new (Mem)
713 CXXMemberCallExpr(Fn, Args, Ty, VK, RP, FPFeatures, MinNumArgs);
714}
715
716CXXMemberCallExpr *CXXMemberCallExpr::CreateEmpty(const ASTContext &Ctx,
717 unsigned NumArgs,
718 bool HasFPFeatures,
720 // Allocate storage for the trailing objects of CallExpr.
721 unsigned SizeOfTrailingObjects =
722 CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs, HasFPFeatures);
724 SizeOfTrailingObjects),
725 alignof(CXXMemberCallExpr));
726 return new (Mem) CXXMemberCallExpr(NumArgs, HasFPFeatures, Empty);
727}
728
730 const Expr *Callee = getCallee()->IgnoreParens();
731 if (const auto *MemExpr = dyn_cast<MemberExpr>(Callee))
732 return MemExpr->getBase();
733 if (const auto *BO = dyn_cast<BinaryOperator>(Callee))
734 if (BO->getOpcode() == BO_PtrMemD || BO->getOpcode() == BO_PtrMemI)
735 return BO->getLHS();
736
737 // FIXME: Will eventually need to cope with member pointers.
738 return nullptr;
739}
740
743 if (Ty->isPointerType())
744 Ty = Ty->getPointeeType();
745 return Ty;
746}
747
749 if (const auto *MemExpr = dyn_cast<MemberExpr>(getCallee()->IgnoreParens()))
750 return cast<CXXMethodDecl>(MemExpr->getMemberDecl());
751
752 // FIXME: Will eventually need to cope with member pointers.
753 // NOTE: Update makeTailCallIfSwiftAsync on fixing this.
754 return nullptr;
755}
756
758 Expr* ThisArg = getImplicitObjectArgument();
759 if (!ThisArg)
760 return nullptr;
761
762 if (ThisArg->getType()->isAnyPointerType())
763 return ThisArg->getType()->getPointeeType()->getAsCXXRecordDecl();
764
765 return ThisArg->getType()->getAsCXXRecordDecl();
766}
767
768//===----------------------------------------------------------------------===//
769// Named casts
770//===----------------------------------------------------------------------===//
771
772/// getCastName - Get the name of the C++ cast being used, e.g.,
773/// "static_cast", "dynamic_cast", "reinterpret_cast", or
774/// "const_cast". The returned pointer must not be freed.
775const char *CXXNamedCastExpr::getCastName() const {
776 switch (getStmtClass()) {
777 case CXXStaticCastExprClass: return "static_cast";
778 case CXXDynamicCastExprClass: return "dynamic_cast";
779 case CXXReinterpretCastExprClass: return "reinterpret_cast";
780 case CXXConstCastExprClass: return "const_cast";
781 case CXXAddrspaceCastExprClass: return "addrspace_cast";
782 default: return "<invalid cast>";
783 }
784}
785
788 CastKind K, Expr *Op, const CXXCastPath *BasePath,
789 TypeSourceInfo *WrittenTy, FPOptionsOverride FPO,
790 SourceLocation L, SourceLocation RParenLoc,
791 SourceRange AngleBrackets) {
792 unsigned PathSize = (BasePath ? BasePath->size() : 0);
793 void *Buffer =
794 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
795 PathSize, FPO.requiresTrailingStorage()));
796 auto *E = new (Buffer) CXXStaticCastExpr(T, VK, K, Op, PathSize, WrittenTy,
797 FPO, L, RParenLoc, AngleBrackets);
798 if (PathSize)
799 llvm::uninitialized_copy(*BasePath,
800 E->getTrailingObjects<CXXBaseSpecifier *>());
801 return E;
802}
803
805 unsigned PathSize,
806 bool HasFPFeatures) {
807 void *Buffer =
808 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
809 PathSize, HasFPFeatures));
810 return new (Buffer) CXXStaticCastExpr(EmptyShell(), PathSize, HasFPFeatures);
811}
812
813CXXDynamicCastExpr *CXXDynamicCastExpr::Create(const ASTContext &C, QualType T,
815 CastKind K, Expr *Op,
816 const CXXCastPath *BasePath,
817 TypeSourceInfo *WrittenTy,
819 SourceLocation RParenLoc,
820 SourceRange AngleBrackets) {
821 unsigned PathSize = (BasePath ? BasePath->size() : 0);
822 void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
823 auto *E =
824 new (Buffer) CXXDynamicCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
825 RParenLoc, AngleBrackets);
826 if (PathSize)
827 llvm::uninitialized_copy(*BasePath, E->getTrailingObjects());
828 return E;
829}
830
832 unsigned PathSize) {
833 void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
834 return new (Buffer) CXXDynamicCastExpr(EmptyShell(), PathSize);
835}
836
837/// isAlwaysNull - Return whether the result of the dynamic_cast is proven
838/// to always be null. For example:
839///
840/// struct A { };
841/// struct B final : A { };
842/// struct C { };
843///
844/// C *f(B* b) { return dynamic_cast<C*>(b); }
846 if (isValueDependent() || getCastKind() != CK_Dynamic)
847 return false;
848
849 QualType SrcType = getSubExpr()->getType();
850 QualType DestType = getType();
851
852 if (DestType->isVoidPointerType())
853 return false;
854
855 if (DestType->isPointerType()) {
856 SrcType = SrcType->getPointeeType();
857 DestType = DestType->getPointeeType();
858 }
859
860 const auto *SrcRD = SrcType->getAsCXXRecordDecl();
861 const auto *DestRD = DestType->getAsCXXRecordDecl();
862 assert(SrcRD && DestRD);
863
864 if (SrcRD->isEffectivelyFinal()) {
865 assert(!SrcRD->isDerivedFrom(DestRD) &&
866 "upcasts should not use CK_Dynamic");
867 return true;
868 }
869
870 if (DestRD->isEffectivelyFinal() && !DestRD->isDerivedFrom(SrcRD))
871 return true;
872
873 return false;
874}
875
879 const CXXCastPath *BasePath,
880 TypeSourceInfo *WrittenTy, SourceLocation L,
881 SourceLocation RParenLoc,
882 SourceRange AngleBrackets) {
883 unsigned PathSize = (BasePath ? BasePath->size() : 0);
884 void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
885 auto *E =
886 new (Buffer) CXXReinterpretCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
887 RParenLoc, AngleBrackets);
888 if (PathSize)
889 llvm::uninitialized_copy(*BasePath, E->getTrailingObjects());
890 return E;
891}
892
895 void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
896 return new (Buffer) CXXReinterpretCastExpr(EmptyShell(), PathSize);
897}
898
899CXXConstCastExpr *CXXConstCastExpr::Create(const ASTContext &C, QualType T,
900 ExprValueKind VK, Expr *Op,
901 TypeSourceInfo *WrittenTy,
903 SourceLocation RParenLoc,
904 SourceRange AngleBrackets) {
905 return new (C) CXXConstCastExpr(T, VK, Op, WrittenTy, L, RParenLoc, AngleBrackets);
906}
907
908CXXConstCastExpr *CXXConstCastExpr::CreateEmpty(const ASTContext &C) {
909 return new (C) CXXConstCastExpr(EmptyShell());
910}
911
914 CastKind K, Expr *Op, TypeSourceInfo *WrittenTy,
915 SourceLocation L, SourceLocation RParenLoc,
916 SourceRange AngleBrackets) {
917 return new (C) CXXAddrspaceCastExpr(T, VK, K, Op, WrittenTy, L, RParenLoc,
918 AngleBrackets);
919}
920
921CXXAddrspaceCastExpr *CXXAddrspaceCastExpr::CreateEmpty(const ASTContext &C) {
922 return new (C) CXXAddrspaceCastExpr(EmptyShell());
923}
924
925CXXFunctionalCastExpr *CXXFunctionalCastExpr::Create(
926 const ASTContext &C, QualType T, ExprValueKind VK, TypeSourceInfo *Written,
927 CastKind K, Expr *Op, const CXXCastPath *BasePath, FPOptionsOverride FPO,
929 unsigned PathSize = (BasePath ? BasePath->size() : 0);
930 void *Buffer =
931 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
932 PathSize, FPO.requiresTrailingStorage()));
933 auto *E = new (Buffer)
934 CXXFunctionalCastExpr(T, VK, Written, K, Op, PathSize, FPO, L, R);
935 if (PathSize)
936 llvm::uninitialized_copy(*BasePath,
937 E->getTrailingObjects<CXXBaseSpecifier *>());
938 return E;
939}
940
941CXXFunctionalCastExpr *CXXFunctionalCastExpr::CreateEmpty(const ASTContext &C,
942 unsigned PathSize,
943 bool HasFPFeatures) {
944 void *Buffer =
945 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
946 PathSize, HasFPFeatures));
947 return new (Buffer)
948 CXXFunctionalCastExpr(EmptyShell(), PathSize, HasFPFeatures);
949}
950
954
956 return RParenLoc.isValid() ? RParenLoc : getSubExpr()->getEndLoc();
957}
958
959UserDefinedLiteral::UserDefinedLiteral(Expr *Fn, ArrayRef<Expr *> Args,
961 SourceLocation LitEndLoc,
962 SourceLocation SuffixLoc,
963 FPOptionsOverride FPFeatures)
964 : CallExpr(UserDefinedLiteralClass, Fn, /*PreArgs=*/{}, Args, Ty, VK,
965 LitEndLoc, FPFeatures, /*MinNumArgs=*/0, NotADL),
966 UDSuffixLoc(SuffixLoc) {}
967
968UserDefinedLiteral::UserDefinedLiteral(unsigned NumArgs, bool HasFPFeatures,
969 EmptyShell Empty)
970 : CallExpr(UserDefinedLiteralClass, /*NumPreArgs=*/0, NumArgs,
971 HasFPFeatures, Empty) {}
972
973UserDefinedLiteral *UserDefinedLiteral::Create(const ASTContext &Ctx, Expr *Fn,
974 ArrayRef<Expr *> Args,
976 SourceLocation LitEndLoc,
977 SourceLocation SuffixLoc,
978 FPOptionsOverride FPFeatures) {
979 // Allocate storage for the trailing objects of CallExpr.
980 unsigned NumArgs = Args.size();
981 unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
982 /*NumPreArgs=*/0, NumArgs, FPFeatures.requiresTrailingStorage());
983 void *Mem =
985 SizeOfTrailingObjects),
986 alignof(UserDefinedLiteral));
987 return new (Mem)
988 UserDefinedLiteral(Fn, Args, Ty, VK, LitEndLoc, SuffixLoc, FPFeatures);
989}
990
991UserDefinedLiteral *UserDefinedLiteral::CreateEmpty(const ASTContext &Ctx,
992 unsigned NumArgs,
993 bool HasFPOptions,
995 // Allocate storage for the trailing objects of CallExpr.
996 unsigned SizeOfTrailingObjects =
997 CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs, HasFPOptions);
998 void *Mem =
1000 SizeOfTrailingObjects),
1001 alignof(UserDefinedLiteral));
1002 return new (Mem) UserDefinedLiteral(NumArgs, HasFPOptions, Empty);
1003}
1004
1007 if (getNumArgs() == 0)
1008 return LOK_Template;
1009 if (getNumArgs() == 2)
1010 return LOK_String;
1011
1012 assert(getNumArgs() == 1 && "unexpected #args in literal operator call");
1013 QualType ParamTy =
1014 cast<FunctionDecl>(getCalleeDecl())->getParamDecl(0)->getType();
1015 if (ParamTy->isPointerType())
1016 return LOK_Raw;
1017 if (ParamTy->isAnyCharacterType())
1018 return LOK_Character;
1019 if (ParamTy->isIntegerType())
1020 return LOK_Integer;
1021 if (ParamTy->isFloatingType())
1022 return LOK_Floating;
1023
1024 llvm_unreachable("unknown kind of literal operator");
1025}
1026
1028#ifndef NDEBUG
1030 assert(LOK != LOK_Template && LOK != LOK_Raw && "not a cooked literal");
1031#endif
1032 return getArg(0);
1033}
1034
1036 return cast<FunctionDecl>(getCalleeDecl())->getLiteralIdentifier();
1037}
1038
1040 bool HasRewrittenInit) {
1041 size_t Size = totalSizeToAlloc<Expr *>(HasRewrittenInit);
1042 auto *Mem = C.Allocate(Size, alignof(CXXDefaultArgExpr));
1043 return new (Mem) CXXDefaultArgExpr(EmptyShell(), HasRewrittenInit);
1044}
1045
1046CXXDefaultArgExpr *CXXDefaultArgExpr::Create(const ASTContext &C,
1047 SourceLocation Loc,
1048 ParmVarDecl *Param,
1049 Expr *RewrittenExpr,
1050 DeclContext *UsedContext) {
1051 size_t Size = totalSizeToAlloc<Expr *>(RewrittenExpr != nullptr);
1052 auto *Mem = C.Allocate(Size, alignof(CXXDefaultArgExpr));
1053 return new (Mem) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param,
1054 RewrittenExpr, UsedContext);
1055}
1056
1061
1063 assert(hasRewrittenInit() &&
1064 "expected this CXXDefaultArgExpr to have a rewritten init.");
1066 if (auto *E = dyn_cast_if_present<FullExpr>(Init))
1067 if (!isa<ConstantExpr>(E))
1068 return E->getSubExpr();
1069 return Init;
1070}
1071
1072CXXDefaultInitExpr::CXXDefaultInitExpr(const ASTContext &Ctx,
1073 SourceLocation Loc, FieldDecl *Field,
1074 QualType Ty, DeclContext *UsedContext,
1075 Expr *RewrittenInitExpr)
1076 : Expr(CXXDefaultInitExprClass, Ty.getNonLValueExprType(Ctx),
1077 Ty->isLValueReferenceType() ? VK_LValue
1078 : Ty->isRValueReferenceType() ? VK_XValue
1079 : VK_PRValue,
1080 /*FIXME*/ OK_Ordinary),
1081 Field(Field), UsedContext(UsedContext) {
1082 CXXDefaultInitExprBits.Loc = Loc;
1083 CXXDefaultInitExprBits.HasRewrittenInit = RewrittenInitExpr != nullptr;
1084
1085 if (CXXDefaultInitExprBits.HasRewrittenInit)
1086 *getTrailingObjects() = RewrittenInitExpr;
1087
1088 assert(Field->hasInClassInitializer());
1089
1091}
1092
1094 bool HasRewrittenInit) {
1095 size_t Size = totalSizeToAlloc<Expr *>(HasRewrittenInit);
1096 auto *Mem = C.Allocate(Size, alignof(CXXDefaultInitExpr));
1097 return new (Mem) CXXDefaultInitExpr(EmptyShell(), HasRewrittenInit);
1098}
1099
1100CXXDefaultInitExpr *CXXDefaultInitExpr::Create(const ASTContext &Ctx,
1101 SourceLocation Loc,
1102 FieldDecl *Field,
1103 DeclContext *UsedContext,
1104 Expr *RewrittenInitExpr) {
1105
1106 size_t Size = totalSizeToAlloc<Expr *>(RewrittenInitExpr != nullptr);
1107 auto *Mem = Ctx.Allocate(Size, alignof(CXXDefaultInitExpr));
1108 return new (Mem) CXXDefaultInitExpr(Ctx, Loc, Field, Field->getType(),
1109 UsedContext, RewrittenInitExpr);
1110}
1111
1113 assert(Field->getInClassInitializer() && "initializer hasn't been parsed");
1114 if (hasRewrittenInit())
1115 return getRewrittenExpr();
1116
1117 return Field->getInClassInitializer();
1118}
1119
1120CXXTemporary *CXXTemporary::Create(const ASTContext &C,
1121 const CXXDestructorDecl *Destructor) {
1122 return new (C) CXXTemporary(Destructor);
1123}
1124
1125CXXBindTemporaryExpr *CXXBindTemporaryExpr::Create(const ASTContext &C,
1126 CXXTemporary *Temp,
1127 Expr* SubExpr) {
1128 assert((SubExpr->getType()->isRecordType() ||
1129 SubExpr->getType()->isArrayType()) &&
1130 "Expression bound to a temporary must have record or array type!");
1131
1132 return new (C) CXXBindTemporaryExpr(Temp, SubExpr);
1133}
1134
1135CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(
1137 ArrayRef<Expr *> Args, SourceRange ParenOrBraceRange,
1138 bool HadMultipleCandidates, bool ListInitialization,
1139 bool StdInitListInitialization, bool ZeroInitialization)
1141 CXXTemporaryObjectExprClass, Ty, TSI->getTypeLoc().getBeginLoc(),
1142 Cons, /* Elidable=*/false, Args, HadMultipleCandidates,
1143 ListInitialization, StdInitListInitialization, ZeroInitialization,
1144 CXXConstructionKind::Complete, ParenOrBraceRange),
1145 TSI(TSI) {
1147}
1148
1149CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(EmptyShell Empty,
1150 unsigned NumArgs)
1151 : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty, NumArgs) {}
1152
1153CXXTemporaryObjectExpr *CXXTemporaryObjectExpr::Create(
1154 const ASTContext &Ctx, CXXConstructorDecl *Cons, QualType Ty,
1155 TypeSourceInfo *TSI, ArrayRef<Expr *> Args, SourceRange ParenOrBraceRange,
1156 bool HadMultipleCandidates, bool ListInitialization,
1157 bool StdInitListInitialization, bool ZeroInitialization) {
1158 unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(Args.size());
1159 void *Mem =
1160 Ctx.Allocate(sizeof(CXXTemporaryObjectExpr) + SizeOfTrailingObjects,
1161 alignof(CXXTemporaryObjectExpr));
1162 return new (Mem) CXXTemporaryObjectExpr(
1163 Cons, Ty, TSI, Args, ParenOrBraceRange, HadMultipleCandidates,
1164 ListInitialization, StdInitListInitialization, ZeroInitialization);
1165}
1166
1169 unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(NumArgs);
1170 void *Mem =
1171 Ctx.Allocate(sizeof(CXXTemporaryObjectExpr) + SizeOfTrailingObjects,
1172 alignof(CXXTemporaryObjectExpr));
1173 return new (Mem) CXXTemporaryObjectExpr(EmptyShell(), NumArgs);
1174}
1175
1179
1182 if (Loc.isInvalid() && getNumArgs())
1183 Loc = getArg(getNumArgs() - 1)->getEndLoc();
1184 return Loc;
1185}
1186
1188 const ASTContext &Ctx, QualType Ty, SourceLocation Loc,
1189 CXXConstructorDecl *Ctor, bool Elidable, ArrayRef<Expr *> Args,
1190 bool HadMultipleCandidates, bool ListInitialization,
1191 bool StdInitListInitialization, bool ZeroInitialization,
1192 CXXConstructionKind ConstructKind, SourceRange ParenOrBraceRange) {
1193 unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(Args.size());
1194 void *Mem = Ctx.Allocate(sizeof(CXXConstructExpr) + SizeOfTrailingObjects,
1195 alignof(CXXConstructExpr));
1196 return new (Mem) CXXConstructExpr(
1197 CXXConstructExprClass, Ty, Loc, Ctor, Elidable, Args,
1198 HadMultipleCandidates, ListInitialization, StdInitListInitialization,
1199 ZeroInitialization, ConstructKind, ParenOrBraceRange);
1200}
1201
1203 unsigned NumArgs) {
1204 unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(NumArgs);
1205 void *Mem = Ctx.Allocate(sizeof(CXXConstructExpr) + SizeOfTrailingObjects,
1206 alignof(CXXConstructExpr));
1207 return new (Mem)
1208 CXXConstructExpr(CXXConstructExprClass, EmptyShell(), NumArgs);
1209}
1210
1213 bool Elidable, ArrayRef<Expr *> Args, bool HadMultipleCandidates,
1214 bool ListInitialization, bool StdInitListInitialization,
1215 bool ZeroInitialization, CXXConstructionKind ConstructKind,
1216 SourceRange ParenOrBraceRange)
1217 : Expr(SC, Ty, VK_PRValue, OK_Ordinary), Constructor(Ctor),
1218 ParenOrBraceRange(ParenOrBraceRange), NumArgs(Args.size()) {
1219 CXXConstructExprBits.Elidable = Elidable;
1220 CXXConstructExprBits.HadMultipleCandidates = HadMultipleCandidates;
1221 CXXConstructExprBits.ListInitialization = ListInitialization;
1222 CXXConstructExprBits.StdInitListInitialization = StdInitListInitialization;
1223 CXXConstructExprBits.ZeroInitialization = ZeroInitialization;
1224 CXXConstructExprBits.ConstructionKind = llvm::to_underlying(ConstructKind);
1225 CXXConstructExprBits.IsImmediateEscalating = false;
1226 CXXConstructExprBits.Loc = Loc;
1227
1228 Stmt **TrailingArgs = getTrailingArgs();
1229 llvm::copy(Args, TrailingArgs);
1230 assert(!llvm::is_contained(Args, nullptr));
1231
1232 // CXXTemporaryObjectExpr does this itself after setting its TypeSourceInfo.
1233 if (SC == CXXConstructExprClass)
1235}
1236
1238 unsigned NumArgs)
1239 : Expr(SC, Empty), NumArgs(NumArgs) {}
1240
1242 LambdaCaptureKind Kind, ValueDecl *Var,
1243 SourceLocation EllipsisLoc)
1244 : DeclAndBits(Var, 0), Loc(Loc), EllipsisLoc(EllipsisLoc) {
1245 unsigned Bits = 0;
1246 if (Implicit)
1247 Bits |= Capture_Implicit;
1248
1249 switch (Kind) {
1250 case LCK_StarThis:
1251 Bits |= Capture_ByCopy;
1252 [[fallthrough]];
1253 case LCK_This:
1254 assert(!Var && "'this' capture cannot have a variable!");
1255 Bits |= Capture_This;
1256 break;
1257
1258 case LCK_ByCopy:
1259 Bits |= Capture_ByCopy;
1260 [[fallthrough]];
1261 case LCK_ByRef:
1262 assert(Var && "capture must have a variable!");
1263 break;
1264 case LCK_VLAType:
1265 assert(!Var && "VLA type capture cannot have a variable!");
1266 break;
1267 }
1268 DeclAndBits.setInt(Bits);
1269}
1270
1272 if (capturesVLAType())
1273 return LCK_VLAType;
1274 bool CapByCopy = DeclAndBits.getInt() & Capture_ByCopy;
1275 if (capturesThis())
1276 return CapByCopy ? LCK_StarThis : LCK_This;
1277 return CapByCopy ? LCK_ByCopy : LCK_ByRef;
1278}
1279
1280LambdaExpr::LambdaExpr(QualType T, SourceRange IntroducerRange,
1281 LambdaCaptureDefault CaptureDefault,
1282 SourceLocation CaptureDefaultLoc, bool ExplicitParams,
1283 bool ExplicitResultType, ArrayRef<Expr *> CaptureInits,
1284 SourceLocation ClosingBrace,
1285 bool ContainsUnexpandedParameterPack)
1286 : Expr(LambdaExprClass, T, VK_PRValue, OK_Ordinary),
1287 IntroducerRange(IntroducerRange), CaptureDefaultLoc(CaptureDefaultLoc),
1288 ClosingBrace(ClosingBrace) {
1289 LambdaExprBits.NumCaptures = CaptureInits.size();
1290 LambdaExprBits.CaptureDefault = CaptureDefault;
1291 LambdaExprBits.ExplicitParams = ExplicitParams;
1292 LambdaExprBits.ExplicitResultType = ExplicitResultType;
1293
1294 CXXRecordDecl *Class = getLambdaClass();
1295 (void)Class;
1296 assert(capture_size() == Class->capture_size() && "Wrong number of captures");
1297 assert(getCaptureDefault() == Class->getLambdaCaptureDefault());
1298
1299 // Copy initialization expressions for the non-static data members.
1300 Stmt **Stored = getStoredStmts();
1301 for (unsigned I = 0, N = CaptureInits.size(); I != N; ++I)
1302 *Stored++ = CaptureInits[I];
1303
1304 // Copy the body of the lambda.
1305 *Stored++ = getCallOperator()->getBody();
1306
1307 setDependence(computeDependence(this, ContainsUnexpandedParameterPack));
1308}
1309
1310LambdaExpr::LambdaExpr(EmptyShell Empty, unsigned NumCaptures)
1311 : Expr(LambdaExprClass, Empty) {
1312 LambdaExprBits.NumCaptures = NumCaptures;
1313
1314 // Initially don't initialize the body of the LambdaExpr. The body will
1315 // be lazily deserialized when needed.
1316 getStoredStmts()[NumCaptures] = nullptr; // Not one past the end.
1317}
1318
1320 SourceRange IntroducerRange,
1321 LambdaCaptureDefault CaptureDefault,
1322 SourceLocation CaptureDefaultLoc,
1323 bool ExplicitParams, bool ExplicitResultType,
1324 ArrayRef<Expr *> CaptureInits,
1325 SourceLocation ClosingBrace,
1326 bool ContainsUnexpandedParameterPack) {
1327 // Determine the type of the expression (i.e., the type of the
1328 // function object we're creating).
1329 CanQualType T = Context.getCanonicalTagType(Class);
1330
1331 unsigned Size = totalSizeToAlloc<Stmt *>(CaptureInits.size() + 1);
1332 void *Mem = Context.Allocate(Size);
1333 return new (Mem)
1334 LambdaExpr(T, IntroducerRange, CaptureDefault, CaptureDefaultLoc,
1335 ExplicitParams, ExplicitResultType, CaptureInits, ClosingBrace,
1336 ContainsUnexpandedParameterPack);
1337}
1338
1340 unsigned NumCaptures) {
1341 unsigned Size = totalSizeToAlloc<Stmt *>(NumCaptures + 1);
1342 void *Mem = C.Allocate(Size);
1343 return new (Mem) LambdaExpr(EmptyShell(), NumCaptures);
1344}
1345
1346void LambdaExpr::initBodyIfNeeded() const {
1347 if (!getStoredStmts()[capture_size()]) {
1348 auto *This = const_cast<LambdaExpr *>(this);
1349 This->getStoredStmts()[capture_size()] = getCallOperator()->getBody();
1350 }
1351}
1352
1354 initBodyIfNeeded();
1355 return getStoredStmts()[capture_size()];
1356}
1357
1359 Stmt *Body = getBody();
1360 if (const auto *CoroBody = dyn_cast<CoroutineBodyStmt>(Body))
1361 return cast<CompoundStmt>(CoroBody->getBody());
1362 return cast<CompoundStmt>(Body);
1363}
1364
1366 return C->capturesVariable() && C->getCapturedVar()->isInitCapture() &&
1367 getCallOperator() == C->getCapturedVar()->getDeclContext();
1368}
1369
1373
1377
1381
1385
1387 return capture_begin() +
1388 getLambdaClass()->getLambdaData().NumExplicitCaptures;
1389}
1390
1394
1398
1402
1406
1410
1413 return Record->getLambdaCallOperator();
1414}
1415
1418 return Record->getDependentLambdaCallOperator();
1419}
1420
1423 return Record->getGenericLambdaTemplateParameterList();
1424}
1425
1428 return Record->getLambdaExplicitTemplateParameters();
1429}
1430
1434
1435bool LambdaExpr::isMutable() const { return !getCallOperator()->isConst(); }
1436
1438 initBodyIfNeeded();
1439 return child_range(getStoredStmts(), getStoredStmts() + capture_size() + 1);
1440}
1441
1443 initBodyIfNeeded();
1444 return const_child_range(getStoredStmts(),
1445 getStoredStmts() + capture_size() + 1);
1446}
1447
1448ExprWithCleanups::ExprWithCleanups(Expr *subexpr,
1449 bool CleanupsHaveSideEffects,
1451 : FullExpr(ExprWithCleanupsClass, subexpr) {
1452 ExprWithCleanupsBits.CleanupsHaveSideEffects = CleanupsHaveSideEffects;
1453 ExprWithCleanupsBits.NumObjects = objects.size();
1454 llvm::copy(objects, getTrailingObjects());
1455}
1456
1457ExprWithCleanups *ExprWithCleanups::Create(const ASTContext &C, Expr *subexpr,
1458 bool CleanupsHaveSideEffects,
1459 ArrayRef<CleanupObject> objects) {
1460 void *buffer = C.Allocate(totalSizeToAlloc<CleanupObject>(objects.size()),
1461 alignof(ExprWithCleanups));
1462 return new (buffer)
1463 ExprWithCleanups(subexpr, CleanupsHaveSideEffects, objects);
1464}
1465
1466ExprWithCleanups::ExprWithCleanups(EmptyShell empty, unsigned numObjects)
1467 : FullExpr(ExprWithCleanupsClass, empty) {
1468 ExprWithCleanupsBits.NumObjects = numObjects;
1469}
1470
1471ExprWithCleanups *ExprWithCleanups::Create(const ASTContext &C,
1472 EmptyShell empty,
1473 unsigned numObjects) {
1474 void *buffer = C.Allocate(totalSizeToAlloc<CleanupObject>(numObjects),
1475 alignof(ExprWithCleanups));
1476 return new (buffer) ExprWithCleanups(empty, numObjects);
1477}
1478
1479CXXUnresolvedConstructExpr::CXXUnresolvedConstructExpr(
1480 QualType T, TypeSourceInfo *TSI, SourceLocation LParenLoc,
1481 ArrayRef<Expr *> Args, SourceLocation RParenLoc, bool IsListInit)
1482 : Expr(CXXUnresolvedConstructExprClass, T,
1483 (TSI->getType()->isLValueReferenceType() ? VK_LValue
1484 : TSI->getType()->isRValueReferenceType() ? VK_XValue
1485 : VK_PRValue),
1486 OK_Ordinary),
1487 TypeAndInitForm(TSI, IsListInit), LParenLoc(LParenLoc),
1488 RParenLoc(RParenLoc) {
1489 CXXUnresolvedConstructExprBits.NumArgs = Args.size();
1490 auto **StoredArgs = getTrailingObjects();
1491 llvm::copy(Args, StoredArgs);
1493}
1494
1495CXXUnresolvedConstructExpr *CXXUnresolvedConstructExpr::Create(
1496 const ASTContext &Context, QualType T, TypeSourceInfo *TSI,
1497 SourceLocation LParenLoc, ArrayRef<Expr *> Args, SourceLocation RParenLoc,
1498 bool IsListInit) {
1499 void *Mem = Context.Allocate(totalSizeToAlloc<Expr *>(Args.size()));
1500 return new (Mem) CXXUnresolvedConstructExpr(T, TSI, LParenLoc, Args,
1501 RParenLoc, IsListInit);
1502}
1503
1506 unsigned NumArgs) {
1507 void *Mem = Context.Allocate(totalSizeToAlloc<Expr *>(NumArgs));
1508 return new (Mem) CXXUnresolvedConstructExpr(EmptyShell(), NumArgs);
1509}
1510
1512 return TypeAndInitForm.getPointer()->getTypeLoc().getBeginLoc();
1513}
1514
1515CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(
1516 const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow,
1517 SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc,
1518 SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope,
1519 DeclarationNameInfo MemberNameInfo,
1520 const TemplateArgumentListInfo *TemplateArgs)
1521 : Expr(CXXDependentScopeMemberExprClass, Ctx.DependentTy, VK_LValue,
1522 OK_Ordinary),
1523 Base(Base), BaseType(BaseType), QualifierLoc(QualifierLoc),
1524 MemberNameInfo(MemberNameInfo) {
1525 CXXDependentScopeMemberExprBits.IsArrow = IsArrow;
1526 CXXDependentScopeMemberExprBits.HasTemplateKWAndArgsInfo =
1527 (TemplateArgs != nullptr) || TemplateKWLoc.isValid();
1528 CXXDependentScopeMemberExprBits.HasFirstQualifierFoundInScope =
1529 FirstQualifierFoundInScope != nullptr;
1530 CXXDependentScopeMemberExprBits.OperatorLoc = OperatorLoc;
1531
1532 if (TemplateArgs) {
1533 auto Deps = TemplateArgumentDependence::None;
1534 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1535 TemplateKWLoc, *TemplateArgs, getTrailingObjects<TemplateArgumentLoc>(),
1536 Deps);
1537 } else if (TemplateKWLoc.isValid()) {
1538 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1539 TemplateKWLoc);
1540 }
1541
1542 if (hasFirstQualifierFoundInScope())
1543 *getTrailingObjects<NamedDecl *>() = FirstQualifierFoundInScope;
1545}
1546
1547CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(
1548 EmptyShell Empty, bool HasTemplateKWAndArgsInfo,
1549 bool HasFirstQualifierFoundInScope)
1550 : Expr(CXXDependentScopeMemberExprClass, Empty) {
1551 CXXDependentScopeMemberExprBits.HasTemplateKWAndArgsInfo =
1552 HasTemplateKWAndArgsInfo;
1553 CXXDependentScopeMemberExprBits.HasFirstQualifierFoundInScope =
1554 HasFirstQualifierFoundInScope;
1555}
1556
1557CXXDependentScopeMemberExpr *CXXDependentScopeMemberExpr::Create(
1558 const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow,
1559 SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc,
1560 SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope,
1561 DeclarationNameInfo MemberNameInfo,
1562 const TemplateArgumentListInfo *TemplateArgs) {
1563 bool HasTemplateKWAndArgsInfo =
1564 (TemplateArgs != nullptr) || TemplateKWLoc.isValid();
1565 unsigned NumTemplateArgs = TemplateArgs ? TemplateArgs->size() : 0;
1566 bool HasFirstQualifierFoundInScope = FirstQualifierFoundInScope != nullptr;
1567
1568 unsigned Size = totalSizeToAlloc<ASTTemplateKWAndArgsInfo,
1570 HasTemplateKWAndArgsInfo, NumTemplateArgs, HasFirstQualifierFoundInScope);
1571
1572 void *Mem = Ctx.Allocate(Size, alignof(CXXDependentScopeMemberExpr));
1573 return new (Mem) CXXDependentScopeMemberExpr(
1574 Ctx, Base, BaseType, IsArrow, OperatorLoc, QualifierLoc, TemplateKWLoc,
1575 FirstQualifierFoundInScope, MemberNameInfo, TemplateArgs);
1576}
1577
1578CXXDependentScopeMemberExpr *CXXDependentScopeMemberExpr::CreateEmpty(
1579 const ASTContext &Ctx, bool HasTemplateKWAndArgsInfo,
1580 unsigned NumTemplateArgs, bool HasFirstQualifierFoundInScope) {
1581 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
1582
1583 unsigned Size = totalSizeToAlloc<ASTTemplateKWAndArgsInfo,
1585 HasTemplateKWAndArgsInfo, NumTemplateArgs, HasFirstQualifierFoundInScope);
1586
1587 void *Mem = Ctx.Allocate(Size, alignof(CXXDependentScopeMemberExpr));
1588 return new (Mem) CXXDependentScopeMemberExpr(
1589 EmptyShell(), HasTemplateKWAndArgsInfo, HasFirstQualifierFoundInScope);
1590}
1591
1593 QualType Ty, bool IsImplicit) {
1594 return new (Ctx) CXXThisExpr(L, Ty, IsImplicit,
1595 Ctx.getLangOpts().HLSL ? VK_LValue : VK_PRValue);
1596}
1597
1598CXXThisExpr *CXXThisExpr::CreateEmpty(const ASTContext &Ctx) {
1599 return new (Ctx) CXXThisExpr(EmptyShell());
1600}
1601
1604 do {
1605 NamedDecl *decl = *begin;
1607 return false;
1608
1609 // Unresolved member expressions should only contain methods and
1610 // method templates.
1611 if (cast<CXXMethodDecl>(decl->getUnderlyingDecl()->getAsFunction())
1612 ->isStatic())
1613 return false;
1614 } while (++begin != end);
1615
1616 return true;
1617}
1618
1619UnresolvedMemberExpr::UnresolvedMemberExpr(
1620 const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base,
1621 QualType BaseType, bool IsArrow, SourceLocation OperatorLoc,
1622 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
1623 const DeclarationNameInfo &MemberNameInfo,
1624 const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin,
1626 : OverloadExpr(
1627 UnresolvedMemberExprClass, Context, QualifierLoc, TemplateKWLoc,
1628 MemberNameInfo, TemplateArgs, Begin, End,
1629 // Dependent
1630 ((Base && Base->isTypeDependent()) || BaseType->isDependentType()),
1631 ((Base && Base->isInstantiationDependent()) ||
1632 BaseType->isInstantiationDependentType()),
1633 // Contains unexpanded parameter pack
1634 ((Base && Base->containsUnexpandedParameterPack()) ||
1635 BaseType->containsUnexpandedParameterPack())),
1636 Base(Base), BaseType(BaseType), OperatorLoc(OperatorLoc) {
1637 UnresolvedMemberExprBits.IsArrow = IsArrow;
1638 UnresolvedMemberExprBits.HasUnresolvedUsing = HasUnresolvedUsing;
1639
1640 // Check whether all of the members are non-static member functions,
1641 // and if so, mark give this bound-member type instead of overload type.
1642 if (hasOnlyNonStaticMemberFunctions(Begin, End))
1643 setType(Context.BoundMemberTy);
1644}
1645
1646UnresolvedMemberExpr::UnresolvedMemberExpr(EmptyShell Empty,
1647 unsigned NumResults,
1648 bool HasTemplateKWAndArgsInfo)
1649 : OverloadExpr(UnresolvedMemberExprClass, Empty, NumResults,
1650 HasTemplateKWAndArgsInfo) {}
1651
1653 if (!Base)
1654 return true;
1655
1656 return cast<Expr>(Base)->isImplicitCXXThis();
1657}
1658
1659UnresolvedMemberExpr *UnresolvedMemberExpr::Create(
1660 const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base,
1661 QualType BaseType, bool IsArrow, SourceLocation OperatorLoc,
1662 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
1663 const DeclarationNameInfo &MemberNameInfo,
1664 const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin,
1666 unsigned NumResults = End - Begin;
1667 bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.isValid();
1668 unsigned NumTemplateArgs = TemplateArgs ? TemplateArgs->size() : 0;
1669 unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
1671 NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
1672 void *Mem = Context.Allocate(Size, alignof(UnresolvedMemberExpr));
1673 return new (Mem) UnresolvedMemberExpr(
1674 Context, HasUnresolvedUsing, Base, BaseType, IsArrow, OperatorLoc,
1675 QualifierLoc, TemplateKWLoc, MemberNameInfo, TemplateArgs, Begin, End);
1676}
1677
1679 const ASTContext &Context, unsigned NumResults,
1680 bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs) {
1681 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
1682 unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
1684 NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
1685 void *Mem = Context.Allocate(Size, alignof(UnresolvedMemberExpr));
1686 return new (Mem)
1687 UnresolvedMemberExpr(EmptyShell(), NumResults, HasTemplateKWAndArgsInfo);
1688}
1689
1691 // Unlike for UnresolvedLookupExpr, it is very easy to re-derive this.
1692
1693 // If there was a nested name specifier, it names the naming class.
1694 // It can't be dependent: after all, we were actually able to do the
1695 // lookup.
1696 CXXRecordDecl *Record = nullptr;
1697 if (NestedNameSpecifier Qualifier = getQualifier();
1698 Qualifier.getKind() == NestedNameSpecifier::Kind::Type) {
1699 const Type *T = getQualifier().getAsType();
1700 Record = T->getAsCXXRecordDecl();
1701 assert(Record && "qualifier in member expression does not name record");
1702 }
1703 // Otherwise the naming class must have been the base class.
1704 else {
1706 if (isArrow())
1707 BaseType = BaseType->castAs<PointerType>()->getPointeeType();
1708
1709 Record = BaseType->getAsCXXRecordDecl();
1710 assert(Record && "base of member expression does not name record");
1711 }
1712
1713 return Record;
1714}
1715
1716SizeOfPackExpr *SizeOfPackExpr::Create(ASTContext &Context,
1717 SourceLocation OperatorLoc,
1718 NamedDecl *Pack, SourceLocation PackLoc,
1719 SourceLocation RParenLoc,
1720 UnsignedOrNone Length,
1721 ArrayRef<TemplateArgument> PartialArgs) {
1722 void *Storage =
1723 Context.Allocate(totalSizeToAlloc<TemplateArgument>(PartialArgs.size()));
1724 return new (Storage) SizeOfPackExpr(Context.getSizeType(), OperatorLoc, Pack,
1725 PackLoc, RParenLoc, Length, PartialArgs);
1726}
1727
1729 unsigned NumPartialArgs) {
1730 void *Storage =
1731 Context.Allocate(totalSizeToAlloc<TemplateArgument>(NumPartialArgs));
1732 return new (Storage) SizeOfPackExpr(EmptyShell(), NumPartialArgs);
1733}
1734
1739
1741 ASTContext &Context, SourceLocation EllipsisLoc, SourceLocation RSquareLoc,
1742 Expr *PackIdExpr, Expr *IndexExpr, std::optional<int64_t> Index,
1743 ArrayRef<Expr *> SubstitutedExprs, bool FullySubstituted) {
1744 QualType Type;
1745 if (Index && FullySubstituted && !SubstitutedExprs.empty())
1746 Type = SubstitutedExprs[*Index]->getType();
1747 else
1748 Type = PackIdExpr->getType();
1749
1750 void *Storage =
1751 Context.Allocate(totalSizeToAlloc<Expr *>(SubstitutedExprs.size()));
1752 return new (Storage)
1753 PackIndexingExpr(Type, EllipsisLoc, RSquareLoc, PackIdExpr, IndexExpr,
1754 SubstitutedExprs, FullySubstituted);
1755}
1756
1758 if (auto *D = dyn_cast<DeclRefExpr>(getPackIdExpression()); D) {
1759 return D->getDecl();
1760 }
1761 assert(false && "invalid declaration kind in pack indexing expression");
1762 return nullptr;
1763}
1764
1767 unsigned NumTransformedExprs) {
1768 void *Storage =
1769 Context.Allocate(totalSizeToAlloc<Expr *>(NumTransformedExprs));
1770 return new (Storage) PackIndexingExpr(EmptyShell{});
1771}
1772
1774 const ASTContext &Context) const {
1775 // Note that, for a class type NTTP, we will have an lvalue of type 'const
1776 // T', so we can't just compute this from the type and value category.
1777
1778 QualType Type = getType();
1779
1781 return Context.getLValueReferenceType(Type);
1782 return Type.getUnqualifiedType();
1783}
1784
1785SubstNonTypeTemplateParmPackExpr::SubstNonTypeTemplateParmPackExpr(
1786 QualType T, ExprValueKind ValueKind, SourceLocation NameLoc,
1787 const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index,
1788 bool Final)
1789 : Expr(SubstNonTypeTemplateParmPackExprClass, T, ValueKind, OK_Ordinary),
1790 AssociatedDecl(AssociatedDecl), Arguments(ArgPack.pack_begin()),
1791 NumArguments(ArgPack.pack_size()), Final(Final), Index(Index),
1792 NameLoc(NameLoc) {
1793 assert(AssociatedDecl != nullptr);
1794 setDependence(ExprDependence::TypeValueInstantiation |
1795 ExprDependence::UnexpandedPack);
1796}
1797
1803
1807
1808FunctionParmPackExpr::FunctionParmPackExpr(QualType T, ValueDecl *ParamPack,
1809 SourceLocation NameLoc,
1810 unsigned NumParams,
1811 ValueDecl *const *Params)
1812 : Expr(FunctionParmPackExprClass, T, VK_LValue, OK_Ordinary),
1813 ParamPack(ParamPack), NameLoc(NameLoc), NumParameters(NumParams) {
1814 if (Params)
1815 std::uninitialized_copy(Params, Params + NumParams, getTrailingObjects());
1816 setDependence(ExprDependence::TypeValueInstantiation |
1817 ExprDependence::UnexpandedPack);
1818}
1819
1822 ValueDecl *ParamPack, SourceLocation NameLoc,
1823 ArrayRef<ValueDecl *> Params) {
1824 return new (Context.Allocate(totalSizeToAlloc<ValueDecl *>(Params.size())))
1825 FunctionParmPackExpr(T, ParamPack, NameLoc, Params.size(), Params.data());
1826}
1827
1830 unsigned NumParams) {
1831 return new (Context.Allocate(totalSizeToAlloc<ValueDecl *>(NumParams)))
1832 FunctionParmPackExpr(QualType(), nullptr, SourceLocation(), 0, nullptr);
1833}
1834
1836 QualType T, Expr *Temporary, bool BoundToLvalueReference,
1838 : Expr(MaterializeTemporaryExprClass, T,
1839 BoundToLvalueReference ? VK_LValue : VK_XValue, OK_Ordinary) {
1840 if (MTD) {
1841 State = MTD;
1842 MTD->ExprWithTemporary = Temporary;
1843 return;
1844 }
1845 State = Temporary;
1847}
1848
1850 unsigned ManglingNumber) {
1851 // We only need extra state if we have to remember more than just the Stmt.
1852 if (!ExtendedBy)
1853 return;
1854
1855 // We may need to allocate extra storage for the mangling number and the
1856 // extended-by ValueDecl.
1859 cast<Expr>(cast<Stmt *>(State)), ExtendedBy, ManglingNumber);
1860
1862 ES->ExtendingDecl = ExtendedBy;
1863 ES->ManglingNumber = ManglingNumber;
1864}
1865
1867 const ASTContext &Context) const {
1868 // C++20 [expr.const]p4:
1869 // An object or reference is usable in constant expressions if it is [...]
1870 // a temporary object of non-volatile const-qualified literal type
1871 // whose lifetime is extended to that of a variable that is usable
1872 // in constant expressions
1873 auto *VD = dyn_cast_or_null<VarDecl>(getExtendingDecl());
1874 return VD && getType().isConstant(Context) &&
1876 getType()->isLiteralType(Context) &&
1877 VD->isUsableInConstantExpressions(Context);
1878}
1879
1880TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind,
1882 SourceLocation RParenLoc,
1883 std::variant<bool, APValue> Value)
1884 : Expr(TypeTraitExprClass, T, VK_PRValue, OK_Ordinary), Loc(Loc),
1885 RParenLoc(RParenLoc) {
1886 assert(Kind <= TT_Last && "invalid enum value!");
1887
1888 TypeTraitExprBits.Kind = Kind;
1889 assert(static_cast<unsigned>(Kind) == TypeTraitExprBits.Kind &&
1890 "TypeTraitExprBits.Kind overflow!");
1891
1892 TypeTraitExprBits.IsBooleanTypeTrait = std::holds_alternative<bool>(Value);
1893 if (TypeTraitExprBits.IsBooleanTypeTrait)
1894 TypeTraitExprBits.Value = std::get<bool>(Value);
1895 else
1896 ::new (getTrailingObjects<APValue>())
1897 APValue(std::get<APValue>(std::move(Value)));
1898
1899 TypeTraitExprBits.NumArgs = Args.size();
1900 assert(Args.size() == TypeTraitExprBits.NumArgs &&
1901 "TypeTraitExprBits.NumArgs overflow!");
1902 auto **ToArgs = getTrailingObjects<TypeSourceInfo *>();
1903 llvm::copy(Args, ToArgs);
1904
1906
1907 assert((TypeTraitExprBits.IsBooleanTypeTrait || isValueDependent() ||
1908 getAPValue().isInt() || getAPValue().isAbsent()) &&
1909 "Only int values are supported by clang");
1910}
1911
1912TypeTraitExpr::TypeTraitExpr(EmptyShell Empty, bool IsStoredAsBool)
1913 : Expr(TypeTraitExprClass, Empty) {
1914 TypeTraitExprBits.IsBooleanTypeTrait = IsStoredAsBool;
1915 if (!IsStoredAsBool)
1916 ::new (getTrailingObjects<APValue>()) APValue();
1917}
1918
1920 SourceLocation Loc,
1921 TypeTrait Kind,
1923 SourceLocation RParenLoc,
1924 bool Value) {
1925 void *Mem =
1926 C.Allocate(totalSizeToAlloc<APValue, TypeSourceInfo *>(0, Args.size()));
1927 return new (Mem) TypeTraitExpr(T, Loc, Kind, Args, RParenLoc, Value);
1928}
1929
1931 SourceLocation Loc, TypeTrait Kind,
1933 SourceLocation RParenLoc, APValue Value) {
1934 void *Mem =
1935 C.Allocate(totalSizeToAlloc<APValue, TypeSourceInfo *>(1, Args.size()));
1936 return new (Mem) TypeTraitExpr(T, Loc, Kind, Args, RParenLoc, Value);
1937}
1938
1940 bool IsStoredAsBool,
1941 unsigned NumArgs) {
1942 void *Mem = C.Allocate(totalSizeToAlloc<APValue, TypeSourceInfo *>(
1943 IsStoredAsBool ? 0 : 1, NumArgs));
1944 return new (Mem) TypeTraitExpr(EmptyShell(), IsStoredAsBool);
1945}
1946
1947CXXReflectExpr::CXXReflectExpr(EmptyShell Empty)
1948 : Expr(CXXReflectExprClass, Empty) {}
1949
1950CXXReflectExpr::CXXReflectExpr(SourceLocation CaretCaretLoc,
1951 const TypeSourceInfo *TSI)
1952 : Expr(CXXReflectExprClass, TSI->getType(), VK_PRValue, OK_Ordinary),
1953 CaretCaretLoc(CaretCaretLoc), Operand(TSI) {}
1954
1956 SourceLocation CaretCaretLoc,
1957 TypeSourceInfo *TSI) {
1958 return new (C) CXXReflectExpr(CaretCaretLoc, TSI);
1959}
1960
1962 return new (C) CXXReflectExpr(EmptyShell());
1963}
1964
1965CUDAKernelCallExpr::CUDAKernelCallExpr(Expr *Fn, CallExpr *Config,
1966 ArrayRef<Expr *> Args, QualType Ty,
1968 FPOptionsOverride FPFeatures,
1969 unsigned MinNumArgs)
1970 : CallExpr(CUDAKernelCallExprClass, Fn, /*PreArgs=*/Config, Args, Ty, VK,
1971 RP, FPFeatures, MinNumArgs, NotADL) {}
1972
1973CUDAKernelCallExpr::CUDAKernelCallExpr(unsigned NumArgs, bool HasFPFeatures,
1974 EmptyShell Empty)
1975 : CallExpr(CUDAKernelCallExprClass, /*NumPreArgs=*/END_PREARG, NumArgs,
1976 HasFPFeatures, Empty) {}
1977
1981 SourceLocation RP, FPOptionsOverride FPFeatures,
1982 unsigned MinNumArgs) {
1983 // Allocate storage for the trailing objects of CallExpr.
1984 unsigned NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1985 unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
1986 /*NumPreArgs=*/END_PREARG, NumArgs, FPFeatures.requiresTrailingStorage());
1987 void *Mem =
1989 SizeOfTrailingObjects),
1990 alignof(CUDAKernelCallExpr));
1991 return new (Mem)
1992 CUDAKernelCallExpr(Fn, Config, Args, Ty, VK, RP, FPFeatures, MinNumArgs);
1993}
1994
1995CUDAKernelCallExpr *CUDAKernelCallExpr::CreateEmpty(const ASTContext &Ctx,
1996 unsigned NumArgs,
1997 bool HasFPFeatures,
1998 EmptyShell Empty) {
1999 // Allocate storage for the trailing objects of CallExpr.
2000 unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
2001 /*NumPreArgs=*/END_PREARG, NumArgs, HasFPFeatures);
2002 void *Mem =
2004 SizeOfTrailingObjects),
2005 alignof(CUDAKernelCallExpr));
2006 return new (Mem) CUDAKernelCallExpr(NumArgs, HasFPFeatures, Empty);
2007}
2008
2011 unsigned NumUserSpecifiedExprs,
2012 SourceLocation InitLoc, SourceLocation LParenLoc,
2013 SourceLocation RParenLoc) {
2014 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(Args.size()));
2015 return new (Mem) CXXParenListInitExpr(Args, T, NumUserSpecifiedExprs, InitLoc,
2016 LParenLoc, RParenLoc);
2017}
2018
2020 unsigned NumExprs,
2021 EmptyShell Empty) {
2022 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumExprs),
2023 alignof(CXXParenListInitExpr));
2024 return new (Mem) CXXParenListInitExpr(Empty, NumExprs);
2025}
2026
2028 SourceLocation LParenLoc, Expr *LHS,
2029 BinaryOperatorKind Opcode, SourceLocation EllipsisLoc,
2030 Expr *RHS, SourceLocation RParenLoc,
2031 UnsignedOrNone NumExpansions)
2032 : Expr(CXXFoldExprClass, T, VK_PRValue, OK_Ordinary), LParenLoc(LParenLoc),
2033 EllipsisLoc(EllipsisLoc), RParenLoc(RParenLoc),
2034 NumExpansions(NumExpansions) {
2035 CXXFoldExprBits.Opcode = Opcode;
2036 // We rely on asserted invariant to distinguish left and right folds.
2037 if (LHS && RHS)
2038 assert(LHS->containsUnexpandedParameterPack() !=
2039 RHS->containsUnexpandedParameterPack() &&
2040 "Exactly one of LHS or RHS should contain an unexpanded pack");
2041 SubExprs[SubExpr::Callee] = Callee;
2042 SubExprs[SubExpr::LHS] = LHS;
2043 SubExprs[SubExpr::RHS] = RHS;
2045}
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:1602
static bool isGLValueFromPointerDeref(const Expr *E)
Definition ExprCXX.cpp:173
static bool UnresolvedLookupExprIsVariableOrConceptParameterPack(UnresolvedSetIterator Begin, UnresolvedSetIterator End)
Definition ExprCXX.cpp:404
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:1995
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:1979
A C++ addrspace_cast expression (currently only enabled for OpenCL).
Definition ExprCXX.h:608
static CXXAddrspaceCastExpr * CreateEmpty(const ASTContext &Context)
Definition ExprCXX.cpp:921
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:913
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:1125
static CXXConstCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, Expr *Op, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Definition ExprCXX.cpp:899
static CXXConstCastExpr * CreateEmpty(const ASTContext &Context)
Definition ExprCXX.cpp:908
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:1187
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:1211
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:586
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:580
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:1202
Represents a C++ constructor within a class.
Definition DeclCXX.h:2620
const ParmVarDecl * getParam() const
Definition ExprCXX.h:1316
Expr * getAdjustedRewrittenExpr()
Definition ExprCXX.cpp:1062
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
Definition ExprCXX.cpp:1046
static CXXDefaultArgExpr * CreateEmpty(const ASTContext &C, bool HasRewrittenInit)
Definition ExprCXX.cpp:1039
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:1100
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:1112
static CXXDefaultInitExpr * CreateEmpty(const ASTContext &C, bool HasRewrittenInit)
Definition ExprCXX.cpp:1093
FunctionDecl * getOperatorDelete() const
Definition ExprCXX.h:2669
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition ExprCXX.cpp:343
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:1557
static CXXDependentScopeMemberExpr * CreateEmpty(const ASTContext &Ctx, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs, bool HasFirstQualifierFoundInScope)
Definition ExprCXX.cpp:1578
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:813
static CXXDynamicCastExpr * CreateEmpty(const ASTContext &Context, unsigned pathSize)
Definition ExprCXX.cpp:831
bool isAlwaysNull() const
isAlwaysNull - Return whether the result of the dynamic_cast is proven to always be null.
Definition ExprCXX.cpp:845
CXXFoldExpr(QualType T, UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Opcode, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, UnsignedOrNone NumExpansions)
Definition ExprCXX.cpp:2027
static CXXFunctionalCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize, bool HasFPFeatures)
Definition ExprCXX.cpp:941
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:951
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.cpp:955
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:925
CXXMethodDecl * getMethodDecl() const
Retrieve the declaration of the called method.
Definition ExprCXX.cpp:748
Expr * getImplicitObjectArgument() const
Retrieve the implicit object argument for the member call.
Definition ExprCXX.cpp:729
static CXXMemberCallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty)
Definition ExprCXX.cpp:716
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:699
QualType getObjectType() const
Retrieve the type of the object argument.
Definition ExprCXX.cpp:741
CXXRecordDecl * getRecordDecl() const
Retrieve the CXXRecordDecl for the underlying type of the implicit object argument.
Definition ExprCXX.cpp:757
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:775
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:298
static CXXNewExpr * CreateEmpty(const ASTContext &Ctx, bool IsArray, bool HasInit, unsigned NumPlacementArgs, bool IsParenTypeId)
Create an empty c++ new expression.
Definition ExprCXX.cpp:320
bool shouldNullCheckAllocation() const
True if the allocation result needs to be null-checked.
Definition ExprCXX.cpp:331
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:629
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:646
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:2010
static CXXParenListInitExpr * CreateEmpty(ASTContext &C, unsigned numExprs, EmptyShell Empty)
Definition ExprCXX.cpp:2019
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:376
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.cpp:397
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition ExprCXX.cpp:390
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:1955
static CXXReflectExpr * CreateEmpty(ASTContext &C)
Definition ExprCXX.cpp:1961
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:877
static CXXReinterpretCastExpr * CreateEmpty(const ASTContext &Context, unsigned pathSize)
Definition ExprCXX.cpp:894
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:228
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:787
static CXXStaticCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize, bool hasFPFeatures)
Definition ExprCXX.cpp:804
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:1153
TypeSourceInfo * getTypeSourceInfo() const
Definition ExprCXX.h:1932
SourceLocation getEndLoc() const LLVM_READONLY
Definition ExprCXX.cpp:1180
static CXXTemporaryObjectExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs)
Definition ExprCXX.cpp:1168
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:1176
Represents a C++ temporary.
Definition ExprCXX.h:1463
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
Definition ExprCXX.cpp:1120
static CXXThisExpr * CreateEmpty(const ASTContext &Ctx)
Definition ExprCXX.cpp:1598
static CXXThisExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType Ty, bool IsImplicit)
Definition ExprCXX.cpp:1592
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:166
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:205
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:1495
SourceLocation getBeginLoc() const LLVM_READONLY
Definition ExprCXX.cpp:1511
static CXXUnresolvedConstructExpr * CreateEmpty(const ASTContext &Context, unsigned NumArgs)
Definition ExprCXX.cpp:1505
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this __uuidof() expression after various required adjustments (removing...
Definition ExprCXX.cpp:220
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:1478
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:1750
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:549
static DependentScopeDeclRefExpr * CreateEmpty(const ASTContext &Context, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition ExprCXX.cpp:564
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:1471
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:3124
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:3085
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
Definition Expr.cpp:3093
Expr()=delete
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition Expr.cpp:3221
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:1821
static FunctionParmPackExpr * CreateEmpty(const ASTContext &Context, unsigned NumParams)
Definition ExprCXX.cpp:1829
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5369
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:1241
LambdaCaptureKind getCaptureKind() const
Determine the kind of capture.
Definition ExprCXX.cpp:1271
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:1370
static LambdaExpr * CreateDeserialized(const ASTContext &C, unsigned NumCaptures)
Construct a new lambda expression that will be deserialized from an external source.
Definition ExprCXX.cpp:1339
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:1319
Stmt * getBody() const
Retrieve the body of the lambda.
Definition ExprCXX.cpp:1353
bool isMutable() const
Determine whether the lambda is mutable, meaning that any captures values can be modified.
Definition ExprCXX.cpp:1435
capture_iterator implicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of implicit lambda captures.
Definition ExprCXX.cpp:1399
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:1391
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
Definition ExprCXX.cpp:1365
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
Definition ExprCXX.cpp:1411
const CompoundStmt * getCompoundStmtBody() const
Retrieve the CompoundStmt representing the body of the lambda.
Definition ExprCXX.cpp:1358
capture_range implicit_captures() const
Retrieve this lambda's implicit captures.
Definition ExprCXX.cpp:1403
const AssociatedConstraint & getTrailingRequiresClause() const
Get the trailing requires clause, if any.
Definition ExprCXX.cpp:1431
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it,...
Definition ExprCXX.cpp:1421
ArrayRef< NamedDecl * > getExplicitTemplateParameters() const
Get the template parameters were explicitly specified (as opposed to being invented by use of an auto...
Definition ExprCXX.cpp:1426
capture_iterator implicit_capture_begin() const
Retrieve an iterator pointing to the first implicit lambda capture.
Definition ExprCXX.cpp:1395
capture_iterator explicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
Definition ExprCXX.cpp:1386
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition ExprCXX.cpp:1374
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:1382
child_range children()
Includes the captures and the body of the lambda.
Definition ExprCXX.cpp:1437
FunctionTemplateDecl * getDependentCallOperator() const
Retrieve the function template call operator associated with this lambda expression.
Definition ExprCXX.cpp:1416
capture_range captures() const
Retrieve this lambda's captures.
Definition ExprCXX.cpp:1378
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Definition ExprCXX.cpp:1407
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:1835
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:1866
void setExtendingDecl(ValueDecl *ExtendedBy, unsigned ManglingNumber)
Definition ExprCXX.cpp:1849
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:484
NamedDecl * getPackDecl() const
Definition ExprCXX.cpp:1757
static PackIndexingExpr * CreateDeserialized(ASTContext &Context, unsigned NumTransformedExprs)
Definition ExprCXX.cpp:1766
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:1740
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:3390
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:8529
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:8630
The collection of all-type qualifiers we support.
Definition TypeBase.h:331
static SizeOfPackExpr * CreateDeserialized(ASTContext &Context, unsigned NumPartialArgs)
Definition ExprCXX.cpp:1728
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs={})
Definition ExprCXX.cpp:1716
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:1395
ExprWithCleanupsBitfields ExprWithCleanupsBits
Definition Stmt.h:1394
StmtClass getStmtClass() const
Definition Stmt.h:1503
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:1397
CXXConstructExprBitfields CXXConstructExprBits
Definition Stmt.h:1393
CXXDependentScopeMemberExprBitfields CXXDependentScopeMemberExprBits
Definition Stmt.h:1396
TypeTraitExprBitfields TypeTraitExprBits
Definition Stmt.h:1391
CXXNewExprBitfields CXXNewExprBits
Definition Stmt.h:1389
llvm::iterator_range< child_iterator > child_range
Definition Stmt.h:1592
CXXFoldExprBitfields CXXFoldExprBits
Definition Stmt.h:1406
CXXOperatorCallExprBitfields CXXOperatorCallExprBits
Definition Stmt.h:1380
CXXDefaultInitExprBitfields CXXDefaultInitExprBits
Definition Stmt.h:1387
DependentScopeDeclRefExprBitfields DependentScopeDeclRefExprBits
Definition Stmt.h:1392
llvm::iterator_range< const_child_iterator > const_child_range
Definition Stmt.h:1593
CXXDefaultArgExprBitfields CXXDefaultArgExprBits
Definition Stmt.h:1386
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:1773
NonTypeTemplateParmDecl * getParameter() const
Definition ExprCXX.cpp:1735
TemplateArgument getArgumentPack() const
Retrieve the template argument pack containing the substituted template arguments.
Definition ExprCXX.cpp:1804
NonTypeTemplateParmDecl * getParameterPack() const
Retrieve the non-type template parameter pack being substituted.
Definition ExprCXX.cpp:1799
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:8416
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:1919
static TypeTraitExpr * CreateDeserialized(const ASTContext &C, bool IsStoredAsBool, unsigned NumArgs)
Definition ExprCXX.cpp:1939
The base class of the type hierarchy.
Definition TypeBase.h:1875
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
Definition Type.cpp:3109
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:8682
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
Definition TypeBase.h:9092
const T * castAs() const
Member-template castAs<specific type>.
Definition TypeBase.h:9342
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:8686
bool isFloatingType() const
Definition Type.cpp:2389
bool isAnyPointerType() const
Definition TypeBase.h:8690
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:472
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:437
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:1659
CXXRecordDecl * getNamingClass()
Retrieve the naming class of this lookup.
Definition ExprCXX.cpp:1690
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:1652
static UnresolvedMemberExpr * CreateEmpty(const ASTContext &Context, unsigned NumResults, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition ExprCXX.cpp:1678
The iterator over UnresolvedSets.
LiteralOperatorKind getLiteralOperatorKind() const
Returns the kind of literal operator invocation which this expression represents.
Definition ExprCXX.cpp:1006
const IdentifierInfo * getUDSuffix() const
Returns the ud-suffix specified for this literal.
Definition ExprCXX.cpp:1035
static UserDefinedLiteral * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation LitEndLoc, SourceLocation SuffixLoc, FPOptionsOverride FPFeatures)
Definition ExprCXX.cpp:973
static UserDefinedLiteral * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPOptions, EmptyShell Empty)
Definition ExprCXX.cpp:991
Expr * getCookedLiteral()
If this is not a raw user-defined literal, get the underlying cooked literal (representing the litera...
Definition ExprCXX.cpp:1027
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:5979
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:1443