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->isPointerType() && !Ty->isReferenceType())
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 : OverloadExpr(UnresolvedLookupExprClass, Context, QualifierLoc,
407 TemplateKWLoc, NameInfo, TemplateArgs, Begin, End,
408 KnownDependent, false, false),
409 NamingClass(NamingClass) {
410 UnresolvedLookupExprBits.RequiresADL = RequiresADL;
411}
412
413UnresolvedLookupExpr::UnresolvedLookupExpr(EmptyShell Empty,
414 unsigned NumResults,
415 bool HasTemplateKWAndArgsInfo)
416 : OverloadExpr(UnresolvedLookupExprClass, Empty, NumResults,
417 HasTemplateKWAndArgsInfo) {}
418
420 const ASTContext &Context, CXXRecordDecl *NamingClass,
421 NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
423 bool KnownDependent) {
424 unsigned NumResults = End - Begin;
425 unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
426 TemplateArgumentLoc>(NumResults, 0, 0);
427 void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
428 return new (Mem) UnresolvedLookupExpr(
429 Context, NamingClass, QualifierLoc,
430 /*TemplateKWLoc=*/SourceLocation(), NameInfo, RequiresADL,
431 /*TemplateArgs=*/nullptr, Begin, End, KnownDependent);
432}
433
435 const ASTContext &Context, CXXRecordDecl *NamingClass,
436 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
437 const DeclarationNameInfo &NameInfo, bool RequiresADL,
439 UnresolvedSetIterator End, bool KnownDependent) {
440 unsigned NumResults = End - Begin;
441 bool HasTemplateKWAndArgsInfo = Args || TemplateKWLoc.isValid();
442 unsigned NumTemplateArgs = Args ? Args->size() : 0;
443 unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
445 NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
446 void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
447 return new (Mem) UnresolvedLookupExpr(Context, NamingClass, QualifierLoc,
448 TemplateKWLoc, NameInfo, RequiresADL,
449 Args, Begin, End, KnownDependent);
450}
451
453 const ASTContext &Context, unsigned NumResults,
454 bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs) {
455 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
456 unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
458 NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
459 void *Mem = Context.Allocate(Size, alignof(UnresolvedLookupExpr));
460 return new (Mem)
461 UnresolvedLookupExpr(EmptyShell(), NumResults, HasTemplateKWAndArgsInfo);
462}
463
465 NestedNameSpecifierLoc QualifierLoc,
466 SourceLocation TemplateKWLoc,
467 const DeclarationNameInfo &NameInfo,
468 const TemplateArgumentListInfo *TemplateArgs,
470 UnresolvedSetIterator End, bool KnownDependent,
471 bool KnownInstantiationDependent,
472 bool KnownContainsUnexpandedParameterPack)
473 : Expr(SC, Context.OverloadTy, VK_LValue, OK_Ordinary), NameInfo(NameInfo),
474 QualifierLoc(QualifierLoc) {
475 unsigned NumResults = End - Begin;
476 OverloadExprBits.NumResults = NumResults;
477 OverloadExprBits.HasTemplateKWAndArgsInfo =
478 (TemplateArgs != nullptr ) || TemplateKWLoc.isValid();
479
480 if (NumResults) {
481 // Copy the results to the trailing array past UnresolvedLookupExpr
482 // or UnresolvedMemberExpr.
484 memcpy(Results, Begin.I, NumResults * sizeof(DeclAccessPair));
485 }
486
487 if (TemplateArgs) {
488 auto Deps = TemplateArgumentDependence::None;
490 TemplateKWLoc, *TemplateArgs, getTrailingTemplateArgumentLoc(), Deps);
491 } else if (TemplateKWLoc.isValid()) {
493 }
494
495 setDependence(computeDependence(this, KnownDependent,
496 KnownInstantiationDependent,
497 KnownContainsUnexpandedParameterPack));
498 if (isTypeDependent())
499 setType(Context.DependentTy);
500}
501
503 bool HasTemplateKWAndArgsInfo)
504 : Expr(SC, Empty) {
505 OverloadExprBits.NumResults = NumResults;
506 OverloadExprBits.HasTemplateKWAndArgsInfo = HasTemplateKWAndArgsInfo;
507}
508
509// DependentScopeDeclRefExpr
510DependentScopeDeclRefExpr::DependentScopeDeclRefExpr(
511 QualType Ty, NestedNameSpecifierLoc QualifierLoc,
512 SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo,
513 const TemplateArgumentListInfo *Args)
514 : Expr(DependentScopeDeclRefExprClass, Ty, VK_LValue, OK_Ordinary),
515 QualifierLoc(QualifierLoc), NameInfo(NameInfo) {
516 DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo =
517 (Args != nullptr) || TemplateKWLoc.isValid();
518 if (Args) {
519 auto Deps = TemplateArgumentDependence::None;
520 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
521 TemplateKWLoc, *Args, getTrailingObjects<TemplateArgumentLoc>(), Deps);
522 } else if (TemplateKWLoc.isValid()) {
523 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
524 TemplateKWLoc);
525 }
527}
528
530 const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc,
531 SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo,
532 const TemplateArgumentListInfo *Args) {
533 assert(QualifierLoc && "should be created for dependent qualifiers");
534 bool HasTemplateKWAndArgsInfo = Args || TemplateKWLoc.isValid();
535 std::size_t Size =
536 totalSizeToAlloc<ASTTemplateKWAndArgsInfo, TemplateArgumentLoc>(
537 HasTemplateKWAndArgsInfo, Args ? Args->size() : 0);
538 void *Mem = Context.Allocate(Size);
539 return new (Mem) DependentScopeDeclRefExpr(Context.DependentTy, QualifierLoc,
540 TemplateKWLoc, NameInfo, Args);
541}
542
545 bool HasTemplateKWAndArgsInfo,
546 unsigned NumTemplateArgs) {
547 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
548 std::size_t Size =
549 totalSizeToAlloc<ASTTemplateKWAndArgsInfo, TemplateArgumentLoc>(
550 HasTemplateKWAndArgsInfo, NumTemplateArgs);
551 void *Mem = Context.Allocate(Size);
552 auto *E = new (Mem) DependentScopeDeclRefExpr(
554 DeclarationNameInfo(), nullptr);
555 E->DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo =
556 HasTemplateKWAndArgsInfo;
557 return E;
558}
559
561 if (const auto *TOE = dyn_cast<CXXTemporaryObjectExpr>(this))
562 return TOE->getBeginLoc();
563 return getLocation();
564}
565
567 if (const auto *TOE = dyn_cast<CXXTemporaryObjectExpr>(this))
568 return TOE->getEndLoc();
569
570 if (ParenOrBraceRange.isValid())
571 return ParenOrBraceRange.getEnd();
572
574 for (unsigned I = getNumArgs(); I > 0; --I) {
575 const Expr *Arg = getArg(I-1);
576 if (!Arg->isDefaultArgument()) {
577 SourceLocation NewEnd = Arg->getEndLoc();
578 if (NewEnd.isValid()) {
579 End = NewEnd;
580 break;
581 }
582 }
583 }
584
585 return End;
586}
587
588CXXOperatorCallExpr::CXXOperatorCallExpr(OverloadedOperatorKind OpKind,
589 Expr *Fn, ArrayRef<Expr *> Args,
590 QualType Ty, ExprValueKind VK,
591 SourceLocation OperatorLoc,
592 FPOptionsOverride FPFeatures,
593 ADLCallKind UsesADL)
594 : CallExpr(CXXOperatorCallExprClass, Fn, /*PreArgs=*/{}, Args, Ty, VK,
595 OperatorLoc, FPFeatures, /*MinNumArgs=*/0, UsesADL) {
596 CXXOperatorCallExprBits.OperatorKind = OpKind;
597 assert(
598 (CXXOperatorCallExprBits.OperatorKind == static_cast<unsigned>(OpKind)) &&
599 "OperatorKind overflow!");
600 Range = getSourceRangeImpl();
601}
602
603CXXOperatorCallExpr::CXXOperatorCallExpr(unsigned NumArgs, bool HasFPFeatures,
604 EmptyShell Empty)
605 : CallExpr(CXXOperatorCallExprClass, /*NumPreArgs=*/0, NumArgs,
606 HasFPFeatures, Empty) {}
607
610 OverloadedOperatorKind OpKind, Expr *Fn,
611 ArrayRef<Expr *> Args, QualType Ty,
612 ExprValueKind VK, SourceLocation OperatorLoc,
613 FPOptionsOverride FPFeatures, ADLCallKind UsesADL) {
614 // Allocate storage for the trailing objects of CallExpr.
615 unsigned NumArgs = Args.size();
616 unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
617 /*NumPreArgs=*/0, NumArgs, FPFeatures.requiresTrailingStorage());
618 void *Mem = Ctx.Allocate(sizeof(CXXOperatorCallExpr) + SizeOfTrailingObjects,
619 alignof(CXXOperatorCallExpr));
620 return new (Mem) CXXOperatorCallExpr(OpKind, Fn, Args, Ty, VK, OperatorLoc,
621 FPFeatures, UsesADL);
622}
623
625 unsigned NumArgs,
626 bool HasFPFeatures,
628 // Allocate storage for the trailing objects of CallExpr.
629 unsigned SizeOfTrailingObjects =
630 CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs, HasFPFeatures);
631 void *Mem = Ctx.Allocate(sizeof(CXXOperatorCallExpr) + SizeOfTrailingObjects,
632 alignof(CXXOperatorCallExpr));
633 return new (Mem) CXXOperatorCallExpr(NumArgs, HasFPFeatures, Empty);
634}
635
636SourceRange CXXOperatorCallExpr::getSourceRangeImpl() const {
638 if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
639 if (getNumArgs() == 1)
640 // Prefix operator
642 else
643 // Postfix operator
645 } else if (Kind == OO_Arrow) {
647 } else if (Kind == OO_Call) {
649 } else if (Kind == OO_Subscript) {
651 } else if (getNumArgs() == 1) {
653 } else if (getNumArgs() == 2) {
654 return SourceRange(getArg(0)->getBeginLoc(), getArg(1)->getEndLoc());
655 } else {
656 return getOperatorLoc();
657 }
658}
659
660CXXMemberCallExpr::CXXMemberCallExpr(Expr *Fn, ArrayRef<Expr *> Args,
661 QualType Ty, ExprValueKind VK,
664 unsigned MinNumArgs)
665 : CallExpr(CXXMemberCallExprClass, Fn, /*PreArgs=*/{}, Args, Ty, VK, RP,
666 FPOptions, MinNumArgs, NotADL) {}
667
668CXXMemberCallExpr::CXXMemberCallExpr(unsigned NumArgs, bool HasFPFeatures,
669 EmptyShell Empty)
670 : CallExpr(CXXMemberCallExprClass, /*NumPreArgs=*/0, NumArgs, HasFPFeatures,
671 Empty) {}
672
674 ArrayRef<Expr *> Args, QualType Ty,
675 ExprValueKind VK,
677 FPOptionsOverride FPFeatures,
678 unsigned MinNumArgs) {
679 // Allocate storage for the trailing objects of CallExpr.
680 unsigned NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
681 unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
682 /*NumPreArgs=*/0, NumArgs, FPFeatures.requiresTrailingStorage());
683 void *Mem = Ctx.Allocate(sizeof(CXXMemberCallExpr) + SizeOfTrailingObjects,
684 alignof(CXXMemberCallExpr));
685 return new (Mem)
686 CXXMemberCallExpr(Fn, Args, Ty, VK, RP, FPFeatures, MinNumArgs);
687}
688
690 unsigned NumArgs,
691 bool HasFPFeatures,
693 // Allocate storage for the trailing objects of CallExpr.
694 unsigned SizeOfTrailingObjects =
695 CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs, HasFPFeatures);
696 void *Mem = Ctx.Allocate(sizeof(CXXMemberCallExpr) + SizeOfTrailingObjects,
697 alignof(CXXMemberCallExpr));
698 return new (Mem) CXXMemberCallExpr(NumArgs, HasFPFeatures, Empty);
699}
700
702 const Expr *Callee = getCallee()->IgnoreParens();
703 if (const auto *MemExpr = dyn_cast<MemberExpr>(Callee))
704 return MemExpr->getBase();
705 if (const auto *BO = dyn_cast<BinaryOperator>(Callee))
706 if (BO->getOpcode() == BO_PtrMemD || BO->getOpcode() == BO_PtrMemI)
707 return BO->getLHS();
708
709 // FIXME: Will eventually need to cope with member pointers.
710 return nullptr;
711}
712
715 if (Ty->isPointerType())
716 Ty = Ty->getPointeeType();
717 return Ty;
718}
719
721 if (const auto *MemExpr = dyn_cast<MemberExpr>(getCallee()->IgnoreParens()))
722 return cast<CXXMethodDecl>(MemExpr->getMemberDecl());
723
724 // FIXME: Will eventually need to cope with member pointers.
725 // NOTE: Update makeTailCallIfSwiftAsync on fixing this.
726 return nullptr;
727}
728
730 Expr* ThisArg = getImplicitObjectArgument();
731 if (!ThisArg)
732 return nullptr;
733
734 if (ThisArg->getType()->isAnyPointerType())
735 return ThisArg->getType()->getPointeeType()->getAsCXXRecordDecl();
736
737 return ThisArg->getType()->getAsCXXRecordDecl();
738}
739
740//===----------------------------------------------------------------------===//
741// Named casts
742//===----------------------------------------------------------------------===//
743
744/// getCastName - Get the name of the C++ cast being used, e.g.,
745/// "static_cast", "dynamic_cast", "reinterpret_cast", or
746/// "const_cast". The returned pointer must not be freed.
747const char *CXXNamedCastExpr::getCastName() const {
748 switch (getStmtClass()) {
749 case CXXStaticCastExprClass: return "static_cast";
750 case CXXDynamicCastExprClass: return "dynamic_cast";
751 case CXXReinterpretCastExprClass: return "reinterpret_cast";
752 case CXXConstCastExprClass: return "const_cast";
753 case CXXAddrspaceCastExprClass: return "addrspace_cast";
754 default: return "<invalid cast>";
755 }
756}
757
760 CastKind K, Expr *Op, const CXXCastPath *BasePath,
761 TypeSourceInfo *WrittenTy, FPOptionsOverride FPO,
762 SourceLocation L, SourceLocation RParenLoc,
763 SourceRange AngleBrackets) {
764 unsigned PathSize = (BasePath ? BasePath->size() : 0);
765 void *Buffer =
766 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
767 PathSize, FPO.requiresTrailingStorage()));
768 auto *E = new (Buffer) CXXStaticCastExpr(T, VK, K, Op, PathSize, WrittenTy,
769 FPO, L, RParenLoc, AngleBrackets);
770 if (PathSize)
771 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
772 E->getTrailingObjects<CXXBaseSpecifier *>());
773 return E;
774}
775
777 unsigned PathSize,
778 bool HasFPFeatures) {
779 void *Buffer =
780 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
781 PathSize, HasFPFeatures));
782 return new (Buffer) CXXStaticCastExpr(EmptyShell(), PathSize, HasFPFeatures);
783}
784
786 ExprValueKind VK,
787 CastKind K, Expr *Op,
788 const CXXCastPath *BasePath,
789 TypeSourceInfo *WrittenTy,
791 SourceLocation RParenLoc,
792 SourceRange AngleBrackets) {
793 unsigned PathSize = (BasePath ? BasePath->size() : 0);
794 void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
795 auto *E =
796 new (Buffer) CXXDynamicCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
797 RParenLoc, AngleBrackets);
798 if (PathSize)
799 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
800 E->getTrailingObjects<CXXBaseSpecifier *>());
801 return E;
802}
803
805 unsigned PathSize) {
806 void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
807 return new (Buffer) CXXDynamicCastExpr(EmptyShell(), PathSize);
808}
809
810/// isAlwaysNull - Return whether the result of the dynamic_cast is proven
811/// to always be null. For example:
812///
813/// struct A { };
814/// struct B final : A { };
815/// struct C { };
816///
817/// C *f(B* b) { return dynamic_cast<C*>(b); }
819 if (isValueDependent() || getCastKind() != CK_Dynamic)
820 return false;
821
822 QualType SrcType = getSubExpr()->getType();
823 QualType DestType = getType();
824
825 if (DestType->isVoidPointerType())
826 return false;
827
828 if (DestType->isPointerType()) {
829 SrcType = SrcType->getPointeeType();
830 DestType = DestType->getPointeeType();
831 }
832
833 const auto *SrcRD = SrcType->getAsCXXRecordDecl();
834 const auto *DestRD = DestType->getAsCXXRecordDecl();
835 assert(SrcRD && DestRD);
836
837 if (SrcRD->isEffectivelyFinal()) {
838 assert(!SrcRD->isDerivedFrom(DestRD) &&
839 "upcasts should not use CK_Dynamic");
840 return true;
841 }
842
843 if (DestRD->isEffectivelyFinal() && !DestRD->isDerivedFrom(SrcRD))
844 return true;
845
846 return false;
847}
848
851 ExprValueKind VK, CastKind K, Expr *Op,
852 const CXXCastPath *BasePath,
853 TypeSourceInfo *WrittenTy, SourceLocation L,
854 SourceLocation RParenLoc,
855 SourceRange AngleBrackets) {
856 unsigned PathSize = (BasePath ? BasePath->size() : 0);
857 void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
858 auto *E =
859 new (Buffer) CXXReinterpretCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
860 RParenLoc, AngleBrackets);
861 if (PathSize)
862 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
863 E->getTrailingObjects<CXXBaseSpecifier *>());
864 return E;
865}
866
869 void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
870 return new (Buffer) CXXReinterpretCastExpr(EmptyShell(), PathSize);
871}
872
874 ExprValueKind VK, Expr *Op,
875 TypeSourceInfo *WrittenTy,
877 SourceLocation RParenLoc,
878 SourceRange AngleBrackets) {
879 return new (C) CXXConstCastExpr(T, VK, Op, WrittenTy, L, RParenLoc, AngleBrackets);
880}
881
883 return new (C) CXXConstCastExpr(EmptyShell());
884}
885
888 CastKind K, Expr *Op, TypeSourceInfo *WrittenTy,
889 SourceLocation L, SourceLocation RParenLoc,
890 SourceRange AngleBrackets) {
891 return new (C) CXXAddrspaceCastExpr(T, VK, K, Op, WrittenTy, L, RParenLoc,
892 AngleBrackets);
893}
894
896 return new (C) CXXAddrspaceCastExpr(EmptyShell());
897}
898
900 const ASTContext &C, QualType T, ExprValueKind VK, TypeSourceInfo *Written,
901 CastKind K, Expr *Op, const CXXCastPath *BasePath, FPOptionsOverride FPO,
903 unsigned PathSize = (BasePath ? BasePath->size() : 0);
904 void *Buffer =
905 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
906 PathSize, FPO.requiresTrailingStorage()));
907 auto *E = new (Buffer)
908 CXXFunctionalCastExpr(T, VK, Written, K, Op, PathSize, FPO, L, R);
909 if (PathSize)
910 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
911 E->getTrailingObjects<CXXBaseSpecifier *>());
912 return E;
913}
914
916 unsigned PathSize,
917 bool HasFPFeatures) {
918 void *Buffer =
919 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
920 PathSize, HasFPFeatures));
921 return new (Buffer)
922 CXXFunctionalCastExpr(EmptyShell(), PathSize, HasFPFeatures);
923}
924
927}
928
930 return RParenLoc.isValid() ? RParenLoc : getSubExpr()->getEndLoc();
931}
932
933UserDefinedLiteral::UserDefinedLiteral(Expr *Fn, ArrayRef<Expr *> Args,
934 QualType Ty, ExprValueKind VK,
935 SourceLocation LitEndLoc,
936 SourceLocation SuffixLoc,
937 FPOptionsOverride FPFeatures)
938 : CallExpr(UserDefinedLiteralClass, Fn, /*PreArgs=*/{}, Args, Ty, VK,
939 LitEndLoc, FPFeatures, /*MinNumArgs=*/0, NotADL),
940 UDSuffixLoc(SuffixLoc) {}
941
942UserDefinedLiteral::UserDefinedLiteral(unsigned NumArgs, bool HasFPFeatures,
943 EmptyShell Empty)
944 : CallExpr(UserDefinedLiteralClass, /*NumPreArgs=*/0, NumArgs,
945 HasFPFeatures, Empty) {}
946
948 ArrayRef<Expr *> Args,
949 QualType Ty, ExprValueKind VK,
950 SourceLocation LitEndLoc,
951 SourceLocation SuffixLoc,
952 FPOptionsOverride FPFeatures) {
953 // Allocate storage for the trailing objects of CallExpr.
954 unsigned NumArgs = Args.size();
955 unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
956 /*NumPreArgs=*/0, NumArgs, FPFeatures.requiresTrailingStorage());
957 void *Mem = Ctx.Allocate(sizeof(UserDefinedLiteral) + SizeOfTrailingObjects,
958 alignof(UserDefinedLiteral));
959 return new (Mem)
960 UserDefinedLiteral(Fn, Args, Ty, VK, LitEndLoc, SuffixLoc, FPFeatures);
961}
962
964 unsigned NumArgs,
965 bool HasFPOptions,
967 // Allocate storage for the trailing objects of CallExpr.
968 unsigned SizeOfTrailingObjects =
969 CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs, HasFPOptions);
970 void *Mem = Ctx.Allocate(sizeof(UserDefinedLiteral) + SizeOfTrailingObjects,
971 alignof(UserDefinedLiteral));
972 return new (Mem) UserDefinedLiteral(NumArgs, HasFPOptions, Empty);
973}
974
977 if (getNumArgs() == 0)
978 return LOK_Template;
979 if (getNumArgs() == 2)
980 return LOK_String;
981
982 assert(getNumArgs() == 1 && "unexpected #args in literal operator call");
983 QualType ParamTy =
984 cast<FunctionDecl>(getCalleeDecl())->getParamDecl(0)->getType();
985 if (ParamTy->isPointerType())
986 return LOK_Raw;
987 if (ParamTy->isAnyCharacterType())
988 return LOK_Character;
989 if (ParamTy->isIntegerType())
990 return LOK_Integer;
991 if (ParamTy->isFloatingType())
992 return LOK_Floating;
993
994 llvm_unreachable("unknown kind of literal operator");
995}
996
998#ifndef NDEBUG
1000 assert(LOK != LOK_Template && LOK != LOK_Raw && "not a cooked literal");
1001#endif
1002 return getArg(0);
1003}
1004
1006 return cast<FunctionDecl>(getCalleeDecl())->getLiteralIdentifier();
1007}
1008
1010 bool HasRewrittenInit) {
1011 size_t Size = totalSizeToAlloc<Expr *>(HasRewrittenInit);
1012 auto *Mem = C.Allocate(Size, alignof(CXXDefaultArgExpr));
1013 return new (Mem) CXXDefaultArgExpr(EmptyShell(), HasRewrittenInit);
1014}
1015
1018 ParmVarDecl *Param,
1019 Expr *RewrittenExpr,
1020 DeclContext *UsedContext) {
1021 size_t Size = totalSizeToAlloc<Expr *>(RewrittenExpr != nullptr);
1022 auto *Mem = C.Allocate(Size, alignof(CXXDefaultArgExpr));
1023 return new (Mem) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param,
1024 RewrittenExpr, UsedContext);
1025}
1026
1028 return CXXDefaultArgExprBits.HasRewrittenInit ? getAdjustedRewrittenExpr()
1029 : getParam()->getDefaultArg();
1030}
1031
1033 assert(hasRewrittenInit() &&
1034 "expected this CXXDefaultArgExpr to have a rewritten init.");
1036 if (auto *E = dyn_cast_if_present<FullExpr>(Init))
1037 if (!isa<ConstantExpr>(E))
1038 return E->getSubExpr();
1039 return Init;
1040}
1041
1042CXXDefaultInitExpr::CXXDefaultInitExpr(const ASTContext &Ctx,
1044 QualType Ty, DeclContext *UsedContext,
1045 Expr *RewrittenInitExpr)
1046 : Expr(CXXDefaultInitExprClass, Ty.getNonLValueExprType(Ctx),
1047 Ty->isLValueReferenceType() ? VK_LValue
1048 : Ty->isRValueReferenceType() ? VK_XValue
1049 : VK_PRValue,
1050 /*FIXME*/ OK_Ordinary),
1051 Field(Field), UsedContext(UsedContext) {
1053 CXXDefaultInitExprBits.HasRewrittenInit = RewrittenInitExpr != nullptr;
1054
1055 if (CXXDefaultInitExprBits.HasRewrittenInit)
1056 *getTrailingObjects<Expr *>() = RewrittenInitExpr;
1057
1058 assert(Field->hasInClassInitializer());
1059
1061}
1062
1064 bool HasRewrittenInit) {
1065 size_t Size = totalSizeToAlloc<Expr *>(HasRewrittenInit);
1066 auto *Mem = C.Allocate(Size, alignof(CXXDefaultInitExpr));
1067 return new (Mem) CXXDefaultInitExpr(EmptyShell(), HasRewrittenInit);
1068}
1069
1072 FieldDecl *Field,
1073 DeclContext *UsedContext,
1074 Expr *RewrittenInitExpr) {
1075
1076 size_t Size = totalSizeToAlloc<Expr *>(RewrittenInitExpr != nullptr);
1077 auto *Mem = Ctx.Allocate(Size, alignof(CXXDefaultInitExpr));
1078 return new (Mem) CXXDefaultInitExpr(Ctx, Loc, Field, Field->getType(),
1079 UsedContext, RewrittenInitExpr);
1080}
1081
1083 assert(Field->getInClassInitializer() && "initializer hasn't been parsed");
1084 if (hasRewrittenInit())
1085 return getRewrittenExpr();
1086
1087 return Field->getInClassInitializer();
1088}
1089
1092 return new (C) CXXTemporary(Destructor);
1093}
1094
1096 CXXTemporary *Temp,
1097 Expr* SubExpr) {
1098 assert((SubExpr->getType()->isRecordType() ||
1099 SubExpr->getType()->isArrayType()) &&
1100 "Expression bound to a temporary must have record or array type!");
1101
1102 return new (C) CXXBindTemporaryExpr(Temp, SubExpr);
1103}
1104
1105CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(
1107 ArrayRef<Expr *> Args, SourceRange ParenOrBraceRange,
1108 bool HadMultipleCandidates, bool ListInitialization,
1109 bool StdInitListInitialization, bool ZeroInitialization)
1111 CXXTemporaryObjectExprClass, Ty, TSI->getTypeLoc().getBeginLoc(),
1112 Cons, /* Elidable=*/false, Args, HadMultipleCandidates,
1113 ListInitialization, StdInitListInitialization, ZeroInitialization,
1114 CXXConstructionKind::Complete, ParenOrBraceRange),
1115 TSI(TSI) {
1117}
1118
1119CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(EmptyShell Empty,
1120 unsigned NumArgs)
1121 : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty, NumArgs) {}
1122
1124 const ASTContext &Ctx, CXXConstructorDecl *Cons, QualType Ty,
1125 TypeSourceInfo *TSI, ArrayRef<Expr *> Args, SourceRange ParenOrBraceRange,
1126 bool HadMultipleCandidates, bool ListInitialization,
1127 bool StdInitListInitialization, bool ZeroInitialization) {
1128 unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(Args.size());
1129 void *Mem =
1130 Ctx.Allocate(sizeof(CXXTemporaryObjectExpr) + SizeOfTrailingObjects,
1131 alignof(CXXTemporaryObjectExpr));
1132 return new (Mem) CXXTemporaryObjectExpr(
1133 Cons, Ty, TSI, Args, ParenOrBraceRange, HadMultipleCandidates,
1134 ListInitialization, StdInitListInitialization, ZeroInitialization);
1135}
1136
1139 unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(NumArgs);
1140 void *Mem =
1141 Ctx.Allocate(sizeof(CXXTemporaryObjectExpr) + SizeOfTrailingObjects,
1142 alignof(CXXTemporaryObjectExpr));
1143 return new (Mem) CXXTemporaryObjectExpr(EmptyShell(), NumArgs);
1144}
1145
1148}
1149
1152 if (Loc.isInvalid() && getNumArgs())
1153 Loc = getArg(getNumArgs() - 1)->getEndLoc();
1154 return Loc;
1155}
1156
1158 const ASTContext &Ctx, QualType Ty, SourceLocation Loc,
1159 CXXConstructorDecl *Ctor, bool Elidable, ArrayRef<Expr *> Args,
1160 bool HadMultipleCandidates, bool ListInitialization,
1161 bool StdInitListInitialization, bool ZeroInitialization,
1162 CXXConstructionKind ConstructKind, SourceRange ParenOrBraceRange) {
1163 unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(Args.size());
1164 void *Mem = Ctx.Allocate(sizeof(CXXConstructExpr) + SizeOfTrailingObjects,
1165 alignof(CXXConstructExpr));
1166 return new (Mem) CXXConstructExpr(
1167 CXXConstructExprClass, Ty, Loc, Ctor, Elidable, Args,
1168 HadMultipleCandidates, ListInitialization, StdInitListInitialization,
1169 ZeroInitialization, ConstructKind, ParenOrBraceRange);
1170}
1171
1173 unsigned NumArgs) {
1174 unsigned SizeOfTrailingObjects = sizeOfTrailingObjects(NumArgs);
1175 void *Mem = Ctx.Allocate(sizeof(CXXConstructExpr) + SizeOfTrailingObjects,
1176 alignof(CXXConstructExpr));
1177 return new (Mem)
1178 CXXConstructExpr(CXXConstructExprClass, EmptyShell(), NumArgs);
1179}
1180
1183 bool Elidable, ArrayRef<Expr *> Args, bool HadMultipleCandidates,
1184 bool ListInitialization, bool StdInitListInitialization,
1185 bool ZeroInitialization, CXXConstructionKind ConstructKind,
1186 SourceRange ParenOrBraceRange)
1187 : Expr(SC, Ty, VK_PRValue, OK_Ordinary), Constructor(Ctor),
1188 ParenOrBraceRange(ParenOrBraceRange), NumArgs(Args.size()) {
1189 CXXConstructExprBits.Elidable = Elidable;
1190 CXXConstructExprBits.HadMultipleCandidates = HadMultipleCandidates;
1191 CXXConstructExprBits.ListInitialization = ListInitialization;
1192 CXXConstructExprBits.StdInitListInitialization = StdInitListInitialization;
1193 CXXConstructExprBits.ZeroInitialization = ZeroInitialization;
1194 CXXConstructExprBits.ConstructionKind = llvm::to_underlying(ConstructKind);
1195 CXXConstructExprBits.IsImmediateEscalating = false;
1197
1198 Stmt **TrailingArgs = getTrailingArgs();
1199 for (unsigned I = 0, N = Args.size(); I != N; ++I) {
1200 assert(Args[I] && "NULL argument in CXXConstructExpr!");
1201 TrailingArgs[I] = Args[I];
1202 }
1203
1204 // CXXTemporaryObjectExpr does this itself after setting its TypeSourceInfo.
1205 if (SC == CXXConstructExprClass)
1207}
1208
1210 unsigned NumArgs)
1211 : Expr(SC, Empty), NumArgs(NumArgs) {}
1212
1214 LambdaCaptureKind Kind, ValueDecl *Var,
1215 SourceLocation EllipsisLoc)
1216 : DeclAndBits(Var, 0), Loc(Loc), EllipsisLoc(EllipsisLoc) {
1217 unsigned Bits = 0;
1218 if (Implicit)
1219 Bits |= Capture_Implicit;
1220
1221 switch (Kind) {
1222 case LCK_StarThis:
1223 Bits |= Capture_ByCopy;
1224 [[fallthrough]];
1225 case LCK_This:
1226 assert(!Var && "'this' capture cannot have a variable!");
1227 Bits |= Capture_This;
1228 break;
1229
1230 case LCK_ByCopy:
1231 Bits |= Capture_ByCopy;
1232 [[fallthrough]];
1233 case LCK_ByRef:
1234 assert(Var && "capture must have a variable!");
1235 break;
1236 case LCK_VLAType:
1237 assert(!Var && "VLA type capture cannot have a variable!");
1238 break;
1239 }
1240 DeclAndBits.setInt(Bits);
1241}
1242
1244 if (capturesVLAType())
1245 return LCK_VLAType;
1246 bool CapByCopy = DeclAndBits.getInt() & Capture_ByCopy;
1247 if (capturesThis())
1248 return CapByCopy ? LCK_StarThis : LCK_This;
1249 return CapByCopy ? LCK_ByCopy : LCK_ByRef;
1250}
1251
1252LambdaExpr::LambdaExpr(QualType T, SourceRange IntroducerRange,
1253 LambdaCaptureDefault CaptureDefault,
1254 SourceLocation CaptureDefaultLoc, bool ExplicitParams,
1255 bool ExplicitResultType, ArrayRef<Expr *> CaptureInits,
1256 SourceLocation ClosingBrace,
1257 bool ContainsUnexpandedParameterPack)
1258 : Expr(LambdaExprClass, T, VK_PRValue, OK_Ordinary),
1259 IntroducerRange(IntroducerRange), CaptureDefaultLoc(CaptureDefaultLoc),
1260 ClosingBrace(ClosingBrace) {
1261 LambdaExprBits.NumCaptures = CaptureInits.size();
1262 LambdaExprBits.CaptureDefault = CaptureDefault;
1263 LambdaExprBits.ExplicitParams = ExplicitParams;
1264 LambdaExprBits.ExplicitResultType = ExplicitResultType;
1265
1266 CXXRecordDecl *Class = getLambdaClass();
1267 (void)Class;
1268 assert(capture_size() == Class->capture_size() && "Wrong number of captures");
1269 assert(getCaptureDefault() == Class->getLambdaCaptureDefault());
1270
1271 // Copy initialization expressions for the non-static data members.
1272 Stmt **Stored = getStoredStmts();
1273 for (unsigned I = 0, N = CaptureInits.size(); I != N; ++I)
1274 *Stored++ = CaptureInits[I];
1275
1276 // Copy the body of the lambda.
1277 *Stored++ = getCallOperator()->getBody();
1278
1279 setDependence(computeDependence(this, ContainsUnexpandedParameterPack));
1280}
1281
1282LambdaExpr::LambdaExpr(EmptyShell Empty, unsigned NumCaptures)
1283 : Expr(LambdaExprClass, Empty) {
1284 LambdaExprBits.NumCaptures = NumCaptures;
1285
1286 // Initially don't initialize the body of the LambdaExpr. The body will
1287 // be lazily deserialized when needed.
1288 getStoredStmts()[NumCaptures] = nullptr; // Not one past the end.
1289}
1290
1292 SourceRange IntroducerRange,
1293 LambdaCaptureDefault CaptureDefault,
1294 SourceLocation CaptureDefaultLoc,
1295 bool ExplicitParams, bool ExplicitResultType,
1296 ArrayRef<Expr *> CaptureInits,
1297 SourceLocation ClosingBrace,
1298 bool ContainsUnexpandedParameterPack) {
1299 // Determine the type of the expression (i.e., the type of the
1300 // function object we're creating).
1301 QualType T = Context.getTypeDeclType(Class);
1302
1303 unsigned Size = totalSizeToAlloc<Stmt *>(CaptureInits.size() + 1);
1304 void *Mem = Context.Allocate(Size);
1305 return new (Mem)
1306 LambdaExpr(T, IntroducerRange, CaptureDefault, CaptureDefaultLoc,
1307 ExplicitParams, ExplicitResultType, CaptureInits, ClosingBrace,
1308 ContainsUnexpandedParameterPack);
1309}
1310
1312 unsigned NumCaptures) {
1313 unsigned Size = totalSizeToAlloc<Stmt *>(NumCaptures + 1);
1314 void *Mem = C.Allocate(Size);
1315 return new (Mem) LambdaExpr(EmptyShell(), NumCaptures);
1316}
1317
1318void LambdaExpr::initBodyIfNeeded() const {
1319 if (!getStoredStmts()[capture_size()]) {
1320 auto *This = const_cast<LambdaExpr *>(this);
1321 This->getStoredStmts()[capture_size()] = getCallOperator()->getBody();
1322 }
1323}
1324
1326 initBodyIfNeeded();
1327 return getStoredStmts()[capture_size()];
1328}
1329
1331 Stmt *Body = getBody();
1332 if (const auto *CoroBody = dyn_cast<CoroutineBodyStmt>(Body))
1333 return cast<CompoundStmt>(CoroBody->getBody());
1334 return cast<CompoundStmt>(Body);
1335}
1336
1338 return C->capturesVariable() && C->getCapturedVar()->isInitCapture() &&
1339 getCallOperator() == C->getCapturedVar()->getDeclContext();
1340}
1341
1343 return getLambdaClass()->captures_begin();
1344}
1345
1347 return getLambdaClass()->captures_end();
1348}
1349
1352}
1353
1355 return capture_begin();
1356}
1357
1359 return capture_begin() +
1360 getLambdaClass()->getLambdaData().NumExplicitCaptures;
1361}
1362
1365}
1366
1368 return explicit_capture_end();
1369}
1370
1372 return capture_end();
1373}
1374
1377}
1378
1380 return getType()->getAsCXXRecordDecl();
1381}
1382
1385 return Record->getLambdaCallOperator();
1386}
1387
1390 return Record->getDependentLambdaCallOperator();
1391}
1392
1395 return Record->getGenericLambdaTemplateParameterList();
1396}
1397
1400 return Record->getLambdaExplicitTemplateParameters();
1401}
1402
1405}
1406
1407bool LambdaExpr::isMutable() const { return !getCallOperator()->isConst(); }
1408
1410 initBodyIfNeeded();
1411 return child_range(getStoredStmts(), getStoredStmts() + capture_size() + 1);
1412}
1413
1415 initBodyIfNeeded();
1416 return const_child_range(getStoredStmts(),
1417 getStoredStmts() + capture_size() + 1);
1418}
1419
1420ExprWithCleanups::ExprWithCleanups(Expr *subexpr,
1421 bool CleanupsHaveSideEffects,
1423 : FullExpr(ExprWithCleanupsClass, subexpr) {
1424 ExprWithCleanupsBits.CleanupsHaveSideEffects = CleanupsHaveSideEffects;
1425 ExprWithCleanupsBits.NumObjects = objects.size();
1426 for (unsigned i = 0, e = objects.size(); i != e; ++i)
1427 getTrailingObjects<CleanupObject>()[i] = objects[i];
1428}
1429
1431 bool CleanupsHaveSideEffects,
1432 ArrayRef<CleanupObject> objects) {
1433 void *buffer = C.Allocate(totalSizeToAlloc<CleanupObject>(objects.size()),
1434 alignof(ExprWithCleanups));
1435 return new (buffer)
1436 ExprWithCleanups(subexpr, CleanupsHaveSideEffects, objects);
1437}
1438
1439ExprWithCleanups::ExprWithCleanups(EmptyShell empty, unsigned numObjects)
1440 : FullExpr(ExprWithCleanupsClass, empty) {
1441 ExprWithCleanupsBits.NumObjects = numObjects;
1442}
1443
1445 EmptyShell empty,
1446 unsigned numObjects) {
1447 void *buffer = C.Allocate(totalSizeToAlloc<CleanupObject>(numObjects),
1448 alignof(ExprWithCleanups));
1449 return new (buffer) ExprWithCleanups(empty, numObjects);
1450}
1451
1452CXXUnresolvedConstructExpr::CXXUnresolvedConstructExpr(
1453 QualType T, TypeSourceInfo *TSI, SourceLocation LParenLoc,
1454 ArrayRef<Expr *> Args, SourceLocation RParenLoc, bool IsListInit)
1455 : Expr(CXXUnresolvedConstructExprClass, T,
1456 (TSI->getType()->isLValueReferenceType() ? VK_LValue
1457 : TSI->getType()->isRValueReferenceType() ? VK_XValue
1458 : VK_PRValue),
1459 OK_Ordinary),
1460 TypeAndInitForm(TSI, IsListInit), LParenLoc(LParenLoc),
1461 RParenLoc(RParenLoc) {
1462 CXXUnresolvedConstructExprBits.NumArgs = Args.size();
1463 auto **StoredArgs = getTrailingObjects<Expr *>();
1464 for (unsigned I = 0; I != Args.size(); ++I)
1465 StoredArgs[I] = Args[I];
1467}
1468
1470 const ASTContext &Context, QualType T, TypeSourceInfo *TSI,
1471 SourceLocation LParenLoc, ArrayRef<Expr *> Args, SourceLocation RParenLoc,
1472 bool IsListInit) {
1473 void *Mem = Context.Allocate(totalSizeToAlloc<Expr *>(Args.size()));
1474 return new (Mem) CXXUnresolvedConstructExpr(T, TSI, LParenLoc, Args,
1475 RParenLoc, IsListInit);
1476}
1477
1480 unsigned NumArgs) {
1481 void *Mem = Context.Allocate(totalSizeToAlloc<Expr *>(NumArgs));
1482 return new (Mem) CXXUnresolvedConstructExpr(EmptyShell(), NumArgs);
1483}
1484
1486 return TypeAndInitForm.getPointer()->getTypeLoc().getBeginLoc();
1487}
1488
1489CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(
1490 const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow,
1491 SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc,
1492 SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope,
1493 DeclarationNameInfo MemberNameInfo,
1494 const TemplateArgumentListInfo *TemplateArgs)
1495 : Expr(CXXDependentScopeMemberExprClass, Ctx.DependentTy, VK_LValue,
1496 OK_Ordinary),
1497 Base(Base), BaseType(BaseType), QualifierLoc(QualifierLoc),
1498 MemberNameInfo(MemberNameInfo) {
1499 CXXDependentScopeMemberExprBits.IsArrow = IsArrow;
1500 CXXDependentScopeMemberExprBits.HasTemplateKWAndArgsInfo =
1501 (TemplateArgs != nullptr) || TemplateKWLoc.isValid();
1502 CXXDependentScopeMemberExprBits.HasFirstQualifierFoundInScope =
1503 FirstQualifierFoundInScope != nullptr;
1504 CXXDependentScopeMemberExprBits.OperatorLoc = OperatorLoc;
1505
1506 if (TemplateArgs) {
1507 auto Deps = TemplateArgumentDependence::None;
1508 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1509 TemplateKWLoc, *TemplateArgs, getTrailingObjects<TemplateArgumentLoc>(),
1510 Deps);
1511 } else if (TemplateKWLoc.isValid()) {
1512 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1513 TemplateKWLoc);
1514 }
1515
1516 if (hasFirstQualifierFoundInScope())
1517 *getTrailingObjects<NamedDecl *>() = FirstQualifierFoundInScope;
1519}
1520
1521CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(
1522 EmptyShell Empty, bool HasTemplateKWAndArgsInfo,
1523 bool HasFirstQualifierFoundInScope)
1524 : Expr(CXXDependentScopeMemberExprClass, Empty) {
1525 CXXDependentScopeMemberExprBits.HasTemplateKWAndArgsInfo =
1526 HasTemplateKWAndArgsInfo;
1527 CXXDependentScopeMemberExprBits.HasFirstQualifierFoundInScope =
1528 HasFirstQualifierFoundInScope;
1529}
1530
1532 const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow,
1533 SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc,
1534 SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope,
1535 DeclarationNameInfo MemberNameInfo,
1536 const TemplateArgumentListInfo *TemplateArgs) {
1537 bool HasTemplateKWAndArgsInfo =
1538 (TemplateArgs != nullptr) || TemplateKWLoc.isValid();
1539 unsigned NumTemplateArgs = TemplateArgs ? TemplateArgs->size() : 0;
1540 bool HasFirstQualifierFoundInScope = FirstQualifierFoundInScope != nullptr;
1541
1542 unsigned Size = totalSizeToAlloc<ASTTemplateKWAndArgsInfo,
1544 HasTemplateKWAndArgsInfo, NumTemplateArgs, HasFirstQualifierFoundInScope);
1545
1546 void *Mem = Ctx.Allocate(Size, alignof(CXXDependentScopeMemberExpr));
1547 return new (Mem) CXXDependentScopeMemberExpr(
1548 Ctx, Base, BaseType, IsArrow, OperatorLoc, QualifierLoc, TemplateKWLoc,
1549 FirstQualifierFoundInScope, MemberNameInfo, TemplateArgs);
1550}
1551
1553 const ASTContext &Ctx, bool HasTemplateKWAndArgsInfo,
1554 unsigned NumTemplateArgs, bool HasFirstQualifierFoundInScope) {
1555 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
1556
1557 unsigned Size = totalSizeToAlloc<ASTTemplateKWAndArgsInfo,
1559 HasTemplateKWAndArgsInfo, NumTemplateArgs, HasFirstQualifierFoundInScope);
1560
1561 void *Mem = Ctx.Allocate(Size, alignof(CXXDependentScopeMemberExpr));
1562 return new (Mem) CXXDependentScopeMemberExpr(
1563 EmptyShell(), HasTemplateKWAndArgsInfo, HasFirstQualifierFoundInScope);
1564}
1565
1567 QualType Ty, bool IsImplicit) {
1568 return new (Ctx) CXXThisExpr(L, Ty, IsImplicit,
1569 Ctx.getLangOpts().HLSL ? VK_LValue : VK_PRValue);
1570}
1571
1573 return new (Ctx) CXXThisExpr(EmptyShell());
1574}
1575
1578 do {
1579 NamedDecl *decl = *begin;
1580 if (isa<UnresolvedUsingValueDecl>(decl))
1581 return false;
1582
1583 // Unresolved member expressions should only contain methods and
1584 // method templates.
1585 if (cast<CXXMethodDecl>(decl->getUnderlyingDecl()->getAsFunction())
1586 ->isStatic())
1587 return false;
1588 } while (++begin != end);
1589
1590 return true;
1591}
1592
1593UnresolvedMemberExpr::UnresolvedMemberExpr(
1594 const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base,
1595 QualType BaseType, bool IsArrow, SourceLocation OperatorLoc,
1596 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
1597 const DeclarationNameInfo &MemberNameInfo,
1600 : OverloadExpr(
1601 UnresolvedMemberExprClass, Context, QualifierLoc, TemplateKWLoc,
1602 MemberNameInfo, TemplateArgs, Begin, End,
1603 // Dependent
1604 ((Base && Base->isTypeDependent()) || BaseType->isDependentType()),
1605 ((Base && Base->isInstantiationDependent()) ||
1606 BaseType->isInstantiationDependentType()),
1607 // Contains unexpanded parameter pack
1608 ((Base && Base->containsUnexpandedParameterPack()) ||
1609 BaseType->containsUnexpandedParameterPack())),
1610 Base(Base), BaseType(BaseType), OperatorLoc(OperatorLoc) {
1611 UnresolvedMemberExprBits.IsArrow = IsArrow;
1612 UnresolvedMemberExprBits.HasUnresolvedUsing = HasUnresolvedUsing;
1613
1614 // Check whether all of the members are non-static member functions,
1615 // and if so, mark give this bound-member type instead of overload type.
1617 setType(Context.BoundMemberTy);
1618}
1619
1620UnresolvedMemberExpr::UnresolvedMemberExpr(EmptyShell Empty,
1621 unsigned NumResults,
1622 bool HasTemplateKWAndArgsInfo)
1623 : OverloadExpr(UnresolvedMemberExprClass, Empty, NumResults,
1624 HasTemplateKWAndArgsInfo) {}
1625
1627 if (!Base)
1628 return true;
1629
1630 return cast<Expr>(Base)->isImplicitCXXThis();
1631}
1632
1634 const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base,
1635 QualType BaseType, bool IsArrow, SourceLocation OperatorLoc,
1636 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
1637 const DeclarationNameInfo &MemberNameInfo,
1640 unsigned NumResults = End - Begin;
1641 bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.isValid();
1642 unsigned NumTemplateArgs = TemplateArgs ? TemplateArgs->size() : 0;
1643 unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
1645 NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
1646 void *Mem = Context.Allocate(Size, alignof(UnresolvedMemberExpr));
1647 return new (Mem) UnresolvedMemberExpr(
1648 Context, HasUnresolvedUsing, Base, BaseType, IsArrow, OperatorLoc,
1649 QualifierLoc, TemplateKWLoc, MemberNameInfo, TemplateArgs, Begin, End);
1650}
1651
1653 const ASTContext &Context, unsigned NumResults,
1654 bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs) {
1655 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
1656 unsigned Size = totalSizeToAlloc<DeclAccessPair, ASTTemplateKWAndArgsInfo,
1658 NumResults, HasTemplateKWAndArgsInfo, NumTemplateArgs);
1659 void *Mem = Context.Allocate(Size, alignof(UnresolvedMemberExpr));
1660 return new (Mem)
1661 UnresolvedMemberExpr(EmptyShell(), NumResults, HasTemplateKWAndArgsInfo);
1662}
1663
1665 // Unlike for UnresolvedLookupExpr, it is very easy to re-derive this.
1666
1667 // If there was a nested name specifier, it names the naming class.
1668 // It can't be dependent: after all, we were actually able to do the
1669 // lookup.
1670 CXXRecordDecl *Record = nullptr;
1671 auto *NNS = getQualifier();
1672 if (NNS && NNS->getKind() != NestedNameSpecifier::Super) {
1673 const Type *T = getQualifier()->getAsType();
1674 assert(T && "qualifier in member expression does not name type");
1676 assert(Record && "qualifier in member expression does not name record");
1677 }
1678 // Otherwise the naming class must have been the base class.
1679 else {
1681 if (isArrow())
1682 BaseType = BaseType->castAs<PointerType>()->getPointeeType();
1683
1684 Record = BaseType->getAsCXXRecordDecl();
1685 assert(Record && "base of member expression does not name record");
1686 }
1687
1688 return Record;
1689}
1690
1692 SourceLocation OperatorLoc,
1693 NamedDecl *Pack, SourceLocation PackLoc,
1694 SourceLocation RParenLoc,
1695 std::optional<unsigned> Length,
1696 ArrayRef<TemplateArgument> PartialArgs) {
1697 void *Storage =
1698 Context.Allocate(totalSizeToAlloc<TemplateArgument>(PartialArgs.size()));
1699 return new (Storage) SizeOfPackExpr(Context.getSizeType(), OperatorLoc, Pack,
1700 PackLoc, RParenLoc, Length, PartialArgs);
1701}
1702
1704 unsigned NumPartialArgs) {
1705 void *Storage =
1706 Context.Allocate(totalSizeToAlloc<TemplateArgument>(NumPartialArgs));
1707 return new (Storage) SizeOfPackExpr(EmptyShell(), NumPartialArgs);
1708}
1709
1711 return cast<NonTypeTemplateParmDecl>(
1713}
1714
1716 ASTContext &Context, SourceLocation EllipsisLoc, SourceLocation RSquareLoc,
1717 Expr *PackIdExpr, Expr *IndexExpr, std::optional<int64_t> Index,
1718 ArrayRef<Expr *> SubstitutedExprs, bool ExpandedToEmptyPack) {
1719 QualType Type;
1720 if (Index && !SubstitutedExprs.empty())
1721 Type = SubstitutedExprs[*Index]->getType();
1722 else
1723 Type = Context.DependentTy;
1724
1725 void *Storage =
1726 Context.Allocate(totalSizeToAlloc<Expr *>(SubstitutedExprs.size()));
1727 return new (Storage)
1728 PackIndexingExpr(Type, EllipsisLoc, RSquareLoc, PackIdExpr, IndexExpr,
1729 SubstitutedExprs, ExpandedToEmptyPack);
1730}
1731
1733 if (auto *D = dyn_cast<DeclRefExpr>(getPackIdExpression()); D) {
1734 NamedDecl *ND = dyn_cast<NamedDecl>(D->getDecl());
1735 assert(ND && "exected a named decl");
1736 return ND;
1737 }
1738 assert(false && "invalid declaration kind in pack indexing expression");
1739 return nullptr;
1740}
1741
1744 unsigned NumTransformedExprs) {
1745 void *Storage =
1746 Context.Allocate(totalSizeToAlloc<Expr *>(NumTransformedExprs));
1747 return new (Storage) PackIndexingExpr(EmptyShell{});
1748}
1749
1751 const ASTContext &Context) const {
1752 // Note that, for a class type NTTP, we will have an lvalue of type 'const
1753 // T', so we can't just compute this from the type and value category.
1755 return Context.getLValueReferenceType(getType());
1756 return getType().getUnqualifiedType();
1757}
1758
1759SubstNonTypeTemplateParmPackExpr::SubstNonTypeTemplateParmPackExpr(
1760 QualType T, ExprValueKind ValueKind, SourceLocation NameLoc,
1761 const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index)
1762 : Expr(SubstNonTypeTemplateParmPackExprClass, T, ValueKind, OK_Ordinary),
1763 AssociatedDecl(AssociatedDecl), Arguments(ArgPack.pack_begin()),
1764 NumArguments(ArgPack.pack_size()), Index(Index), NameLoc(NameLoc) {
1765 assert(AssociatedDecl != nullptr);
1766 setDependence(ExprDependence::TypeValueInstantiation |
1767 ExprDependence::UnexpandedPack);
1768}
1769
1772 return cast<NonTypeTemplateParmDecl>(
1774}
1775
1777 return TemplateArgument(llvm::ArrayRef(Arguments, NumArguments));
1778}
1779
1780FunctionParmPackExpr::FunctionParmPackExpr(QualType T, VarDecl *ParamPack,
1781 SourceLocation NameLoc,
1782 unsigned NumParams,
1783 VarDecl *const *Params)
1784 : Expr(FunctionParmPackExprClass, T, VK_LValue, OK_Ordinary),
1785 ParamPack(ParamPack), NameLoc(NameLoc), NumParameters(NumParams) {
1786 if (Params)
1787 std::uninitialized_copy(Params, Params + NumParams,
1788 getTrailingObjects<VarDecl *>());
1789 setDependence(ExprDependence::TypeValueInstantiation |
1790 ExprDependence::UnexpandedPack);
1791}
1792
1795 VarDecl *ParamPack, SourceLocation NameLoc,
1796 ArrayRef<VarDecl *> Params) {
1797 return new (Context.Allocate(totalSizeToAlloc<VarDecl *>(Params.size())))
1798 FunctionParmPackExpr(T, ParamPack, NameLoc, Params.size(), Params.data());
1799}
1800
1803 unsigned NumParams) {
1804 return new (Context.Allocate(totalSizeToAlloc<VarDecl *>(NumParams)))
1805 FunctionParmPackExpr(QualType(), nullptr, SourceLocation(), 0, nullptr);
1806}
1807
1809 QualType T, Expr *Temporary, bool BoundToLvalueReference,
1811 : Expr(MaterializeTemporaryExprClass, T,
1812 BoundToLvalueReference ? VK_LValue : VK_XValue, OK_Ordinary) {
1813 if (MTD) {
1814 State = MTD;
1815 MTD->ExprWithTemporary = Temporary;
1816 return;
1817 }
1818 State = Temporary;
1820}
1821
1823 unsigned ManglingNumber) {
1824 // We only need extra state if we have to remember more than just the Stmt.
1825 if (!ExtendedBy)
1826 return;
1827
1828 // We may need to allocate extra storage for the mangling number and the
1829 // extended-by ValueDecl.
1830 if (!State.is<LifetimeExtendedTemporaryDecl *>())
1832 cast<Expr>(State.get<Stmt *>()), ExtendedBy, ManglingNumber);
1833
1834 auto ES = State.get<LifetimeExtendedTemporaryDecl *>();
1835 ES->ExtendingDecl = ExtendedBy;
1836 ES->ManglingNumber = ManglingNumber;
1837}
1838
1840 const ASTContext &Context) const {
1841 // C++20 [expr.const]p4:
1842 // An object or reference is usable in constant expressions if it is [...]
1843 // a temporary object of non-volatile const-qualified literal type
1844 // whose lifetime is extended to that of a variable that is usable
1845 // in constant expressions
1846 auto *VD = dyn_cast_or_null<VarDecl>(getExtendingDecl());
1847 return VD && getType().isConstant(Context) &&
1849 getType()->isLiteralType(Context) &&
1850 VD->isUsableInConstantExpressions(Context);
1851}
1852
1853TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind,
1855 SourceLocation RParenLoc, bool Value)
1856 : Expr(TypeTraitExprClass, T, VK_PRValue, OK_Ordinary), Loc(Loc),
1857 RParenLoc(RParenLoc) {
1858 assert(Kind <= TT_Last && "invalid enum value!");
1859 TypeTraitExprBits.Kind = Kind;
1860 assert(static_cast<unsigned>(Kind) == TypeTraitExprBits.Kind &&
1861 "TypeTraitExprBits.Kind overflow!");
1862 TypeTraitExprBits.Value = Value;
1863 TypeTraitExprBits.NumArgs = Args.size();
1864 assert(Args.size() == TypeTraitExprBits.NumArgs &&
1865 "TypeTraitExprBits.NumArgs overflow!");
1866
1867 auto **ToArgs = getTrailingObjects<TypeSourceInfo *>();
1868 for (unsigned I = 0, N = Args.size(); I != N; ++I)
1869 ToArgs[I] = Args[I];
1870
1872}
1873
1876 TypeTrait Kind,
1878 SourceLocation RParenLoc,
1879 bool Value) {
1880 void *Mem = C.Allocate(totalSizeToAlloc<TypeSourceInfo *>(Args.size()));
1881 return new (Mem) TypeTraitExpr(T, Loc, Kind, Args, RParenLoc, Value);
1882}
1883
1885 unsigned NumArgs) {
1886 void *Mem = C.Allocate(totalSizeToAlloc<TypeSourceInfo *>(NumArgs));
1887 return new (Mem) TypeTraitExpr(EmptyShell());
1888}
1889
1890CUDAKernelCallExpr::CUDAKernelCallExpr(Expr *Fn, CallExpr *Config,
1891 ArrayRef<Expr *> Args, QualType Ty,
1893 FPOptionsOverride FPFeatures,
1894 unsigned MinNumArgs)
1895 : CallExpr(CUDAKernelCallExprClass, Fn, /*PreArgs=*/Config, Args, Ty, VK,
1896 RP, FPFeatures, MinNumArgs, NotADL) {}
1897
1898CUDAKernelCallExpr::CUDAKernelCallExpr(unsigned NumArgs, bool HasFPFeatures,
1899 EmptyShell Empty)
1900 : CallExpr(CUDAKernelCallExprClass, /*NumPreArgs=*/END_PREARG, NumArgs,
1901 HasFPFeatures, Empty) {}
1902
1906 SourceLocation RP, FPOptionsOverride FPFeatures,
1907 unsigned MinNumArgs) {
1908 // Allocate storage for the trailing objects of CallExpr.
1909 unsigned NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1910 unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
1911 /*NumPreArgs=*/END_PREARG, NumArgs, FPFeatures.requiresTrailingStorage());
1912 void *Mem = Ctx.Allocate(sizeof(CUDAKernelCallExpr) + SizeOfTrailingObjects,
1913 alignof(CUDAKernelCallExpr));
1914 return new (Mem)
1915 CUDAKernelCallExpr(Fn, Config, Args, Ty, VK, RP, FPFeatures, MinNumArgs);
1916}
1917
1919 unsigned NumArgs,
1920 bool HasFPFeatures,
1921 EmptyShell Empty) {
1922 // Allocate storage for the trailing objects of CallExpr.
1923 unsigned SizeOfTrailingObjects = CallExpr::sizeOfTrailingObjects(
1924 /*NumPreArgs=*/END_PREARG, NumArgs, HasFPFeatures);
1925 void *Mem = Ctx.Allocate(sizeof(CUDAKernelCallExpr) + SizeOfTrailingObjects,
1926 alignof(CUDAKernelCallExpr));
1927 return new (Mem) CUDAKernelCallExpr(NumArgs, HasFPFeatures, Empty);
1928}
1929
1932 unsigned NumUserSpecifiedExprs,
1933 SourceLocation InitLoc, SourceLocation LParenLoc,
1934 SourceLocation RParenLoc) {
1935 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(Args.size()));
1936 return new (Mem) CXXParenListInitExpr(Args, T, NumUserSpecifiedExprs, InitLoc,
1937 LParenLoc, RParenLoc);
1938}
1939
1941 unsigned NumExprs,
1942 EmptyShell Empty) {
1943 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumExprs),
1944 alignof(CXXParenListInitExpr));
1945 return new (Mem) CXXParenListInitExpr(Empty, NumExprs);
1946}
1947
1949 SourceLocation LParenLoc, Expr *LHS,
1950 BinaryOperatorKind Opcode,
1951 SourceLocation EllipsisLoc, Expr *RHS,
1952 SourceLocation RParenLoc,
1953 std::optional<unsigned> NumExpansions)
1954 : Expr(CXXFoldExprClass, T, VK_PRValue, OK_Ordinary), LParenLoc(LParenLoc),
1955 EllipsisLoc(EllipsisLoc), RParenLoc(RParenLoc),
1956 NumExpansions(NumExpansions ? *NumExpansions + 1 : 0), Opcode(Opcode) {
1957 // We rely on asserted invariant to distinguish left and right folds.
1958 assert(((LHS && LHS->containsUnexpandedParameterPack()) !=
1959 (RHS && RHS->containsUnexpandedParameterPack())) &&
1960 "Exactly one of LHS or RHS should contain an unexpanded pack");
1961 SubExprs[SubExpr::Callee] = Callee;
1962 SubExprs[SubExpr::LHS] = LHS;
1963 SubExprs[SubExpr::RHS] = RHS;
1965}
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:1576
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:186
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:1146
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:1634
const LangOptions & getLangOpts() const
Definition: ASTContext.h:796
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
CanQualType BoundMemberTy
Definition: ASTContext.h:1146
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:733
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:1918
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:1904
A C++ addrspace_cast expression (currently only enabled for OpenCL).
Definition: ExprCXX.h:601
static CXXAddrspaceCastExpr * CreateEmpty(const ASTContext &Context)
Definition: ExprCXX.cpp:895
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:887
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:1095
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:873
static CXXConstCastExpr * CreateEmpty(const ASTContext &Context)
Definition: ExprCXX.cpp:882
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:1157
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:1181
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:566
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:560
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:1172
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2535
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1268
const ParmVarDecl * getParam() const
Definition: ExprCXX.h:1310
Expr * getAdjustedRewrittenExpr()
Definition: ExprCXX.cpp:1032
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
Definition: ExprCXX.cpp:1016
static CXXDefaultArgExpr * CreateEmpty(const ASTContext &C, bool HasRewrittenInit)
Definition: ExprCXX.cpp:1009
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:1070
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:1082
static CXXDefaultInitExpr * CreateEmpty(const ASTContext &C, bool HasRewrittenInit)
Definition: ExprCXX.cpp:1063
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:3681
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:1531
static CXXDependentScopeMemberExpr * CreateEmpty(const ASTContext &Ctx, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs, bool HasFirstQualifierFoundInScope)
Definition: ExprCXX.cpp:1552
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2799
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:785
static CXXDynamicCastExpr * CreateEmpty(const ASTContext &Context, unsigned pathSize)
Definition: ExprCXX.cpp:804
bool isAlwaysNull() const
isAlwaysNull - Return whether the result of the dynamic_cast is proven to always be null.
Definition: ExprCXX.cpp:818
CXXFoldExpr(QualType T, UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Opcode, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, std::optional< unsigned > NumExpansions)
Definition: ExprCXX.cpp:1948
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:915
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:925
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:929
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:899
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:720
Expr * getImplicitObjectArgument() const
Retrieve the implicit object argument for the member call.
Definition: ExprCXX.cpp:701
static CXXMemberCallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty)
Definition: ExprCXX.cpp:689
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:673
QualType getObjectType() const
Retrieve the type of the object argument.
Definition: ExprCXX.cpp:713
CXXRecordDecl * getRecordDecl() const
Retrieve the CXXRecordDecl for the underlying type of the implicit object argument.
Definition: ExprCXX.cpp:729
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2060
bool isConst() const
Definition: DeclCXX.h:2112
const char * getCastName() const
getCastName - Get the name of the C++ cast being used, e.g., "static_cast", "dynamic_cast",...
Definition: ExprCXX.cpp:747
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:609
static CXXOperatorCallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty)
Definition: ExprCXX.cpp:624
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:159
Represents a list-initialization with parenthesis.
Definition: ExprCXX.h:4952
static CXXParenListInitExpr * Create(ASTContext &C, ArrayRef< Expr * > Args, QualType T, unsigned NumUserSpecifiedExprs, SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Definition: ExprCXX.cpp:1931
static CXXParenListInitExpr * CreateEmpty(ASTContext &C, unsigned numExprs, EmptyShell Empty)
Definition: ExprCXX.cpp:1940
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:1111
capture_const_iterator captures_begin() const
Definition: DeclCXX.h:1105
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:850
static CXXReinterpretCastExpr * CreateEmpty(const ASTContext &Context, unsigned pathSize)
Definition: ExprCXX.cpp:868
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:759
static CXXStaticCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize, bool hasFPFeatures)
Definition: ExprCXX.cpp:776
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:1123
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:1914
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:1150
static CXXTemporaryObjectExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs)
Definition: ExprCXX.cpp:1138
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:1146
Represents a C++ temporary.
Definition: ExprCXX.h:1457
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
Definition: ExprCXX.cpp:1090
Represents the this expression in C++.
Definition: ExprCXX.h:1152
static CXXThisExpr * CreateEmpty(const ASTContext &Ctx)
Definition: ExprCXX.cpp:1572
static CXXThisExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType Ty, bool IsImplicit)
Definition: ExprCXX.cpp:1566
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:3555
static CXXUnresolvedConstructExpr * Create(const ASTContext &Context, QualType T, TypeSourceInfo *TSI, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool IsListInit)
Definition: ExprCXX.cpp:1469
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:1485
static CXXUnresolvedConstructExpr * CreateEmpty(const ASTContext &Context, unsigned NumArgs)
Definition: ExprCXX.cpp:1479
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:1425
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
bool hasAttr() const
Definition: DeclBase.h:583
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:3321
static DependentScopeDeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
Definition: ExprCXX.cpp:529
static DependentScopeDeclRefExpr * CreateEmpty(const ASTContext &Context, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition: ExprCXX.cpp:544
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:3472
static ExprWithCleanups * Create(const ASTContext &C, EmptyShell empty, unsigned numObjects)
Definition: ExprCXX.cpp:1444
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:3329
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Definition: ExprCXX.h:4646
static FunctionParmPackExpr * Create(const ASTContext &Context, QualType T, VarDecl *ParamPack, SourceLocation NameLoc, ArrayRef< VarDecl * > Params)
Definition: ExprCXX.cpp:1794
static FunctionParmPackExpr * CreateEmpty(const ASTContext &Context, unsigned NumParams)
Definition: ExprCXX.cpp:1802
Represents a prototype with parameter type info, e.g.
Definition: Type.h:4973
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:1213
LambdaCaptureKind getCaptureKind() const
Determine the kind of capture.
Definition: ExprCXX.cpp:1243
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:1342
static LambdaExpr * CreateDeserialized(const ASTContext &C, unsigned NumCaptures)
Construct a new lambda expression that will be deserialized from an external source.
Definition: ExprCXX.cpp:1311
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:1291
Stmt * getBody() const
Retrieve the body of the lambda.
Definition: ExprCXX.cpp:1325
bool isMutable() const
Determine whether the lambda is mutable, meaning that any captures values can be modified.
Definition: ExprCXX.cpp:1407
capture_iterator implicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of implicit lambda captures.
Definition: ExprCXX.cpp:1371
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:1363
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
Definition: ExprCXX.cpp:1337
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
Definition: ExprCXX.cpp:1383
const CompoundStmt * getCompoundStmtBody() const
Retrieve the CompoundStmt representing the body of the lambda.
Definition: ExprCXX.cpp:1330
capture_range implicit_captures() const
Retrieve this lambda's implicit captures.
Definition: ExprCXX.cpp:1375
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it,...
Definition: ExprCXX.cpp:1393
ArrayRef< NamedDecl * > getExplicitTemplateParameters() const
Get the template parameters were explicitly specified (as opposed to being invented by use of an auto...
Definition: ExprCXX.cpp:1398
capture_iterator implicit_capture_begin() const
Retrieve an iterator pointing to the first implicit lambda capture.
Definition: ExprCXX.cpp:1367
capture_iterator explicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
Definition: ExprCXX.cpp:1358
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition: ExprCXX.cpp:1346
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:1403
capture_iterator explicit_capture_begin() const
Retrieve an iterator pointing to the first explicit lambda capture.
Definition: ExprCXX.cpp:1354
child_range children()
Includes the captures and the body of the lambda.
Definition: ExprCXX.cpp:1409
FunctionTemplateDecl * getDependentCallOperator() const
Retrieve the function template call operator associated with this lambda expression.
Definition: ExprCXX.cpp:1388
capture_range captures() const
Retrieve this lambda's captures.
Definition: ExprCXX.cpp:1350
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Definition: ExprCXX.cpp:1379
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
Definition: DeclCXX.h:3229
static LifetimeExtendedTemporaryDecl * Create(Expr *Temp, ValueDecl *EDec, unsigned Mangling)
Definition: DeclCXX.h:3254
MaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference, LifetimeExtendedTemporaryDecl *MTD=nullptr)
Definition: ExprCXX.cpp:1808
ValueDecl * getExtendingDecl()
Get the declaration which triggered the lifetime-extension of this temporary, if any.
Definition: ExprCXX.h:4776
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:1839
void setExtendingDecl(ValueDecl *ExtendedBy, unsigned ManglingNumber)
Definition: ExprCXX.cpp:1822
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:4097
TemplateArgumentLoc * getTrailingTemplateArgumentLoc()
Return the optional template arguments.
Definition: ExprCXX.h:4107
DeclAccessPair * getTrailingResults()
Return the results. Defined after UnresolvedMemberExpr.
Definition: ExprCXX.h:4091
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:464
NamedDecl * getPackDecl() const
Definition: ExprCXX.cpp:1732
static PackIndexingExpr * CreateDeserialized(ASTContext &Context, unsigned NumTransformedExprs)
Definition: ExprCXX.cpp:1743
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:1715
Expr * getPackIdExpression() const
Definition: ExprCXX.h:4442
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:3161
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:7827
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:7944
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition: Type.h:7837
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:4256
static SizeOfPackExpr * CreateDeserialized(ASTContext &Context, unsigned NumPartialArgs)
Definition: ExprCXX.cpp:1703
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:1691
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:4524
QualType getParameterType(const ASTContext &Ctx) const
Determine the substituted type of the template parameter.
Definition: ExprCXX.cpp:1750
NonTypeTemplateParmDecl * getParameter() const
Definition: ExprCXX.cpp:1710
TemplateArgument getArgumentPack() const
Retrieve the template argument pack containing the substituted template arguments.
Definition: ExprCXX.cpp:1776
NonTypeTemplateParmDecl * getParameterPack() const
Retrieve the non-type template parameter pack being substituted.
Definition: ExprCXX.cpp:1771
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
Definition: ExprCXX.h:4597
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:7714
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:7725
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:1874
static TypeTraitExpr * CreateDeserialized(const ASTContext &C, unsigned NumArgs)
Definition: ExprCXX.cpp:1884
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:2889
bool isVoidPointerType() const
Definition: Type.cpp:665
bool isArrayType() const
Definition: Type.h:8064
bool isPointerType() const
Definition: Type.h:7996
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
Definition: Type.h:8335
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:8583
bool isReferenceType() const
Definition: Type.h:8010
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:2672
bool isFloatingType() const
Definition: Type.cpp:2249
bool isAnyPointerType() const
Definition: Type.h:8000
bool isRecordType() const
Definition: Type.h:8092
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 * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent)
Definition: ExprCXX.cpp:419
static UnresolvedLookupExpr * CreateEmpty(const ASTContext &Context, unsigned NumResults, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition: ExprCXX.cpp:452
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition: ExprCXX.h:3941
QualType getBaseType() const
Definition: ExprCXX.h:4023
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
Definition: ExprCXX.h:4033
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:1633
CXXRecordDecl * getNamingClass()
Retrieve the naming class of this lookup.
Definition: ExprCXX.cpp:1664
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:1626
static UnresolvedMemberExpr * CreateEmpty(const ASTContext &Context, unsigned NumResults, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition: ExprCXX.cpp:1652
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:976
const IdentifierInfo * getUDSuffix() const
Returns the ud-suffix specified for this literal.
Definition: ExprCXX.cpp:1005
static UserDefinedLiteral * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation LitEndLoc, SourceLocation SuffixLoc, FPOptionsOverride FPFeatures)
Definition: ExprCXX.cpp:947
static UserDefinedLiteral * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPOptions, EmptyShell Empty)
Definition: ExprCXX.cpp:963
Expr * getCookedLiteral()
If this is not a raw user-defined literal, get the underlying cooked literal (representing the litera...
Definition: ExprCXX.cpp:997
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:148
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:129
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:132
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
Definition: Specifiers.h:141
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:136
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