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