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