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