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