13#ifndef LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
14#define LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
45#include "llvm/ADT/ArrayRef.h"
46#include "llvm/Support/ErrorHandling.h"
50using namespace llvm::omp;
106template<
typename Derived>
111 class ForgetPartiallySubstitutedPackRAII {
116 ForgetPartiallySubstitutedPackRAII(Derived &Self) : Self(Self) {
117 Old = Self.ForgetPartiallySubstitutedPack();
120 ~ForgetPartiallySubstitutedPackRAII() {
121 Self.RememberPartiallySubstitutedPack(Old);
138 Derived &
getDerived() {
return static_cast<Derived&
>(*this); }
142 return static_cast<const Derived&
>(*this);
207 OldLocation = Self.getDerived().getBaseLocation();
208 OldEntity = Self.getDerived().getBaseEntity();
211 Self.getDerived().setBase(Location, Entity);
215 Self.getDerived().setBase(OldLocation, OldEntity);
288 bool &ShouldExpand,
bool &RetainExpansion,
289 std::optional<unsigned> &NumExpansions) {
290 ShouldExpand =
false;
405 const X##Attr *Transform##X##Attr(const X##Attr *R) { return R; }
406#include "clang/Basic/AttrList.inc"
416 const X##Attr *TransformStmt##X##Attr(const Stmt *, const Stmt *, \
417 const X##Attr *A) { \
418 return getDerived().Transform##X##Attr(A); \
420#include "clang/Basic/AttrList.inc"
466 bool *ArgChanged =
nullptr);
475 llvm::DenseMap<Decl *, Decl *>::iterator Known
478 return Known->second;
506 assert(New.size() == 1 &&
507 "must override transformedLocalDecl if performing pack expansion");
545 NamedDecl *FirstQualifierInScope =
nullptr);
590 NamedDecl *FirstQualifierInScope =
nullptr,
591 bool AllowInjectedClassName =
false);
603 bool Uneval =
false);
626 bool Uneval =
false) {
645 template<
typename InputIterator>
649 bool Uneval =
false);
661#define ABSTRACT_TYPELOC(CLASS, PARENT)
662#define TYPELOC(CLASS, PARENT) \
663 QualType Transform##CLASS##Type(TypeLocBuilder &TLB, CLASS##TypeLoc T);
664#include "clang/AST/TypeLocNodes.def"
668 bool SuppressObjCLifetime);
672 bool SuppressObjCLifetime);
674 template<
typename Fn>
681 template <
typename Fn>
683 Fn TransformModifiedType);
731 return getDerived().TransformFunctionTypeParams(
732 Loc, Params, ParamTypes, ParamInfos, PTypes, PVars, PInfos,
nullptr);
750 KWLoc, Params,
nullptr,
751 nullptr, PTypes, &TransParams, PInfos))
764 std::optional<unsigned> NumExpansions,
765 bool ExpectParameterPack);
792 bool IsAddressOfOperand,
800 bool IsAddressOfOperand);
806#define STMT(Node, Parent) \
807 LLVM_ATTRIBUTE_NOINLINE \
808 StmtResult Transform##Node(Node *S);
809#define VALUESTMT(Node, Parent) \
810 LLVM_ATTRIBUTE_NOINLINE \
811 StmtResult Transform##Node(Node *S, StmtDiscardKind SDK);
812#define EXPR(Node, Parent) \
813 LLVM_ATTRIBUTE_NOINLINE \
814 ExprResult Transform##Node(Node *E);
815#define ABSTRACT_STMT(Stmt)
816#include "clang/AST/StmtNodes.inc"
818#define GEN_CLANG_CLAUSE_CLASS
819#define CLAUSE_CLASS(Enum, Str, Class) \
820 LLVM_ATTRIBUTE_NOINLINE \
821 OMPClause *Transform##Class(Class *S);
822#include "llvm/Frontend/OpenMP/OMP.inc"
899 const llvm::APInt *Size,
Expr *SizeExpr,
900 unsigned IndexTypeQuals,
SourceRange BracketsRange);
909 const llvm::APInt &Size,
Expr *SizeExpr,
910 unsigned IndexTypeQuals,
920 unsigned IndexTypeQuals,
930 unsigned IndexTypeQuals,
941 unsigned IndexTypeQuals,
979 unsigned NumColumns);
1066 bool FullySubstituted,
1080 TypeConstraintConcept,
1081 TypeConstraintArgs);
1089 Template, Deduced,
false);
1135 bool AllowInjectedClassName) {
1139 SS.
Adopt(QualifierLoc);
1141 SS, TemplateKWLoc, *Name, NameLoc,
QualType(),
nullptr,
1142 AllowInjectedClassName);
1156 getDerived().RebuildTemplateSpecializationType(InstName, NameLoc, Args);
1173 bool DeducedTSTContext) {
1175 SS.
Adopt(QualifierLoc);
1188 *
Id, IdLoc, DeducedTSTContext);
1206 switch (
Result.getResultKind()) {
1217 llvm_unreachable(
"Tag lookup cannot find non-tags");
1229 switch (
Result.getResultKind()) {
1235 SemaRef.
Diag(IdLoc, diag::err_tag_reference_non_tag)
1236 << SomeDecl << NTK << llvm::to_underlying(Kind);
1242 << llvm::to_underlying(Kind) <<
Id << DC
1251 SemaRef.
Diag(KeywordLoc, diag::err_use_with_wrong_tag) <<
Id;
1269 std::optional<unsigned> NumExpansions) {
1314 bool AllowInjectedClassName);
1327 bool AllowInjectedClassName);
1337 Decl *AssociatedDecl,
unsigned Index,
1340 ArgPack, AssociatedDecl, Index, Final);
1418 Then, ElseLoc, Else);
1472 Inc, RParenLoc, Body);
1517 bool IsVolatile,
unsigned NumOutputs,
1524 NumInputs, Names, Constraints, Exprs,
1525 AsmString, Clobbers, NumLabels, RParenLoc);
1534 StringRef AsmString,
1535 unsigned NumOutputs,
unsigned NumInputs,
1541 NumOutputs, NumInputs,
1542 Constraints, Clobbers, Exprs, EndLoc);
1571 CoawaitLoc, Operand, OpCoawaitLookup);
1575 Suspend.
get(),
true);
1677 Kind, DirName, CancelRegion, Clauses, AStmt, StartLoc, EndLoc,
1678 PrevMappedDirective);
1692 NameModifier,
Condition, StartLoc, LParenLoc, NameModifierLoc, ColonLoc,
1794 Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc);
1807 Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc);
1820 M1, M2, Kind, ChunkSize, StartLoc, LParenLoc, M1Loc, M2Loc, KindLoc,
1871 VarList, LPKind, LPKindLoc, ColonLoc, StartLoc, LParenLoc, EndLoc);
1898 VarList, Modifier, StartLoc, LParenLoc, ModifierLoc, ColonLoc, EndLoc,
1899 ReductionIdScopeSpec, ReductionId, UnresolvedReductions);
1913 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1914 ReductionId, UnresolvedReductions);
1929 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1930 ReductionId, UnresolvedReductions);
1943 VarList, Step, StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc,
1944 StepModifierLoc, EndLoc);
1957 VarList, Alignment, StartLoc, LParenLoc, ColonLoc, EndLoc);
2017 Data, DepModifier, VarList, StartLoc, LParenLoc, EndLoc);
2030 Modifier,
Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2045 IteratorModifier, MapTypeModifiers, MapTypeModifiersLoc,
2046 MapperIdScopeSpec, MapperId, MapType, IsMapTypeImplicit, MapLoc,
2047 ColonLoc, VarList, Locs,
2048 false, UnresolvedMappers);
2061 Allocate, VarList, StartLoc, LParenLoc, ColonLoc, EndLoc);
2084 ThreadLimit, StartLoc, LParenLoc, EndLoc);
2108 Modifier,
Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2121 Modifier, NumTasks, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2156 Kind, ChunkSize, StartLoc, LParenLoc, KindLoc, CommaLoc, EndLoc);
2171 MotionModifiers, MotionModifiersLoc, MapperIdScopeSpec, MapperId,
2172 ColonLoc, VarList, Locs, UnresolvedMappers);
2187 MotionModifiers, MotionModifiersLoc, MapperIdScopeSpec, MapperId,
2188 ColonLoc, VarList, Locs, UnresolvedMappers);
2239 M, Kind, StartLoc, LParenLoc, MLoc, KindLoc, EndLoc);
2286 StartLoc, LParenLoc, EndLoc,
Data);
2299 StartLoc, LParenLoc, ColonLoc, EndLoc, Modifier, Locators);
2311 Modifier, Kind, StartLoc, LParenLoc, ModifierKwLoc, KindKwLoc, EndLoc);
2324 InteropVar, InteropInfo, StartLoc, LParenLoc, VarLoc, EndLoc);
2335 LParenLoc, VarLoc, EndLoc);
2347 InteropVar, StartLoc, LParenLoc, VarLoc, EndLoc);
2486 DepType, DepLoc, ColonLoc, VarList, StartLoc, LParenLoc, EndLoc);
2545 StartLoc, IdLoc,
Id);
2582 if (
DeclStmt *RangeStmt = dyn_cast<DeclStmt>(Range)) {
2583 if (RangeStmt->isSingleDecl()) {
2584 if (
VarDecl *RangeVar = dyn_cast<VarDecl>(RangeStmt->getSingleDecl())) {
2585 if (RangeVar->isInvalidDecl())
2588 Expr *RangeExpr = RangeVar->getInit();
2595 diag::err_objc_for_range_init_stmt)
2596 <<
Init->getSourceRange();
2599 RangeExpr, RParenLoc);
2606 ForLoc, CoawaitLoc,
Init, ColonLoc, Range,
Begin, End, Cond, Inc,
2620 QualifierLoc, NameInfo, Nested);
2682 SS.
Adopt(QualifierLoc);
2794 if (IsOMPArraySection)
2796 Base, LBracketLoc, LowerBound, ColonLocFirst, ColonLocSecond, Length,
2797 Stride, RBracketLoc);
2799 assert(Stride ==
nullptr && !ColonLocSecond.
isValid() &&
2800 "Stride/second colon not allowed for OpenACC");
2803 Base, LBracketLoc, LowerBound, ColonLocFirst, Length, RBracketLoc);
2815 Base, LParenLoc, RParenLoc, Dims, BracketsRanges);
2827 nullptr, IteratorKwLoc, LLoc, RLoc,
Data);
2837 Expr *ExecConfig =
nullptr) {
2839 nullptr, Callee, LParenLoc, Args, RParenLoc, ExecConfig);
2846 nullptr, Callee, LParenLoc, Args, RParenLoc);
2864 if (!
Member->getDeclName()) {
2868 assert(
Member->getType()->isRecordType() &&
2869 "unnamed member not of record type?");
2881 Base, isArrow, OpLoc, EmptySS, cast<FieldDecl>(
Member),
2886 SS.
Adopt(QualifierLoc);
2900 if (
getSema().isUnevaluatedContext() &&
Base->isImplicitCXXThis() &&
2901 isa<FieldDecl, IndirectFieldDecl, MSPropertyDecl>(
Member)) {
2902 if (
auto *ThisClass = cast<CXXThisExpr>(
Base)
2905 ->getAsCXXRecordDecl()) {
2906 auto *
Class = cast<CXXRecordDecl>(
Member->getDeclContext());
2909 if (!ThisClass->Equals(
Class) && !ThisClass->isDerivedFrom(
Class))
2917 FirstQualifierInScope,
2918 R, ExplicitTemplateArgs,
3096 Expr *ControllingExpr,
3101 ControllingExpr, Types, Exprs);
3116 ControllingType, Types, Exprs);
3149 case Stmt::CXXStaticCastExprClass:
3150 return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo,
3151 RAngleLoc, LParenLoc,
3152 SubExpr, RParenLoc);
3154 case Stmt::CXXDynamicCastExprClass:
3155 return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo,
3156 RAngleLoc, LParenLoc,
3157 SubExpr, RParenLoc);
3159 case Stmt::CXXReinterpretCastExprClass:
3160 return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo,
3161 RAngleLoc, LParenLoc,
3165 case Stmt::CXXConstCastExprClass:
3166 return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo,
3167 RAngleLoc, LParenLoc,
3168 SubExpr, RParenLoc);
3170 case Stmt::CXXAddrspaceCastExprClass:
3171 return getDerived().RebuildCXXAddrspaceCastExpr(
3172 OpLoc, LAngleLoc, TInfo, RAngleLoc, LParenLoc, SubExpr, RParenLoc);
3175 llvm_unreachable(
"Invalid C++ named cast");
3253 OpLoc, tok::kw_addrspace_cast, TInfo, SubExpr,
3265 bool ListInitialization) {
3269 if (
auto *PLE = dyn_cast<ParenListExpr>(Sub))
3271 TInfo, LParenLoc,
MultiExprArg(PLE->getExprs(), PLE->getNumExprs()),
3272 RParenLoc, ListInitialization);
3275 ListInitialization);
3339 if (
getSema().CheckCXXThisType(ThisLoc, ThisType))
3349 bool IsThrownVariableInScope) {
3359 Expr *RewrittenExpr) {
3361 RewrittenExpr,
getSema().CurContext);
3396 std::optional<Expr *> ArraySize,
3415 bool IsGlobalDelete,
3466 bool IsAddressOfOperand,
3469 SS.
Adopt(QualifierLoc);
3471 if (TemplateArgs || TemplateKWLoc.
isValid())
3476 SS, NameInfo, IsAddressOfOperand,
nullptr, RecoveryTSI);
3498 bool IsElidable,
MultiExprArg Args,
bool HadMultipleCandidates,
3499 bool ListInitialization,
bool StdInitListInitialization,
3505 if (Constructor->isInheritingConstructor())
3506 FoundCtor = Constructor->getInheritedConstructor().getConstructor();
3509 if (
getSema().CompleteConstructorCall(FoundCtor,
T, Args, Loc,
3516 HadMultipleCandidates,
3518 StdInitListInitialization,
3519 RequiresZeroInit, ConstructKind,
3527 bool ConstructsVBase,
3528 bool InheritedFromVBase) {
3530 Loc,
T, Constructor, ConstructsVBase, InheritedFromVBase);
3541 bool ListInitialization) {
3543 TSInfo, LParenOrBraceLoc, Args, RParenOrBraceLoc, ListInitialization);
3554 bool ListInitialization) {
3556 RParenLoc, ListInitialization);
3573 SS.
Adopt(QualifierLoc);
3576 OperatorLoc, IsArrow,
3578 FirstQualifierInScope,
3580 TemplateArgs,
nullptr);
3596 SS.
Adopt(QualifierLoc);
3599 OperatorLoc, IsArrow,
3601 FirstQualifierInScope,
3602 R, TemplateArgs,
nullptr);
3617 std::optional<unsigned> Length,
3620 RParenLoc, Length, PartialArgs);
3625 Expr *PackIdExpression,
Expr *IndexExpr,
3627 bool EmptyPack =
false) {
3629 IndexExpr, RSquareLoc, ExpandedExprs,
3659 NamedConcept, TALI);
3677 LocalParameters, RParenLoc, Requirements,
3731 Expr **Elements,
unsigned NumElements) {
3741 getterMethod, setterMethod);
3774 Sel, Method, LBracLoc, SelectorLocs,
3789 Sel, Method, LBracLoc, SelectorLocs,
3805 Sel, Method, LBracLoc, SelectorLocs,
3810 Sel, Method, LBracLoc, SelectorLocs,
3822 bool IsArrow,
bool IsFreeIvar) {
3831 if (IsFreeIvar &&
Result.isUsable())
3832 cast<ObjCIvarRefExpr>(
Result.get())->setIsFreeIvar(IsFreeIvar);
3868 PropertyLoc,
Base));
3900 assert(!Lookup.
empty() &&
"No __builtin_shufflevector?");
3909 CK_BuiltinFnToFnPtr).
get();
3935 std::optional<unsigned> NumExpansions) {
3940 EllipsisLoc, NumExpansions);
3962 llvm_unreachable(
"Pack expansion pattern has no parameter packs");
3983 std::optional<unsigned> NumExpansions) {
3996 std::optional<unsigned> NumExpansions) {
3998 EllipsisLoc, RHS, RParenLoc,
4056 bool DeducibleTSTContext);
4068template <
typename Derived>
4073 switch (S->getStmtClass()) {
4078#define STMT(Node, Parent) \
4079 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
4080#define VALUESTMT(Node, Parent) \
4081 case Stmt::Node##Class: \
4082 return getDerived().Transform##Node(cast<Node>(S), SDK);
4083#define ABSTRACT_STMT(Node)
4084#define EXPR(Node, Parent)
4085#include "clang/AST/StmtNodes.inc"
4088#define STMT(Node, Parent)
4089#define ABSTRACT_STMT(Stmt)
4090#define EXPR(Node, Parent) case Stmt::Node##Class:
4091#include "clang/AST/StmtNodes.inc"
4093 ExprResult E = getDerived().TransformExpr(cast<Expr>(S));
4095 if (SDK == SDK_StmtExprResult)
4096 E = getSema().ActOnStmtExprResult(E);
4097 return getSema().ActOnExprStmt(E, SDK == SDK_Discarded);
4104template<
typename Derived>
4109 switch (S->getClauseKind()) {
4112#define GEN_CLANG_CLAUSE_CLASS
4113#define CLAUSE_CLASS(Enum, Str, Class) \
4115 return getDerived().Transform##Class(cast<Class>(S));
4116#include "llvm/Frontend/OpenMP/OMP.inc"
4123template<
typename Derived>
4130#define STMT(Node, Parent) case Stmt::Node##Class: break;
4131#define ABSTRACT_STMT(Stmt)
4132#define EXPR(Node, Parent) \
4133 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
4134#include "clang/AST/StmtNodes.inc"
4140template<
typename Derived>
4148 if (
auto *FE = dyn_cast<FullExpr>(
Init))
4149 Init = FE->getSubExpr();
4151 if (
auto *AIL = dyn_cast<ArrayInitLoopExpr>(
Init)) {
4157 Init = MTE->getSubExpr();
4160 Init = Binder->getSubExpr();
4163 Init = ICE->getSubExprAsWritten();
4166 dyn_cast<CXXStdInitializerListExpr>(
Init))
4167 return TransformInitializer(ILE->getSubExpr(), NotCopyInit);
4174 return getDerived().TransformExpr(
Init);
4179 return getDerived().RebuildParenListExpr(
Parens.getBegin(), std::nullopt,
4184 if (isa<ImplicitValueInitExpr>(
Init))
4185 return getDerived().RebuildParenListExpr(
SourceLocation(), std::nullopt,
4190 if (!Construct || isa<CXXTemporaryObjectExpr>(Construct))
4191 return getDerived().TransformExpr(
Init);
4196 return TransformInitializer(Construct->
getArg(0), NotCopyInit);
4203 getSema().keepInLifetimeExtendingContext();
4205 bool ArgChanged =
false;
4207 true, NewArgs, &ArgChanged))
4212 return getDerived().RebuildInitList(Construct->
getBeginLoc(), NewArgs,
4217 if (
Parens.isInvalid()) {
4220 assert(NewArgs.empty() &&
4221 "no parens or braces but have direct init with arguments?");
4224 return getDerived().RebuildParenListExpr(
Parens.getBegin(), NewArgs,
4228template<
typename Derived>
4234 for (
unsigned I = 0; I != NumInputs; ++I) {
4236 if (IsCall && getDerived().DropCallArgument(Inputs[I])) {
4244 Expr *Pattern = Expansion->getPattern();
4247 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
4248 assert(!Unexpanded.empty() &&
"Pack expansion without parameter packs?");
4253 bool RetainExpansion =
false;
4254 std::optional<unsigned> OrigNumExpansions = Expansion->getNumExpansions();
4255 std::optional<unsigned> NumExpansions = OrigNumExpansions;
4256 if (getDerived().TryExpandParameterPacks(Expansion->getEllipsisLoc(),
4259 Expand, RetainExpansion,
4268 ExprResult OutPattern = getDerived().TransformExpr(Pattern);
4272 ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.
get(),
4273 Expansion->getEllipsisLoc(),
4275 if (Out.isInvalid())
4280 Outputs.push_back(Out.get());
4286 if (ArgChanged) *ArgChanged =
true;
4290 for (
unsigned I = 0; I != *NumExpansions; ++I) {
4292 ExprResult Out = getDerived().TransformExpr(Pattern);
4293 if (Out.isInvalid())
4296 if (Out.get()->containsUnexpandedParameterPack()) {
4297 Out = getDerived().RebuildPackExpansion(
4298 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4299 if (Out.isInvalid())
4303 Outputs.push_back(Out.get());
4308 if (RetainExpansion) {
4309 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
4311 ExprResult Out = getDerived().TransformExpr(Pattern);
4312 if (Out.isInvalid())
4315 Out = getDerived().RebuildPackExpansion(
4316 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4317 if (Out.isInvalid())
4320 Outputs.push_back(Out.get());
4327 IsCall ? getDerived().TransformInitializer(Inputs[I],
false)
4328 : getDerived().TransformExpr(Inputs[I]);
4332 if (
Result.get() != Inputs[I] && ArgChanged)
4335 Outputs.push_back(
Result.get());
4341template <
typename Derived>
4345 VarDecl *ConditionVar = cast_or_null<VarDecl>(
4346 getDerived().TransformDefinition(Var->
getLocation(), Var));
4351 return getSema().ActOnConditionVariable(ConditionVar, Loc, Kind);
4360 return getSema().ActOnCondition(
nullptr, Loc, CondExpr.
get(), Kind,
4367template <
typename Derived>
4375 Qualifier = Qualifier.getPrefix())
4391 SS, FirstQualifierInScope,
false))
4398 cast_or_null<NamespaceDecl>(getDerived().TransformDecl(
4406 cast_or_null<NamespaceAliasDecl>(getDerived().TransformDecl(
4421 cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
4430 FirstQualifierInScope, SS);
4440 diag::warn_cxx98_compat_enum_nested_name_spec);
4443 SS.
Adopt(ETL.getQualifierLoc());
4444 TL = ETL.getNamedTypeLoc();
4463 FirstQualifierInScope =
nullptr;
4469 !getDerived().AlwaysRebuild())
4482template<
typename Derived>
4490 switch (Name.getNameKind()) {
4501 TemplateDecl *OldTemplate = Name.getCXXDeductionGuideTemplate();
4502 TemplateDecl *NewTemplate = cast_or_null<TemplateDecl>(
4503 getDerived().TransformDecl(NameInfo.
getLoc(), OldTemplate));
4519 NewTInfo = getDerived().TransformType(OldTInfo);
4527 QualType NewT = getDerived().TransformType(Name.getCXXNameType());
4543 llvm_unreachable(
"Unknown name kind.");
4546template<
typename Derived>
4553 bool AllowInjectedClassName) {
4555 TemplateDecl *Template = QTN->getUnderlyingTemplate().getAsTemplateDecl();
4556 assert(Template &&
"qualified template name must refer to a template");
4559 = cast_or_null<TemplateDecl>(getDerived().TransformDecl(NameLoc,
4564 if (!getDerived().AlwaysRebuild() &&
4566 TransTemplate == Template)
4569 return getDerived().RebuildTemplateName(SS, QTN->hasTemplateKeyword(),
4577 FirstQualifierInScope =
nullptr;
4580 if (!getDerived().AlwaysRebuild() &&
4588 if (DTN->isIdentifier()) {
4589 return getDerived().RebuildTemplateName(SS,
4591 *DTN->getIdentifier(),
4594 FirstQualifierInScope,
4595 AllowInjectedClassName);
4598 return getDerived().RebuildTemplateName(SS, TemplateKWLoc,
4599 DTN->getOperator(), NameLoc,
4600 ObjectType, AllowInjectedClassName);
4603 if (
TemplateDecl *Template = Name.getAsTemplateDecl()) {
4605 = cast_or_null<TemplateDecl>(getDerived().TransformDecl(NameLoc,
4610 if (!getDerived().AlwaysRebuild() &&
4611 TransTemplate == Template)
4618 = Name.getAsSubstTemplateTemplateParmPack()) {
4619 return getDerived().RebuildTemplateName(
4620 SubstPack->getArgumentPack(), SubstPack->getAssociatedDecl(),
4621 SubstPack->getIndex(), SubstPack->getFinal());
4625 llvm_unreachable(
"overloaded function decl survived to here");
4628template<
typename Derived>
4632 Output = getSema().getTrivialTemplateArgumentLoc(
4633 Arg,
QualType(), getDerived().getBaseLocation());
4636template <
typename Derived>
4644 llvm_unreachable(
"Unexpected TemplateArgument");
4654 QualType NewT = getDerived().TransformType(
T);
4661 ValueDecl *NewD = D ? cast_or_null<ValueDecl>(getDerived().TransformDecl(
4662 getDerived().getBaseLocation(), D))
4667 if (NewT ==
T && D == NewD)
4684 llvm_unreachable(
"unexpected template argument kind");
4694 DI = getDerived().TransformType(DI);
4705 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
4711 SS.
Adopt(QualifierLoc);
4712 TemplateName Template = getDerived().TransformTemplateName(
4723 llvm_unreachable(
"Caller should expand pack expansions");
4738 ExprResult E = getDerived().TransformExpr(InputExpr);
4753template<
typename Derived,
typename InputIterator>
4761 typedef typename std::iterator_traits<InputIterator>::difference_type
4791 Self.InventTemplateArgumentLoc(*
Iter,
Result);
4799 return X.Iter == Y.Iter;
4804 return X.Iter != Y.Iter;
4808template<
typename Derived>
4809template<
typename InputIterator>
4820 if (getSema().CodeSynthesisContexts.back().Kind ==
4822 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
4834 if (TransformTemplateArguments(PackLocIterator(*
this,
4835 In.getArgument().pack_begin()),
4836 PackLocIterator(*
this,
4837 In.getArgument().pack_end()),
4844 if (In.getArgument().isPackExpansion()) {
4848 std::optional<unsigned> OrigNumExpansions;
4850 = getSema().getTemplateArgumentPackExpansionPattern(
4851 In, Ellipsis, OrigNumExpansions);
4854 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
4855 assert(!Unexpanded.empty() &&
"Pack expansion without parameter packs?");
4860 bool RetainExpansion =
false;
4861 std::optional<unsigned> NumExpansions = OrigNumExpansions;
4862 if (getDerived().TryExpandParameterPacks(Ellipsis,
4876 if (getDerived().TransformTemplateArgument(Pattern, OutPattern, Uneval))
4879 Out = getDerived().RebuildPackExpansion(OutPattern, Ellipsis,
4881 if (Out.getArgument().isNull())
4890 for (
unsigned I = 0; I != *NumExpansions; ++I) {
4893 if (getDerived().TransformTemplateArgument(Pattern, Out, Uneval))
4896 if (Out.getArgument().containsUnexpandedParameterPack()) {
4897 Out = getDerived().RebuildPackExpansion(Out, Ellipsis,
4899 if (Out.getArgument().isNull())
4908 if (RetainExpansion) {
4909 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
4911 if (getDerived().TransformTemplateArgument(Pattern, Out, Uneval))
4914 Out = getDerived().RebuildPackExpansion(Out, Ellipsis,
4916 if (Out.getArgument().isNull())
4926 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
4940template<
typename Derived>
4942 if (getDerived().AlreadyTransformed(
T))
4948 getDerived().getBaseLocation());
4958template<
typename Derived>
4962 getDerived().getBaseEntity());
4963 if (getDerived().AlreadyTransformed(DI->
getType()))
4978template<
typename Derived>
4981 switch (
T.getTypeLocClass()) {
4982#define ABSTRACT_TYPELOC(CLASS, PARENT)
4983#define TYPELOC(CLASS, PARENT) \
4984 case TypeLoc::CLASS: \
4985 return getDerived().Transform##CLASS##Type(TLB, \
4986 T.castAs<CLASS##TypeLoc>());
4987#include "clang/AST/TypeLocNodes.def"
4990 llvm_unreachable(
"unhandled type loc!");
4993template<
typename Derived>
4995 if (!isa<DependentNameType>(
T))
4996 return TransformType(
T);
4998 if (getDerived().AlreadyTransformed(
T))
5001 getDerived().getBaseLocation());
5002 TypeSourceInfo *NewDI = getDerived().TransformTypeWithDeducedTST(DI);
5006template<
typename Derived>
5009 if (!isa<DependentNameType>(DI->
getType()))
5010 return TransformType(DI);
5014 getDerived().getBaseEntity());
5015 if (getDerived().AlreadyTransformed(DI->
getType()))
5035 Result = getDerived().RebuildQualifiedType(
Result, QTL);
5044template<
typename Derived>
5049 TypeLoc UnqualTL =
T.getUnqualifiedLoc();
5050 auto SuppressObjCLifetime =
5051 T.getType().getLocalQualifiers().hasObjCLifetime();
5053 Result = getDerived().TransformTemplateTypeParmType(TLB, TTP,
5054 SuppressObjCLifetime);
5055 }
else if (
auto STTP = UnqualTL.
getAs<SubstTemplateTypeParmPackTypeLoc>()) {
5056 Result = getDerived().TransformSubstTemplateTypeParmPackType(
5057 TLB, STTP, SuppressObjCLifetime);
5059 Result = getDerived().TransformType(TLB, UnqualTL);
5078template <
typename Derived>
5088 SemaRef.
Diag(Loc, diag::err_address_space_mismatch_templ_inst)
5119 else if (
T.getObjCLifetime()) {
5124 if ((AutoTy = dyn_cast<AutoType>(
T)) && AutoTy->
isDeduced()) {
5140 SemaRef.
Diag(Loc, diag::err_attr_objc_ownership_redundant) <<
T;
5149template<
typename Derived>
5155 if (getDerived().AlreadyTransformed(TL.
getType()))
5159 TransformTSIInObjectScope(TL, ObjectType, UnqualLookup, SS);
5165template<
typename Derived>
5167TreeTransform<Derived>::TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
5168 QualType ObjectType,
5169 NamedDecl *UnqualLookup,
5171 if (getDerived().AlreadyTransformed(TSInfo->getType()))
5174 return TransformTSIInObjectScope(TSInfo->getTypeLoc(), ObjectType,
5178template <
typename Derived>
5179TypeSourceInfo *TreeTransform<Derived>::TransformTSIInObjectScope(
5180 TypeLoc TL, QualType ObjectType, NamedDecl *UnqualLookup,
5182 QualType
T = TL.getType();
5183 assert(!getDerived().AlreadyTransformed(
T));
5188 if (isa<TemplateSpecializationType>(
T)) {
5189 TemplateSpecializationTypeLoc SpecTL =
5190 TL.castAs<TemplateSpecializationTypeLoc>();
5192 TemplateName Template = getDerived().TransformTemplateName(
5193 SS, SpecTL.getTypePtr()->getTemplateName(), SpecTL.getTemplateNameLoc(),
5194 ObjectType, UnqualLookup,
true);
5195 if (Template.isNull())
5198 Result = getDerived().TransformTemplateSpecializationType(TLB, SpecTL,
5200 }
else if (isa<DependentTemplateSpecializationType>(
T)) {
5201 DependentTemplateSpecializationTypeLoc SpecTL =
5202 TL.castAs<DependentTemplateSpecializationTypeLoc>();
5204 TemplateName Template
5205 = getDerived().RebuildTemplateName(SS,
5206 SpecTL.getTemplateKeywordLoc(),
5207 *SpecTL.getTypePtr()->getIdentifier(),
5208 SpecTL.getTemplateNameLoc(),
5209 ObjectType, UnqualLookup,
5211 if (Template.isNull())
5214 Result = getDerived().TransformDependentTemplateSpecializationType(TLB,
5220 Result = getDerived().TransformType(TLB, TL);
5229template <
class TyLoc>
static inline
5231 TyLoc NewT = TLB.
push<TyLoc>(
T.getType());
5232 NewT.setNameLoc(
T.getNameLoc());
5236template<
typename Derived>
5237QualType TreeTransform<Derived>::TransformBuiltinType(TypeLocBuilder &TLB,
5239 BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(
T.getType());
5240 NewT.setBuiltinLoc(
T.getBuiltinLoc());
5241 if (
T.needsExtraLocalData())
5242 NewT.getWrittenBuiltinSpecs() =
T.getWrittenBuiltinSpecs();
5246template<
typename Derived>
5247QualType TreeTransform<Derived>::TransformComplexType(TypeLocBuilder &TLB,
5253template <
typename Derived>
5254QualType TreeTransform<Derived>::TransformAdjustedType(TypeLocBuilder &TLB,
5255 AdjustedTypeLoc TL) {
5257 return getDerived().TransformType(TLB, TL.getOriginalLoc());
5260template<
typename Derived>
5261QualType TreeTransform<Derived>::TransformDecayedType(TypeLocBuilder &TLB,
5262 DecayedTypeLoc TL) {
5263 QualType OriginalType = getDerived().TransformType(TLB, TL.getOriginalLoc());
5264 if (OriginalType.isNull())
5267 QualType
Result = TL.getType();
5268 if (getDerived().AlwaysRebuild() ||
5269 OriginalType != TL.getOriginalLoc().getType())
5271 TLB.push<DecayedTypeLoc>(
Result);
5276template <
typename Derived>
5278TreeTransform<Derived>::TransformArrayParameterType(TypeLocBuilder &TLB,
5279 ArrayParameterTypeLoc TL) {
5280 QualType OriginalType = getDerived().TransformType(TLB, TL.getElementLoc());
5281 if (OriginalType.isNull())
5284 QualType
Result = TL.getType();
5285 if (getDerived().AlwaysRebuild() ||
5286 OriginalType != TL.getElementLoc().getType())
5288 TLB.push<ArrayParameterTypeLoc>(
Result);
5293template<
typename Derived>
5294QualType TreeTransform<Derived>::TransformPointerType(TypeLocBuilder &TLB,
5295 PointerTypeLoc TL) {
5296 QualType PointeeType
5297 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5298 if (PointeeType.isNull())
5301 QualType
Result = TL.getType();
5302 if (PointeeType->getAs<ObjCObjectType>()) {
5309 ObjCObjectPointerTypeLoc NewT = TLB.push<ObjCObjectPointerTypeLoc>(
Result);
5310 NewT.setStarLoc(TL.getStarLoc());
5314 if (getDerived().AlwaysRebuild() ||
5315 PointeeType != TL.getPointeeLoc().getType()) {
5316 Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc());
5323 TLB.TypeWasModifiedSafely(
Result->getPointeeType());
5325 PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(
Result);
5326 NewT.setSigilLoc(TL.getSigilLoc());
5330template<
typename Derived>
5332TreeTransform<Derived>::TransformBlockPointerType(TypeLocBuilder &TLB,
5333 BlockPointerTypeLoc TL) {
5334 QualType PointeeType
5335 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5336 if (PointeeType.isNull())
5339 QualType
Result = TL.getType();
5340 if (getDerived().AlwaysRebuild() ||
5341 PointeeType != TL.getPointeeLoc().getType()) {
5342 Result = getDerived().RebuildBlockPointerType(PointeeType,
5348 BlockPointerTypeLoc NewT = TLB.push<BlockPointerTypeLoc>(
Result);
5349 NewT.setSigilLoc(TL.getSigilLoc());
5357template<
typename Derived>
5365 if (PointeeType.
isNull())
5369 if (getDerived().AlwaysRebuild() ||
5370 PointeeType !=
T->getPointeeTypeAsWritten()) {
5371 Result = getDerived().RebuildReferenceType(PointeeType,
5372 T->isSpelledAsLValue(),
5385 if (isa<LValueReferenceType>(
Result))
5394template<
typename Derived>
5398 return TransformReferenceType(TLB, TL);
5401template<
typename Derived>
5403TreeTransform<Derived>::TransformRValueReferenceType(TypeLocBuilder &TLB,
5404 RValueReferenceTypeLoc TL) {
5405 return TransformReferenceType(TLB, TL);
5408template<
typename Derived>
5410TreeTransform<Derived>::TransformMemberPointerType(TypeLocBuilder &TLB,
5411 MemberPointerTypeLoc TL) {
5412 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5413 if (PointeeType.isNull())
5416 TypeSourceInfo* OldClsTInfo = TL.getClassTInfo();
5417 TypeSourceInfo *NewClsTInfo =
nullptr;
5419 NewClsTInfo = getDerived().TransformType(OldClsTInfo);
5424 const MemberPointerType *
T = TL.getTypePtr();
5425 QualType OldClsType = QualType(
T->getClass(), 0);
5426 QualType NewClsType;
5428 NewClsType = NewClsTInfo->getType();
5430 NewClsType = getDerived().TransformType(OldClsType);
5431 if (NewClsType.isNull())
5435 QualType
Result = TL.getType();
5436 if (getDerived().AlwaysRebuild() ||
5438 NewClsType != OldClsType) {
5439 Result = getDerived().RebuildMemberPointerType(PointeeType, NewClsType,
5447 const MemberPointerType *MPT =
Result->getAs<MemberPointerType>();
5448 if (MPT && PointeeType != MPT->getPointeeType()) {
5449 assert(isa<AdjustedType>(MPT->getPointeeType()));
5450 TLB.push<AdjustedTypeLoc>(MPT->getPointeeType());
5453 MemberPointerTypeLoc NewTL = TLB.push<MemberPointerTypeLoc>(
Result);
5454 NewTL.setSigilLoc(TL.getSigilLoc());
5455 NewTL.setClassTInfo(NewClsTInfo);
5460template<
typename Derived>
5462TreeTransform<Derived>::TransformConstantArrayType(TypeLocBuilder &TLB,
5463 ConstantArrayTypeLoc TL) {
5464 const ConstantArrayType *
T = TL.getTypePtr();
5465 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5466 if (ElementType.isNull())
5470 Expr *OldSize = TL.getSizeExpr();
5472 OldSize =
const_cast<Expr*
>(
T->getSizeExpr());
5473 Expr *NewSize =
nullptr;
5477 NewSize = getDerived().TransformExpr(OldSize).template getAs<Expr>();
5481 QualType
Result = TL.getType();
5482 if (getDerived().AlwaysRebuild() ||
5483 ElementType !=
T->getElementType() ||
5484 (
T->getSizeExpr() && NewSize != OldSize)) {
5485 Result = getDerived().RebuildConstantArrayType(ElementType,
5486 T->getSizeModifier(),
5487 T->getSize(), NewSize,
5488 T->getIndexTypeCVRQualifiers(),
5489 TL.getBracketsRange());
5498 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(
Result);
5499 NewTL.setLBracketLoc(TL.getLBracketLoc());
5500 NewTL.setRBracketLoc(TL.getRBracketLoc());
5501 NewTL.setSizeExpr(NewSize);
5506template<
typename Derived>
5507QualType TreeTransform<Derived>::TransformIncompleteArrayType(
5508 TypeLocBuilder &TLB,
5509 IncompleteArrayTypeLoc TL) {
5510 const IncompleteArrayType *
T = TL.getTypePtr();
5511 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5512 if (ElementType.isNull())
5515 QualType
Result = TL.getType();
5516 if (getDerived().AlwaysRebuild() ||
5517 ElementType !=
T->getElementType()) {
5518 Result = getDerived().RebuildIncompleteArrayType(ElementType,
5519 T->getSizeModifier(),
5520 T->getIndexTypeCVRQualifiers(),
5521 TL.getBracketsRange());
5526 IncompleteArrayTypeLoc NewTL = TLB.push<IncompleteArrayTypeLoc>(
Result);
5527 NewTL.setLBracketLoc(TL.getLBracketLoc());
5528 NewTL.setRBracketLoc(TL.getRBracketLoc());
5529 NewTL.setSizeExpr(
nullptr);
5534template<
typename Derived>
5536TreeTransform<Derived>::TransformVariableArrayType(TypeLocBuilder &TLB,
5537 VariableArrayTypeLoc TL) {
5538 const VariableArrayType *
T = TL.getTypePtr();
5539 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5540 if (ElementType.isNull())
5545 EnterExpressionEvaluationContext Context(
5547 SizeResult = getDerived().TransformExpr(
T->getSizeExpr());
5549 if (SizeResult.isInvalid())
5553 if (SizeResult.isInvalid())
5556 Expr *
Size = SizeResult.get();
5558 QualType
Result = TL.getType();
5559 if (getDerived().AlwaysRebuild() ||
5560 ElementType !=
T->getElementType() ||
5561 Size !=
T->getSizeExpr()) {
5562 Result = getDerived().RebuildVariableArrayType(ElementType,
5563 T->getSizeModifier(),
5565 T->getIndexTypeCVRQualifiers(),
5566 TL.getBracketsRange());
5573 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(
Result);
5574 NewTL.setLBracketLoc(TL.getLBracketLoc());
5575 NewTL.setRBracketLoc(TL.getRBracketLoc());
5576 NewTL.setSizeExpr(Size);
5581template<
typename Derived>
5583TreeTransform<Derived>::TransformDependentSizedArrayType(TypeLocBuilder &TLB,
5584 DependentSizedArrayTypeLoc TL) {
5585 const DependentSizedArrayType *
T = TL.getTypePtr();
5586 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5587 if (ElementType.isNull())
5595 SemaRef.
ExprEvalContexts.back().InConditionallyConstantEvaluateContext =
true;
5598 Expr *origSize = TL.getSizeExpr();
5599 if (!origSize) origSize =
T->getSizeExpr();
5602 = getDerived().TransformExpr(origSize);
5604 if (sizeResult.isInvalid())
5607 Expr *size = sizeResult.get();
5609 QualType
Result = TL.getType();
5610 if (getDerived().AlwaysRebuild() ||
5611 ElementType !=
T->getElementType() ||
5613 Result = getDerived().RebuildDependentSizedArrayType(ElementType,
5614 T->getSizeModifier(),
5616 T->getIndexTypeCVRQualifiers(),
5617 TL.getBracketsRange());
5624 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(
Result);
5625 NewTL.setLBracketLoc(TL.getLBracketLoc());
5626 NewTL.setRBracketLoc(TL.getRBracketLoc());
5627 NewTL.setSizeExpr(size);
5632template <
typename Derived>
5633QualType TreeTransform<Derived>::TransformDependentVectorType(
5634 TypeLocBuilder &TLB, DependentVectorTypeLoc TL) {
5635 const DependentVectorType *
T = TL.getTypePtr();
5636 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5637 if (ElementType.isNull())
5645 if (
Size.isInvalid())
5648 QualType
Result = TL.getType();
5649 if (getDerived().AlwaysRebuild() || ElementType !=
T->getElementType() ||
5650 Size.get() !=
T->getSizeExpr()) {
5651 Result = getDerived().RebuildDependentVectorType(
5652 ElementType,
Size.get(),
T->getAttributeLoc(),
T->getVectorKind());
5658 if (isa<DependentVectorType>(
Result)) {
5659 DependentVectorTypeLoc NewTL =
5660 TLB.push<DependentVectorTypeLoc>(
Result);
5661 NewTL.setNameLoc(TL.getNameLoc());
5663 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(
Result);
5664 NewTL.setNameLoc(TL.getNameLoc());
5670template<
typename Derived>
5671QualType TreeTransform<Derived>::TransformDependentSizedExtVectorType(
5672 TypeLocBuilder &TLB,
5673 DependentSizedExtVectorTypeLoc TL) {
5674 const DependentSizedExtVectorType *
T = TL.getTypePtr();
5677 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5678 if (ElementType.isNull())
5687 if (
Size.isInvalid())
5690 QualType
Result = TL.getType();
5691 if (getDerived().AlwaysRebuild() ||
5692 ElementType !=
T->getElementType() ||
5693 Size.get() !=
T->getSizeExpr()) {
5694 Result = getDerived().RebuildDependentSizedExtVectorType(ElementType,
5696 T->getAttributeLoc());
5702 if (isa<DependentSizedExtVectorType>(
Result)) {
5703 DependentSizedExtVectorTypeLoc NewTL
5704 = TLB.push<DependentSizedExtVectorTypeLoc>(
Result);
5705 NewTL.setNameLoc(TL.getNameLoc());
5707 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(
Result);
5708 NewTL.setNameLoc(TL.getNameLoc());
5714template <
typename Derived>
5716TreeTransform<Derived>::TransformConstantMatrixType(TypeLocBuilder &TLB,
5717 ConstantMatrixTypeLoc TL) {
5718 const ConstantMatrixType *
T = TL.getTypePtr();
5719 QualType ElementType = getDerived().TransformType(
T->getElementType());
5720 if (ElementType.isNull())
5723 QualType
Result = TL.getType();
5724 if (getDerived().AlwaysRebuild() || ElementType !=
T->getElementType()) {
5725 Result = getDerived().RebuildConstantMatrixType(
5726 ElementType,
T->getNumRows(),
T->getNumColumns());
5731 ConstantMatrixTypeLoc NewTL = TLB.push<ConstantMatrixTypeLoc>(
Result);
5732 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
5733 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
5734 NewTL.setAttrRowOperand(TL.getAttrRowOperand());
5735 NewTL.setAttrColumnOperand(TL.getAttrColumnOperand());
5740template <
typename Derived>
5741QualType TreeTransform<Derived>::TransformDependentSizedMatrixType(
5742 TypeLocBuilder &TLB, DependentSizedMatrixTypeLoc TL) {
5743 const DependentSizedMatrixType *
T = TL.getTypePtr();
5745 QualType ElementType = getDerived().TransformType(
T->getElementType());
5746 if (ElementType.isNull()) {
5754 Expr *origRows = TL.getAttrRowOperand();
5756 origRows =
T->getRowExpr();
5757 Expr *origColumns = TL.getAttrColumnOperand();
5759 origColumns =
T->getColumnExpr();
5761 ExprResult rowResult = getDerived().TransformExpr(origRows);
5763 if (rowResult.isInvalid())
5766 ExprResult columnResult = getDerived().TransformExpr(origColumns);
5768 if (columnResult.isInvalid())
5771 Expr *rows = rowResult.get();
5772 Expr *columns = columnResult.get();
5774 QualType
Result = TL.getType();
5775 if (getDerived().AlwaysRebuild() || ElementType !=
T->getElementType() ||
5776 rows != origRows || columns != origColumns) {
5777 Result = getDerived().RebuildDependentSizedMatrixType(
5778 ElementType, rows, columns,
T->getAttributeLoc());
5786 MatrixTypeLoc NewTL = TLB.push<MatrixTypeLoc>(
Result);
5787 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
5788 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
5789 NewTL.setAttrRowOperand(rows);
5790 NewTL.setAttrColumnOperand(columns);
5794template <
typename Derived>
5795QualType TreeTransform<Derived>::TransformDependentAddressSpaceType(
5796 TypeLocBuilder &TLB, DependentAddressSpaceTypeLoc TL) {
5797 const DependentAddressSpaceType *
T = TL.getTypePtr();
5799 QualType pointeeType = getDerived().TransformType(
T->
getPointeeType());
5801 if (pointeeType.isNull())
5808 ExprResult AddrSpace = getDerived().TransformExpr(
T->getAddrSpaceExpr());
5810 if (AddrSpace.isInvalid())
5813 QualType
Result = TL.getType();
5814 if (getDerived().AlwaysRebuild() || pointeeType !=
T->
getPointeeType() ||
5815 AddrSpace.get() !=
T->getAddrSpaceExpr()) {
5816 Result = getDerived().RebuildDependentAddressSpaceType(
5817 pointeeType, AddrSpace.get(),
T->getAttributeLoc());
5823 if (isa<DependentAddressSpaceType>(
Result)) {
5824 DependentAddressSpaceTypeLoc NewTL =
5825 TLB.push<DependentAddressSpaceTypeLoc>(
Result);
5827 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
5828 NewTL.setAttrExprOperand(TL.getAttrExprOperand());
5829 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
5832 TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(
5833 Result, getDerived().getBaseLocation());
5834 TransformType(TLB, DI->getTypeLoc());
5840template <
typename Derived>
5841QualType TreeTransform<Derived>::TransformVectorType(TypeLocBuilder &TLB,
5843 const VectorType *
T = TL.getTypePtr();
5844 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5845 if (ElementType.isNull())
5848 QualType
Result = TL.getType();
5849 if (getDerived().AlwaysRebuild() ||
5850 ElementType !=
T->getElementType()) {
5851 Result = getDerived().RebuildVectorType(ElementType,
T->getNumElements(),
5852 T->getVectorKind());
5857 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(
Result);
5858 NewTL.setNameLoc(TL.getNameLoc());
5863template<
typename Derived>
5864QualType TreeTransform<Derived>::TransformExtVectorType(TypeLocBuilder &TLB,
5865 ExtVectorTypeLoc TL) {
5866 const VectorType *
T = TL.getTypePtr();
5867 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5868 if (ElementType.isNull())
5871 QualType
Result = TL.getType();
5872 if (getDerived().AlwaysRebuild() ||
5873 ElementType !=
T->getElementType()) {
5874 Result = getDerived().RebuildExtVectorType(ElementType,
5875 T->getNumElements(),
5881 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(
Result);
5882 NewTL.setNameLoc(TL.getNameLoc());
5887template <
typename Derived>
5890 std::optional<unsigned> NumExpansions,
bool ExpectParameterPack) {
5894 if (NumExpansions && isa<PackExpansionType>(OldDI->
getType())) {
5921 NewDI = getDerived().TransformType(OldDI);
5925 if (NewDI == OldDI && indexAdjustment == 0)
5939 transformedLocalDecl(OldParm, {newParm});
5943template <
typename Derived>
5951 unsigned *LastParamTransformed) {
5952 int indexAdjustment = 0;
5954 unsigned NumParams = Params.size();
5955 for (
unsigned i = 0; i != NumParams; ++i) {
5956 if (LastParamTransformed)
5957 *LastParamTransformed = i;
5959 assert(OldParm->getFunctionScopeIndex() == i);
5961 std::optional<unsigned> NumExpansions;
5963 if (OldParm->isParameterPack()) {
5968 TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
5974 bool ShouldExpand =
false;
5975 bool RetainExpansion =
false;
5976 std::optional<unsigned> OrigNumExpansions;
5977 if (Unexpanded.size() > 0) {
5979 NumExpansions = OrigNumExpansions;
5980 if (getDerived().TryExpandParameterPacks(ExpansionTL.
getEllipsisLoc(),
5981 Pattern.getSourceRange(),
5993 "Could not find parameter packs or undeduced auto type!");
6000 getDerived().ExpandingFunctionParameterPack(OldParm);
6001 for (
unsigned I = 0; I != *NumExpansions; ++I) {
6004 = getDerived().TransformFunctionTypeParam(OldParm,
6012 PInfos.
set(OutParamTypes.size(), ParamInfos[i]);
6013 OutParamTypes.push_back(NewParm->
getType());
6015 PVars->push_back(NewParm);
6020 if (RetainExpansion) {
6021 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6023 = getDerived().TransformFunctionTypeParam(OldParm,
6031 PInfos.
set(OutParamTypes.size(), ParamInfos[i]);
6032 OutParamTypes.push_back(NewParm->
getType());
6034 PVars->push_back(NewParm);
6050 NewParm = getDerived().TransformFunctionTypeParam(OldParm,
6055 "Parameter pack no longer a parameter pack after "
6058 NewParm = getDerived().TransformFunctionTypeParam(
6059 OldParm, indexAdjustment, std::nullopt,
6067 PInfos.
set(OutParamTypes.size(), ParamInfos[i]);
6068 OutParamTypes.push_back(NewParm->
getType());
6070 PVars->push_back(NewParm);
6078 bool IsPackExpansion =
false;
6079 std::optional<unsigned> NumExpansions;
6082 = dyn_cast<PackExpansionType>(OldType)) {
6084 QualType Pattern = Expansion->getPattern();
6086 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
6089 bool ShouldExpand =
false;
6090 bool RetainExpansion =
false;
6091 if (getDerived().TryExpandParameterPacks(Loc,
SourceRange(),
6102 for (
unsigned I = 0; I != *NumExpansions; ++I) {
6104 QualType NewType = getDerived().TransformType(Pattern);
6109 NewType = getSema().getASTContext().getPackExpansionType(
6110 NewType, std::nullopt);
6117 PInfos.
set(OutParamTypes.size(), ParamInfos[i]);
6118 OutParamTypes.push_back(NewType);
6120 PVars->push_back(
nullptr);
6129 if (RetainExpansion) {
6130 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6131 QualType NewType = getDerived().TransformType(Pattern);
6136 PInfos.
set(OutParamTypes.size(), ParamInfos[i]);
6137 OutParamTypes.push_back(NewType);
6139 PVars->push_back(
nullptr);
6144 OldType = Expansion->getPattern();
6145 IsPackExpansion =
true;
6147 NewType = getDerived().TransformType(OldType);
6149 NewType = getDerived().TransformType(OldType);
6155 if (IsPackExpansion)
6156 NewType = getSema().Context.getPackExpansionType(NewType,
6160 PInfos.
set(OutParamTypes.size(), ParamInfos[i]);
6161 OutParamTypes.push_back(NewType);
6163 PVars->push_back(
nullptr);
6168 for (
unsigned i = 0, e = PVars->size(); i != e; ++i)
6170 assert(parm->getFunctionScopeIndex() == i);
6177template<
typename Derived>
6182 return getDerived().TransformFunctionProtoType(
6185 return getDerived().TransformExceptionSpec(TL.
getBeginLoc(), ESI,
6186 ExceptionStorage, Changed);
6190template<
typename Derived>
template<
typename Fn>
6193 Qualifiers ThisTypeQuals, Fn TransformExceptionSpec) {
6210 if (getDerived().TransformFunctionTypeParams(
6214 ParamTypes, &ParamDecls, ExtParamInfos))
6226 SemaRef, !ThisContext && RD ? RD : ThisContext, ThisTypeQuals);
6228 ResultType = getDerived().TransformType(TLB, TL.
getReturnLoc());
6234 ResultType = getDerived().TransformType(TLB, TL.
getReturnLoc());
6238 if (getDerived().TransformFunctionTypeParams(
6242 ParamTypes, &ParamDecls, ExtParamInfos))
6248 bool EPIChanged =
false;
6253 if (
auto NewExtParamInfos =
6267 if (getDerived().AlwaysRebuild() || ResultType !=
T->
getReturnType() ||
6269 Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI);
6280 for (
unsigned i = 0, e = NewTL.
getNumParams(); i != e; ++i)
6286template<
typename Derived>
6296 auto *Method = dyn_cast_if_present<CXXMethodDecl>(ESI.
SourceTemplate);
6298 SemaRef, Method ? Method->getParent() :
nullptr,
6299 Method ? Method->getMethodQualifiers() :
Qualifiers{},
6309 getSema().ActOnNoexceptSpec(NoexceptExpr.
get(), EST);
6332 assert(!Unexpanded.empty() &&
"Pack expansion without parameter packs?");
6337 bool Expand =
false;
6338 bool RetainExpansion =
false;
6339 std::optional<unsigned> NumExpansions = PackExpansion->getNumExpansions();
6342 if (getDerived().TryExpandParameterPacks(
6344 RetainExpansion, NumExpansions))
6352 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6357 Exceptions.push_back(
U);
6363 for (
unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
6366 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6370 Exceptions.push_back(
U);
6379 Exceptions.push_back(
U);
6389template<
typename Derived>
6399 if (getDerived().AlwaysRebuild() || ResultType !=
T->
getReturnType())
6400 Result = getDerived().RebuildFunctionNoProtoType(ResultType);
6411template <
typename Derived>
6412QualType TreeTransform<Derived>::TransformUnresolvedUsingType(
6413 TypeLocBuilder &TLB, UnresolvedUsingTypeLoc TL) {
6414 const UnresolvedUsingType *
T = TL.getTypePtr();
6415 Decl *D = getDerived().TransformDecl(TL.getNameLoc(),
T->getDecl());
6419 QualType
Result = TL.getType();
6420 if (getDerived().AlwaysRebuild() || D !=
T->getDecl()) {
6421 Result = getDerived().RebuildUnresolvedUsingType(TL.getNameLoc(), D);
6428 TypeSpecTypeLoc NewTL = TLB.pushTypeSpec(
Result);
6429 NewTL.setNameLoc(TL.getNameLoc());
6434template <
typename Derived>
6435QualType TreeTransform<Derived>::TransformUsingType(TypeLocBuilder &TLB,
6437 const UsingType *
T = TL.getTypePtr();
6439 auto *Found = cast_or_null<UsingShadowDecl>(getDerived().TransformDecl(
6440 TL.getLocalSourceRange().getBegin(),
T->getFoundDecl()));
6444 QualType Underlying = getDerived().TransformType(
T->
desugar());
6445 if (Underlying.isNull())
6448 QualType
Result = TL.getType();
6449 if (getDerived().AlwaysRebuild() || Found !=
T->getFoundDecl() ||
6450 Underlying !=
T->getUnderlyingType()) {
6451 Result = getDerived().RebuildUsingType(Found, Underlying);
6456 TLB.pushTypeSpec(
Result).setNameLoc(TL.getNameLoc());
6460template<
typename Derived>
6461QualType TreeTransform<Derived>::TransformTypedefType(TypeLocBuilder &TLB,
6462 TypedefTypeLoc TL) {
6463 const TypedefType *
T = TL.getTypePtr();
6464 TypedefNameDecl *Typedef
6465 = cast_or_null<TypedefNameDecl>(getDerived().TransformDecl(TL.getNameLoc(),
6470 QualType
Result = TL.getType();
6471 if (getDerived().AlwaysRebuild() ||
6472 Typedef !=
T->getDecl()) {
6473 Result = getDerived().RebuildTypedefType(Typedef);
6478 TypedefTypeLoc NewTL = TLB.push<TypedefTypeLoc>(
Result);
6479 NewTL.setNameLoc(TL.getNameLoc());
6484template<
typename Derived>
6485QualType TreeTransform<Derived>::TransformTypeOfExprType(TypeLocBuilder &TLB,
6486 TypeOfExprTypeLoc TL) {
6492 ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr());
6500 QualType
Result = TL.getType();
6502 if (getDerived().AlwaysRebuild() || E.get() != TL.getUnderlyingExpr()) {
6504 getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc(), Kind);
6509 TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(
Result);
6510 NewTL.setTypeofLoc(TL.getTypeofLoc());
6511 NewTL.setLParenLoc(TL.getLParenLoc());
6512 NewTL.setRParenLoc(TL.getRParenLoc());
6517template<
typename Derived>
6518QualType TreeTransform<Derived>::TransformTypeOfType(TypeLocBuilder &TLB,
6520 TypeSourceInfo* Old_Under_TI = TL.getUnmodifiedTInfo();
6521 TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI);
6525 QualType
Result = TL.getType();
6527 if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
6528 Result = getDerived().RebuildTypeOfType(New_Under_TI->getType(), Kind);
6533 TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(
Result);
6534 NewTL.setTypeofLoc(TL.getTypeofLoc());
6535 NewTL.setLParenLoc(TL.getLParenLoc());
6536 NewTL.setRParenLoc(TL.getRParenLoc());
6537 NewTL.setUnmodifiedTInfo(New_Under_TI);
6542template<
typename Derived>
6543QualType TreeTransform<Derived>::TransformDecltypeType(TypeLocBuilder &TLB,
6544 DecltypeTypeLoc TL) {
6545 const DecltypeType *
T = TL.getTypePtr();
6552 ExprResult E = getDerived().TransformExpr(
T->getUnderlyingExpr());
6556 E = getSema().ActOnDecltypeExpression(E.get());
6560 QualType
Result = TL.getType();
6561 if (getDerived().AlwaysRebuild() ||
6562 E.get() !=
T->getUnderlyingExpr()) {
6563 Result = getDerived().RebuildDecltypeType(E.get(), TL.getDecltypeLoc());
6569 DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(
Result);
6570 NewTL.setDecltypeLoc(TL.getDecltypeLoc());
6571 NewTL.setRParenLoc(TL.getRParenLoc());
6575template <
typename Derived>
6577TreeTransform<Derived>::TransformPackIndexingType(TypeLocBuilder &TLB,
6578 PackIndexingTypeLoc TL) {
6580 ExprResult IndexExpr = getDerived().TransformExpr(TL.getIndexExpr());
6581 if (IndexExpr.isInvalid())
6583 QualType Pattern = TL.getPattern();
6585 const PackIndexingType *PIT = TL.getTypePtr();
6589 bool NotYetExpanded = Types.empty();
6590 bool FullySubstituted =
true;
6595 for (
const QualType &
T : Types) {
6597 QualType Transformed = getDerived().TransformType(
T);
6598 if (Transformed.isNull())
6600 SubtitutedTypes.push_back(Transformed);
6605 getSema().collectUnexpandedParameterPacks(
T, Unexpanded);
6606 assert(!Unexpanded.empty() &&
"Pack expansion without parameter packs?");
6609 bool ShouldExpand =
true;
6610 bool RetainExpansion =
false;
6611 std::optional<unsigned> OrigNumExpansions;
6612 std::optional<unsigned> NumExpansions = OrigNumExpansions;
6613 if (getDerived().TryExpandParameterPacks(TL.getEllipsisLoc(), SourceRange(),
6614 Unexpanded, ShouldExpand,
6615 RetainExpansion, NumExpansions))
6617 if (!ShouldExpand) {
6618 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
6621 TypeSourceInfo *TI =
6623 QualType Pack = getDerived().TransformType(TLB, TI->getTypeLoc());
6626 if (NotYetExpanded) {
6627 FullySubstituted =
false;
6628 QualType Out = getDerived().RebuildPackIndexingType(
6629 Pack, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
6634 PackIndexingTypeLoc Loc = TLB.push<PackIndexingTypeLoc>(Out);
6635 Loc.setEllipsisLoc(TL.getEllipsisLoc());
6638 SubtitutedTypes.push_back(Pack);
6641 for (
unsigned I = 0; I != *NumExpansions; ++I) {
6642 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
6643 QualType Out = getDerived().TransformType(
T);
6646 SubtitutedTypes.push_back(Out);
6650 if (RetainExpansion) {
6651 FullySubstituted =
false;
6652 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6653 QualType Out = getDerived().TransformType(
T);
6656 SubtitutedTypes.push_back(Out);
6660 QualType
Result = getDerived().TransformType(TLB, TL.getPatternLoc());
6662 QualType Out = getDerived().RebuildPackIndexingType(
6663 Result, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
6664 FullySubstituted, SubtitutedTypes);
6668 PackIndexingTypeLoc Loc = TLB.push<PackIndexingTypeLoc>(Out);
6669 Loc.setEllipsisLoc(TL.getEllipsisLoc());
6673template<
typename Derived>
6674QualType TreeTransform<Derived>::TransformUnaryTransformType(
6675 TypeLocBuilder &TLB,
6676 UnaryTransformTypeLoc TL) {
6677 QualType
Result = TL.getType();
6678 if (
Result->isDependentType()) {
6679 const UnaryTransformType *
T = TL.getTypePtr();
6681 getDerived().TransformType(TL.getUnderlyingTInfo())->getType();
6682 Result = getDerived().RebuildUnaryTransformType(NewBase,
6689 UnaryTransformTypeLoc NewTL = TLB.push<UnaryTransformTypeLoc>(
Result);
6690 NewTL.setKWLoc(TL.getKWLoc());
6691 NewTL.setParensRange(TL.getParensRange());
6692 NewTL.setUnderlyingTInfo(TL.getUnderlyingTInfo());
6696template<
typename Derived>
6697QualType TreeTransform<Derived>::TransformDeducedTemplateSpecializationType(
6698 TypeLocBuilder &TLB, DeducedTemplateSpecializationTypeLoc TL) {
6699 const DeducedTemplateSpecializationType *
T = TL.getTypePtr();
6702 TemplateName TemplateName = getDerived().TransformTemplateName(
6703 SS,
T->getTemplateName(), TL.getTemplateNameLoc());
6704 if (TemplateName.isNull())
6707 QualType OldDeduced =
T->getDeducedType();
6708 QualType NewDeduced;
6709 if (!OldDeduced.isNull()) {
6710 NewDeduced = getDerived().TransformType(OldDeduced);
6711 if (NewDeduced.isNull())
6715 QualType
Result = getDerived().RebuildDeducedTemplateSpecializationType(
6716 TemplateName, NewDeduced);
6720 DeducedTemplateSpecializationTypeLoc NewTL =
6721 TLB.push<DeducedTemplateSpecializationTypeLoc>(
Result);
6722 NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
6727template<
typename Derived>
6728QualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB,
6730 const RecordType *
T = TL.getTypePtr();
6732 = cast_or_null<RecordDecl>(getDerived().TransformDecl(TL.getNameLoc(),
6737 QualType
Result = TL.getType();
6738 if (getDerived().AlwaysRebuild() ||
6745 RecordTypeLoc NewTL = TLB.push<RecordTypeLoc>(
Result);
6746 NewTL.setNameLoc(TL.getNameLoc());
6751template<
typename Derived>
6752QualType TreeTransform<Derived>::TransformEnumType(TypeLocBuilder &TLB,
6754 const EnumType *
T = TL.getTypePtr();
6756 = cast_or_null<EnumDecl>(getDerived().TransformDecl(TL.getNameLoc(),
6761 QualType
Result = TL.getType();
6762 if (getDerived().AlwaysRebuild() ||
6763 Enum !=
T->getDecl()) {
6769 EnumTypeLoc NewTL = TLB.push<EnumTypeLoc>(
Result);
6770 NewTL.setNameLoc(TL.getNameLoc());
6775template<
typename Derived>
6776QualType TreeTransform<Derived>::TransformInjectedClassNameType(
6777 TypeLocBuilder &TLB,
6778 InjectedClassNameTypeLoc TL) {
6779 Decl *D = getDerived().TransformDecl(TL.getNameLoc(),
6780 TL.getTypePtr()->getDecl());
6781 if (!D)
return QualType();
6784 TLB.pushTypeSpec(
T).setNameLoc(TL.getNameLoc());
6788template<
typename Derived>
6792 return getDerived().TransformTemplateTypeParmType(
6797template <
typename Derived>
6803template<
typename Derived>
6804QualType TreeTransform<Derived>::TransformSubstTemplateTypeParmType(
6805 TypeLocBuilder &TLB,
6806 SubstTemplateTypeParmTypeLoc TL) {
6807 const SubstTemplateTypeParmType *
T = TL.getTypePtr();
6810 getDerived().TransformDecl(TL.getNameLoc(),
T->getAssociatedDecl());
6815 TemporaryBase Rebase(*
this, TL.getNameLoc(), DeclarationName());
6816 QualType Replacement = getDerived().TransformType(
T->getReplacementType());
6817 if (Replacement.isNull())
6821 Replacement, NewReplaced,
T->getIndex(),
T->getPackIndex());
6824 SubstTemplateTypeParmTypeLoc NewTL
6825 = TLB.push<SubstTemplateTypeParmTypeLoc>(
Result);
6826 NewTL.setNameLoc(TL.getNameLoc());
6831template<
typename Derived>
6835 return getDerived().TransformSubstTemplateTypeParmPackType(
6839template <
typename Derived>
6845template<
typename Derived>
6855 = getDerived().TransformTemplateName(SS,
T->getTemplateName(),
6860 return getDerived().TransformTemplateSpecializationType(TLB, TL, Template);
6863template<
typename Derived>
6871 if (getDerived().AlwaysRebuild() ||
6873 Result = getDerived().RebuildAtomicType(ValueType, TL.
getKWLoc());
6878 AtomicTypeLoc NewTL = TLB.
push<AtomicTypeLoc>(
Result);
6886template <
typename Derived>
6887QualType TreeTransform<Derived>::TransformPipeType(TypeLocBuilder &TLB,
6889 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
6890 if (ValueType.isNull())
6893 QualType
Result = TL.getType();
6894 if (getDerived().AlwaysRebuild() || ValueType != TL.getValueLoc().getType()) {
6895 const PipeType *PT =
Result->castAs<PipeType>();
6896 bool isReadPipe = PT->isReadOnly();
6897 Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc(), isReadPipe);
6902 PipeTypeLoc NewTL = TLB.push<PipeTypeLoc>(
Result);
6903 NewTL.setKWLoc(TL.getKWLoc());
6908template <
typename Derived>
6909QualType TreeTransform<Derived>::TransformBitIntType(TypeLocBuilder &TLB,
6911 const BitIntType *EIT = TL.getTypePtr();
6912 QualType
Result = TL.getType();
6914 if (getDerived().AlwaysRebuild()) {
6915 Result = getDerived().RebuildBitIntType(EIT->isUnsigned(),
6916 EIT->getNumBits(), TL.getNameLoc());
6921 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(
Result);
6922 NewTL.setNameLoc(TL.getNameLoc());
6926template <
typename Derived>
6927QualType TreeTransform<Derived>::TransformDependentBitIntType(
6928 TypeLocBuilder &TLB, DependentBitIntTypeLoc TL) {
6929 const DependentBitIntType *EIT = TL.getTypePtr();
6933 ExprResult BitsExpr = getDerived().TransformExpr(EIT->getNumBitsExpr());
6936 if (BitsExpr.isInvalid())
6939 QualType
Result = TL.getType();
6941 if (getDerived().AlwaysRebuild() || BitsExpr.get() != EIT->getNumBitsExpr()) {
6942 Result = getDerived().RebuildDependentBitIntType(
6943 EIT->isUnsigned(), BitsExpr.get(), TL.getNameLoc());
6949 if (isa<DependentBitIntType>(
Result)) {
6950 DependentBitIntTypeLoc NewTL = TLB.push<DependentBitIntTypeLoc>(
Result);
6951 NewTL.setNameLoc(TL.getNameLoc());
6953 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(
Result);
6954 NewTL.setNameLoc(TL.getNameLoc());
6964 template<
typename ArgLocContainer>
6966 ArgLocContainer *Container;
6991 : Container(&Container), Index(Index) { }
7005 return Container->getArgLoc(Index);
7009 return pointer(Container->getArgLoc(Index));
7014 return X.Container == Y.Container &&
X.Index == Y.Index;
7023template<
typename Derived>
7024QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB,
7026 const AutoType *
T = TL.getTypePtr();
7027 QualType OldDeduced =
T->getDeducedType();
7028 QualType NewDeduced;
7029 if (!OldDeduced.isNull()) {
7030 NewDeduced = getDerived().TransformType(OldDeduced);
7031 if (NewDeduced.isNull())
7035 ConceptDecl *NewCD =
nullptr;
7036 TemplateArgumentListInfo NewTemplateArgs;
7037 NestedNameSpecifierLoc NewNestedNameSpec;
7038 if (
T->isConstrained()) {
7039 assert(TL.getConceptReference());
7040 NewCD = cast_or_null<ConceptDecl>(getDerived().TransformDecl(
7041 TL.getConceptNameLoc(),
T->getTypeConstraintConcept()));
7043 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7044 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7045 typedef TemplateArgumentLocContainerIterator<AutoTypeLoc> ArgIterator;
7046 if (getDerived().TransformTemplateArguments(
7047 ArgIterator(TL, 0), ArgIterator(TL, TL.getNumArgs()),
7051 if (TL.getNestedNameSpecifierLoc()) {
7053 = getDerived().TransformNestedNameSpecifierLoc(
7054 TL.getNestedNameSpecifierLoc());
7055 if (!NewNestedNameSpec)
7060 QualType
Result = TL.getType();
7061 if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced ||
7065 NewArgList.reserve(NewTemplateArgs.size());
7066 for (
const auto &ArgLoc : NewTemplateArgs.arguments())
7067 NewArgList.push_back(ArgLoc.getArgument());
7068 Result = getDerived().RebuildAutoType(NewDeduced,
T->getKeyword(), NewCD,
7074 AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(
Result);
7075 NewTL.setNameLoc(TL.getNameLoc());
7076 NewTL.setRParenLoc(TL.getRParenLoc());
7077 NewTL.setConceptReference(
nullptr);
7079 if (
T->isConstrained()) {
7080 DeclarationNameInfo DNI = DeclarationNameInfo(
7081 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName(),
7082 TL.getConceptNameLoc(),
7083 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName());
7085 SemaRef.
Context, NewNestedNameSpec, TL.getTemplateKWLoc(), DNI,
7086 TL.getFoundDecl(), TL.getTypePtr()->getTypeConstraintConcept(),
7088 NewTL.setConceptReference(CR);
7094template <
typename Derived>
7096 TypeLocBuilder &TLB,
7097 TemplateSpecializationTypeLoc TL,
7098 TemplateName Template) {
7099 TemplateArgumentListInfo NewTemplateArgs;
7100 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7101 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7102 typedef TemplateArgumentLocContainerIterator<TemplateSpecializationTypeLoc>
7104 if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
7105 ArgIterator(TL, TL.getNumArgs()),
7112 getDerived().RebuildTemplateSpecializationType(Template,
7113 TL.getTemplateNameLoc(),
7121 if (isa<DependentTemplateSpecializationType>(
Result)) {
7122 DependentTemplateSpecializationTypeLoc NewTL
7123 = TLB.push<DependentTemplateSpecializationTypeLoc>(
Result);
7124 NewTL.setElaboratedKeywordLoc(SourceLocation());
7125 NewTL.setQualifierLoc(NestedNameSpecifierLoc());
7126 NewTL.setTemplateKeywordLoc(TL.getTemplateKeywordLoc());
7127 NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
7128 NewTL.setLAngleLoc(TL.getLAngleLoc());
7129 NewTL.setRAngleLoc(TL.getRAngleLoc());
7130 for (
unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
7131 NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
7135 TemplateSpecializationTypeLoc NewTL
7136 = TLB.push<TemplateSpecializationTypeLoc>(
Result);
7137 NewTL.setTemplateKeywordLoc(TL.getTemplateKeywordLoc());
7138 NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
7139 NewTL.setLAngleLoc(TL.getLAngleLoc());
7140 NewTL.setRAngleLoc(TL.getRAngleLoc());
7141 for (
unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
7142 NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
7148template <
typename Derived>
7159 if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
7167 QualType Result = getSema().Context.getDependentTemplateSpecializationType(
7169 DTN->getIdentifier(), NewTemplateArgs.
arguments());
7179 for (
unsigned i = 0, e = NewTemplateArgs.
size(); i != e; ++i)
7185 = getDerived().RebuildTemplateSpecializationType(Template,
7197 for (
unsigned i = 0, e = NewTemplateArgs.
size(); i != e; ++i)
7204template<
typename Derived>
7219 QualType NamedT = getDerived().TransformType(TLB, TL.
getNamedTypeLoc());
7220 if (NamedT.isNull())
7229 if (
const TemplateSpecializationType *TST =
7230 NamedT->getAs<TemplateSpecializationType>()) {
7231 TemplateName Template = TST->getTemplateName();
7232 if (TypeAliasTemplateDecl *TAT = dyn_cast_or_null<TypeAliasTemplateDecl>(
7233 Template.getAsTemplateDecl())) {
7235 diag::err_tag_reference_non_tag)
7237 << llvm::to_underlying(
7239 SemaRef.
Diag(TAT->getLocation(), diag::note_declared_at);
7245 if (getDerived().AlwaysRebuild() ||
7247 NamedT !=
T->getNamedType()) {
7250 QualifierLoc, NamedT);
7255 ElaboratedTypeLoc NewTL = TLB.
push<ElaboratedTypeLoc>(
Result);
7257 NewTL.setQualifierLoc(QualifierLoc);
7261template <
typename Derived>
7262template <
typename Fn>
7267 if (modifiedType.
isNull())
7272 const Attr *newAttr = oldAttr ? getDerived().TransformAttr(oldAttr) :
nullptr;
7273 if (oldAttr && !newAttr)
7279 if (getDerived().AlwaysRebuild() ||
7285 if (equivalentType.
isNull())
7294 diag::err_nullability_nonpointer)
7310template <
typename Derived>
7313 return getDerived().TransformAttributedType(
7315 return getDerived().TransformType(TLB, ModifiedLoc);
7319template <
typename Derived>
7328 Expr *NewCount =
nullptr;
7330 ExprResult CountResult = getDerived().TransformExpr(OldCount);
7333 NewCount = CountResult.
get();
7337 if (getDerived().AlwaysRebuild() || InnerTy != OldTy->
desugar() ||
7338 OldCount != NewCount) {
7347template <
typename Derived>
7348QualType TreeTransform<Derived>::TransformBTFTagAttributedType(
7349 TypeLocBuilder &TLB, BTFTagAttributedTypeLoc TL) {
7351 llvm_unreachable(
"Unexpected TreeTransform for BTFTagAttributedType");
7354template<
typename Derived>
7356TreeTransform<Derived>::TransformParenType(TypeLocBuilder &TLB,
7358 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7362 QualType
Result = TL.getType();
7363 if (getDerived().AlwaysRebuild() ||
7364 Inner != TL.getInnerLoc().getType()) {
7365 Result = getDerived().RebuildParenType(Inner);
7370 ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(
Result);
7371 NewTL.setLParenLoc(TL.getLParenLoc());
7372 NewTL.setRParenLoc(TL.getRParenLoc());
7376template <
typename Derived>
7378TreeTransform<Derived>::TransformMacroQualifiedType(TypeLocBuilder &TLB,
7379 MacroQualifiedTypeLoc TL) {
7380 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7384 QualType
Result = TL.getType();
7385 if (getDerived().AlwaysRebuild() || Inner != TL.getInnerLoc().getType()) {
7387 getDerived().RebuildMacroQualifiedType(Inner, TL.getMacroIdentifier());
7392 MacroQualifiedTypeLoc NewTL = TLB.push<MacroQualifiedTypeLoc>(
Result);
7393 NewTL.setExpansionLoc(TL.getExpansionLoc());
7397template<
typename Derived>
7398QualType TreeTransform<Derived>::TransformDependentNameType(
7399 TypeLocBuilder &TLB, DependentNameTypeLoc TL) {
7400 return TransformDependentNameType(TLB, TL,
false);
7403template<
typename Derived>
7404QualType TreeTransform<Derived>::TransformDependentNameType(
7405 TypeLocBuilder &TLB, DependentNameTypeLoc TL,
bool DeducedTSTContext) {
7406 const DependentNameType *
T = TL.getTypePtr();
7408 NestedNameSpecifierLoc QualifierLoc
7409 = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
7414 = getDerived().RebuildDependentNameType(
T->getKeyword(),
7415 TL.getElaboratedKeywordLoc(),
7423 if (
const ElaboratedType* ElabT =
Result->getAs<ElaboratedType>()) {
7424 QualType NamedT = ElabT->getNamedType();
7425 TLB.pushTypeSpec(NamedT).setNameLoc(TL.getNameLoc());
7427 ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(
Result);
7428 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7429 NewTL.setQualifierLoc(QualifierLoc);
7431 DependentNameTypeLoc NewTL = TLB.push<DependentNameTypeLoc>(
Result);
7432 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7433 NewTL.setQualifierLoc(QualifierLoc);
7434 NewTL.setNameLoc(TL.getNameLoc());
7439template<
typename Derived>
7442 DependentTemplateSpecializationTypeLoc TL) {
7443 NestedNameSpecifierLoc QualifierLoc;
7444 if (TL.getQualifierLoc()) {
7446 = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
7452 .TransformDependentTemplateSpecializationType(TLB, TL, QualifierLoc);
7455template<
typename Derived>
7468 if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
7473 QualType Result = getDerived().RebuildDependentTemplateSpecializationType(
7481 QualType NamedT = ElabT->getNamedType();
7490 for (
unsigned I = 0, E = NewTemplateArgs.
size(); I != E; ++I)
7497 }
else if (isa<DependentTemplateSpecializationType>(
Result)) {
7506 for (
unsigned I = 0, E = NewTemplateArgs.
size(); I != E; ++I)
7515 for (
unsigned I = 0, E = NewTemplateArgs.
size(); I != E; ++I)
7521template<
typename Derived>
7530 if (getDerived().AlwaysRebuild() ||
7532 Result = getDerived().RebuildPackExpansionType(Pattern,
7540 PackExpansionTypeLoc NewT = TLB.
push<PackExpansionTypeLoc>(
Result);
7545template<
typename Derived>
7547TreeTransform<Derived>::TransformObjCInterfaceType(TypeLocBuilder &TLB,
7548 ObjCInterfaceTypeLoc TL) {
7550 TLB.pushFullCopy(TL);
7551 return TL.getType();
7554template<
typename Derived>
7556TreeTransform<Derived>::TransformObjCTypeParamType(TypeLocBuilder &TLB,
7557 ObjCTypeParamTypeLoc TL) {
7558 const ObjCTypeParamType *
T = TL.getTypePtr();
7559 ObjCTypeParamDecl *OTP = cast_or_null<ObjCTypeParamDecl>(
7560 getDerived().TransformDecl(
T->getDecl()->getLocation(),
T->getDecl()));
7564 QualType
Result = TL.getType();
7565 if (getDerived().AlwaysRebuild() ||
7566 OTP !=
T->getDecl()) {
7567 Result = getDerived().RebuildObjCTypeParamType(
7568 OTP, TL.getProtocolLAngleLoc(),
7569 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
7570 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
7575 ObjCTypeParamTypeLoc NewTL = TLB.push<ObjCTypeParamTypeLoc>(
Result);
7576 if (TL.getNumProtocols()) {
7577 NewTL.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
7578 for (
unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
7579 NewTL.setProtocolLoc(i, TL.getProtocolLoc(i));
7580 NewTL.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
7585template<
typename Derived>
7587TreeTransform<Derived>::TransformObjCObjectType(TypeLocBuilder &TLB,
7588 ObjCObjectTypeLoc TL) {
7590 QualType BaseType = getDerived().TransformType(TLB, TL.getBaseLoc());
7591 if (BaseType.isNull())
7594 bool AnyChanged = BaseType != TL.getBaseLoc().getType();
7598 for (
unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i) {
7599 TypeSourceInfo *TypeArgInfo = TL.getTypeArgTInfo(i);
7600 TypeLoc TypeArgLoc = TypeArgInfo->getTypeLoc();
7601 QualType TypeArg = TypeArgInfo->getType();
7602 if (
auto PackExpansionLoc = TypeArgLoc.getAs<PackExpansionTypeLoc>()) {
7606 const auto *PackExpansion = PackExpansionLoc.getType()
7607 ->castAs<PackExpansionType>();
7611 assert(!Unexpanded.empty() &&
"Pack expansion without parameter packs?");
7615 TypeLoc PatternLoc = PackExpansionLoc.getPatternLoc();
7616 bool Expand =
false;
7617 bool RetainExpansion =
false;
7618 std::optional<unsigned> NumExpansions = PackExpansion->getNumExpansions();
7619 if (getDerived().TryExpandParameterPacks(
7620 PackExpansionLoc.getEllipsisLoc(), PatternLoc.getSourceRange(),
7621 Unexpanded, Expand, RetainExpansion, NumExpansions))
7628 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
7630 TypeLocBuilder TypeArgBuilder;
7631 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
7632 QualType NewPatternType = getDerived().TransformType(TypeArgBuilder,
7634 if (NewPatternType.isNull())
7638 NewPatternType, NumExpansions);
7639 auto NewExpansionLoc = TLB.push<PackExpansionTypeLoc>(NewExpansionType);
7640 NewExpansionLoc.setEllipsisLoc(PackExpansionLoc.getEllipsisLoc());
7641 NewTypeArgInfos.push_back(
7642 TypeArgBuilder.getTypeSourceInfo(SemaRef.
Context, NewExpansionType));
7648 for (
unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
7649 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), ArgIdx);
7651 TypeLocBuilder TypeArgBuilder;
7652 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
7654 QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder,
7656 if (NewTypeArg.isNull())
7659 NewTypeArgInfos.push_back(
7660 TypeArgBuilder.getTypeSourceInfo(SemaRef.
Context, NewTypeArg));
7666 TypeLocBuilder TypeArgBuilder;
7667 TypeArgBuilder.reserve(TypeArgLoc.getFullDataSize());
7668 QualType NewTypeArg =
7669 getDerived().TransformType(TypeArgBuilder, TypeArgLoc);
7670 if (NewTypeArg.isNull())
7674 if (NewTypeArg == TypeArg) {
7675 NewTypeArgInfos.push_back(TypeArgInfo);
7679 NewTypeArgInfos.push_back(
7680 TypeArgBuilder.getTypeSourceInfo(SemaRef.
Context, NewTypeArg));
7684 QualType
Result = TL.getType();
7685 if (getDerived().AlwaysRebuild() || AnyChanged) {
7687 Result = getDerived().RebuildObjCObjectType(
7688 BaseType, TL.getBeginLoc(), TL.getTypeArgsLAngleLoc(), NewTypeArgInfos,
7689 TL.getTypeArgsRAngleLoc(), TL.getProtocolLAngleLoc(),
7690 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
7691 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
7697 ObjCObjectTypeLoc NewT = TLB.push<ObjCObjectTypeLoc>(
Result);
7698 NewT.setHasBaseTypeAsWritten(
true);
7699 NewT.setTypeArgsLAngleLoc(TL.getTypeArgsLAngleLoc());
7700 for (
unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
7701 NewT.setTypeArgTInfo(i, NewTypeArgInfos[i]);
7702 NewT.setTypeArgsRAngleLoc(TL.getTypeArgsRAngleLoc());
7703 NewT.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
7704 for (
unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
7705 NewT.setProtocolLoc(i, TL.getProtocolLoc(i));
7706 NewT.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
7710template<
typename Derived>
7712TreeTransform<Derived>::TransformObjCObjectPointerType(TypeLocBuilder &TLB,
7713 ObjCObjectPointerTypeLoc TL) {
7714 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
7715 if (PointeeType.isNull())
7718 QualType
Result = TL.getType();
7719 if (getDerived().AlwaysRebuild() ||
7720 PointeeType != TL.getPointeeLoc().getType()) {
7721 Result = getDerived().RebuildObjCObjectPointerType(PointeeType,
7727 ObjCObjectPointerTypeLoc NewT = TLB.push<ObjCObjectPointerTypeLoc>(
Result);
7728 NewT.setStarLoc(TL.getStarLoc());
7735template<
typename Derived>
7737TreeTransform<Derived>::TransformNullStmt(NullStmt *S) {
7741template<
typename Derived>
7744 return getDerived().TransformCompoundStmt(S,
false);
7747template<
typename Derived>
7753 if (S->hasStoredFPFeatures())
7754 getSema().resetFPOptions(
7755 S->getStoredFPFeatures().applyOverrides(getSema().getLangOpts()));
7758 bool SubStmtInvalid =
false;
7759 bool SubStmtChanged =
false;
7761 for (
auto *B : S->body()) {
7763 B, IsStmtExpr && B ==
ExprResult ? SDK_StmtExprResult : SDK_Discarded);
7765 if (
Result.isInvalid()) {
7768 if (isa<DeclStmt>(B))
7772 SubStmtInvalid =
true;
7776 SubStmtChanged = SubStmtChanged ||
Result.get() != B;
7777 Statements.push_back(
Result.getAs<Stmt>());
7783 if (!getDerived().AlwaysRebuild() &&
7787 return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
7793template<
typename Derived>
7795TreeTransform<Derived>::TransformCaseStmt(CaseStmt *S) {
7802 LHS = getDerived().TransformExpr(S->getLHS());
7804 if (LHS.isInvalid())
7808 RHS = getDerived().TransformExpr(S->getRHS());
7810 if (RHS.isInvalid())
7817 StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(),
7819 S->getEllipsisLoc(),
7822 if (Case.isInvalid())
7827 getDerived().TransformStmt(S->getSubStmt());
7828 if (SubStmt.isInvalid())
7832 return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get());
7835template <
typename Derived>
7836StmtResult TreeTransform<Derived>::TransformDefaultStmt(DefaultStmt *S) {
7839 getDerived().TransformStmt(S->getSubStmt());
7840 if (SubStmt.isInvalid())
7844 return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
7848template<
typename Derived>
7850TreeTransform<Derived>::TransformLabelStmt(LabelStmt *S, StmtDiscardKind SDK) {
7851 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
7852 if (SubStmt.isInvalid())
7855 Decl *LD = getDerived().TransformDecl(S->getDecl()->getLocation(),
7863 if (LD == S->getDecl())
7864 S->getDecl()->setStmt(
nullptr);
7867 return getDerived().RebuildLabelStmt(S->getIdentLoc(),
7868 cast<LabelDecl>(LD), SourceLocation(),
7872template <
typename Derived>
7881 return getDerived().Transform##X##Attr(cast<X##Attr>(R));
7882#include "clang/Basic/AttrList.inc"
7887template <
typename Derived>
7898 return getDerived().TransformStmt##X##Attr(OrigS, InstS, cast<X##Attr>(R));
7899#include "clang/Basic/AttrList.inc"
7901 return TransformAttr(R);
7904template <
typename Derived>
7907 StmtDiscardKind SDK) {
7908 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
7912 bool AttrsChanged =
false;
7916 for (
const auto *I : S->getAttrs()) {
7918 getDerived().TransformStmtAttr(S->getSubStmt(), SubStmt.
get(), I);
7919 AttrsChanged |= (I != R);
7924 if (SubStmt.
get() == S->getSubStmt() && !AttrsChanged)
7932 return getDerived().RebuildAttributedStmt(S->getAttrLoc(), Attrs,
7936template<
typename Derived>
7938TreeTransform<Derived>::TransformIfStmt(IfStmt *S) {
7941 if (
Init.isInvalid())
7944 Sema::ConditionResult Cond;
7945 if (!S->isConsteval()) {
7947 Cond = getDerived().TransformCondition(
7948 S->getIfLoc(), S->getConditionVariable(), S->getCond(),
7951 if (Cond.isInvalid())
7956 std::optional<bool> ConstexprConditionValue;
7957 if (S->isConstexpr())
7958 ConstexprConditionValue = Cond.getKnownValue();
7962 if (!ConstexprConditionValue || *ConstexprConditionValue) {
7963 Then = getDerived().TransformStmt(S->getThen());
7964 if (Then.isInvalid())
7970 Then =
new (getSema().Context)
7971 CompoundStmt(S->getThen()->getBeginLoc(), S->getThen()->getEndLoc());
7976 if (!ConstexprConditionValue || !*ConstexprConditionValue) {
7977 Else = getDerived().TransformStmt(S->getElse());
7978 if (Else.isInvalid())
7980 }
else if (S->getElse() && ConstexprConditionValue &&
7981 *ConstexprConditionValue) {
7985 Else =
new (getSema().Context)
7986 CompoundStmt(S->getElse()->getBeginLoc(), S->getElse()->getEndLoc());
7989 if (!getDerived().AlwaysRebuild() &&
7990 Init.get() == S->getInit() &&
7991 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
7992 Then.get() == S->getThen() &&
7993 Else.get() == S->getElse())
7996 return getDerived().RebuildIfStmt(
7997 S->getIfLoc(), S->getStatementKind(), S->getLParenLoc(), Cond,
7998 S->getRParenLoc(),
Init.get(), Then.get(), S->getElseLoc(), Else.get());
8001template<
typename Derived>
8003TreeTransform<Derived>::TransformSwitchStmt(SwitchStmt *S) {
8006 if (
Init.isInvalid())
8010 Sema::ConditionResult Cond = getDerived().TransformCondition(
8011 S->getSwitchLoc(), S->getConditionVariable(), S->getCond(),
8013 if (Cond.isInvalid())
8018 getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), S->getLParenLoc(),
8019 Init.get(), Cond, S->getRParenLoc());
8024 StmtResult Body = getDerived().TransformStmt(S->getBody());
8025 if (Body.isInvalid())
8029 return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(),
Switch.get(),
8033template<
typename Derived>
8035TreeTransform<Derived>::TransformWhileStmt(WhileStmt *S) {
8037 Sema::ConditionResult Cond = getDerived().TransformCondition(
8038 S->getWhileLoc(), S->getConditionVariable(), S->getCond(),
8040 if (Cond.isInvalid())
8044 StmtResult Body = getDerived().TransformStmt(S->getBody());
8045 if (Body.isInvalid())
8048 if (!getDerived().AlwaysRebuild() &&
8049 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8050 Body.get() == S->getBody())
8053 return getDerived().RebuildWhileStmt(S->getWhileLoc(), S->getLParenLoc(),
8054 Cond, S->getRParenLoc(), Body.get());
8057template<
typename Derived>
8059TreeTransform<Derived>::TransformDoStmt(DoStmt *S) {
8061 StmtResult Body = getDerived().TransformStmt(S->getBody());
8062 if (Body.isInvalid())
8066 ExprResult Cond = getDerived().TransformExpr(S->getCond());
8067 if (Cond.isInvalid())
8070 if (!getDerived().AlwaysRebuild() &&
8071 Cond.get() == S->getCond() &&
8072 Body.get() == S->getBody())
8075 return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(),
8076 S->getWhileLoc(), Cond.get(),
8080template<
typename Derived>
8082TreeTransform<Derived>::TransformForStmt(ForStmt *S) {
8083 if (getSema().getLangOpts().OpenMP)
8084 getSema().OpenMP().startOpenMPLoop();
8088 if (
Init.isInvalid())
8093 if (getSema().getLangOpts().OpenMP &&
Init.isUsable())
8094 getSema().OpenMP().ActOnOpenMPLoopInitialization(S->getForLoc(),
8098 Sema::ConditionResult Cond = getDerived().TransformCondition(
8099 S->getForLoc(), S->getConditionVariable(), S->getCond(),
8101 if (Cond.isInvalid())
8106 if (
Inc.isInvalid())
8109 Sema::FullExprArg FullInc(getSema().MakeFullDiscardedValueExpr(
Inc.get()));
8110 if (S->getInc() && !FullInc.get())
8114 StmtResult Body = getDerived().TransformStmt(S->getBody());
8115 if (Body.isInvalid())
8118 if (!getDerived().AlwaysRebuild() &&
8119 Init.get() == S->getInit() &&
8120 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8121 Inc.get() == S->getInc() &&
8122 Body.get() == S->getBody())
8125 return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
8126 Init.get(), Cond, FullInc,
8127 S->getRParenLoc(), Body.get());
8130template<
typename Derived>
8132TreeTransform<Derived>::TransformGotoStmt(GotoStmt *S) {
8133 Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
8139 return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
8140 cast<LabelDecl>(LD));
8143template<
typename Derived>
8145TreeTransform<Derived>::TransformIndirectGotoStmt(IndirectGotoStmt *S) {
8151 if (!getDerived().AlwaysRebuild() &&
8152 Target.get() == S->getTarget())
8155 return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
8159template<
typename Derived>
8161TreeTransform<Derived>::TransformContinueStmt(ContinueStmt *S) {
8165template<
typename Derived>
8167TreeTransform<Derived>::TransformBreakStmt(BreakStmt *S) {
8171template<
typename Derived>
8173TreeTransform<Derived>::TransformReturnStmt(ReturnStmt *S) {
8181 return getDerived().RebuildReturnStmt(S->getReturnLoc(),
Result.get());
8184template<
typename Derived>
8186TreeTransform<Derived>::TransformDeclStmt(DeclStmt *S) {
8187 bool DeclChanged =
false;
8189 for (
auto *D : S->decls()) {
8190 Decl *Transformed = getDerived().TransformDefinition(D->getLocation(), D);
8194 if (Transformed != D)
8197 Decls.push_back(Transformed);
8200 if (!getDerived().AlwaysRebuild() && !DeclChanged)
8203 return getDerived().RebuildDeclStmt(Decls, S->getBeginLoc(), S->getEndLoc());
8206template<
typename Derived>
8208TreeTransform<Derived>::TransformGCCAsmStmt(GCCAsmStmt *S) {
8217 bool ExprsChanged =
false;
8220 for (
unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
8221 Names.push_back(S->getOutputIdentifier(I));
8224 Constraints.push_back(S->getOutputConstraintLiteral(I));
8227 Expr *OutputExpr = S->getOutputExpr(I);
8232 ExprsChanged |=
Result.get() != OutputExpr;
8234 Exprs.push_back(
Result.get());
8238 for (
unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
8239 Names.push_back(S->getInputIdentifier(I));
8242 Constraints.push_back(S->getInputConstraintLiteral(I));
8245 Expr *InputExpr = S->getInputExpr(I);
8250 ExprsChanged |=
Result.get() != InputExpr;
8252 Exprs.push_back(
Result.get());
8256 for (
unsigned I = 0, E = S->getNumLabels(); I != E; ++I) {
8257 Names.push_back(S->getLabelIdentifier(I));
8262 ExprsChanged |=
Result.get() != S->getLabelExpr(I);
8263 Exprs.push_back(
Result.get());
8265 if (!getDerived().AlwaysRebuild() && !ExprsChanged)
8269 for (
unsigned I = 0, E = S->getNumClobbers(); I != E; ++I)
8270 Clobbers.push_back(S->getClobberStringLiteral(I));
8273 AsmString = S->getAsmString();
8274 return getDerived().RebuildGCCAsmStmt(S->getAsmLoc(), S->isSimple(),
8275 S->isVolatile(), S->getNumOutputs(),
8276 S->getNumInputs(), Names.data(),
8277 Constraints, Exprs, AsmString.get(),
8278 Clobbers, S->getNumLabels(),
8282template<
typename Derived>
8284TreeTransform<Derived>::TransformMSAsmStmt(MSAsmStmt *S) {
8287 bool HadError =
false, HadChange =
false;
8291 TransformedExprs.reserve(SrcExprs.size());
8292 for (
unsigned i = 0, e = SrcExprs.size(); i != e; ++i) {
8294 if (!
Result.isUsable()) {
8297 HadChange |= (
Result.get() != SrcExprs[i]);
8298 TransformedExprs.push_back(
Result.get());
8303 if (!HadChange && !getDerived().AlwaysRebuild())
8306 return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), S->getLBraceLoc(),
8307 AsmToks, S->getAsmString(),
8308 S->getNumOutputs(), S->getNumInputs(),
8309 S->getAllConstraints(), S->getClobbers(),
8310 TransformedExprs, S->getEndLoc());
8314template<
typename Derived>
8316TreeTransform<Derived>::TransformCoroutineBodyStmt(CoroutineBodyStmt *S) {
8318 auto *FD = cast<FunctionDecl>(SemaRef.
CurContext);
8319 assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
8320 ScopeInfo->NeedsCoroutineSuspends &&
8321 ScopeInfo->CoroutineSuspends.first ==
nullptr &&
8322 ScopeInfo->CoroutineSuspends.second ==
nullptr &&
8323 "expected clean scope info");
8327 ScopeInfo->setNeedsCoroutineSuspends(
false);
8340 getDerived().transformedLocalDecl(S->getPromiseDecl(), {Promise});
8341 ScopeInfo->CoroutinePromise = Promise;
8346 StmtResult InitSuspend = getDerived().TransformStmt(S->getInitSuspendStmt());
8347 if (InitSuspend.isInvalid())
8350 getDerived().TransformStmt(S->getFinalSuspendStmt());
8351 if (FinalSuspend.isInvalid() ||
8354 ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
8355 assert(isa<Expr>(InitSuspend.get()) && isa<Expr>(FinalSuspend.get()));
8357 StmtResult BodyRes = getDerived().TransformStmt(S->getBody());
8358 if (BodyRes.isInvalid())
8361 CoroutineStmtBuilder Builder(SemaRef, *FD, *ScopeInfo, BodyRes.get());
8362 if (Builder.isInvalid())
8365 Expr *ReturnObject = S->getReturnValueInit();
8366 assert(ReturnObject &&
"the return object is expected to be valid");
8367 ExprResult Res = getDerived().TransformInitializer(ReturnObject,
8369 if (Res.isInvalid())
8371 Builder.ReturnValue = Res.get();
8376 if (S->hasDependentPromiseType()) {
8379 if (!Promise->getType()->isDependentType()) {
8380 assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
8381 !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
8382 "these nodes should not have been built yet");
8383 if (!Builder.buildDependentStatements())
8387 if (
auto *OnFallthrough = S->getFallthroughHandler()) {
8388 StmtResult Res = getDerived().TransformStmt(OnFallthrough);
8389 if (Res.isInvalid())
8391 Builder.OnFallthrough = Res.get();
8394 if (
auto *OnException = S->getExceptionHandler()) {
8395 StmtResult Res = getDerived().TransformStmt(OnException);
8396 if (Res.isInvalid())
8398 Builder.OnException = Res.get();
8401 if (
auto *OnAllocFailure = S->getReturnStmtOnAllocFailure()) {
8402 StmtResult Res = getDerived().TransformStmt(OnAllocFailure);
8403 if (Res.isInvalid())
8405 Builder.ReturnStmtOnAllocFailure = Res.get();
8409 assert(S->getAllocate() && S->getDeallocate() &&
8410 "allocation and deallocation calls must already be built");
8411 ExprResult AllocRes = getDerived().TransformExpr(S->getAllocate());
8412 if (AllocRes.isInvalid())
8414 Builder.Allocate = AllocRes.get();
8416 ExprResult DeallocRes = getDerived().TransformExpr(S->getDeallocate());
8417 if (DeallocRes.isInvalid())
8419 Builder.Deallocate = DeallocRes.get();
8421 if (
auto *ResultDecl = S->getResultDecl()) {
8422 StmtResult Res = getDerived().TransformStmt(ResultDecl);
8423 if (Res.isInvalid())
8425 Builder.ResultDecl = Res.get();
8428 if (
auto *ReturnStmt = S->getReturnStmt()) {
8429 StmtResult Res = getDerived().TransformStmt(ReturnStmt);
8430 if (Res.isInvalid())
8432 Builder.ReturnStmt = Res.get();
8436 return getDerived().RebuildCoroutineBodyStmt(Builder);
8439template<
typename Derived>
8441TreeTransform<Derived>::TransformCoreturnStmt(CoreturnStmt *S) {
8449 return getDerived().RebuildCoreturnStmt(S->getKeywordLoc(),
Result.get(),
8453template <
typename Derived>
8454ExprResult TreeTransform<Derived>::TransformCoawaitExpr(CoawaitExpr *E) {
8466 ExprResult Lookup = getSema().BuildOperatorCoawaitLookupExpr(
8467 getSema().getCurScope(), E->getKeywordLoc());
8471 return getDerived().RebuildCoawaitExpr(
8472 E->getKeywordLoc(),
Operand.get(),
8473 cast<UnresolvedLookupExpr>(Lookup.get()), E->isImplicit());
8476template <
typename Derived>
8478TreeTransform<Derived>::TransformDependentCoawaitExpr(DependentCoawaitExpr *E) {
8479 ExprResult OperandResult = getDerived().TransformInitializer(E->getOperand(),
8481 if (OperandResult.isInvalid())
8484 ExprResult LookupResult = getDerived().TransformUnresolvedLookupExpr(
8485 E->getOperatorCoawaitLookup());
8487 if (LookupResult.isInvalid())
8492 return getDerived().RebuildDependentCoawaitExpr(
8493 E->getKeywordLoc(), OperandResult.get(),
8494 cast<UnresolvedLookupExpr>(LookupResult.get()));
8497template<
typename Derived>
8499TreeTransform<Derived>::TransformCoyieldExpr(CoyieldExpr *E) {
8507 return getDerived().RebuildCoyieldExpr(E->getKeywordLoc(),
Result.get());
8512template<
typename Derived>
8514TreeTransform<Derived>::TransformObjCAtTryStmt(ObjCAtTryStmt *S) {
8516 StmtResult TryBody = getDerived().TransformStmt(S->getTryBody());
8517 if (TryBody.isInvalid())
8521 bool AnyCatchChanged =
false;
8523 for (
unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
8524 StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I));
8525 if (Catch.isInvalid())
8527 if (Catch.get() != S->getCatchStmt(I))
8528 AnyCatchChanged =
true;
8529 CatchStmts.push_back(Catch.get());
8534 if (S->getFinallyStmt()) {
8535 Finally = getDerived().TransformStmt(S->getFinallyStmt());
8536 if (Finally.isInvalid())
8541 if (!getDerived().AlwaysRebuild() &&
8542 TryBody.get() == S->getTryBody() &&
8544 Finally.get() == S->getFinallyStmt())
8548 return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(),
8549 CatchStmts, Finally.get());
8552template<
typename Derived>
8554TreeTransform<Derived>::TransformObjCAtCatchStmt(ObjCAtCatchStmt *S) {
8556 VarDecl *Var =
nullptr;
8557 if (VarDecl *FromVar = S->getCatchParamDecl()) {
8558 TypeSourceInfo *TSInfo =
nullptr;
8559 if (FromVar->getTypeSourceInfo()) {
8560 TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo());
8567 T = TSInfo->getType();
8569 T = getDerived().TransformType(FromVar->getType());
8574 Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo,
T);
8579 StmtResult Body = getDerived().TransformStmt(S->getCatchBody());
8580 if (Body.isInvalid())
8583 return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(),
8588template<
typename Derived>
8590TreeTransform<Derived>::TransformObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
8592 StmtResult Body = getDerived().TransformStmt(S->getFinallyBody());
8593 if (Body.isInvalid())
8597 if (!getDerived().AlwaysRebuild() &&
8598 Body.get() == S->getFinallyBody())
8602 return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(),
8606template<
typename Derived>
8608TreeTransform<Derived>::TransformObjCAtThrowStmt(ObjCAtThrowStmt *S) {
8610 if (S->getThrowExpr()) {
8611 Operand = getDerived().TransformExpr(S->getThrowExpr());
8616 if (!getDerived().AlwaysRebuild() &&
8617 Operand.get() == S->getThrowExpr())
8620 return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(),
Operand.get());
8623template<
typename Derived>
8625TreeTransform<Derived>::TransformObjCAtSynchronizedStmt(
8626 ObjCAtSynchronizedStmt *S) {
8632 getDerived().RebuildObjCAtSynchronizedOperand(S->getAtSynchronizedLoc(),
8638 StmtResult Body = getDerived().TransformStmt(S->getSynchBody());
8639 if (Body.isInvalid())
8643 if (!getDerived().AlwaysRebuild() &&
8644 Object.get() == S->getSynchExpr() &&
8645 Body.get() == S->getSynchBody())
8649 return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(),
8650 Object.get(), Body.get());
8653template<
typename Derived>
8655TreeTransform<Derived>::TransformObjCAutoreleasePoolStmt(
8656 ObjCAutoreleasePoolStmt *S) {
8658 StmtResult Body = getDerived().TransformStmt(S->getSubStmt());
8659 if (Body.isInvalid())
8663 if (!getDerived().AlwaysRebuild() &&
8664 Body.get() == S->getSubStmt())
8668 return getDerived().RebuildObjCAutoreleasePoolStmt(
8669 S->getAtLoc(), Body.get());
8672template<
typename Derived>
8674TreeTransform<Derived>::TransformObjCForCollectionStmt(
8675 ObjCForCollectionStmt *S) {
8678 getDerived().TransformStmt(S->getElement(), SDK_NotDiscarded);
8679 if (Element.isInvalid())
8683 ExprResult Collection = getDerived().TransformExpr(S->getCollection());
8684 if (Collection.isInvalid())
8688 StmtResult Body = getDerived().TransformStmt(S->getBody());
8689 if (Body.isInvalid())
8693 if (!getDerived().AlwaysRebuild() &&
8694 Element.get() == S->getElement() &&
8695 Collection.get() == S->getCollection() &&
8696 Body.get() == S->getBody())
8700 return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(),
8707template <
typename Derived>
8708StmtResult TreeTransform<Derived>::TransformCXXCatchStmt(CXXCatchStmt *S) {
8710 VarDecl *Var =
nullptr;
8711 if (VarDecl *ExceptionDecl = S->getExceptionDecl()) {
8713 getDerived().TransformType(ExceptionDecl->getTypeSourceInfo());
8717 Var = getDerived().RebuildExceptionDecl(
8718 ExceptionDecl,
T, ExceptionDecl->getInnerLocStart(),
8719 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
8720 if (!Var || Var->isInvalidDecl())
8725 StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
8726 if (Handler.isInvalid())
8729 if (!getDerived().AlwaysRebuild() && !Var &&
8730 Handler.get() == S->getHandlerBlock())
8733 return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), Var, Handler.get());
8736template <
typename Derived>
8737StmtResult TreeTransform<Derived>::TransformCXXTryStmt(CXXTryStmt *S) {
8739 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
8740 if (TryBlock.isInvalid())
8744 bool HandlerChanged =
false;
8746 for (
unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
8747 StmtResult Handler = getDerived().TransformCXXCatchStmt(S->getHandler(I));
8748 if (Handler.isInvalid())
8751 HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I);
8752 Handlers.push_back(Handler.getAs<Stmt>());
8755 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
8759 return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(),
8763template<
typename Derived>
8765TreeTransform<Derived>::TransformCXXForRangeStmt(CXXForRangeStmt *S) {
8766 EnterExpressionEvaluationContext ForRangeInitContext(
8774 auto &LastRecord = getSema().ExprEvalContexts.back();
8775 LastRecord.InLifetimeExtendingContext =
true;
8778 S->getInit() ? getDerived().TransformStmt(S->getInit()) :
StmtResult();
8779 if (
Init.isInvalid())
8783 if (
Range.isInvalid())
8788 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps.empty());
8789 auto ForRangeLifetimeExtendTemps =
8790 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps;
8795 StmtResult End = getDerived().TransformStmt(S->getEndStmt());
8796 if (End.isInvalid())
8799 ExprResult Cond = getDerived().TransformExpr(S->getCond());
8800 if (Cond.isInvalid())
8804 if (Cond.isInvalid())
8810 if (
Inc.isInvalid())
8815 StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
8816 if (LoopVar.isInvalid())
8820 if (getDerived().AlwaysRebuild() ||
8821 Init.get() != S->getInit() ||
8822 Range.get() != S->getRangeStmt() ||
8823 Begin.get() != S->getBeginStmt() ||
8824 End.get() != S->getEndStmt() ||
8825 Cond.get() != S->getCond() ||
8826 Inc.get() != S->getInc() ||
8827 LoopVar.get() != S->getLoopVarStmt()) {
8828 NewStmt = getDerived().RebuildCXXForRangeStmt(
8829 S->getForLoc(), S->getCoawaitLoc(),
Init.get(), S->getColonLoc(),
8831 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
8832 if (NewStmt.isInvalid() && LoopVar.get() != S->getLoopVarStmt()) {
8835 cast<DeclStmt>(LoopVar.get())->getSingleDecl());
8840 StmtResult Body = getDerived().TransformStmt(S->getBody());
8841 if (Body.isInvalid())
8846 if (Body.get() != S->getBody() && NewStmt.get() == S) {
8847 NewStmt = getDerived().RebuildCXXForRangeStmt(
8848 S->getForLoc(), S->getCoawaitLoc(),
Init.get(), S->getColonLoc(),
8850 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
8851 if (NewStmt.isInvalid())
8855 if (NewStmt.get() == S)
8858 return FinishCXXForRangeStmt(NewStmt.get(), Body.get());
8861template<
typename Derived>
8863TreeTransform<Derived>::TransformMSDependentExistsStmt(
8864 MSDependentExistsStmt *S) {
8866 NestedNameSpecifierLoc QualifierLoc;
8867 if (S->getQualifierLoc()) {
8869 = getDerived().TransformNestedNameSpecifierLoc(S->getQualifierLoc());
8875 DeclarationNameInfo NameInfo = S->getNameInfo();
8876 if (NameInfo.getName()) {
8877 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
8878 if (!NameInfo.getName())
8883 if (!getDerived().AlwaysRebuild() &&
8884 QualifierLoc == S->getQualifierLoc() &&
8885 NameInfo.getName() == S->getNameInfo().getName())
8890 SS.Adopt(QualifierLoc);
8891 bool Dependent =
false;
8892 switch (getSema().CheckMicrosoftIfExistsSymbol(
nullptr, SS, NameInfo)) {
8894 if (S->isIfExists())
8897 return new (getSema().Context) NullStmt(S->getKeywordLoc());
8900 if (S->isIfNotExists())
8903 return new (getSema().Context) NullStmt(S->getKeywordLoc());
8914 StmtResult SubStmt = getDerived().TransformCompoundStmt(S->getSubStmt());
8915 if (SubStmt.isInvalid())
8923 return getDerived().RebuildMSDependentExistsStmt(S->getKeywordLoc(),
8930template<
typename Derived>
8932TreeTransform<Derived>::TransformMSPropertyRefExpr(MSPropertyRefExpr *E) {
8933 NestedNameSpecifierLoc QualifierLoc;
8934 if (E->getQualifierLoc()) {
8936 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
8941 MSPropertyDecl *PD = cast_or_null<MSPropertyDecl>(
8942 getDerived().TransformDecl(E->getMemberLoc(), E->getPropertyDecl()));
8947 if (
Base.isInvalid())
8951 MSPropertyRefExpr(
Base.get(), PD, E->isArrow(),
8953 QualifierLoc, E->getMemberLoc());
8956template <
typename Derived>
8957ExprResult TreeTransform<Derived>::TransformMSPropertySubscriptExpr(
8958 MSPropertySubscriptExpr *E) {
8959 auto BaseRes = getDerived().TransformExpr(E->getBase());
8960 if (BaseRes.isInvalid())
8962 auto IdxRes = getDerived().TransformExpr(E->getIdx());
8963 if (IdxRes.isInvalid())
8966 if (!getDerived().AlwaysRebuild() &&
8967 BaseRes.get() == E->getBase() &&
8968 IdxRes.get() == E->getIdx())
8971 return getDerived().RebuildArraySubscriptExpr(
8972 BaseRes.get(), SourceLocation(), IdxRes.get(), E->getRBracketLoc());
8975template <
typename Derived>
8976StmtResult TreeTransform<Derived>::TransformSEHTryStmt(SEHTryStmt *S) {
8977 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
8978 if (TryBlock.isInvalid())
8981 StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler());
8982 if (Handler.isInvalid())
8985 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
8986 Handler.get() == S->getHandler())
8989 return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(), S->getTryLoc(),
8990 TryBlock.get(), Handler.get());
8993template <
typename Derived>
8994StmtResult TreeTransform<Derived>::TransformSEHFinallyStmt(SEHFinallyStmt *S) {
8996 if (
Block.isInvalid())
8999 return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(),
Block.get());
9002template <
typename Derived>
9003StmtResult TreeTransform<Derived>::TransformSEHExceptStmt(SEHExceptStmt *S) {
9004 ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr());
9005 if (FilterExpr.isInvalid())
9009 if (
Block.isInvalid())
9012 return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(), FilterExpr.get(),
9016template <
typename Derived>
9018 if (isa<SEHFinallyStmt>(Handler))
9019 return getDerived().TransformSEHFinallyStmt(cast<SEHFinallyStmt>(Handler));
9021 return getDerived().TransformSEHExceptStmt(cast<SEHExceptStmt>(Handler));
9024template<
typename Derived>
9034template <
typename Derived>
9036TreeTransform<Derived>::TransformOMPCanonicalLoop(OMPCanonicalLoop *L) {
9040 return getDerived().TransformStmt(L->getLoopStmt());
9043template <
typename Derived>
9050 TClauses.reserve(Clauses.size());
9054 getDerived().getSema().OpenMP().StartOpenMPClause((*I)->getClauseKind());
9055 OMPClause *Clause = getDerived().TransformOMPClause(*I);
9056 getDerived().getSema().OpenMP().EndOpenMPClause();
9058 TClauses.push_back(Clause);
9060 TClauses.push_back(
nullptr);
9065 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9079 Body = getDerived().TransformStmt(CS);
9081 getSema().getLangOpts().OpenMPIRBuilder)
9082 Body = getDerived().RebuildOMPCanonicalLoop(Body.
get());
9085 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9090 if (TClauses.size() != Clauses.size()) {
9097 DirName = cast<OMPCriticalDirective>(D)->getDirectiveName();
9098 DirName = getDerived().TransformDeclarationNameInfo(DirName);
9102 CancelRegion = cast<OMPCancellationPointDirective>(D)->getCancelRegion();
9104 CancelRegion = cast<OMPCancelDirective>(D)->getCancelRegion();
9107 return getDerived().RebuildOMPExecutableDirective(
9113template <
typename Derived>
9117 SemaRef.
Diag(D->
getBeginLoc(), diag::err_omp_instantiation_not_supported)
9122template <
typename Derived>
9124TreeTransform<Derived>::TransformOMPParallelDirective(OMPParallelDirective *D) {
9125 DeclarationNameInfo DirName;
9126 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9127 OMPD_parallel, DirName,
nullptr, D->getBeginLoc());
9128 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9129 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9133template <
typename Derived>
9135TreeTransform<Derived>::TransformOMPSimdDirective(OMPSimdDirective *D) {
9136 DeclarationNameInfo DirName;
9137 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9138 OMPD_simd, DirName,
nullptr, D->getBeginLoc());
9139 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9140 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9144template <
typename Derived>
9146TreeTransform<Derived>::TransformOMPTileDirective(OMPTileDirective *D) {
9147 DeclarationNameInfo DirName;
9148 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9149 D->getDirectiveKind(), DirName,
nullptr, D->getBeginLoc());
9150 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9151 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9155template <
typename Derived>
9157TreeTransform<Derived>::TransformOMPUnrollDirective(OMPUnrollDirective *D) {
9158 DeclarationNameInfo DirName;
9159 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9160 D->getDirectiveKind(), DirName,
nullptr, D->getBeginLoc());
9161 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9162 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9166template <
typename Derived>
9168TreeTransform<Derived>::TransformOMPForDirective(OMPForDirective *D) {
9169 DeclarationNameInfo DirName;
9170 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9171 OMPD_for, DirName,
nullptr, D->getBeginLoc());
9172 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9173 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9177template <
typename Derived>
9179TreeTransform<Derived>::TransformOMPForSimdDirective(OMPForSimdDirective *D) {
9180 DeclarationNameInfo DirName;
9181 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9182 OMPD_for_simd, DirName,
nullptr, D->getBeginLoc());
9183 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9184 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9188template <
typename Derived>
9190TreeTransform<Derived>::TransformOMPSectionsDirective(OMPSectionsDirective *D) {
9191 DeclarationNameInfo DirName;
9192 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9193 OMPD_sections, DirName,
nullptr, D->getBeginLoc());
9194 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9195 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9199template <
typename Derived>
9201TreeTransform<Derived>::TransformOMPSectionDirective(OMPSectionDirective *D) {
9202 DeclarationNameInfo DirName;
9203 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9204 OMPD_section, DirName,
nullptr, D->getBeginLoc());
9205 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9206 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9210template <
typename Derived>
9212TreeTransform<Derived>::TransformOMPScopeDirective(OMPScopeDirective *D) {
9213 DeclarationNameInfo DirName;
9214 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9215 OMPD_scope, DirName,
nullptr, D->getBeginLoc());
9216 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9217 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9221template <
typename Derived>
9223TreeTransform<Derived>::TransformOMPSingleDirective(OMPSingleDirective *D) {
9224 DeclarationNameInfo DirName;
9225 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9226 OMPD_single, DirName,
nullptr, D->getBeginLoc());
9227 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9228 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9232template <
typename Derived>
9234TreeTransform<Derived>::TransformOMPMasterDirective(OMPMasterDirective *D) {
9235 DeclarationNameInfo DirName;
9236 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9237 OMPD_master, DirName,
nullptr, D->getBeginLoc());
9238 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9239 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9243template <
typename Derived>
9245TreeTransform<Derived>::TransformOMPCriticalDirective(OMPCriticalDirective *D) {
9246 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9247 OMPD_critical, D->getDirectiveName(),
nullptr, D->getBeginLoc());
9248 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9249 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9253template <
typename Derived>
9254StmtResult TreeTransform<Derived>::TransformOMPParallelForDirective(
9255 OMPParallelForDirective *D) {
9256 DeclarationNameInfo DirName;
9257 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9258 OMPD_parallel_for, DirName,
nullptr, D->getBeginLoc());
9259 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9260 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9264template <
typename Derived>
9265StmtResult TreeTransform<Derived>::TransformOMPParallelForSimdDirective(
9266 OMPParallelForSimdDirective *D) {
9267 DeclarationNameInfo DirName;
9268 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9269 OMPD_parallel_for_simd, DirName,
nullptr, D->getBeginLoc());
9270 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9271 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9275template <
typename Derived>
9276StmtResult TreeTransform<Derived>::TransformOMPParallelMasterDirective(
9277 OMPParallelMasterDirective *D) {
9278 DeclarationNameInfo DirName;
9279 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9280 OMPD_parallel_master, DirName,
nullptr, D->getBeginLoc());
9281 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9282 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9286template <
typename Derived>
9287StmtResult TreeTransform<Derived>::TransformOMPParallelMaskedDirective(
9288 OMPParallelMaskedDirective *D) {
9289 DeclarationNameInfo DirName;
9290 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9291 OMPD_parallel_masked, DirName,
nullptr, D->getBeginLoc());
9292 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9293 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9297template <
typename Derived>
9298StmtResult TreeTransform<Derived>::TransformOMPParallelSectionsDirective(
9299 OMPParallelSectionsDirective *D) {
9300 DeclarationNameInfo DirName;
9301 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9302 OMPD_parallel_sections, DirName,
nullptr, D->getBeginLoc());
9303 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9304 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9308template <
typename Derived>
9310TreeTransform<Derived>::TransformOMPTaskDirective(OMPTaskDirective *D) {
9311 DeclarationNameInfo DirName;
9312 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9313 OMPD_task, DirName,
nullptr, D->getBeginLoc());
9314 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9315 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9319template <
typename Derived>
9320StmtResult TreeTransform<Derived>::TransformOMPTaskyieldDirective(
9321 OMPTaskyieldDirective *D) {
9322 DeclarationNameInfo DirName;
9323 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9324 OMPD_taskyield, DirName,
nullptr, D->getBeginLoc());
9325 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9326 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9330template <
typename Derived>
9332TreeTransform<Derived>::TransformOMPBarrierDirective(OMPBarrierDirective *D) {
9333 DeclarationNameInfo DirName;
9334 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9335 OMPD_barrier, DirName,
nullptr, D->getBeginLoc());
9336 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9337 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9341template <
typename Derived>
9343TreeTransform<Derived>::TransformOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
9344 DeclarationNameInfo DirName;
9345 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9346 OMPD_taskwait, DirName,
nullptr, D->getBeginLoc());
9347 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9348 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9352template <
typename Derived>
9354TreeTransform<Derived>::TransformOMPErrorDirective(OMPErrorDirective *D) {
9355 DeclarationNameInfo DirName;
9356 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9357 OMPD_error, DirName,
nullptr, D->getBeginLoc());
9358 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9359 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9363template <
typename Derived>
9364StmtResult TreeTransform<Derived>::TransformOMPTaskgroupDirective(
9365 OMPTaskgroupDirective *D) {
9366 DeclarationNameInfo DirName;
9367 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9368 OMPD_taskgroup, DirName,
nullptr, D->getBeginLoc());
9369 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9370 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9374template <
typename Derived>
9376TreeTransform<Derived>::TransformOMPFlushDirective(OMPFlushDirective *D) {
9377 DeclarationNameInfo DirName;
9378 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9379 OMPD_flush, DirName,
nullptr, D->getBeginLoc());
9380 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9381 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9385template <
typename Derived>
9387TreeTransform<Derived>::TransformOMPDepobjDirective(OMPDepobjDirective *D) {
9388 DeclarationNameInfo DirName;
9389 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9390 OMPD_depobj, DirName,
nullptr, D->getBeginLoc());
9391 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9392 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9396template <
typename Derived>
9398TreeTransform<Derived>::TransformOMPScanDirective(OMPScanDirective *D) {
9399 DeclarationNameInfo DirName;
9400 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9401 OMPD_scan, DirName,
nullptr, D->getBeginLoc());
9402 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9403 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9407template <
typename Derived>
9409TreeTransform<Derived>::TransformOMPOrderedDirective(OMPOrderedDirective *D) {
9410 DeclarationNameInfo DirName;
9411 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9412 OMPD_ordered, DirName,
nullptr, D->getBeginLoc());
9413 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9414 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9418template <
typename Derived>
9420TreeTransform<Derived>::TransformOMPAtomicDirective(OMPAtomicDirective *D) {
9421 DeclarationNameInfo DirName;
9422 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9423 OMPD_atomic, DirName,
nullptr, D->getBeginLoc());
9424 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9425 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9429template <
typename Derived>
9431TreeTransform<Derived>::TransformOMPTargetDirective(OMPTargetDirective *D) {
9432 DeclarationNameInfo DirName;
9433 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9434 OMPD_target, DirName,
nullptr, D->getBeginLoc());
9435 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9436 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9440template <
typename Derived>
9441StmtResult TreeTransform<Derived>::TransformOMPTargetDataDirective(
9442 OMPTargetDataDirective *D) {
9443 DeclarationNameInfo DirName;
9444 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9445 OMPD_target_data, DirName,
nullptr, D->getBeginLoc());
9446 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9447 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9451template <
typename Derived>
9452StmtResult TreeTransform<Derived>::TransformOMPTargetEnterDataDirective(
9453 OMPTargetEnterDataDirective *D) {
9454 DeclarationNameInfo DirName;
9455 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9456 OMPD_target_enter_data, DirName,
nullptr, D->getBeginLoc());
9457 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9458 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9462template <
typename Derived>
9463StmtResult TreeTransform<Derived>::TransformOMPTargetExitDataDirective(
9464 OMPTargetExitDataDirective *D) {
9465 DeclarationNameInfo DirName;
9466 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9467 OMPD_target_exit_data, DirName,
nullptr, D->getBeginLoc());
9468 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9469 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9473template <
typename Derived>
9474StmtResult TreeTransform<Derived>::TransformOMPTargetParallelDirective(
9475 OMPTargetParallelDirective *D) {
9476 DeclarationNameInfo DirName;
9477 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9478 OMPD_target_parallel, DirName,
nullptr, D->getBeginLoc());
9479 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9480 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9484template <
typename Derived>
9485StmtResult TreeTransform<Derived>::TransformOMPTargetParallelForDirective(
9486 OMPTargetParallelForDirective *D) {
9487 DeclarationNameInfo DirName;
9488 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9489 OMPD_target_parallel_for, DirName,
nullptr, D->getBeginLoc());
9490 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9491 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9495template <
typename Derived>
9496StmtResult TreeTransform<Derived>::TransformOMPTargetUpdateDirective(
9497 OMPTargetUpdateDirective *D) {
9498 DeclarationNameInfo DirName;
9499 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9500 OMPD_target_update, DirName,
nullptr, D->getBeginLoc());
9501 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9502 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9506template <
typename Derived>
9508TreeTransform<Derived>::TransformOMPTeamsDirective(OMPTeamsDirective *D) {
9509 DeclarationNameInfo DirName;
9510 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9511 OMPD_teams, DirName,
nullptr, D->getBeginLoc());
9512 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9513 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9517template <
typename Derived>
9518StmtResult TreeTransform<Derived>::TransformOMPCancellationPointDirective(
9519 OMPCancellationPointDirective *D) {
9520 DeclarationNameInfo DirName;
9521 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9522 OMPD_cancellation_point, DirName,
nullptr, D->getBeginLoc());
9523 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9524 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9528template <
typename Derived>
9530TreeTransform<Derived>::TransformOMPCancelDirective(OMPCancelDirective *D) {
9531 DeclarationNameInfo DirName;
9532 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9533 OMPD_cancel, DirName,
nullptr, D->getBeginLoc());
9534 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9535 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9539template <
typename Derived>
9541TreeTransform<Derived>::TransformOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
9542 DeclarationNameInfo DirName;
9543 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9544 OMPD_taskloop, DirName,
nullptr, D->getBeginLoc());
9545 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9546 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9550template <
typename Derived>
9551StmtResult TreeTransform<Derived>::TransformOMPTaskLoopSimdDirective(
9552 OMPTaskLoopSimdDirective *D) {
9553 DeclarationNameInfo DirName;
9554 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9555 OMPD_taskloop_simd, DirName,
nullptr, D->getBeginLoc());
9556 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9557 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9561template <
typename Derived>
9562StmtResult TreeTransform<Derived>::TransformOMPMasterTaskLoopDirective(
9563 OMPMasterTaskLoopDirective *D) {
9564 DeclarationNameInfo DirName;
9565 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9566 OMPD_master_taskloop, DirName,
nullptr, D->getBeginLoc());
9567 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9568 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9572template <
typename Derived>
9573StmtResult TreeTransform<Derived>::TransformOMPMaskedTaskLoopDirective(
9574 OMPMaskedTaskLoopDirective *D) {
9575 DeclarationNameInfo DirName;
9576 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9577 OMPD_masked_taskloop, DirName,
nullptr, D->getBeginLoc());
9578 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9579 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9583template <
typename Derived>
9584StmtResult TreeTransform<Derived>::TransformOMPMasterTaskLoopSimdDirective(
9585 OMPMasterTaskLoopSimdDirective *D) {
9586 DeclarationNameInfo DirName;
9587 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9588 OMPD_master_taskloop_simd, DirName,
nullptr, D->getBeginLoc());
9589 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9590 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9594template <
typename Derived>
9595StmtResult TreeTransform<Derived>::TransformOMPMaskedTaskLoopSimdDirective(
9596 OMPMaskedTaskLoopSimdDirective *D) {
9597 DeclarationNameInfo DirName;
9598 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9599 OMPD_masked_taskloop_simd, DirName,
nullptr, D->getBeginLoc());
9600 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9601 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9605template <
typename Derived>
9606StmtResult TreeTransform<Derived>::TransformOMPParallelMasterTaskLoopDirective(
9607 OMPParallelMasterTaskLoopDirective *D) {
9608 DeclarationNameInfo DirName;
9609 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9610 OMPD_parallel_master_taskloop, DirName,
nullptr, D->getBeginLoc());
9611 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9612 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9616template <
typename Derived>
9617StmtResult TreeTransform<Derived>::TransformOMPParallelMaskedTaskLoopDirective(
9618 OMPParallelMaskedTaskLoopDirective *D) {
9619 DeclarationNameInfo DirName;
9620 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9621 OMPD_parallel_masked_taskloop, DirName,
nullptr, D->getBeginLoc());
9622 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9623 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9627template <
typename Derived>
9629TreeTransform<Derived>::TransformOMPParallelMasterTaskLoopSimdDirective(
9630 OMPParallelMasterTaskLoopSimdDirective *D) {
9631 DeclarationNameInfo DirName;
9632 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9633 OMPD_parallel_master_taskloop_simd, DirName,
nullptr, D->getBeginLoc());
9634 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9635 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9639template <
typename Derived>
9641TreeTransform<Derived>::TransformOMPParallelMaskedTaskLoopSimdDirective(
9642 OMPParallelMaskedTaskLoopSimdDirective *D) {
9643 DeclarationNameInfo DirName;
9644 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9645 OMPD_parallel_masked_taskloop_simd, DirName,
nullptr, D->getBeginLoc());
9646 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9647 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9651template <
typename Derived>
9652StmtResult TreeTransform<Derived>::TransformOMPDistributeDirective(
9653 OMPDistributeDirective *D) {
9654 DeclarationNameInfo DirName;
9655 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9656 OMPD_distribute, DirName,
nullptr, D->getBeginLoc());
9657 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9658 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9662template <
typename Derived>
9663StmtResult TreeTransform<Derived>::TransformOMPDistributeParallelForDirective(
9664 OMPDistributeParallelForDirective *D) {
9665 DeclarationNameInfo DirName;
9666 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9667 OMPD_distribute_parallel_for, DirName,
nullptr, D->getBeginLoc());
9668 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9669 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9673template <
typename Derived>
9675TreeTransform<Derived>::TransformOMPDistributeParallelForSimdDirective(
9676 OMPDistributeParallelForSimdDirective *D) {
9677 DeclarationNameInfo DirName;
9678 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9679 OMPD_distribute_parallel_for_simd, DirName,
nullptr, D->getBeginLoc());
9680 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9681 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9685template <
typename Derived>
9686StmtResult TreeTransform<Derived>::TransformOMPDistributeSimdDirective(
9687 OMPDistributeSimdDirective *D) {
9688 DeclarationNameInfo DirName;
9689 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9690 OMPD_distribute_simd, DirName,
nullptr, D->getBeginLoc());
9691 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9692 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9696template <
typename Derived>
9697StmtResult TreeTransform<Derived>::TransformOMPTargetParallelForSimdDirective(
9698 OMPTargetParallelForSimdDirective *D) {
9699 DeclarationNameInfo DirName;
9700 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9701 OMPD_target_parallel_for_simd, DirName,
nullptr, D->getBeginLoc());
9702 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9703 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9707template <
typename Derived>
9708StmtResult TreeTransform<Derived>::TransformOMPTargetSimdDirective(
9709 OMPTargetSimdDirective *D) {
9710 DeclarationNameInfo DirName;
9711 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9712 OMPD_target_simd, DirName,
nullptr, D->getBeginLoc());
9713 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9714 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9718template <
typename Derived>
9719StmtResult TreeTransform<Derived>::TransformOMPTeamsDistributeDirective(
9720 OMPTeamsDistributeDirective *D) {
9721 DeclarationNameInfo DirName;
9722 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9723 OMPD_teams_distribute, DirName,
nullptr, D->getBeginLoc());
9724 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9725 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9729template <
typename Derived>
9730StmtResult TreeTransform<Derived>::TransformOMPTeamsDistributeSimdDirective(
9731 OMPTeamsDistributeSimdDirective *D) {
9732 DeclarationNameInfo DirName;
9733 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9734 OMPD_teams_distribute_simd, DirName,
nullptr, D->getBeginLoc());
9735 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9736 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9740template <
typename Derived>
9741StmtResult TreeTransform<Derived>::TransformOMPTeamsDistributeParallelForSimdDirective(
9742 OMPTeamsDistributeParallelForSimdDirective *D) {
9743 DeclarationNameInfo DirName;
9744 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9745 OMPD_teams_distribute_parallel_for_simd, DirName,
nullptr,
9747 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9748 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9752template <
typename Derived>
9753StmtResult TreeTransform<Derived>::TransformOMPTeamsDistributeParallelForDirective(
9754 OMPTeamsDistributeParallelForDirective *D) {
9755 DeclarationNameInfo DirName;
9756 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9757 OMPD_teams_distribute_parallel_for, DirName,
nullptr, D->getBeginLoc());
9758 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9759 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9763template <
typename Derived>
9764StmtResult TreeTransform<Derived>::TransformOMPTargetTeamsDirective(
9765 OMPTargetTeamsDirective *D) {
9766 DeclarationNameInfo DirName;
9767 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9768 OMPD_target_teams, DirName,
nullptr, D->getBeginLoc());
9769 auto Res = getDerived().TransformOMPExecutableDirective(D);
9770 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9774template <
typename Derived>
9775StmtResult TreeTransform<Derived>::TransformOMPTargetTeamsDistributeDirective(
9776 OMPTargetTeamsDistributeDirective *D) {
9777 DeclarationNameInfo DirName;
9778 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9779 OMPD_target_teams_distribute, DirName,
nullptr, D->getBeginLoc());
9780 auto Res = getDerived().TransformOMPExecutableDirective(D);
9781 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9785template <
typename Derived>
9787TreeTransform<Derived>::TransformOMPTargetTeamsDistributeParallelForDirective(
9788 OMPTargetTeamsDistributeParallelForDirective *D) {
9789 DeclarationNameInfo DirName;
9790 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9791 OMPD_target_teams_distribute_parallel_for, DirName,
nullptr,
9793 auto Res = getDerived().TransformOMPExecutableDirective(D);
9794 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9798template <
typename Derived>
9800 TransformOMPTargetTeamsDistributeParallelForSimdDirective(
9801 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
9802 DeclarationNameInfo DirName;
9803 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9804 OMPD_target_teams_distribute_parallel_for_simd, DirName,
nullptr,
9806 auto Res = getDerived().TransformOMPExecutableDirective(D);
9807 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9811template <
typename Derived>
9813TreeTransform<Derived>::TransformOMPTargetTeamsDistributeSimdDirective(
9814 OMPTargetTeamsDistributeSimdDirective *D) {
9815 DeclarationNameInfo DirName;
9816 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9817 OMPD_target_teams_distribute_simd, DirName,
nullptr, D->getBeginLoc());
9818 auto Res = getDerived().TransformOMPExecutableDirective(D);
9819 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9823template <
typename Derived>
9825TreeTransform<Derived>::TransformOMPInteropDirective(OMPInteropDirective *D) {
9826 DeclarationNameInfo DirName;
9827 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9828 OMPD_interop, DirName,
nullptr, D->getBeginLoc());
9829 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9830 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9834template <
typename Derived>
9836TreeTransform<Derived>::TransformOMPDispatchDirective(OMPDispatchDirective *D) {
9837 DeclarationNameInfo DirName;
9838 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9839 OMPD_dispatch, DirName,
nullptr, D->getBeginLoc());
9840 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9841 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9845template <
typename Derived>
9847TreeTransform<Derived>::TransformOMPMaskedDirective(OMPMaskedDirective *D) {
9848 DeclarationNameInfo DirName;
9849 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9850 OMPD_masked, DirName,
nullptr, D->getBeginLoc());
9851 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9852 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9856template <
typename Derived>
9857StmtResult TreeTransform<Derived>::TransformOMPGenericLoopDirective(
9858 OMPGenericLoopDirective *D) {
9859 DeclarationNameInfo DirName;
9860 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9861 OMPD_loop, DirName,
nullptr, D->getBeginLoc());
9862 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9863 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9867template <
typename Derived>
9868StmtResult TreeTransform<Derived>::TransformOMPTeamsGenericLoopDirective(
9869 OMPTeamsGenericLoopDirective *D) {
9870 DeclarationNameInfo DirName;
9871 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9872 OMPD_teams_loop, DirName,
nullptr, D->getBeginLoc());
9873 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9874 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9878template <
typename Derived>
9879StmtResult TreeTransform<Derived>::TransformOMPTargetTeamsGenericLoopDirective(
9880 OMPTargetTeamsGenericLoopDirective *D) {
9881 DeclarationNameInfo DirName;
9882 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9883 OMPD_target_teams_loop, DirName,
nullptr, D->getBeginLoc());
9884 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9885 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9889template <
typename Derived>
9890StmtResult TreeTransform<Derived>::TransformOMPParallelGenericLoopDirective(
9891 OMPParallelGenericLoopDirective *D) {
9892 DeclarationNameInfo DirName;
9893 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9894 OMPD_parallel_loop, DirName,
nullptr, D->getBeginLoc());
9895 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9896 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9900template <
typename Derived>
9902TreeTransform<Derived>::TransformOMPTargetParallelGenericLoopDirective(
9903 OMPTargetParallelGenericLoopDirective *D) {
9904 DeclarationNameInfo DirName;
9905 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9906 OMPD_target_parallel_loop, DirName,
nullptr, D->getBeginLoc());
9907 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9908 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9915template <
typename Derived>
9916OMPClause *TreeTransform<Derived>::TransformOMPIfClause(OMPIfClause *
C) {
9917 ExprResult Cond = getDerived().TransformExpr(
C->getCondition());
9918 if (Cond.isInvalid())
9920 return getDerived().RebuildOMPIfClause(
9921 C->getNameModifier(), Cond.get(),
C->getBeginLoc(),
C->getLParenLoc(),
9922 C->getNameModifierLoc(),
C->getColonLoc(),
C->getEndLoc());
9925template <
typename Derived>
9926OMPClause *TreeTransform<Derived>::TransformOMPFinalClause(OMPFinalClause *
C) {
9927 ExprResult Cond = getDerived().TransformExpr(
C->getCondition());
9928 if (Cond.isInvalid())
9930 return getDerived().RebuildOMPFinalClause(Cond.get(),
C->getBeginLoc(),
9931 C->getLParenLoc(),
C->getEndLoc());
9934template <
typename Derived>
9936TreeTransform<Derived>::TransformOMPNumThreadsClause(OMPNumThreadsClause *
C) {
9937 ExprResult NumThreads = getDerived().TransformExpr(
C->getNumThreads());
9938 if (NumThreads.isInvalid())
9940 return getDerived().RebuildOMPNumThreadsClause(
9941 NumThreads.get(),
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
9944template <
typename Derived>
9946TreeTransform<Derived>::TransformOMPSafelenClause(OMPSafelenClause *
C) {
9947 ExprResult E = getDerived().TransformExpr(
C->getSafelen());
9950 return getDerived().RebuildOMPSafelenClause(
9951 E.get(),
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
9954template <
typename Derived>
9956TreeTransform<Derived>::TransformOMPAllocatorClause(OMPAllocatorClause *
C) {
9957 ExprResult E = getDerived().TransformExpr(
C->getAllocator());
9960 return getDerived().RebuildOMPAllocatorClause(
9961 E.get(),
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
9964template <
typename Derived>
9966TreeTransform<Derived>::TransformOMPSimdlenClause(OMPSimdlenClause *
C) {
9967 ExprResult E = getDerived().TransformExpr(
C->getSimdlen());
9970 return getDerived().RebuildOMPSimdlenClause(
9971 E.get(),
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
9974template <
typename Derived>
9975OMPClause *TreeTransform<Derived>::TransformOMPSizesClause(OMPSizesClause *
C) {
9977 TransformedSizes.reserve(
C->getNumSizes());
9979 for (Expr *E :
C->getSizesRefs()) {
9981 TransformedSizes.push_back(
nullptr);
9990 TransformedSizes.push_back(
T.get());
9993 if (!Changed && !getDerived().AlwaysRebuild())
9995 return RebuildOMPSizesClause(TransformedSizes,
C->getBeginLoc(),
9996 C->getLParenLoc(),
C->getEndLoc());
9999template <
typename Derived>
10000OMPClause *TreeTransform<Derived>::TransformOMPFullClause(OMPFullClause *
C) {
10001 if (!getDerived().AlwaysRebuild())
10003 return RebuildOMPFullClause(
C->getBeginLoc(),
C->getEndLoc());
10006template <
typename Derived>
10008TreeTransform<Derived>::TransformOMPPartialClause(OMPPartialClause *
C) {
10009 ExprResult T = getDerived().TransformExpr(
C->getFactor());
10012 Expr *Factor =
T.get();
10013 bool Changed = Factor !=
C->getFactor();
10015 if (!Changed && !getDerived().AlwaysRebuild())
10017 return RebuildOMPPartialClause(Factor,
C->getBeginLoc(),
C->getLParenLoc(),
10021template <
typename Derived>
10023TreeTransform<Derived>::TransformOMPCollapseClause(OMPCollapseClause *
C) {
10024 ExprResult E = getDerived().TransformExpr(
C->getNumForLoops());
10027 return getDerived().RebuildOMPCollapseClause(
10028 E.get(),
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10031template <
typename Derived>
10033TreeTransform<Derived>::TransformOMPDefaultClause(OMPDefaultClause *
C) {
10034 return getDerived().RebuildOMPDefaultClause(
10035 C->getDefaultKind(),
C->getDefaultKindKwLoc(),
C->getBeginLoc(),
10036 C->getLParenLoc(),
C->getEndLoc());
10039template <
typename Derived>
10041TreeTransform<Derived>::TransformOMPProcBindClause(OMPProcBindClause *
C) {
10042 return getDerived().RebuildOMPProcBindClause(
10043 C->getProcBindKind(),
C->getProcBindKindKwLoc(),
C->getBeginLoc(),
10044 C->getLParenLoc(),
C->getEndLoc());
10047template <
typename Derived>
10049TreeTransform<Derived>::TransformOMPScheduleClause(OMPScheduleClause *
C) {
10050 ExprResult E = getDerived().TransformExpr(
C->getChunkSize());
10053 return getDerived().RebuildOMPScheduleClause(
10054 C->getFirstScheduleModifier(),
C->getSecondScheduleModifier(),
10055 C->getScheduleKind(), E.get(),
C->getBeginLoc(),
C->getLParenLoc(),
10056 C->getFirstScheduleModifierLoc(),
C->getSecondScheduleModifierLoc(),
10057 C->getScheduleKindLoc(),
C->getCommaLoc(),
C->getEndLoc());
10060template <
typename Derived>
10062TreeTransform<Derived>::TransformOMPOrderedClause(OMPOrderedClause *
C) {
10064 if (
auto *Num =
C->getNumForLoops()) {
10065 E = getDerived().TransformExpr(Num);
10069 return getDerived().RebuildOMPOrderedClause(
C->getBeginLoc(),
C->getEndLoc(),
10070 C->getLParenLoc(), E.get());
10073template <
typename Derived>
10075TreeTransform<Derived>::TransformOMPDetachClause(OMPDetachClause *
C) {
10077 if (Expr *Evt =
C->getEventHandler()) {
10078 E = getDerived().TransformExpr(Evt);
10082 return getDerived().RebuildOMPDetachClause(E.get(),
C->getBeginLoc(),
10083 C->getLParenLoc(),
C->getEndLoc());
10086template <
typename Derived>
10088TreeTransform<Derived>::TransformOMPNowaitClause(OMPNowaitClause *
C) {
10093template <
typename Derived>
10095TreeTransform<Derived>::TransformOMPUntiedClause(OMPUntiedClause *
C) {
10100template <
typename Derived>
10102TreeTransform<Derived>::TransformOMPMergeableClause(OMPMergeableClause *
C) {
10107template <
typename Derived>
10108OMPClause *TreeTransform<Derived>::TransformOMPReadClause(OMPReadClause *
C) {
10113template <
typename Derived>
10114OMPClause *TreeTransform<Derived>::TransformOMPWriteClause(OMPWriteClause *
C) {
10119template <
typename Derived>
10121TreeTransform<Derived>::TransformOMPUpdateClause(OMPUpdateClause *
C) {
10126template <
typename Derived>
10128TreeTransform<Derived>::TransformOMPCaptureClause(OMPCaptureClause *
C) {
10133template <
typename Derived>
10135TreeTransform<Derived>::TransformOMPCompareClause(OMPCompareClause *
C) {
10140template <
typename Derived>
10141OMPClause *TreeTransform<Derived>::TransformOMPFailClause(OMPFailClause *
C) {
10146template <
typename Derived>
10148TreeTransform<Derived>::TransformOMPSeqCstClause(OMPSeqCstClause *
C) {
10153template <
typename Derived>
10155TreeTransform<Derived>::TransformOMPAcqRelClause(OMPAcqRelClause *
C) {
10160template <
typename Derived>
10162TreeTransform<Derived>::TransformOMPAcquireClause(OMPAcquireClause *
C) {
10167template <
typename Derived>
10169TreeTransform<Derived>::TransformOMPReleaseClause(OMPReleaseClause *
C) {
10174template <
typename Derived>
10176TreeTransform<Derived>::TransformOMPRelaxedClause(OMPRelaxedClause *
C) {
10181template <
typename Derived>
10182OMPClause *TreeTransform<Derived>::TransformOMPWeakClause(OMPWeakClause *
C) {
10187template <
typename Derived>
10189TreeTransform<Derived>::TransformOMPThreadsClause(OMPThreadsClause *
C) {
10194template <
typename Derived>
10195OMPClause *TreeTransform<Derived>::TransformOMPSIMDClause(OMPSIMDClause *
C) {
10200template <
typename Derived>
10202TreeTransform<Derived>::TransformOMPNogroupClause(OMPNogroupClause *
C) {
10207template <
typename Derived>
10208OMPClause *TreeTransform<Derived>::TransformOMPInitClause(OMPInitClause *
C) {
10209 ExprResult IVR = getDerived().TransformExpr(
C->getInteropVar());
10210 if (IVR.isInvalid())
10213 OMPInteropInfo InteropInfo(
C->getIsTarget(),
C->getIsTargetSync());
10214 InteropInfo.PreferTypes.reserve(
C->varlist_size() - 1);
10215 for (Expr *E : llvm::drop_begin(
C->varlists())) {
10216 ExprResult ER = getDerived().TransformExpr(cast<Expr>(E));
10217 if (ER.isInvalid())
10219 InteropInfo.PreferTypes.push_back(ER.get());
10221 return getDerived().RebuildOMPInitClause(IVR.get(), InteropInfo,
10222 C->getBeginLoc(),
C->getLParenLoc(),
10223 C->getVarLoc(),
C->getEndLoc());
10226template <
typename Derived>
10227OMPClause *TreeTransform<Derived>::TransformOMPUseClause(OMPUseClause *
C) {
10228 ExprResult ER = getDerived().TransformExpr(
C->getInteropVar());
10229 if (ER.isInvalid())
10231 return getDerived().RebuildOMPUseClause(ER.get(),
C->getBeginLoc(),
10232 C->getLParenLoc(),
C->getVarLoc(),
10236template <
typename Derived>
10238TreeTransform<Derived>::TransformOMPDestroyClause(OMPDestroyClause *
C) {
10240 if (Expr *IV =
C->getInteropVar()) {
10241 ER = getDerived().TransformExpr(IV);
10242 if (ER.isInvalid())
10245 return getDerived().RebuildOMPDestroyClause(ER.get(),
C->getBeginLoc(),
10246 C->getLParenLoc(),
C->getVarLoc(),
10250template <
typename Derived>
10252TreeTransform<Derived>::TransformOMPNovariantsClause(OMPNovariantsClause *
C) {
10253 ExprResult Cond = getDerived().TransformExpr(
C->getCondition());
10254 if (Cond.isInvalid())
10256 return getDerived().RebuildOMPNovariantsClause(
10257 Cond.get(),
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10260template <
typename Derived>
10262TreeTransform<Derived>::TransformOMPNocontextClause(OMPNocontextClause *
C) {
10263 ExprResult Cond = getDerived().TransformExpr(
C->getCondition());
10264 if (Cond.isInvalid())
10266 return getDerived().RebuildOMPNocontextClause(
10267 Cond.get(),
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10270template <
typename Derived>
10272TreeTransform<Derived>::TransformOMPFilterClause(OMPFilterClause *
C) {
10273 ExprResult ThreadID = getDerived().TransformExpr(
C->getThreadID());
10274 if (ThreadID.isInvalid())
10276 return getDerived().RebuildOMPFilterClause(ThreadID.get(),
C->getBeginLoc(),
10277 C->getLParenLoc(),
C->getEndLoc());
10280template <
typename Derived>
10281OMPClause *TreeTransform<Derived>::TransformOMPAlignClause(OMPAlignClause *
C) {
10282 ExprResult E = getDerived().TransformExpr(
C->getAlignment());
10285 return getDerived().RebuildOMPAlignClause(E.get(),
C->getBeginLoc(),
10286 C->getLParenLoc(),
C->getEndLoc());
10289template <
typename Derived>
10290OMPClause *TreeTransform<Derived>::TransformOMPUnifiedAddressClause(
10291 OMPUnifiedAddressClause *
C) {
10292 llvm_unreachable(
"unified_address clause cannot appear in dependent context");
10295template <
typename Derived>
10296OMPClause *TreeTransform<Derived>::TransformOMPUnifiedSharedMemoryClause(
10297 OMPUnifiedSharedMemoryClause *
C) {
10299 "unified_shared_memory clause cannot appear in dependent context");
10302template <
typename Derived>
10303OMPClause *TreeTransform<Derived>::TransformOMPReverseOffloadClause(
10304 OMPReverseOffloadClause *
C) {
10305 llvm_unreachable(
"reverse_offload clause cannot appear in dependent context");
10308template <
typename Derived>
10309OMPClause *TreeTransform<Derived>::TransformOMPDynamicAllocatorsClause(
10310 OMPDynamicAllocatorsClause *
C) {
10312 "dynamic_allocators clause cannot appear in dependent context");
10315template <
typename Derived>
10316OMPClause *TreeTransform<Derived>::TransformOMPAtomicDefaultMemOrderClause(
10317 OMPAtomicDefaultMemOrderClause *
C) {
10319 "atomic_default_mem_order clause cannot appear in dependent context");
10322template <
typename Derived>
10323OMPClause *TreeTransform<Derived>::TransformOMPAtClause(OMPAtClause *
C) {
10324 return getDerived().RebuildOMPAtClause(
C->getAtKind(),
C->getAtKindKwLoc(),
10325 C->getBeginLoc(),
C->getLParenLoc(),
10329template <
typename Derived>
10331TreeTransform<Derived>::TransformOMPSeverityClause(OMPSeverityClause *
C) {
10332 return getDerived().RebuildOMPSeverityClause(
10333 C->getSeverityKind(),
C->getSeverityKindKwLoc(),
C->getBeginLoc(),
10334 C->getLParenLoc(),
C->getEndLoc());
10337template <
typename Derived>
10339TreeTransform<Derived>::TransformOMPMessageClause(OMPMessageClause *
C) {
10340 ExprResult E = getDerived().TransformExpr(
C->getMessageString());
10343 return getDerived().RebuildOMPMessageClause(
10344 C->getMessageString(),
C->getBeginLoc(),
C->getLParenLoc(),
10348template <
typename Derived>
10350TreeTransform<Derived>::TransformOMPPrivateClause(OMPPrivateClause *
C) {
10352 Vars.reserve(
C->varlist_size());
10353 for (
auto *VE :
C->varlists()) {
10354 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10355 if (EVar.isInvalid())
10357 Vars.push_back(EVar.get());
10359 return getDerived().RebuildOMPPrivateClause(
10360 Vars,
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10363template <
typename Derived>
10364OMPClause *TreeTransform<Derived>::TransformOMPFirstprivateClause(
10365 OMPFirstprivateClause *
C) {
10367 Vars.reserve(
C->varlist_size());
10368 for (
auto *VE :
C->varlists()) {
10369 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10370 if (EVar.isInvalid())
10372 Vars.push_back(EVar.get());
10374 return getDerived().RebuildOMPFirstprivateClause(
10375 Vars,
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10378template <
typename Derived>
10380TreeTransform<Derived>::TransformOMPLastprivateClause(OMPLastprivateClause *
C) {
10382 Vars.reserve(
C->varlist_size());
10383 for (
auto *VE :
C->varlists()) {
10384 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10385 if (EVar.isInvalid())
10387 Vars.push_back(EVar.get());
10389 return getDerived().RebuildOMPLastprivateClause(
10390 Vars,
C->getKind(),
C->getKindLoc(),
C->getColonLoc(),
C->getBeginLoc(),
10391 C->getLParenLoc(),
C->getEndLoc());
10394template <
typename Derived>
10396TreeTransform<Derived>::TransformOMPSharedClause(OMPSharedClause *
C) {
10398 Vars.reserve(
C->varlist_size());
10399 for (
auto *VE :
C->varlists()) {
10400 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10401 if (EVar.isInvalid())
10403 Vars.push_back(EVar.get());
10405 return getDerived().RebuildOMPSharedClause(Vars,
C->getBeginLoc(),
10406 C->getLParenLoc(),
C->getEndLoc());
10409template <
typename Derived>
10411TreeTransform<Derived>::TransformOMPReductionClause(OMPReductionClause *
C) {
10413 Vars.reserve(
C->varlist_size());
10414 for (
auto *VE :
C->varlists()) {
10415 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10416 if (EVar.isInvalid())
10418 Vars.push_back(EVar.get());
10420 CXXScopeSpec ReductionIdScopeSpec;
10421 ReductionIdScopeSpec.Adopt(
C->getQualifierLoc());
10423 DeclarationNameInfo NameInfo =
C->getNameInfo();
10424 if (NameInfo.getName()) {
10425 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
10426 if (!NameInfo.getName())
10432 for (
auto *E :
C->reduction_ops()) {
10435 auto *ULE = cast<UnresolvedLookupExpr>(E);
10436 UnresolvedSet<8> Decls;
10437 for (
auto *D : ULE->decls()) {
10439 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
10440 Decls.addDecl(InstD, InstD->getAccess());
10444 ReductionIdScopeSpec.getWithLocInContext(SemaRef.
Context), NameInfo,
10445 true, Decls.begin(), Decls.end(),
10448 UnresolvedReductions.push_back(
nullptr);
10450 return getDerived().RebuildOMPReductionClause(
10451 Vars,
C->getModifier(),
C->getBeginLoc(),
C->getLParenLoc(),
10452 C->getModifierLoc(),
C->getColonLoc(),
C->getEndLoc(),
10453 ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
10456template <
typename Derived>
10457OMPClause *TreeTransform<Derived>::TransformOMPTaskReductionClause(
10458 OMPTaskReductionClause *
C) {
10460 Vars.reserve(
C->varlist_size());
10461 for (
auto *VE :
C->varlists()) {
10462 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10463 if (EVar.isInvalid())
10465 Vars.push_back(EVar.get());
10467 CXXScopeSpec ReductionIdScopeSpec;
10468 ReductionIdScopeSpec.Adopt(
C->getQualifierLoc());
10470 DeclarationNameInfo NameInfo =
C->getNameInfo();
10471 if (NameInfo.getName()) {
10472 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
10473 if (!NameInfo.getName())
10479 for (
auto *E :
C->reduction_ops()) {
10482 auto *ULE = cast<UnresolvedLookupExpr>(E);
10483 UnresolvedSet<8> Decls;
10484 for (
auto *D : ULE->decls()) {
10486 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
10487 Decls.addDecl(InstD, InstD->getAccess());
10491 ReductionIdScopeSpec.getWithLocInContext(SemaRef.
Context), NameInfo,
10492 true, Decls.begin(), Decls.end(),
10495 UnresolvedReductions.push_back(
nullptr);
10497 return getDerived().RebuildOMPTaskReductionClause(
10498 Vars,
C->getBeginLoc(),
C->getLParenLoc(),
C->getColonLoc(),
10499 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
10502template <
typename Derived>
10504TreeTransform<Derived>::TransformOMPInReductionClause(OMPInReductionClause *
C) {
10506 Vars.reserve(
C->varlist_size());
10507 for (
auto *VE :
C->varlists()) {
10508 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10509 if (EVar.isInvalid())
10511 Vars.push_back(EVar.get());
10513 CXXScopeSpec ReductionIdScopeSpec;
10514 ReductionIdScopeSpec.Adopt(
C->getQualifierLoc());
10516 DeclarationNameInfo NameInfo =
C->getNameInfo();
10517 if (NameInfo.getName()) {
10518 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
10519 if (!NameInfo.getName())
10525 for (
auto *E :
C->reduction_ops()) {
10528 auto *ULE = cast<UnresolvedLookupExpr>(E);
10529 UnresolvedSet<8> Decls;
10530 for (
auto *D : ULE->decls()) {
10532 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
10533 Decls.addDecl(InstD, InstD->getAccess());
10537 ReductionIdScopeSpec.getWithLocInContext(SemaRef.
Context), NameInfo,
10538 true, Decls.begin(), Decls.end(),
10541 UnresolvedReductions.push_back(
nullptr);
10543 return getDerived().RebuildOMPInReductionClause(
10544 Vars,
C->getBeginLoc(),
C->getLParenLoc(),
C->getColonLoc(),
10545 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
10548template <
typename Derived>
10550TreeTransform<Derived>::TransformOMPLinearClause(OMPLinearClause *
C) {
10552 Vars.reserve(
C->varlist_size());
10553 for (
auto *VE :
C->varlists()) {
10554 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10555 if (EVar.isInvalid())
10557 Vars.push_back(EVar.get());
10559 ExprResult Step = getDerived().TransformExpr(
C->getStep());
10560 if (Step.isInvalid())
10562 return getDerived().RebuildOMPLinearClause(
10563 Vars, Step.get(),
C->getBeginLoc(),
C->getLParenLoc(),
C->getModifier(),
10564 C->getModifierLoc(),
C->getColonLoc(),
C->getStepModifierLoc(),
10568template <
typename Derived>
10570TreeTransform<Derived>::TransformOMPAlignedClause(OMPAlignedClause *
C) {
10572 Vars.reserve(
C->varlist_size());
10573 for (
auto *VE :
C->varlists()) {
10574 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10575 if (EVar.isInvalid())
10577 Vars.push_back(EVar.get());
10579 ExprResult Alignment = getDerived().TransformExpr(
C->getAlignment());
10580 if (Alignment.isInvalid())
10582 return getDerived().RebuildOMPAlignedClause(
10583 Vars, Alignment.get(),
C->getBeginLoc(),
C->getLParenLoc(),
10584 C->getColonLoc(),
C->getEndLoc());
10587template <
typename Derived>
10589TreeTransform<Derived>::TransformOMPCopyinClause(OMPCopyinClause *
C) {
10591 Vars.reserve(
C->varlist_size());
10592 for (
auto *VE :
C->varlists()) {
10593 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10594 if (EVar.isInvalid())
10596 Vars.push_back(EVar.get());
10598 return getDerived().RebuildOMPCopyinClause(Vars,
C->getBeginLoc(),
10599 C->getLParenLoc(),
C->getEndLoc());
10602template <
typename Derived>
10604TreeTransform<Derived>::TransformOMPCopyprivateClause(OMPCopyprivateClause *
C) {
10606 Vars.reserve(
C->varlist_size());
10607 for (
auto *VE :
C->varlists()) {
10608 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10609 if (EVar.isInvalid())
10611 Vars.push_back(EVar.get());
10613 return getDerived().RebuildOMPCopyprivateClause(
10614 Vars,
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10617template <
typename Derived>
10618OMPClause *TreeTransform<Derived>::TransformOMPFlushClause(OMPFlushClause *
C) {
10620 Vars.reserve(
C->varlist_size());
10621 for (
auto *VE :
C->varlists()) {
10622 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10623 if (EVar.isInvalid())
10625 Vars.push_back(EVar.get());
10627 return getDerived().RebuildOMPFlushClause(Vars,
C->getBeginLoc(),
10628 C->getLParenLoc(),
C->getEndLoc());
10631template <
typename Derived>
10633TreeTransform<Derived>::TransformOMPDepobjClause(OMPDepobjClause *
C) {
10634 ExprResult E = getDerived().TransformExpr(
C->getDepobj());
10637 return getDerived().RebuildOMPDepobjClause(E.get(),
C->getBeginLoc(),
10638 C->getLParenLoc(),
C->getEndLoc());
10641template <
typename Derived>
10643TreeTransform<Derived>::TransformOMPDependClause(OMPDependClause *
C) {
10645 Expr *DepModifier =
C->getModifier();
10647 ExprResult DepModRes = getDerived().TransformExpr(DepModifier);
10648 if (DepModRes.isInvalid())
10650 DepModifier = DepModRes.
get();
10652 Vars.reserve(
C->varlist_size());
10653 for (
auto *VE :
C->varlists()) {
10654 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10655 if (EVar.isInvalid())
10657 Vars.push_back(EVar.get());
10659 return getDerived().RebuildOMPDependClause(
10660 {
C->getDependencyKind(),
C->getDependencyLoc(),
C->getColonLoc(),
10661 C->getOmpAllMemoryLoc()},
10662 DepModifier, Vars,
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10665template <
typename Derived>
10667TreeTransform<Derived>::TransformOMPDeviceClause(OMPDeviceClause *
C) {
10668 ExprResult E = getDerived().TransformExpr(
C->getDevice());
10671 return getDerived().RebuildOMPDeviceClause(
10672 C->getModifier(), E.get(),
C->getBeginLoc(),
C->getLParenLoc(),
10673 C->getModifierLoc(),
C->getEndLoc());
10676template <
typename Derived,
class T>
10683 Vars.reserve(
C->varlist_size());
10684 for (
auto *VE :
C->varlists()) {
10688 Vars.push_back(EVar.
get());
10692 if (
C->getMapperQualifierLoc()) {
10693 QualifierLoc = TT.
getDerived().TransformNestedNameSpecifierLoc(
10694 C->getMapperQualifierLoc());
10698 MapperIdScopeSpec.
Adopt(QualifierLoc);
10699 MapperIdInfo =
C->getMapperIdInfo();
10700 if (MapperIdInfo.
getName()) {
10701 MapperIdInfo = TT.
getDerived().TransformDeclarationNameInfo(MapperIdInfo);
10707 for (
auto *E :
C->mapperlists()) {
10710 auto *ULE = cast<UnresolvedLookupExpr>(E);
10712 for (
auto *D : ULE->decls()) {
10714 cast<NamedDecl>(TT.
getDerived().TransformDecl(E->getExprLoc(), D));
10720 MapperIdInfo,
true, Decls.
begin(), Decls.
end(),
10723 UnresolvedMappers.push_back(
nullptr);
10729template <
typename Derived>
10730OMPClause *TreeTransform<Derived>::TransformOMPMapClause(OMPMapClause *
C) {
10731 OMPVarListLocTy Locs(
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10733 Expr *IteratorModifier =
C->getIteratorModifier();
10734 if (IteratorModifier) {
10735 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
10736 if (MapModRes.isInvalid())
10738 IteratorModifier = MapModRes.
get();
10740 CXXScopeSpec MapperIdScopeSpec;
10741 DeclarationNameInfo MapperIdInfo;
10743 if (transformOMPMappableExprListClause<Derived, OMPMapClause>(
10744 *
this,
C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
10746 return getDerived().RebuildOMPMapClause(
10747 IteratorModifier,
C->getMapTypeModifiers(),
C->getMapTypeModifiersLoc(),
10748 MapperIdScopeSpec, MapperIdInfo,
C->getMapType(),
C->isImplicitMapType(),
10749 C->getMapLoc(),
C->getColonLoc(), Vars, Locs, UnresolvedMappers);
10752template <
typename Derived>
10754TreeTransform<Derived>::TransformOMPAllocateClause(OMPAllocateClause *
C) {
10755 Expr *Allocator =
C->getAllocator();
10757 ExprResult AllocatorRes = getDerived().TransformExpr(Allocator);
10758 if (AllocatorRes.isInvalid())
10760 Allocator = AllocatorRes.get();
10763 Vars.reserve(
C->varlist_size());
10764 for (
auto *VE :
C->varlists()) {
10765 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10766 if (EVar.isInvalid())
10768 Vars.push_back(EVar.get());
10770 return getDerived().RebuildOMPAllocateClause(
10771 Allocator, Vars,
C->getBeginLoc(),
C->getLParenLoc(),
C->getColonLoc(),
10775template <
typename Derived>
10777TreeTransform<Derived>::TransformOMPNumTeamsClause(OMPNumTeamsClause *
C) {
10778 ExprResult E = getDerived().TransformExpr(
C->getNumTeams());
10781 return getDerived().RebuildOMPNumTeamsClause(
10782 E.get(),
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10785template <
typename Derived>
10787TreeTransform<Derived>::TransformOMPThreadLimitClause(OMPThreadLimitClause *
C) {
10788 ExprResult E = getDerived().TransformExpr(
C->getThreadLimit());
10791 return getDerived().RebuildOMPThreadLimitClause(
10792 E.get(),
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10795template <
typename Derived>
10797TreeTransform<Derived>::TransformOMPPriorityClause(OMPPriorityClause *
C) {
10798 ExprResult E = getDerived().TransformExpr(
C->getPriority());
10801 return getDerived().RebuildOMPPriorityClause(
10802 E.get(),
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10805template <
typename Derived>
10807TreeTransform<Derived>::TransformOMPGrainsizeClause(OMPGrainsizeClause *
C) {
10808 ExprResult E = getDerived().TransformExpr(
C->getGrainsize());
10811 return getDerived().RebuildOMPGrainsizeClause(
10812 C->getModifier(), E.get(),
C->getBeginLoc(),
C->getLParenLoc(),
10813 C->getModifierLoc(),
C->getEndLoc());
10816template <
typename Derived>
10818TreeTransform<Derived>::TransformOMPNumTasksClause(OMPNumTasksClause *
C) {
10819 ExprResult E = getDerived().TransformExpr(
C->getNumTasks());
10822 return getDerived().RebuildOMPNumTasksClause(
10823 C->getModifier(), E.get(),
C->getBeginLoc(),
C->getLParenLoc(),
10824 C->getModifierLoc(),
C->getEndLoc());
10827template <
typename Derived>
10828OMPClause *TreeTransform<Derived>::TransformOMPHintClause(OMPHintClause *
C) {
10829 ExprResult E = getDerived().TransformExpr(
C->getHint());
10832 return getDerived().RebuildOMPHintClause(E.get(),
C->getBeginLoc(),
10833 C->getLParenLoc(),
C->getEndLoc());
10836template <
typename Derived>
10837OMPClause *TreeTransform<Derived>::TransformOMPDistScheduleClause(
10838 OMPDistScheduleClause *
C) {
10839 ExprResult E = getDerived().TransformExpr(
C->getChunkSize());
10842 return getDerived().RebuildOMPDistScheduleClause(
10843 C->getDistScheduleKind(), E.get(),
C->getBeginLoc(),
C->getLParenLoc(),
10844 C->getDistScheduleKindLoc(),
C->getCommaLoc(),
C->getEndLoc());
10847template <
typename Derived>
10849TreeTransform<Derived>::TransformOMPDefaultmapClause(OMPDefaultmapClause *
C) {
10852 return getDerived().RebuildOMPDefaultmapClause(
C->getDefaultmapModifier(),
10853 C->getDefaultmapKind(),
10856 C->getDefaultmapModifierLoc(),
10857 C->getDefaultmapKindLoc(),
10861template <
typename Derived>
10862OMPClause *TreeTransform<Derived>::TransformOMPToClause(OMPToClause *
C) {
10863 OMPVarListLocTy Locs(
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10865 CXXScopeSpec MapperIdScopeSpec;
10866 DeclarationNameInfo MapperIdInfo;
10868 if (transformOMPMappableExprListClause<Derived, OMPToClause>(
10869 *
this,
C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
10871 return getDerived().RebuildOMPToClause(
10872 C->getMotionModifiers(),
C->getMotionModifiersLoc(), MapperIdScopeSpec,
10873 MapperIdInfo,
C->getColonLoc(), Vars, Locs, UnresolvedMappers);
10876template <
typename Derived>
10877OMPClause *TreeTransform<Derived>::TransformOMPFromClause(OMPFromClause *
C) {
10878 OMPVarListLocTy Locs(
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10880 CXXScopeSpec MapperIdScopeSpec;
10881 DeclarationNameInfo MapperIdInfo;
10883 if (transformOMPMappableExprListClause<Derived, OMPFromClause>(
10884 *
this,
C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
10886 return getDerived().RebuildOMPFromClause(
10887 C->getMotionModifiers(),
C->getMotionModifiersLoc(), MapperIdScopeSpec,
10888 MapperIdInfo,
C->getColonLoc(), Vars, Locs, UnresolvedMappers);
10891template <
typename Derived>
10892OMPClause *TreeTransform<Derived>::TransformOMPUseDevicePtrClause(
10893 OMPUseDevicePtrClause *
C) {
10895 Vars.reserve(
C->varlist_size());
10896 for (
auto *VE :
C->varlists()) {
10897 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10898 if (EVar.isInvalid())
10900 Vars.push_back(EVar.get());
10902 OMPVarListLocTy Locs(
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10903 return getDerived().RebuildOMPUseDevicePtrClause(Vars, Locs);
10906template <
typename Derived>
10907OMPClause *TreeTransform<Derived>::TransformOMPUseDeviceAddrClause(
10908 OMPUseDeviceAddrClause *
C) {
10910 Vars.reserve(
C->varlist_size());
10911 for (
auto *VE :
C->varlists()) {
10912 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10913 if (EVar.isInvalid())
10915 Vars.push_back(EVar.get());
10917 OMPVarListLocTy Locs(
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10918 return getDerived().RebuildOMPUseDeviceAddrClause(Vars, Locs);
10921template <
typename Derived>
10923TreeTransform<Derived>::TransformOMPIsDevicePtrClause(OMPIsDevicePtrClause *
C) {
10925 Vars.reserve(
C->varlist_size());
10926 for (
auto *VE :
C->varlists()) {
10927 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10928 if (EVar.isInvalid())
10930 Vars.push_back(EVar.get());
10932 OMPVarListLocTy Locs(
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10933 return getDerived().RebuildOMPIsDevicePtrClause(Vars, Locs);
10936template <
typename Derived>
10937OMPClause *TreeTransform<Derived>::TransformOMPHasDeviceAddrClause(
10938 OMPHasDeviceAddrClause *
C) {
10940 Vars.reserve(
C->varlist_size());
10941 for (
auto *VE :
C->varlists()) {
10942 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10943 if (EVar.isInvalid())
10945 Vars.push_back(EVar.get());
10947 OMPVarListLocTy Locs(
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10948 return getDerived().RebuildOMPHasDeviceAddrClause(Vars, Locs);
10951template <
typename Derived>
10953TreeTransform<Derived>::TransformOMPNontemporalClause(OMPNontemporalClause *
C) {
10955 Vars.reserve(
C->varlist_size());
10956 for (
auto *VE :
C->varlists()) {
10957 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10958 if (EVar.isInvalid())
10960 Vars.push_back(EVar.get());
10962 return getDerived().RebuildOMPNontemporalClause(
10963 Vars,
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10966template <
typename Derived>
10968TreeTransform<Derived>::TransformOMPInclusiveClause(OMPInclusiveClause *
C) {
10970 Vars.reserve(
C->varlist_size());
10971 for (
auto *VE :
C->varlists()) {
10972 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10973 if (EVar.isInvalid())
10975 Vars.push_back(EVar.get());
10977 return getDerived().RebuildOMPInclusiveClause(
10978 Vars,
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10981template <
typename Derived>
10983TreeTransform<Derived>::TransformOMPExclusiveClause(OMPExclusiveClause *
C) {
10985 Vars.reserve(
C->varlist_size());
10986 for (
auto *VE :
C->varlists()) {
10987 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10988 if (EVar.isInvalid())
10990 Vars.push_back(EVar.get());
10992 return getDerived().RebuildOMPExclusiveClause(
10993 Vars,
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
10996template <
typename Derived>
10997OMPClause *TreeTransform<Derived>::TransformOMPUsesAllocatorsClause(
10998 OMPUsesAllocatorsClause *
C) {
11000 Data.reserve(
C->getNumberOfAllocators());
11001 for (
unsigned I = 0, E =
C->getNumberOfAllocators(); I < E; ++I) {
11002 OMPUsesAllocatorsClause::Data D =
C->getAllocatorData(I);
11003 ExprResult Allocator = getDerived().TransformExpr(D.Allocator);
11004 if (Allocator.isInvalid())
11007 if (Expr *AT = D.AllocatorTraits) {
11008 AllocatorTraits = getDerived().TransformExpr(AT);
11009 if (AllocatorTraits.isInvalid())
11012 SemaOpenMP::UsesAllocatorsData &NewD =
Data.emplace_back();
11013 NewD.Allocator = Allocator.get();
11014 NewD.AllocatorTraits = AllocatorTraits.get();
11015 NewD.LParenLoc = D.LParenLoc;
11016 NewD.RParenLoc = D.RParenLoc;
11018 return getDerived().RebuildOMPUsesAllocatorsClause(
11019 Data,
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
11022template <
typename Derived>
11024TreeTransform<Derived>::TransformOMPAffinityClause(OMPAffinityClause *
C) {
11026 Locators.reserve(
C->varlist_size());
11028 if (Expr *Modifier =
C->getModifier()) {
11029 ModifierRes = getDerived().TransformExpr(Modifier);
11030 if (ModifierRes.isInvalid())
11033 for (Expr *E :
C->varlists()) {
11034 ExprResult Locator = getDerived().TransformExpr(E);
11035 if (Locator.isInvalid())
11037 Locators.push_back(Locator.get());
11039 return getDerived().RebuildOMPAffinityClause(
11040 C->getBeginLoc(),
C->getLParenLoc(),
C->getColonLoc(),
C->getEndLoc(),
11041 ModifierRes.get(), Locators);
11044template <
typename Derived>
11045OMPClause *TreeTransform<Derived>::TransformOMPOrderClause(OMPOrderClause *
C) {
11046 return getDerived().RebuildOMPOrderClause(
11047 C->getKind(),
C->getKindKwLoc(),
C->getBeginLoc(),
C->getLParenLoc(),
11048 C->getEndLoc(),
C->getModifier(),
C->getModifierKwLoc());
11051template <
typename Derived>
11052OMPClause *TreeTransform<Derived>::TransformOMPBindClause(OMPBindClause *
C) {
11053 return getDerived().RebuildOMPBindClause(
11054 C->getBindKind(),
C->getBindKindLoc(),
C->getBeginLoc(),
11055 C->getLParenLoc(),
C->getEndLoc());
11058template <
typename Derived>
11059OMPClause *TreeTransform<Derived>::TransformOMPXDynCGroupMemClause(
11060 OMPXDynCGroupMemClause *
C) {
11062 if (
Size.isInvalid())
11064 return getDerived().RebuildOMPXDynCGroupMemClause(
11065 Size.get(),
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
11068template <
typename Derived>
11070TreeTransform<Derived>::TransformOMPDoacrossClause(OMPDoacrossClause *
C) {
11072 Vars.reserve(
C->varlist_size());
11073 for (
auto *VE :
C->varlists()) {
11074 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11075 if (EVar.isInvalid())
11077 Vars.push_back(EVar.get());
11079 return getDerived().RebuildOMPDoacrossClause(
11080 C->getDependenceType(),
C->getDependenceLoc(),
C->getColonLoc(), Vars,
11081 C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
11084template <
typename Derived>
11086TreeTransform<Derived>::TransformOMPXAttributeClause(OMPXAttributeClause *
C) {
11088 for (
auto *A :
C->getAttrs())
11089 NewAttrs.push_back(getDerived().TransformAttr(A));
11090 return getDerived().RebuildOMPXAttributeClause(
11091 NewAttrs,
C->getBeginLoc(),
C->getLParenLoc(),
C->getEndLoc());
11094template <
typename Derived>
11095OMPClause *TreeTransform<Derived>::TransformOMPXBareClause(OMPXBareClause *
C) {
11096 return getDerived().RebuildOMPXBareClause(
C->getBeginLoc(),
C->getEndLoc());
11103template <
typename Derived>
11104class OpenACCClauseTransform final
11105 :
public OpenACCClauseVisitor<OpenACCClauseTransform<Derived>> {
11106 TreeTransform<Derived> &Self;
11107 SemaOpenACC::OpenACCParsedClause &ParsedClause;
11108 OpenACCClause *NewClause =
nullptr;
11111 OpenACCClauseTransform(TreeTransform<Derived> &Self,
11112 SemaOpenACC::OpenACCParsedClause &PC)
11113 : Self(Self), ParsedClause(PC) {}
11115 OpenACCClause *CreatedClause()
const {
return NewClause; }
11117#define VISIT_CLAUSE(CLAUSE_NAME) \
11118 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
11119#include "clang/Basic/OpenACCClauses.def"
11122template <
typename Derived>
11123void OpenACCClauseTransform<Derived>::VisitDefaultClause(
11124 const OpenACCDefaultClause &
C) {
11133template <
typename Derived>
11134void OpenACCClauseTransform<Derived>::VisitIfClause(
const OpenACCIfClause &
C) {
11135 Expr *Cond =
const_cast<Expr *
>(
C.getConditionExpr());
11136 assert(Cond &&
"If constructed with invalid Condition");
11137 Sema::ConditionResult Res =
Self.TransformCondition(
11140 if (Res.isInvalid() || !Res.get().second)
11151template <
typename Derived>
11152void OpenACCClauseTransform<Derived>::VisitSelfClause(
11153 const OpenACCSelfClause &
C) {
11155 if (
C.hasConditionExpr()) {
11156 Expr *Cond =
const_cast<Expr *
>(
C.getConditionExpr());
11157 Sema::ConditionResult Res =
11158 Self.TransformCondition(Cond->getExprLoc(),
nullptr, Cond,
11161 if (Res.isInvalid() || !Res.get().second)
11173template <
typename Derived>
11174void OpenACCClauseTransform<Derived>::VisitNumGangsClause(
11175 const OpenACCNumGangsClause &
C) {
11178 for (Expr *CurIntExpr :
C.getIntExprs()) {
11181 if (!Res.isUsable())
11186 C.getBeginLoc(), Res.get());
11187 if (!Res.isUsable())
11190 InstantiatedIntExprs.push_back(Res.get());
11199template <
typename Derived>
11200void OpenACCClauseTransform<Derived>::VisitNumWorkersClause(
11201 const OpenACCNumWorkersClause &
C) {
11202 Expr *IntExpr =
const_cast<Expr *
>(
C.getIntExpr());
11203 assert(IntExpr &&
"num_workers clause constructed with invalid int expr");
11206 if (!Res.isUsable())
11211 C.getBeginLoc(), Res.get());
11212 if (!Res.isUsable())
11222template <
typename Derived>
11223void OpenACCClauseTransform<Derived>::VisitVectorLengthClause(
11224 const OpenACCVectorLengthClause &
C) {
11225 Expr *IntExpr =
const_cast<Expr *
>(
C.getIntExpr());
11226 assert(IntExpr &&
"vector_length clause constructed with invalid int expr");
11229 if (!Res.isUsable())
11234 C.getBeginLoc(), Res.get());
11235 if (!Res.isUsable())
11245template <
typename Derived>
11246OpenACCClause *TreeTransform<Derived>::TransformOpenACCClause(
11250 SemaOpenACC::OpenACCParsedClause ParsedClause(
11251 DirKind, OldClause->getClauseKind(), OldClause->getBeginLoc());
11252 ParsedClause.
setEndLoc(OldClause->getEndLoc());
11254 if (
const auto *WithParms = dyn_cast<OpenACCClauseWithParams>(OldClause))
11257 OpenACCClauseTransform<Derived> Transform{*
this, ParsedClause};
11258 Transform.Visit(OldClause);
11260 return Transform.CreatedClause();
11263template <
typename Derived>
11265TreeTransform<Derived>::TransformOpenACCClauseList(
11268 for (
const auto *Clause : OldClauses) {
11269 if (OpenACCClause *TransformedClause = getDerived().TransformOpenACCClause(
11270 TransformedClauses, DirKind, Clause))
11271 TransformedClauses.push_back(TransformedClause);
11273 return TransformedClauses;
11276template <
typename Derived>
11277StmtResult TreeTransform<Derived>::TransformOpenACCComputeConstruct(
11278 OpenACCComputeConstruct *
C) {
11279 getSema().OpenACC().ActOnConstruct(
C->getDirectiveKind(),
C->getBeginLoc());
11283 if (getSema().OpenACC().ActOnStartStmtDirective(
C->getDirectiveKind(),
11288 getDerived().TransformOpenACCClauseList(
C->getDirectiveKind(),
11292 StmtResult StrBlock = getDerived().TransformStmt(
C->getStructuredBlock());
11294 getSema().OpenACC().ActOnAssociatedStmt(
C->getDirectiveKind(), StrBlock);
11296 return getDerived().RebuildOpenACCComputeConstruct(
11297 C->getDirectiveKind(),
C->getBeginLoc(),
C->getEndLoc(),
11298 TransformedClauses, StrBlock);
11304template<
typename Derived>
11306TreeTransform<Derived>::TransformConstantExpr(ConstantExpr *E) {
11307 return TransformExpr(E->getSubExpr());
11310template <
typename Derived>
11311ExprResult TreeTransform<Derived>::TransformSYCLUniqueStableNameExpr(
11312 SYCLUniqueStableNameExpr *E) {
11313 if (!E->isTypeDependent())
11316 TypeSourceInfo *NewT = getDerived().TransformType(E->getTypeSourceInfo());
11321 if (!getDerived().AlwaysRebuild() && E->getTypeSourceInfo() == NewT)
11324 return getDerived().RebuildSYCLUniqueStableNameExpr(
11325 E->getLocation(), E->getLParenLocation(), E->getRParenLocation(), NewT);
11328template<
typename Derived>
11330TreeTransform<Derived>::TransformPredefinedExpr(PredefinedExpr *E) {
11331 if (!E->isTypeDependent())
11334 return getDerived().RebuildPredefinedExpr(E->getLocation(),
11335 E->getIdentKind());
11338template<
typename Derived>
11340TreeTransform<Derived>::TransformDeclRefExpr(DeclRefExpr *E) {
11341 NestedNameSpecifierLoc QualifierLoc;
11342 if (E->getQualifierLoc()) {
11344 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
11350 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
11355 NamedDecl *Found = ND;
11356 if (E->getFoundDecl() != E->getDecl()) {
11357 Found = cast_or_null<NamedDecl>(
11358 getDerived().TransformDecl(E->getLocation(), E->getFoundDecl()));
11363 DeclarationNameInfo NameInfo = E->getNameInfo();
11364 if (NameInfo.getName()) {
11365 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11366 if (!NameInfo.getName())
11370 if (!getDerived().AlwaysRebuild() &&
11371 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter() &&
11372 QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
11373 Found == E->getFoundDecl() &&
11374 NameInfo.getName() == E->getDecl()->getDeclName() &&
11375 !E->hasExplicitTemplateArgs()) {
11384 TemplateArgumentListInfo TransArgs, *TemplateArgs =
nullptr;
11385 if (E->hasExplicitTemplateArgs()) {
11386 TemplateArgs = &TransArgs;
11387 TransArgs.setLAngleLoc(E->getLAngleLoc());
11388 TransArgs.setRAngleLoc(E->getRAngleLoc());
11389 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
11390 E->getNumTemplateArgs(),
11395 return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
11396 Found, TemplateArgs);
11399template<
typename Derived>
11401TreeTransform<Derived>::TransformIntegerLiteral(IntegerLiteral *E) {
11405template <
typename Derived>
11406ExprResult TreeTransform<Derived>::TransformFixedPointLiteral(
11407 FixedPointLiteral *E) {
11411template<
typename Derived>
11413TreeTransform<Derived>::TransformFloatingLiteral(FloatingLiteral *E) {
11417template<
typename Derived>
11419TreeTransform<Derived>::TransformImaginaryLiteral(ImaginaryLiteral *E) {
11423template<
typename Derived>
11425TreeTransform<Derived>::TransformStringLiteral(StringLiteral *E) {
11429template<
typename Derived>
11431TreeTransform<Derived>::TransformCharacterLiteral(CharacterLiteral *E) {
11435template<
typename Derived>
11437TreeTransform<Derived>::TransformUserDefinedLiteral(UserDefinedLiteral *E) {
11438 return getDerived().TransformCallExpr(E);
11441template<
typename Derived>
11443TreeTransform<Derived>::TransformGenericSelectionExpr(GenericSelectionExpr *E) {
11445 TypeSourceInfo *ControllingType =
nullptr;
11446 if (E->isExprPredicate())
11447 ControllingExpr = getDerived().TransformExpr(E->getControllingExpr());
11449 ControllingType = getDerived().TransformType(E->getControllingType());
11451 if (ControllingExpr.isInvalid() && !ControllingType)
11457 TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
11459 TypeSourceInfo *AssocType = getDerived().TransformType(TSI);
11462 AssocTypes.push_back(AssocType);
11464 AssocTypes.push_back(
nullptr);
11468 getDerived().TransformExpr(Assoc.getAssociationExpr());
11469 if (AssocExpr.isInvalid())
11471 AssocExprs.push_back(AssocExpr.get());
11474 if (!ControllingType)
11475 return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
11476 E->getDefaultLoc(),
11478 ControllingExpr.get(),
11481 return getDerived().RebuildGenericSelectionExpr(
11482 E->getGenericLoc(), E->getDefaultLoc(), E->getRParenLoc(),
11483 ControllingType, AssocTypes, AssocExprs);
11486template<
typename Derived>
11488TreeTransform<Derived>::TransformParenExpr(ParenExpr *E) {
11489 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
11490 if (SubExpr.isInvalid())
11493 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
11496 return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
11503template<
typename Derived>
11507 return getDerived().TransformDependentScopeDeclRefExpr(
11508 DRE,
true,
nullptr);
11510 return getDerived().TransformUnresolvedLookupExpr(
11513 return getDerived().TransformExpr(E);
11516template<
typename Derived>
11521 SubExpr = TransformAddressOfOperand(E->
getSubExpr());
11527 if (!getDerived().AlwaysRebuild() && SubExpr.
get() == E->
getSubExpr())
11535template<
typename Derived>
11537TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
11539 TypeSourceInfo *
Type = getDerived().TransformType(E->getTypeSourceInfo());
11549 bool ExprChanged =
false;
11550 typedef Sema::OffsetOfComponent Component;
11552 for (
unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
11553 const OffsetOfNode &ON = E->getComponent(I);
11555 Comp.isBrackets =
true;
11556 Comp.LocStart = ON.getSourceRange().getBegin();
11557 Comp.LocEnd = ON.getSourceRange().getEnd();
11558 switch (ON.getKind()) {
11560 Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
11561 ExprResult Index = getDerived().TransformExpr(FromIndex);
11562 if (Index.isInvalid())
11565 ExprChanged = ExprChanged || Index.get() != FromIndex;
11566 Comp.isBrackets =
true;
11567 Comp.U.E = Index.get();
11573 Comp.isBrackets =
false;
11574 Comp.U.IdentInfo = ON.getFieldName();
11575 if (!
Comp.U.IdentInfo)
11585 Components.push_back(Comp);
11589 if (!getDerived().AlwaysRebuild() &&
11590 Type == E->getTypeSourceInfo() &&
11595 return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type,
11596 Components, E->getRParenLoc());
11599template<
typename Derived>
11601TreeTransform<Derived>::TransformOpaqueValueExpr(OpaqueValueExpr *E) {
11602 assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
11603 "opaque value expression requires transformation");
11607template<
typename Derived>
11609TreeTransform<Derived>::TransformTypoExpr(TypoExpr *E) {
11613template <
typename Derived>
11614ExprResult TreeTransform<Derived>::TransformRecoveryExpr(RecoveryExpr *E) {
11617 for (Expr *
C : E->subExpressions()) {
11619 if (NewC.isInvalid())
11621 Children.push_back(NewC.get());
11625 if (!getDerived().AlwaysRebuild() && !Changed)
11627 return getDerived().RebuildRecoveryExpr(E->getBeginLoc(), E->getEndLoc(),
11628 Children, E->getType());
11631template<
typename Derived>
11633TreeTransform<Derived>::TransformPseudoObjectExpr(PseudoObjectExpr *E) {
11641 ExprResult result = getDerived().TransformExpr(newSyntacticForm);
11642 if (result.isInvalid())
return ExprError();
11647 if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
11653template<
typename Derived>
11655TreeTransform<Derived>::TransformUnaryExprOrTypeTraitExpr(
11656 UnaryExprOrTypeTraitExpr *E) {
11657 if (E->isArgumentType()) {
11658 TypeSourceInfo *OldT = E->getArgumentTypeInfo();
11660 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
11664 if (!getDerived().AlwaysRebuild() && OldT == NewT)
11667 return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
11669 E->getSourceRange());
11681 TypeSourceInfo *RecoveryTSI =
nullptr;
11683 auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr());
11685 PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) :
nullptr)
11686 SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr(
11687 PE, DRE,
false, &RecoveryTSI);
11689 SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
11692 return getDerived().RebuildUnaryExprOrTypeTrait(
11693 RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange());
11694 }
else if (SubExpr.isInvalid())
11697 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
11700 return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
11701 E->getOperatorLoc(),
11703 E->getSourceRange());
11706template<
typename Derived>
11708TreeTransform<Derived>::TransformArraySubscriptExpr(ArraySubscriptExpr *E) {
11709 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
11710 if (LHS.isInvalid())
11713 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
11714 if (RHS.isInvalid())
11718 if (!getDerived().AlwaysRebuild() &&
11719 LHS.get() == E->getLHS() &&
11720 RHS.get() == E->getRHS())
11723 return getDerived().RebuildArraySubscriptExpr(
11725 E->getLHS()->getBeginLoc(), RHS.get(), E->getRBracketLoc());
11728template <
typename Derived>
11730TreeTransform<Derived>::TransformMatrixSubscriptExpr(MatrixSubscriptExpr *E) {
11732 if (
Base.isInvalid())
11735 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
11736 if (RowIdx.isInvalid())
11739 ExprResult ColumnIdx = getDerived().TransformExpr(E->getColumnIdx());
11740 if (ColumnIdx.isInvalid())
11743 if (!getDerived().AlwaysRebuild() &&
Base.get() == E->getBase() &&
11744 RowIdx.get() == E->getRowIdx() && ColumnIdx.get() == E->getColumnIdx())
11747 return getDerived().RebuildMatrixSubscriptExpr(
11748 Base.get(), RowIdx.get(), ColumnIdx.get(), E->getRBracketLoc());
11751template <
typename Derived>
11753TreeTransform<Derived>::TransformArraySectionExpr(ArraySectionExpr *E) {
11755 if (
Base.isInvalid())
11759 if (E->getLowerBound()) {
11760 LowerBound = getDerived().TransformExpr(E->getLowerBound());
11761 if (LowerBound.isInvalid())
11766 if (E->getLength()) {
11767 Length = getDerived().TransformExpr(E->getLength());
11768 if (Length.isInvalid())
11773 if (E->isOMPArraySection()) {
11774 if (Expr *Str = E->getStride()) {
11775 Stride = getDerived().TransformExpr(Str);
11776 if (Stride.isInvalid())
11781 if (!getDerived().AlwaysRebuild() &&
Base.get() == E->getBase() &&
11782 LowerBound.get() == E->getLowerBound() &&
11783 Length.get() == E->getLength() &&
11784 (E->isOpenACCArraySection() || Stride.get() == E->getStride()))
11787 return getDerived().RebuildArraySectionExpr(
11788 E->isOMPArraySection(),
Base.get(), E->getBase()->getEndLoc(),
11789 LowerBound.get(), E->getColonLocFirst(),
11790 E->isOMPArraySection() ? E->getColonLocSecond() : SourceLocation{},
11791 Length.get(), Stride.get(), E->getRBracketLoc());
11794template <
typename Derived>
11796TreeTransform<Derived>::TransformOMPArrayShapingExpr(OMPArrayShapingExpr *E) {
11798 if (
Base.isInvalid())
11802 bool ErrorFound =
false;
11803 for (Expr *Dim : E->getDimensions()) {
11804 ExprResult DimRes = getDerived().TransformExpr(Dim);
11805 if (DimRes.isInvalid()) {
11809 Dims.push_back(DimRes.get());
11814 return getDerived().RebuildOMPArrayShapingExpr(
Base.get(), E->getLParenLoc(),
11815 E->getRParenLoc(), Dims,
11816 E->getBracketsRanges());
11819template <
typename Derived>
11821TreeTransform<Derived>::TransformOMPIteratorExpr(OMPIteratorExpr *E) {
11822 unsigned NumIterators = E->numOfIterators();
11825 bool ErrorFound =
false;
11826 bool NeedToRebuild = getDerived().AlwaysRebuild();
11827 for (
unsigned I = 0; I < NumIterators; ++I) {
11828 auto *D = cast<VarDecl>(E->getIteratorDecl(I));
11829 Data[I].DeclIdent = D->getIdentifier();
11830 Data[I].DeclIdentLoc = D->getLocation();
11831 if (D->getLocation() == D->getBeginLoc()) {
11833 "Implicit type must be int.");
11835 TypeSourceInfo *TSI = getDerived().TransformType(D->getTypeSourceInfo());
11836 QualType
DeclTy = getDerived().TransformType(D->getType());
11839 OMPIteratorExpr::IteratorRange
Range = E->getIteratorRange(I);
11843 ErrorFound = ErrorFound ||
11844 !(!D->getTypeSourceInfo() || (
Data[I].Type.getAsOpaquePtr() &&
11845 !
Data[I].Type.get().isNull())) ||
11850 Data[I].Range.End = End.get();
11851 Data[I].Range.Step = Step.get();
11852 Data[I].AssignLoc = E->getAssignLoc(I);
11853 Data[I].ColonLoc = E->getColonLoc(I);
11854 Data[I].SecColonLoc = E->getSecondColonLoc(I);
11857 (D->getTypeSourceInfo() &&
Data[I].Type.get().getTypePtrOrNull() !=
11858 D->getType().getTypePtrOrNull()) ||
11864 if (!NeedToRebuild)
11867 ExprResult Res = getDerived().RebuildOMPIteratorExpr(
11868 E->getIteratorKwLoc(), E->getLParenLoc(), E->getRParenLoc(),
Data);
11869 if (!Res.isUsable())
11871 auto *IE = cast<OMPIteratorExpr>(Res.get());
11872 for (
unsigned I = 0; I < NumIterators; ++I)
11873 getDerived().transformedLocalDecl(E->getIteratorDecl(I),
11874 IE->getIteratorDecl(I));
11878template<
typename Derived>
11880TreeTransform<Derived>::TransformCallExpr(CallExpr *E) {
11887 bool ArgChanged =
false;
11889 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(),
true, Args,
11893 if (!getDerived().AlwaysRebuild() &&
11894 Callee.get() == E->getCallee() &&
11899 SourceLocation FakeLParenLoc
11902 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
11903 if (E->hasStoredFPFeatures()) {
11904 FPOptionsOverride NewOverrides = E->getFPFeatures();
11905 getSema().CurFPFeatures =
11906 NewOverrides.applyOverrides(getSema().getLangOpts());
11907 getSema().FpPragmaStack.CurrentValue = NewOverrides;
11910 return getDerived().RebuildCallExpr(
Callee.get(), FakeLParenLoc,
11912 E->getRParenLoc());
11915template<
typename Derived>
11917TreeTransform<Derived>::TransformMemberExpr(MemberExpr *E) {
11919 if (
Base.isInvalid())
11922 NestedNameSpecifierLoc QualifierLoc;
11923 if (E->hasQualifier()) {
11925 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
11930 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
11933 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
11934 E->getMemberDecl()));
11938 NamedDecl *FoundDecl = E->getFoundDecl();
11939 if (FoundDecl == E->getMemberDecl()) {
11942 FoundDecl = cast_or_null<NamedDecl>(
11943 getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
11948 if (!getDerived().AlwaysRebuild() &&
11949 Base.get() == E->getBase() &&
11950 QualifierLoc == E->getQualifierLoc() &&
11951 Member == E->getMemberDecl() &&
11952 FoundDecl == E->getFoundDecl() &&
11953 !E->hasExplicitTemplateArgs()) {
11957 if (!(isa<CXXThisExpr>(E->getBase()) &&
11958 getSema().OpenMP().isOpenMPRebuildMemberExpr(
11959 cast<ValueDecl>(
Member)))) {
11967 TemplateArgumentListInfo TransArgs;
11968 if (E->hasExplicitTemplateArgs()) {
11969 TransArgs.setLAngleLoc(E->getLAngleLoc());
11970 TransArgs.setRAngleLoc(E->getRAngleLoc());
11971 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
11972 E->getNumTemplateArgs(),
11978 SourceLocation FakeOperatorLoc =
11985 NamedDecl *FirstQualifierInScope =
nullptr;
11986 DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
11987 if (MemberNameInfo.getName()) {
11988 MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
11989 if (!MemberNameInfo.getName())
11993 return getDerived().RebuildMemberExpr(
Base.get(), FakeOperatorLoc,
12000 (E->hasExplicitTemplateArgs()
12001 ? &TransArgs :
nullptr),
12002 FirstQualifierInScope);
12005template<
typename Derived>
12007TreeTransform<Derived>::TransformBinaryOperator(BinaryOperator *E) {
12008 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
12009 if (LHS.isInvalid())
12013 getDerived().TransformInitializer(E->getRHS(),
false);
12014 if (RHS.isInvalid())
12017 if (!getDerived().AlwaysRebuild() &&
12018 LHS.get() == E->getLHS() &&
12019 RHS.get() == E->getRHS())
12022 if (E->isCompoundAssignmentOp())
12024 return getDerived().RebuildBinaryOperator(
12025 E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get());
12026 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
12027 FPOptionsOverride NewOverrides(E->getFPFeatures());
12028 getSema().CurFPFeatures =
12029 NewOverrides.applyOverrides(getSema().getLangOpts());
12030 getSema().FpPragmaStack.CurrentValue = NewOverrides;
12031 return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
12032 LHS.get(), RHS.get());
12035template <
typename Derived>
12036ExprResult TreeTransform<Derived>::TransformCXXRewrittenBinaryOperator(
12037 CXXRewrittenBinaryOperator *E) {
12038 CXXRewrittenBinaryOperator::DecomposedForm Decomp = E->getDecomposedForm();
12040 ExprResult LHS = getDerived().TransformExpr(
const_cast<Expr*
>(Decomp.LHS));
12041 if (LHS.isInvalid())
12044 ExprResult RHS = getDerived().TransformExpr(
const_cast<Expr*
>(Decomp.RHS));
12045 if (RHS.isInvalid())
12050 UnresolvedSet<2> UnqualLookups;
12051 bool ChangedAnyLookups =
false;
12052 Expr *PossibleBinOps[] = {E->getSemanticForm(),
12053 const_cast<Expr *
>(Decomp.InnerBinOp)};
12054 for (Expr *PossibleBinOp : PossibleBinOps) {
12055 auto *Op = dyn_cast<CXXOperatorCallExpr>(PossibleBinOp->IgnoreImplicit());
12058 auto *
Callee = dyn_cast<DeclRefExpr>(Op->getCallee()->IgnoreImplicit());
12059 if (!Callee || isa<CXXMethodDecl>(
Callee->getDecl()))
12064 NamedDecl *Found = cast_or_null<NamedDecl>(getDerived().TransformDecl(
12065 E->getOperatorLoc(),
Callee->getFoundDecl()));
12068 if (Found !=
Callee->getFoundDecl())
12069 ChangedAnyLookups =
true;
12070 UnqualLookups.addDecl(Found);
12073 if (!getDerived().AlwaysRebuild() && !ChangedAnyLookups &&
12074 LHS.get() == Decomp.LHS && RHS.get() == Decomp.RHS) {
12080 const Expr *StopAt[] = {Decomp.LHS, Decomp.RHS};
12085 return getDerived().RebuildCXXRewrittenBinaryOperator(
12086 E->getOperatorLoc(), Decomp.Opcode, UnqualLookups, LHS.get(), RHS.get());
12089template<
typename Derived>
12091TreeTransform<Derived>::TransformCompoundAssignOperator(
12092 CompoundAssignOperator *E) {
12093 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
12094 FPOptionsOverride NewOverrides(E->getFPFeatures());
12095 getSema().CurFPFeatures =
12096 NewOverrides.applyOverrides(getSema().getLangOpts());
12097 getSema().FpPragmaStack.CurrentValue = NewOverrides;
12098 return getDerived().TransformBinaryOperator(E);
12101template<
typename Derived>
12103TransformBinaryConditionalOperator(BinaryConditionalOperator *e) {
12107 ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
12108 if (commonExpr.isInvalid())
12111 ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
12112 if (rhs.isInvalid())
12115 if (!getDerived().AlwaysRebuild() &&
12116 commonExpr.get() == e->getCommon() &&
12117 rhs.get() == e->getFalseExpr())
12120 return getDerived().RebuildConditionalOperator(commonExpr.get(),
12121 e->getQuestionLoc(),
12127template<
typename Derived>
12129TreeTransform<Derived>::TransformConditionalOperator(ConditionalOperator *E) {
12130 ExprResult Cond = getDerived().TransformExpr(E->getCond());
12131 if (Cond.isInvalid())
12134 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
12135 if (LHS.isInvalid())
12138 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
12139 if (RHS.isInvalid())
12142 if (!getDerived().AlwaysRebuild() &&
12143 Cond.get() == E->getCond() &&
12144 LHS.get() == E->getLHS() &&
12145 RHS.get() == E->getRHS())
12148 return getDerived().RebuildConditionalOperator(Cond.get(),
12149 E->getQuestionLoc(),
12155template<
typename Derived>
12157TreeTransform<Derived>::TransformImplicitCastExpr(ImplicitCastExpr *E) {
12160 return getDerived().TransformExpr(E->getSubExprAsWritten());
12163template<
typename Derived>
12165TreeTransform<Derived>::TransformCStyleCastExpr(CStyleCastExpr *E) {
12166 TypeSourceInfo *
Type = getDerived().TransformType(E->getTypeInfoAsWritten());
12171 = getDerived().TransformExpr(E->getSubExprAsWritten());
12172 if (SubExpr.isInvalid())
12175 if (!getDerived().AlwaysRebuild() &&
12176 Type == E->getTypeInfoAsWritten() &&
12177 SubExpr.get() == E->getSubExpr())
12180 return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
12186template<
typename Derived>
12188TreeTransform<Derived>::TransformCompoundLiteralExpr(CompoundLiteralExpr *E) {
12189 TypeSourceInfo *OldT = E->getTypeSourceInfo();
12190 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
12194 ExprResult Init = getDerived().TransformExpr(E->getInitializer());
12195 if (
Init.isInvalid())
12198 if (!getDerived().AlwaysRebuild() &&
12200 Init.get() == E->getInitializer())
12207 return getDerived().RebuildCompoundLiteralExpr(
12208 E->getLParenLoc(), NewT,
12209 E->getInitializer()->getEndLoc(),
Init.get());
12212template<
typename Derived>
12214TreeTransform<Derived>::TransformExtVectorElementExpr(ExtVectorElementExpr *E) {
12216 if (
Base.isInvalid())
12219 if (!getDerived().AlwaysRebuild() &&
12220 Base.get() == E->getBase())
12224 SourceLocation FakeOperatorLoc =
12226 return getDerived().RebuildExtVectorElementExpr(
12227 Base.get(), FakeOperatorLoc, E->isArrow(), E->getAccessorLoc(),
12231template<
typename Derived>
12233TreeTransform<Derived>::TransformInitListExpr(InitListExpr *E) {
12234 if (InitListExpr *Syntactic = E->getSyntacticForm())
12237 bool InitChanged =
false;
12239 EnterExpressionEvaluationContext Context(
12243 if (getDerived().TransformExprs(E->getInits(), E->getNumInits(),
false,
12244 Inits, &InitChanged))
12247 if (!getDerived().AlwaysRebuild() && !InitChanged) {
12254 return getDerived().RebuildInitList(E->getLBraceLoc(), Inits,
12255 E->getRBraceLoc());
12258template<
typename Derived>
12260TreeTransform<Derived>::TransformDesignatedInitExpr(DesignatedInitExpr *E) {
12265 if (
Init.isInvalid())
12270 bool ExprChanged =
false;
12271 for (
const DesignatedInitExpr::Designator &D : E->designators()) {
12272 if (D.isFieldDesignator()) {
12273 if (D.getFieldDecl()) {
12274 FieldDecl *
Field = cast_or_null<FieldDecl>(
12275 getDerived().TransformDecl(D.getFieldLoc(), D.getFieldDecl()));
12276 if (Field != D.getFieldDecl())
12279 ExprChanged =
true;
12280 if (
Field->isAnonymousStructOrUnion())
12286 ExprChanged =
true;
12289 D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
12293 if (D.isArrayDesignator()) {
12294 ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D));
12295 if (Index.isInvalid())
12298 Desig.AddDesignator(
12301 ExprChanged = ExprChanged ||
Init.get() != E->getArrayIndex(D);
12302 ArrayExprs.push_back(Index.get());
12306 assert(D.isArrayRangeDesignator() &&
"New kind of designator?");
12308 = getDerived().TransformExpr(E->getArrayRangeStart(D));
12309 if (Start.isInvalid())
12312 ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D));
12313 if (End.isInvalid())
12317 Start.get(), End.get(), D.getLBracketLoc(), D.getEllipsisLoc()));
12319 ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) ||
12320 End.get() != E->getArrayRangeEnd(D);
12322 ArrayExprs.push_back(Start.get());
12323 ArrayExprs.push_back(End.get());
12326 if (!getDerived().AlwaysRebuild() &&
12327 Init.get() == E->getInit() &&
12331 return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs,
12332 E->getEqualOrColonLoc(),
12333 E->usesGNUSyntax(),
Init.get());
12338template<
typename Derived>
12340TreeTransform<Derived>::TransformDesignatedInitUpdateExpr(
12341 DesignatedInitUpdateExpr *E) {
12342 llvm_unreachable(
"Unexpected DesignatedInitUpdateExpr in syntactic form of "
12347template<
typename Derived>
12349TreeTransform<Derived>::TransformNoInitExpr(
12351 llvm_unreachable(
"Unexpected NoInitExpr in syntactic form of initializer");
12355template<
typename Derived>
12357TreeTransform<Derived>::TransformArrayInitLoopExpr(ArrayInitLoopExpr *E) {
12358 llvm_unreachable(
"Unexpected ArrayInitLoopExpr outside of initializer");
12362template<
typename Derived>
12364TreeTransform<Derived>::TransformArrayInitIndexExpr(ArrayInitIndexExpr *E) {
12365 llvm_unreachable(
"Unexpected ArrayInitIndexExpr outside of initializer");
12369template<
typename Derived>
12371TreeTransform<Derived>::TransformImplicitValueInitExpr(
12372 ImplicitValueInitExpr *E) {
12373 TemporaryBase Rebase(*
this, E->getBeginLoc(), DeclarationName());
12377 QualType
T = getDerived().TransformType(E->getType());
12381 if (!getDerived().AlwaysRebuild() &&
12385 return getDerived().RebuildImplicitValueInitExpr(
T);
12388template<
typename Derived>
12390TreeTransform<Derived>::TransformVAArgExpr(VAArgExpr *E) {
12391 TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
12395 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
12396 if (SubExpr.isInvalid())
12399 if (!getDerived().AlwaysRebuild() &&
12400 TInfo == E->getWrittenTypeInfo() &&
12401 SubExpr.get() == E->getSubExpr())
12404 return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
12405 TInfo, E->getRParenLoc());
12408template<
typename Derived>
12410TreeTransform<Derived>::TransformParenListExpr(ParenListExpr *E) {
12411 bool ArgumentChanged =
false;
12413 if (TransformExprs(E->getExprs(), E->getNumExprs(),
true, Inits,
12417 return getDerived().RebuildParenListExpr(E->getLParenLoc(),
12419 E->getRParenLoc());
12427template<
typename Derived>
12429TreeTransform<Derived>::TransformAddrLabelExpr(AddrLabelExpr *E) {
12430 Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
12435 return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
12436 cast<LabelDecl>(LD));
12439template<
typename Derived>
12441TreeTransform<Derived>::TransformStmtExpr(StmtExpr *E) {
12444 = getDerived().TransformCompoundStmt(E->getSubStmt(),
true);
12445 if (SubStmt.isInvalid()) {
12450 unsigned OldDepth = E->getTemplateDepth();
12451 unsigned NewDepth = getDerived().TransformTemplateDepth(OldDepth);
12453 if (!getDerived().AlwaysRebuild() && OldDepth == NewDepth &&
12454 SubStmt.get() == E->getSubStmt()) {
12460 return getDerived().RebuildStmtExpr(E->getLParenLoc(), SubStmt.get(),
12461 E->getRParenLoc(), NewDepth);
12464template<
typename Derived>
12466TreeTransform<Derived>::TransformChooseExpr(ChooseExpr *E) {
12467 ExprResult Cond = getDerived().TransformExpr(E->getCond());
12468 if (Cond.isInvalid())
12471 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
12472 if (LHS.isInvalid())
12475 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
12476 if (RHS.isInvalid())
12479 if (!getDerived().AlwaysRebuild() &&
12480 Cond.get() == E->getCond() &&
12481 LHS.get() == E->getLHS() &&
12482 RHS.get() == E->getRHS())
12485 return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
12486 Cond.get(), LHS.get(), RHS.get(),
12487 E->getRParenLoc());
12490template<
typename Derived>
12492TreeTransform<Derived>::TransformGNUNullExpr(GNUNullExpr *E) {
12496template<
typename Derived>
12498TreeTransform<Derived>::TransformCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
12499 switch (E->getOperator()) {
12503 case OO_Array_Delete:
12504 llvm_unreachable(
"new and delete operators cannot use CXXOperatorCallExpr");
12509 assert(E->getNumArgs() >= 1 &&
"Object call is missing arguments");
12518 static_cast<Expr *
>(
Object.get())->getEndLoc());
12522 if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1,
true,
12526 if (E->getOperator() == OO_Subscript)
12527 return getDerived().RebuildCxxSubscriptExpr(
Object.get(), FakeLParenLoc,
12528 Args, E->getEndLoc());
12530 return getDerived().RebuildCallExpr(
Object.get(), FakeLParenLoc, Args,
12534#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
12538#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
12539#include "clang/Basic/OperatorKinds.def"
12541 case OO_Conditional:
12542 llvm_unreachable(
"conditional operator is not actually overloadable");
12546 llvm_unreachable(
"not an overloaded operator?");
12550 if (E->getOperator() == OO_Amp)
12551 First = getDerived().TransformAddressOfOperand(E->getArg(0));
12553 First = getDerived().TransformExpr(E->getArg(0));
12554 if (
First.isInvalid())
12558 if (E->getNumArgs() == 2) {
12560 getDerived().TransformInitializer(E->getArg(1),
false);
12561 if (Second.isInvalid())
12565 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
12566 FPOptionsOverride NewOverrides(E->getFPFeatures());
12567 getSema().CurFPFeatures =
12568 NewOverrides.applyOverrides(getSema().getLangOpts());
12569 getSema().FpPragmaStack.CurrentValue = NewOverrides;
12571 Expr *
Callee = E->getCallee();
12572 if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
12573 LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
12575 if (getDerived().TransformOverloadExprDecls(ULE, ULE->requiresADL(), R))
12578 return getDerived().RebuildCXXOperatorCallExpr(
12579 E->getOperator(), E->getOperatorLoc(),
Callee->getBeginLoc(),
12580 ULE->requiresADL(), R.asUnresolvedSet(),
First.get(), Second.get());
12583 UnresolvedSet<1> Functions;
12584 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Callee))
12585 Callee = ICE->getSubExprAsWritten();
12586 NamedDecl *DR = cast<DeclRefExpr>(Callee)->getDecl();
12587 ValueDecl *VD = cast_or_null<ValueDecl>(
12588 getDerived().TransformDecl(DR->getLocation(), DR));
12592 if (!isa<CXXMethodDecl>(VD))
12593 Functions.addDecl(VD);
12595 return getDerived().RebuildCXXOperatorCallExpr(
12596 E->getOperator(), E->getOperatorLoc(),
Callee->getBeginLoc(),
12597 false, Functions,
First.get(), Second.get());
12600template<
typename Derived>
12602TreeTransform<Derived>::TransformCXXMemberCallExpr(CXXMemberCallExpr *E) {
12603 return getDerived().TransformCallExpr(E);
12606template <
typename Derived>
12607ExprResult TreeTransform<Derived>::TransformSourceLocExpr(SourceLocExpr *E) {
12609 getSema().CurContext != E->getParentContext();
12611 if (!getDerived().AlwaysRebuild() && !NeedRebuildFunc)
12614 return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getType(),
12615 E->getBeginLoc(), E->getEndLoc(),
12616 getSema().CurContext);
12619template<
typename Derived>
12621TreeTransform<Derived>::TransformCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
12628 ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
12629 if (EC.isInvalid())
12633 bool ArgChanged =
false;
12635 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(),
true, Args,
12639 if (!getDerived().AlwaysRebuild() &&
12640 Callee.get() == E->getCallee() &&
12645 SourceLocation FakeLParenLoc
12647 return getDerived().RebuildCallExpr(
Callee.get(), FakeLParenLoc,
12649 E->getRParenLoc(), EC.get());
12652template<
typename Derived>
12664 if (!getDerived().AlwaysRebuild() &&
12668 return getDerived().RebuildCXXNamedCastExpr(
12675template<
typename Derived>
12684 if (Sub.isInvalid())
12687 return getDerived().RebuildBuiltinBitCastExpr(BCE->
getBeginLoc(), TSI,
12691template<
typename Derived>
12693TreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) {
12694 return getDerived().TransformCXXNamedCastExpr(E);
12697template<
typename Derived>
12699TreeTransform<Derived>::TransformCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
12700 return getDerived().TransformCXXNamedCastExpr(E);
12703template<
typename Derived>
12705TreeTransform<Derived>::TransformCXXReinterpretCastExpr(
12706 CXXReinterpretCastExpr *E) {
12707 return getDerived().TransformCXXNamedCastExpr(E);
12710template<
typename Derived>
12712TreeTransform<Derived>::TransformCXXConstCastExpr(CXXConstCastExpr *E) {
12713 return getDerived().TransformCXXNamedCastExpr(E);
12716template<
typename Derived>
12718TreeTransform<Derived>::TransformCXXAddrspaceCastExpr(CXXAddrspaceCastExpr *E) {
12719 return getDerived().TransformCXXNamedCastExpr(E);
12722template<
typename Derived>
12724TreeTransform<Derived>::TransformCXXFunctionalCastExpr(
12725 CXXFunctionalCastExpr *E) {
12726 TypeSourceInfo *
Type =
12727 getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten());
12732 = getDerived().TransformExpr(E->getSubExprAsWritten());
12733 if (SubExpr.isInvalid())
12736 if (!getDerived().AlwaysRebuild() &&
12737 Type == E->getTypeInfoAsWritten() &&
12738 SubExpr.get() == E->getSubExpr())
12741 return getDerived().RebuildCXXFunctionalCastExpr(Type,
12745 E->isListInitialization());
12748template<
typename Derived>
12750TreeTransform<Derived>::TransformCXXTypeidExpr(CXXTypeidExpr *E) {
12751 if (E->isTypeOperand()) {
12752 TypeSourceInfo *TInfo
12753 = getDerived().TransformType(E->getTypeOperandSourceInfo());
12757 if (!getDerived().AlwaysRebuild() &&
12758 TInfo == E->getTypeOperandSourceInfo())
12761 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
12762 TInfo, E->getEndLoc());
12768 Expr *Op = E->getExprOperand();
12770 if (E->isGLValue())
12771 if (
auto *RecordT = Op->getType()->getAs<RecordType>())
12772 if (cast<CXXRecordDecl>(RecordT->getDecl())->isPolymorphic())
12775 EnterExpressionEvaluationContext
Unevaluated(SemaRef, EvalCtx,
12778 ExprResult SubExpr = getDerived().TransformExpr(Op);
12779 if (SubExpr.isInvalid())
12782 if (!getDerived().AlwaysRebuild() &&
12783 SubExpr.get() == E->getExprOperand())
12786 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
12787 SubExpr.get(), E->getEndLoc());
12790template<
typename Derived>
12792TreeTransform<Derived>::TransformCXXUuidofExpr(CXXUuidofExpr *E) {
12793 if (E->isTypeOperand()) {
12794 TypeSourceInfo *TInfo
12795 = getDerived().TransformType(E->getTypeOperandSourceInfo());
12799 if (!getDerived().AlwaysRebuild() &&
12800 TInfo == E->getTypeOperandSourceInfo())
12803 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
12804 TInfo, E->getEndLoc());
12810 ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
12811 if (SubExpr.isInvalid())
12814 if (!getDerived().AlwaysRebuild() &&
12815 SubExpr.get() == E->getExprOperand())
12818 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
12819 SubExpr.get(), E->getEndLoc());
12822template<
typename Derived>
12824TreeTransform<Derived>::TransformCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
12828template<
typename Derived>
12830TreeTransform<Derived>::TransformCXXNullPtrLiteralExpr(
12831 CXXNullPtrLiteralExpr *E) {
12835template<
typename Derived>
12837TreeTransform<Derived>::TransformCXXThisExpr(CXXThisExpr *E) {
12848 QualType
T = [&]() {
12849 auto &S = getSema();
12850 if (E->isCapturedByCopyInLambdaWithExplicitObjectParameter())
12853 return getDerived().TransformType(E->getType());
12857 if (!getDerived().AlwaysRebuild() &&
T == E->getType()) {
12860 getSema().MarkThisReferenced(E);
12864 return getDerived().RebuildCXXThisExpr(E->getBeginLoc(),
T, E->isImplicit());
12867template<
typename Derived>
12869TreeTransform<Derived>::TransformCXXThrowExpr(CXXThrowExpr *E) {
12870 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
12871 if (SubExpr.isInvalid())
12874 if (!getDerived().AlwaysRebuild() &&
12875 SubExpr.get() == E->getSubExpr())
12878 return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
12879 E->isThrownVariableInScope());
12882template<
typename Derived>
12884TreeTransform<Derived>::TransformCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
12885 ParmVarDecl *Param = cast_or_null<ParmVarDecl>(
12886 getDerived().TransformDecl(E->getBeginLoc(), E->getParam()));
12891 if (E->hasRewrittenInit()) {
12892 InitRes = getDerived().TransformExpr(E->getRewrittenExpr());
12893 if (InitRes.isInvalid())
12897 if (!getDerived().AlwaysRebuild() && Param == E->getParam() &&
12898 E->getUsedContext() == SemaRef.
CurContext &&
12899 InitRes.get() == E->getRewrittenExpr())
12902 return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param,
12906template<
typename Derived>
12908TreeTransform<Derived>::TransformCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
12909 FieldDecl *
Field = cast_or_null<FieldDecl>(
12910 getDerived().TransformDecl(E->getBeginLoc(), E->getField()));
12914 if (!getDerived().AlwaysRebuild() && Field == E->getField() &&
12918 return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field);
12921template<
typename Derived>
12923TreeTransform<Derived>::TransformCXXScalarValueInitExpr(
12924 CXXScalarValueInitExpr *E) {
12925 TypeSourceInfo *
T = getDerived().TransformType(E->getTypeSourceInfo());
12929 if (!getDerived().AlwaysRebuild() &&
12930 T == E->getTypeSourceInfo())
12933 return getDerived().RebuildCXXScalarValueInitExpr(
T,
12934 T->getTypeLoc().getEndLoc(),
12935 E->getRParenLoc());
12938template<
typename Derived>
12940TreeTransform<Derived>::TransformCXXNewExpr(CXXNewExpr *E) {
12942 TypeSourceInfo *AllocTypeInfo =
12943 getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo());
12944 if (!AllocTypeInfo)
12948 std::optional<Expr *> ArraySize;
12949 if (E->isArray()) {
12951 if (std::optional<Expr *> OldArraySize = E->getArraySize()) {
12952 NewArraySize = getDerived().TransformExpr(*OldArraySize);
12953 if (NewArraySize.isInvalid())
12956 ArraySize = NewArraySize.get();
12960 bool ArgumentChanged =
false;
12962 if (getDerived().TransformExprs(E->getPlacementArgs(),
12963 E->getNumPlacementArgs(),
true,
12964 PlacementArgs, &ArgumentChanged))
12968 Expr *OldInit = E->getInitializer();
12971 NewInit = getDerived().TransformInitializer(OldInit,
true);
12972 if (NewInit.isInvalid())
12976 FunctionDecl *OperatorNew =
nullptr;
12977 if (E->getOperatorNew()) {
12978 OperatorNew = cast_or_null<FunctionDecl>(
12979 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorNew()));
12984 FunctionDecl *OperatorDelete =
nullptr;
12985 if (E->getOperatorDelete()) {
12986 OperatorDelete = cast_or_null<FunctionDecl>(
12987 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
12988 if (!OperatorDelete)
12992 if (!getDerived().AlwaysRebuild() &&
12993 AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
12994 ArraySize == E->getArraySize() &&
12995 NewInit.get() == OldInit &&
12996 OperatorNew == E->getOperatorNew() &&
12997 OperatorDelete == E->getOperatorDelete() &&
12998 !ArgumentChanged) {
13003 if (OperatorDelete)
13006 if (E->isArray() && !E->getAllocatedType()->isDependentType()) {
13007 QualType ElementType
13009 if (
const RecordType *RecordT = ElementType->getAs<RecordType>()) {
13010 CXXRecordDecl *
Record = cast<CXXRecordDecl>(RecordT->getDecl());
13020 QualType AllocType = AllocTypeInfo->getType();
13030 }
else if (
const ConstantArrayType *ConsArrayT
13031 = dyn_cast<ConstantArrayType>(ArrayT)) {
13035 AllocType = ConsArrayT->getElementType();
13036 }
else if (
const DependentSizedArrayType *DepArrayT
13037 = dyn_cast<DependentSizedArrayType>(ArrayT)) {
13038 if (DepArrayT->getSizeExpr()) {
13039 ArraySize = DepArrayT->getSizeExpr();
13040 AllocType = DepArrayT->getElementType();
13045 return getDerived().RebuildCXXNewExpr(
13046 E->getBeginLoc(), E->isGlobalNew(),
13047 E->getBeginLoc(), PlacementArgs,
13048 E->getBeginLoc(), E->getTypeIdParens(), AllocType,
13049 AllocTypeInfo, ArraySize, E->getDirectInitRange(), NewInit.get());
13052template<
typename Derived>
13054TreeTransform<Derived>::TransformCXXDeleteExpr(CXXDeleteExpr *E) {
13060 FunctionDecl *OperatorDelete =
nullptr;
13061 if (E->getOperatorDelete()) {
13062 OperatorDelete = cast_or_null<FunctionDecl>(
13063 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
13064 if (!OperatorDelete)
13068 if (!getDerived().AlwaysRebuild() &&
13069 Operand.get() == E->getArgument() &&
13070 OperatorDelete == E->getOperatorDelete()) {
13073 if (OperatorDelete)
13076 if (!E->getArgument()->isTypeDependent()) {
13078 E->getDestroyedType());
13079 if (
const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) {
13080 CXXRecordDecl *
Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
13089 return getDerived().RebuildCXXDeleteExpr(
13090 E->getBeginLoc(), E->isGlobalDelete(), E->isArrayForm(),
Operand.get());
13093template<
typename Derived>
13095TreeTransform<Derived>::TransformCXXPseudoDestructorExpr(
13096 CXXPseudoDestructorExpr *E) {
13098 if (
Base.isInvalid())
13102 bool MayBePseudoDestructor =
false;
13104 E->getOperatorLoc(),
13105 E->isArrow()? tok::arrow : tok::period,
13107 MayBePseudoDestructor);
13108 if (
Base.isInvalid())
13111 QualType ObjectType = ObjectTypePtr.get();
13112 NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
13113 if (QualifierLoc) {
13115 = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
13120 SS.Adopt(QualifierLoc);
13122 PseudoDestructorTypeStorage Destroyed;
13123 if (E->getDestroyedTypeInfo()) {
13124 TypeSourceInfo *DestroyedTypeInfo
13125 = getDerived().TransformTypeInObjectScope(E->getDestroyedTypeInfo(),
13126 ObjectType,
nullptr, SS);
13127 if (!DestroyedTypeInfo)
13129 Destroyed = DestroyedTypeInfo;
13130 }
else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
13133 Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(),
13134 E->getDestroyedTypeLoc());
13138 *E->getDestroyedTypeIdentifier(), E->getDestroyedTypeLoc(),
13139 nullptr, SS, ObjectTypePtr,
false);
13145 E->getDestroyedTypeLoc());
13148 TypeSourceInfo *ScopeTypeInfo =
nullptr;
13149 if (E->getScopeTypeInfo()) {
13150 CXXScopeSpec EmptySS;
13151 ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
13152 E->getScopeTypeInfo(), ObjectType,
nullptr, EmptySS);
13153 if (!ScopeTypeInfo)
13157 return getDerived().RebuildCXXPseudoDestructorExpr(
Base.get(),
13158 E->getOperatorLoc(),
13162 E->getColonColonLoc(),
13167template <
typename Derived>
13172 bool AllEmptyPacks =
true;
13173 for (
auto *OldD : Old->
decls()) {
13174 Decl *InstD = getDerived().TransformDecl(Old->
getNameLoc(), OldD);
13178 if (isa<UsingShadowDecl>(OldD))
13187 NamedDecl *SingleDecl = cast<NamedDecl>(InstD);
13189 if (
auto *UPD = dyn_cast<UsingPackDecl>(InstD))
13190 Decls = UPD->expansions();
13193 for (
auto *D : Decls) {
13194 if (
auto *UD = dyn_cast<UsingDecl>(D)) {
13195 for (
auto *SD : UD->shadows())
13202 AllEmptyPacks &= Decls.empty();
13211 if (AllEmptyPacks && !RequiresADL) {
13212 getSema().Diag(Old->
getNameLoc(), diag::err_using_pack_expansion_empty)
13213 << isa<UnresolvedMemberExpr>(Old) << Old->
getName();
13223template <
typename Derived>
13226 return TransformUnresolvedLookupExpr(Old,
false);
13229template <
typename Derived>
13232 bool IsAddressOfOperand) {
13237 if (TransformOverloadExprDecls(Old, Old->
requiresADL(), R))
13244 = getDerived().TransformNestedNameSpecifierLoc(Old->
getQualifierLoc());
13248 SS.
Adopt(QualifierLoc);
13252 CXXRecordDecl *NamingClass
13253 = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
13256 if (!NamingClass) {
13261 R.setNamingClass(NamingClass);
13282 SS, TemplateKWLoc, R,
13289 return getDerived().RebuildDeclarationNameExpr(SS, R, Old->
requiresADL());
13292 return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
13296template<
typename Derived>
13298TreeTransform<Derived>::TransformTypeTraitExpr(TypeTraitExpr *E) {
13299 bool ArgChanged =
false;
13301 for (
unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
13302 TypeSourceInfo *From = E->getArg(I);
13303 TypeLoc FromTL = From->getTypeLoc();
13304 if (!FromTL.getAs<PackExpansionTypeLoc>()) {
13305 TypeLocBuilder TLB;
13306 TLB.reserve(FromTL.getFullDataSize());
13307 QualType To = getDerived().TransformType(TLB, FromTL);
13311 if (To == From->getType())
13312 Args.push_back(From);
13314 Args.push_back(TLB.getTypeSourceInfo(SemaRef.
Context, To));
13323 PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>();
13324 TypeLoc PatternTL = ExpansionTL.getPatternLoc();
13330 bool Expand =
true;
13331 bool RetainExpansion =
false;
13332 std::optional<unsigned> OrigNumExpansions =
13333 ExpansionTL.getTypePtr()->getNumExpansions();
13334 std::optional<unsigned> NumExpansions = OrigNumExpansions;
13335 if (getDerived().TryExpandParameterPacks(ExpansionTL.getEllipsisLoc(),
13336 PatternTL.getSourceRange(),
13338 Expand, RetainExpansion,
13346 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
13348 TypeLocBuilder TLB;
13349 TLB.reserve(From->getTypeLoc().getFullDataSize());
13351 QualType To = getDerived().TransformType(TLB, PatternTL);
13355 To = getDerived().RebuildPackExpansionType(To,
13356 PatternTL.getSourceRange(),
13357 ExpansionTL.getEllipsisLoc(),
13362 PackExpansionTypeLoc ToExpansionTL
13363 = TLB.push<PackExpansionTypeLoc>(To);
13364 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
13365 Args.push_back(TLB.getTypeSourceInfo(SemaRef.
Context, To));
13371 for (
unsigned I = 0; I != *NumExpansions; ++I) {
13372 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(SemaRef, I);
13373 TypeLocBuilder TLB;
13374 TLB.reserve(PatternTL.getFullDataSize());
13375 QualType To = getDerived().TransformType(TLB, PatternTL);
13379 if (To->containsUnexpandedParameterPack()) {
13380 To = getDerived().RebuildPackExpansionType(To,
13381 PatternTL.getSourceRange(),
13382 ExpansionTL.getEllipsisLoc(),
13387 PackExpansionTypeLoc ToExpansionTL
13388 = TLB.push<PackExpansionTypeLoc>(To);
13389 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
13392 Args.push_back(TLB.getTypeSourceInfo(SemaRef.
Context, To));
13395 if (!RetainExpansion)
13400 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
13402 TypeLocBuilder TLB;
13403 TLB.reserve(From->getTypeLoc().getFullDataSize());
13405 QualType To = getDerived().TransformType(TLB, PatternTL);
13409 To = getDerived().RebuildPackExpansionType(To,
13410 PatternTL.getSourceRange(),
13411 ExpansionTL.getEllipsisLoc(),
13416 PackExpansionTypeLoc ToExpansionTL
13417 = TLB.push<PackExpansionTypeLoc>(To);
13418 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
13419 Args.push_back(TLB.getTypeSourceInfo(SemaRef.
Context, To));
13422 if (!getDerived().AlwaysRebuild() && !ArgChanged)
13425 return getDerived().RebuildTypeTrait(E->getTrait(), E->getBeginLoc(), Args,
13429template<
typename Derived>
13431TreeTransform<Derived>::TransformConceptSpecializationExpr(
13432 ConceptSpecializationExpr *E) {
13433 const ASTTemplateArgumentListInfo *Old = E->getTemplateArgsAsWritten();
13434 TemplateArgumentListInfo TransArgs(Old->LAngleLoc, Old->RAngleLoc);
13435 if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
13436 Old->NumTemplateArgs, TransArgs))
13439 return getDerived().RebuildConceptSpecializationExpr(
13440 E->getNestedNameSpecifierLoc(), E->getTemplateKWLoc(),
13441 E->getConceptNameInfo(), E->getFoundDecl(), E->getNamedConcept(),
13445template<
typename Derived>
13447TreeTransform<Derived>::TransformRequiresExpr(RequiresExpr *E) {
13450 Sema::ExtParameterInfoBuilder ExtParamInfos;
13454 EnterExpressionEvaluationContext Ctx(
13459 getSema().Context, getSema().CurContext,
13460 E->getBody()->getBeginLoc());
13462 Sema::ContextRAII SavedContext(getSema(), Body,
false);
13464 ExprResult TypeParamResult = getDerived().TransformRequiresTypeParams(
13465 E->getRequiresKWLoc(), E->getRBraceLoc(), E, Body,
13466 E->getLocalParameters(), TransParamTypes, TransParams, ExtParamInfos);
13468 for (ParmVarDecl *Param : TransParams)
13470 Param->setDeclContext(Body);
13476 if (!TypeParamResult.isUnset())
13477 return TypeParamResult;
13480 if (getDerived().TransformRequiresExprRequirements(E->getRequirements(),
13484 for (concepts::Requirement *Req : TransReqs) {
13485 if (
auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
13486 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
13487 ER->getReturnTypeRequirement()
13488 .getTypeConstraintTemplateParameterList()->getParam(0)
13489 ->setDeclContext(Body);
13494 return getDerived().RebuildRequiresExpr(
13495 E->getRequiresKWLoc(), Body, E->getLParenLoc(), TransParams,
13496 E->getRParenLoc(), TransReqs, E->getRBraceLoc());
13499template<
typename Derived>
13505 if (
auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
13506 TransReq = getDerived().TransformTypeRequirement(TypeReq);
13507 else if (
auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
13508 TransReq = getDerived().TransformExprRequirement(ExprReq);
13510 TransReq = getDerived().TransformNestedRequirement(
13511 cast<concepts::NestedRequirement>(Req));
13514 Transformed.push_back(TransReq);
13519template<
typename Derived>
13524 if (getDerived().AlwaysRebuild())
13525 return getDerived().RebuildTypeRequirement(
13532 return getDerived().RebuildTypeRequirement(TransType);
13535template<
typename Derived>
13538 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *> TransExpr;
13547 TransExpr = TransExprRes.
get();
13550 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> TransRetReq;
13552 if (RetReq.isEmpty())
13553 TransRetReq.emplace();
13554 else if (RetReq.isSubstitutionFailure())
13555 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
13556 else if (RetReq.isTypeConstraint()) {
13558 RetReq.getTypeConstraintTemplateParameterList();
13560 getDerived().TransformTemplateParameterList(OrigTPL);
13563 TransRetReq.emplace(TPL);
13565 assert(TransRetReq &&
"All code paths leading here must set TransRetReq");
13566 if (
Expr *E = TransExpr.dyn_cast<
Expr *>())
13567 return getDerived().RebuildExprRequirement(E, Req->
isSimple(),
13569 std::move(*TransRetReq));
13570 return getDerived().RebuildExprRequirement(
13575template<
typename Derived>
13580 if (getDerived().AlwaysRebuild())
13581 return getDerived().RebuildNestedRequirement(
13589 return getDerived().RebuildNestedRequirement(TransConstraint.
get());
13592template<
typename Derived>
13599 if (!getDerived().AlwaysRebuild() &&
13619template<
typename Derived>
13621TreeTransform<Derived>::TransformExpressionTraitExpr(ExpressionTraitExpr *E) {
13626 SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
13627 if (SubExpr.isInvalid())
13630 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
13634 return getDerived().RebuildExpressionTrait(E->getTrait(), E->getBeginLoc(),
13635 SubExpr.get(), E->getEndLoc());
13638template <
typename Derived>
13642 ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr(
13643 DRE, AddrTaken, RecoveryTSI);
13650 if (!getDerived().AlwaysRebuild() && NewDRE.
get() == DRE)
13652 return getDerived().RebuildParenExpr(NewDRE.
get(), PE->
getLParen(),
13656template <
typename Derived>
13659 return TransformDependentScopeDeclRefExpr(E,
false,
13663template <
typename Derived>
13679 getDerived().TransformDeclarationNameInfo(E->
getNameInfo());
13684 if (!getDerived().AlwaysRebuild() && QualifierLoc == E->
getQualifierLoc() &&
13690 return getDerived().RebuildDependentScopeDeclRefExpr(
13691 QualifierLoc, TemplateKWLoc, NameInfo,
nullptr,
13692 IsAddressOfOperand, RecoveryTSI);
13696 if (getDerived().TransformTemplateArguments(
13700 return getDerived().RebuildDependentScopeDeclRefExpr(
13701 QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand,
13705template<
typename Derived>
13707TreeTransform<Derived>::TransformCXXConstructExpr(CXXConstructExpr *E) {
13711 if (getDerived().AllowSkippingCXXConstructExpr() &&
13712 ((E->getNumArgs() == 1 ||
13713 (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) &&
13714 (!getDerived().DropCallArgument(E->getArg(0))) &&
13715 !E->isListInitialization()))
13716 return getDerived().TransformInitializer(E->getArg(0),
13719 TemporaryBase Rebase(*
this, E->getBeginLoc(), DeclarationName());
13721 QualType
T = getDerived().TransformType(E->getType());
13725 CXXConstructorDecl *
Constructor = cast_or_null<CXXConstructorDecl>(
13726 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
13730 bool ArgumentChanged =
false;
13733 EnterExpressionEvaluationContext Context(
13735 E->isListInitialization());
13736 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(),
true, Args,
13741 if (!getDerived().AlwaysRebuild() &&
13742 T == E->getType() &&
13743 Constructor == E->getConstructor() &&
13744 !ArgumentChanged) {
13751 return getDerived().RebuildCXXConstructExpr(
13752 T, E->getBeginLoc(), Constructor, E->isElidable(), Args,
13753 E->hadMultipleCandidates(), E->isListInitialization(),
13754 E->isStdInitListInitialization(), E->requiresZeroInitialization(),
13755 E->getConstructionKind(), E->getParenOrBraceRange());
13758template<
typename Derived>
13759ExprResult TreeTransform<Derived>::TransformCXXInheritedCtorInitExpr(
13760 CXXInheritedCtorInitExpr *E) {
13761 QualType
T = getDerived().TransformType(E->getType());
13765 CXXConstructorDecl *
Constructor = cast_or_null<CXXConstructorDecl>(
13766 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
13770 if (!getDerived().AlwaysRebuild() &&
13771 T == E->getType() &&
13772 Constructor == E->getConstructor()) {
13779 return getDerived().RebuildCXXInheritedCtorInitExpr(
13780 T, E->getLocation(), Constructor,
13781 E->constructsVBase(), E->inheritedFromVBase());
13788template<
typename Derived>
13790TreeTransform<Derived>::TransformCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
13791 if (
auto *Dtor = E->getTemporary()->getDestructor())
13793 const_cast<CXXDestructorDecl *
>(Dtor));
13794 return getDerived().TransformExpr(E->getSubExpr());
13802template<
typename Derived>
13804TreeTransform<Derived>::TransformExprWithCleanups(ExprWithCleanups *E) {
13805 return getDerived().TransformExpr(E->getSubExpr());
13808template<
typename Derived>
13810TreeTransform<Derived>::TransformCXXTemporaryObjectExpr(
13811 CXXTemporaryObjectExpr *E) {
13812 TypeSourceInfo *
T =
13813 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
13817 CXXConstructorDecl *
Constructor = cast_or_null<CXXConstructorDecl>(
13818 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
13822 bool ArgumentChanged =
false;
13824 Args.reserve(E->getNumArgs());
13826 EnterExpressionEvaluationContext Context(
13828 E->isListInitialization());
13829 if (TransformExprs(E->getArgs(), E->getNumArgs(),
true, Args,
13834 if (!getDerived().AlwaysRebuild() &&
13835 T == E->getTypeSourceInfo() &&
13836 Constructor == E->getConstructor() &&
13837 !ArgumentChanged) {
13845 SourceLocation LParenLoc =
T->getTypeLoc().getEndLoc();
13846 return getDerived().RebuildCXXTemporaryObjectExpr(
13847 T, LParenLoc, Args, E->getEndLoc(),
13848 LParenLoc.isInvalid());
13851template<
typename Derived>
13853TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
13856 typedef std::pair<ExprResult, QualType> InitCaptureInfoTy;
13857 struct TransformedInitCapture {
13859 SourceLocation EllipsisLoc;
13864 InitCaptures.resize(E->explicit_capture_end() - E->explicit_capture_begin());
13866 CEnd = E->capture_end();
13868 if (!E->isInitCapture(
C))
13871 TransformedInitCapture &
Result = InitCaptures[
C - E->capture_begin()];
13872 auto *OldVD = cast<VarDecl>(
C->getCapturedVar());
13874 auto SubstInitCapture = [&](SourceLocation EllipsisLoc,
13875 std::optional<unsigned> NumExpansions) {
13876 ExprResult NewExprInitResult = getDerived().TransformInitializer(
13879 if (NewExprInitResult.isInvalid()) {
13880 Result.Expansions.push_back(InitCaptureInfoTy(
ExprError(), QualType()));
13883 Expr *NewExprInit = NewExprInitResult.get();
13885 QualType NewInitCaptureType =
13886 getSema().buildLambdaInitCaptureInitialization(
13887 C->getLocation(),
C->getCaptureKind() ==
LCK_ByRef,
13888 EllipsisLoc, NumExpansions, OldVD->getIdentifier(),
13889 cast<VarDecl>(
C->getCapturedVar())->getInitStyle() !=
13892 Result.Expansions.push_back(
13893 InitCaptureInfoTy(NewExprInit, NewInitCaptureType));
13897 if (OldVD->isParameterPack()) {
13898 PackExpansionTypeLoc ExpansionTL = OldVD->getTypeSourceInfo()
13900 .castAs<PackExpansionTypeLoc>();
13906 bool Expand =
true;
13907 bool RetainExpansion =
false;
13908 std::optional<unsigned> OrigNumExpansions =
13909 ExpansionTL.getTypePtr()->getNumExpansions();
13910 std::optional<unsigned> NumExpansions = OrigNumExpansions;
13911 if (getDerived().TryExpandParameterPacks(
13912 ExpansionTL.getEllipsisLoc(),
13913 OldVD->getInit()->getSourceRange(), Unexpanded, Expand,
13914 RetainExpansion, NumExpansions))
13917 for (
unsigned I = 0; I != *NumExpansions; ++I) {
13918 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
13919 SubstInitCapture(SourceLocation(), std::nullopt);
13922 if (!Expand || RetainExpansion) {
13923 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
13924 SubstInitCapture(ExpansionTL.getEllipsisLoc(), NumExpansions);
13925 Result.EllipsisLoc = ExpansionTL.getEllipsisLoc();
13928 SubstInitCapture(SourceLocation(), std::nullopt);
13932 LambdaScopeInfo *LSI = getSema().PushLambdaScope();
13933 Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
13944 DeclContext *DC = getSema().CurContext;
13962 while (DC->getDeclKind() == Decl::Kind::RequiresExprBody)
13963 DC = DC->getParent();
13964 if ((getSema().isUnevaluatedContext() ||
13965 getSema().isConstantEvaluatedContext()) &&
13966 (DC->isFileContext() || !DC->getParent()->isDependentContext()))
13969 CXXRecordDecl *OldClass = E->getLambdaClass();
13970 CXXRecordDecl *
Class = getSema().createLambdaClosureType(
13971 E->getIntroducerRange(),
nullptr, DependencyKind,
13972 E->getCaptureDefault());
13973 getDerived().transformedLocalDecl(OldClass, {
Class});
13975 CXXMethodDecl *NewCallOperator =
13976 getSema().CreateLambdaCallOperator(E->getIntroducerRange(),
Class);
13977 NewCallOperator->setLexicalDeclContext(getSema().CurContext);
13980 getSema().buildLambdaScope(LSI, NewCallOperator, E->getIntroducerRange(),
13981 E->getCaptureDefault(), E->getCaptureDefaultLoc(),
13982 E->hasExplicitParameters(), E->isMutable());
13985 Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
13992 CEnd = E->capture_end();
13996 if (
C->isImplicit())
14000 if (
C->capturesThis()) {
14006 Sema::CXXThisScopeRAII ThisScope(
14008 dyn_cast_if_present<CXXRecordDecl>(
14009 getSema().getFunctionLevelDeclContext()),
14011 getSema().CheckCXXThisCapture(
C->getLocation(),
C->isExplicit(),
14018 if (
C->capturesVLAType())
14022 if (E->isInitCapture(
C)) {
14023 TransformedInitCapture &NewC = InitCaptures[
C - E->capture_begin()];
14025 auto *OldVD = cast<VarDecl>(
C->getCapturedVar());
14028 for (InitCaptureInfoTy &Info : NewC.Expansions) {
14030 QualType InitQualType = Info.second;
14031 if (
Init.isInvalid() || InitQualType.isNull()) {
14035 VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl(
14036 OldVD->getLocation(), InitQualType, NewC.EllipsisLoc,
14037 OldVD->getIdentifier(), OldVD->getInitStyle(),
Init.get(),
14038 getSema().CurContext);
14043 NewVDs.push_back(NewVD);
14044 getSema().addInitCapture(LSI, NewVD,
C->getCaptureKind() ==
LCK_ByRef);
14050 getDerived().transformedLocalDecl(OldVD, NewVDs);
14054 assert(
C->capturesVariable() &&
"unexpected kind of lambda capture");
14062 SourceLocation EllipsisLoc;
14063 if (
C->isPackExpansion()) {
14065 bool ShouldExpand =
false;
14066 bool RetainExpansion =
false;
14067 std::optional<unsigned> NumExpansions;
14068 if (getDerived().TryExpandParameterPacks(
C->getEllipsisLoc(),
14071 ShouldExpand, RetainExpansion,
14077 if (ShouldExpand) {
14081 auto *Pack = cast<VarDecl>(
C->getCapturedVar());
14082 for (
unsigned I = 0; I != *NumExpansions; ++I) {
14083 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
14084 VarDecl *CapturedVar
14085 = cast_or_null<VarDecl>(getDerived().TransformDecl(
C->getLocation(),
14087 if (!CapturedVar) {
14093 getSema().tryCaptureVariable(CapturedVar,
C->getLocation(), Kind);
14101 EllipsisLoc =
C->getEllipsisLoc();
14105 auto *CapturedVar = cast_or_null<ValueDecl>(
14106 getDerived().TransformDecl(
C->getLocation(),
C->getCapturedVar()));
14107 if (!CapturedVar || CapturedVar->isInvalidDecl()) {
14113 getSema().tryCaptureVariable(CapturedVar,
C->getLocation(), Kind,
14116 getSema().finishLambdaExplicitCaptures(LSI);
14120 auto TPL = getDerived().TransformTemplateParameterList(
14121 E->getTemplateParameterList());
14122 LSI->GLTemplateParameterList = TPL;
14124 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator,
Class,
14131 TypeSourceInfo *NewCallOpTSI =
nullptr;
14133 auto OldCallOpTypeLoc =
14134 E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
14136 auto TransformFunctionProtoTypeLoc =
14137 [
this](TypeLocBuilder &TLB, FunctionProtoTypeLoc FPTL) -> QualType {
14139 return this->TransformFunctionProtoType(
14140 TLB, FPTL,
nullptr, Qualifiers(),
14141 [&](FunctionProtoType::ExceptionSpecInfo &ESI,
bool &Changed) {
14142 return TransformExceptionSpec(FPTL.getBeginLoc(), ESI,
14143 ExceptionStorage, Changed);
14147 QualType NewCallOpType;
14148 TypeLocBuilder NewCallOpTLBuilder;
14150 if (
auto ATL = OldCallOpTypeLoc.getAs<AttributedTypeLoc>()) {
14151 NewCallOpType = this->TransformAttributedType(
14152 NewCallOpTLBuilder, ATL,
14153 [&](TypeLocBuilder &TLB, TypeLoc TL) -> QualType {
14154 return TransformFunctionProtoTypeLoc(
14155 TLB, TL.castAs<FunctionProtoTypeLoc>());
14158 auto FPTL = OldCallOpTypeLoc.castAs<FunctionProtoTypeLoc>();
14159 NewCallOpType = TransformFunctionProtoTypeLoc(NewCallOpTLBuilder, FPTL);
14162 if (NewCallOpType.isNull())
14165 NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context, NewCallOpType);
14169 if (
auto ATL = NewCallOpTSI->getTypeLoc().getAs<AttributedTypeLoc>()) {
14170 Params = ATL.getModifiedLoc().castAs<FunctionProtoTypeLoc>().getParams();
14172 auto FPTL = NewCallOpTSI->getTypeLoc().castAs<FunctionProtoTypeLoc>();
14173 Params = FPTL.getParams();
14176 getSema().CompleteLambdaCallOperator(
14177 NewCallOperator, E->getCallOperator()->getLocation(),
14178 E->getCallOperator()->getInnerLocStart(),
14179 E->getCallOperator()->getTrailingRequiresClause(), NewCallOpTSI,
14180 E->getCallOperator()->getConstexprKind(),
14181 E->getCallOperator()->getStorageClass(), Params,
14182 E->hasExplicitResultType());
14184 getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
14185 getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
14189 Sema::ContextRAII ManglingContext(getSema(),
Class->getDeclContext());
14191 std::optional<CXXRecordDecl::LambdaNumbering> Numbering;
14192 if (getDerived().ReplacingOriginal()) {
14193 Numbering = OldClass->getLambdaNumbering();
14196 getSema().handleLambdaNumbering(
Class, NewCallOperator, Numbering);
14201 getSema().PushExpressionEvaluationContext(
14202 E->getCallOperator()->isConsteval() ?
14206 Sema::CodeSynthesisContext
C;
14208 C.PointOfInstantiation = E->getBody()->getBeginLoc();
14209 getSema().pushCodeSynthesisContext(
C);
14213 Invalid ?
StmtError() : getDerived().TransformLambdaBody(E, E->getBody());
14215 getSema().popCodeSynthesisContext();
14218 FuncScopeCleanup.disable();
14220 if (Body.isInvalid()) {
14221 SavedContext.pop();
14222 getSema().ActOnLambdaError(E->getBeginLoc(),
nullptr,
14230 auto LSICopy = *LSI;
14231 getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(),
14233 SavedContext.pop();
14268 DependencyKind = getDerived().ComputeLambdaDependency(&LSICopy);
14269 Class->setLambdaDependencyKind(DependencyKind);
14272 Class->setTypeForDecl(
nullptr);
14273 getSema().Context.getTypeDeclType(
Class);
14275 return getSema().BuildLambdaExpr(E->getBeginLoc(), Body.get()->getEndLoc(),
14279template<
typename Derived>
14282 return TransformStmt(S);
14285template<
typename Derived>
14294 if (!
C->isImplicit())
14298 if (
C->capturesThis()) {
14299 getSema().CheckCXXThisCapture(
C->getLocation(),
C->isExplicit(),
14306 if (
C->capturesVLAType())
14309 assert(
C->capturesVariable() &&
"unexpected kind of lambda capture");
14313 VarDecl *CapturedVar = cast_or_null<VarDecl>(
14314 getDerived().TransformDecl(
C->getLocation(),
C->getCapturedVar()));
14319 getSema().tryCaptureVariable(CapturedVar,
C->getLocation());
14325template<
typename Derived>
14334 bool ArgumentChanged =
false;
14346 if (!getDerived().AlwaysRebuild() &&
14352 return getDerived().RebuildCXXUnresolvedConstructExpr(
14356template<
typename Derived>
14358TreeTransform<Derived>::TransformCXXDependentScopeMemberExpr(
14359 CXXDependentScopeMemberExpr *E) {
14364 QualType ObjectType;
14365 if (!E->isImplicitAccess()) {
14366 OldBase = E->getBase();
14367 Base = getDerived().TransformExpr(OldBase);
14368 if (
Base.isInvalid())
14373 bool MayBePseudoDestructor =
false;
14375 E->getOperatorLoc(),
14376 E->isArrow()? tok::arrow : tok::period,
14378 MayBePseudoDestructor);
14379 if (
Base.isInvalid())
14382 ObjectType = ObjectTy.get();
14383 BaseType = ((Expr*)
Base.get())->getType();
14386 BaseType = getDerived().TransformType(E->getBaseType());
14387 ObjectType = BaseType->castAs<PointerType>()->getPointeeType();
14392 NamedDecl *FirstQualifierInScope
14393 = getDerived().TransformFirstQualifierInScope(
14394 E->getFirstQualifierFoundInScope(),
14395 E->getQualifierLoc().getBeginLoc());
14397 NestedNameSpecifierLoc QualifierLoc;
14398 if (E->getQualifier()) {
14400 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
14402 FirstQualifierInScope);
14407 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
14413 DeclarationNameInfo NameInfo
14414 = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
14415 if (!NameInfo.getName())
14418 if (!E->hasExplicitTemplateArgs()) {
14421 if (!getDerived().AlwaysRebuild() &&
14422 Base.get() == OldBase &&
14423 BaseType == E->getBaseType() &&
14424 QualifierLoc == E->getQualifierLoc() &&
14425 NameInfo.getName() == E->getMember() &&
14426 FirstQualifierInScope == E->getFirstQualifierFoundInScope())
14429 return getDerived().RebuildCXXDependentScopeMemberExpr(
Base.get(),
14432 E->getOperatorLoc(),
14435 FirstQualifierInScope,
14440 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
14441 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
14442 E->getNumTemplateArgs(),
14446 return getDerived().RebuildCXXDependentScopeMemberExpr(
Base.get(),
14449 E->getOperatorLoc(),
14452 FirstQualifierInScope,
14457template <
typename Derived>
14458ExprResult TreeTransform<Derived>::TransformUnresolvedMemberExpr(
14459 UnresolvedMemberExpr *Old) {
14463 if (!Old->isImplicitAccess()) {
14464 Base = getDerived().TransformExpr(Old->getBase());
14465 if (
Base.isInvalid())
14468 getSema().PerformMemberExprBaseConversion(
Base.get(), Old->isArrow());
14469 if (
Base.isInvalid())
14471 BaseType =
Base.get()->getType();
14473 BaseType = getDerived().TransformType(Old->getBaseType());
14476 NestedNameSpecifierLoc QualifierLoc;
14477 if (Old->getQualifierLoc()) {
14479 getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
14484 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
14489 if (TransformOverloadExprDecls(Old,
false, R))
14493 if (Old->getNamingClass()) {
14494 CXXRecordDecl *NamingClass = cast_or_null<CXXRecordDecl>(
14495 getDerived().TransformDecl(Old->getMemberLoc(), Old->getNamingClass()));
14499 R.setNamingClass(NamingClass);
14502 TemplateArgumentListInfo TransArgs;
14503 if (Old->hasExplicitTemplateArgs()) {
14504 TransArgs.setLAngleLoc(Old->getLAngleLoc());
14505 TransArgs.setRAngleLoc(Old->getRAngleLoc());
14506 if (getDerived().TransformTemplateArguments(
14507 Old->getTemplateArgs(), Old->getNumTemplateArgs(), TransArgs))
14515 NamedDecl *FirstQualifierInScope =
nullptr;
14517 return getDerived().RebuildUnresolvedMemberExpr(
14518 Base.get(), BaseType, Old->getOperatorLoc(), Old->isArrow(), QualifierLoc,
14519 TemplateKWLoc, FirstQualifierInScope, R,
14520 (Old->hasExplicitTemplateArgs() ? &TransArgs :
nullptr));
14523template<
typename Derived>
14525TreeTransform<Derived>::TransformCXXNoexceptExpr(CXXNoexceptExpr *E) {
14528 ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
14529 if (SubExpr.isInvalid())
14532 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
14535 return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
14538template<
typename Derived>
14540TreeTransform<Derived>::TransformPackExpansionExpr(PackExpansionExpr *E) {
14541 ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
14542 if (Pattern.isInvalid())
14545 if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
14548 return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
14549 E->getNumExpansions());
14552template<
typename Derived>
14554TreeTransform<Derived>::TransformSizeOfPackExpr(SizeOfPackExpr *E) {
14557 if (!E->isValueDependent())
14564 TemplateArgument ArgStorage;
14567 if (E->isPartiallySubstituted()) {
14568 PackArgs = E->getPartialArguments();
14569 }
else if (E->isValueDependent()) {
14571 bool ShouldExpand =
false;
14572 bool RetainExpansion =
false;
14573 std::optional<unsigned> NumExpansions;
14574 if (getDerived().TryExpandParameterPacks(E->getOperatorLoc(), E->getPackLoc(),
14576 ShouldExpand, RetainExpansion,
14582 if (ShouldExpand) {
14583 auto *Pack = E->getPack();
14584 if (
auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
14585 ArgStorage = getSema().Context.getPackExpansionType(
14587 }
else if (
auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
14588 ArgStorage = TemplateArgument(TemplateName(TTPD), std::nullopt);
14590 auto *VD = cast<ValueDecl>(Pack);
14591 ExprResult DRE = getSema().BuildDeclRefExpr(
14592 VD, VD->getType().getNonLValueExprType(getSema().Context),
14595 if (DRE.isInvalid())
14597 ArgStorage =
new (getSema().Context)
14598 PackExpansionExpr(getSema().Context.DependentTy, DRE.get(),
14599 E->getPackLoc(), std::nullopt);
14601 PackArgs = ArgStorage;
14606 if (!PackArgs.size()) {
14607 auto *Pack = cast_or_null<NamedDecl>(
14608 getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
14611 return getDerived().RebuildSizeOfPackExpr(
14612 E->getOperatorLoc(), Pack, E->getPackLoc(), E->getRParenLoc(),
14613 std::nullopt, std::nullopt);
14617 std::optional<unsigned>
Result = 0;
14618 for (
const TemplateArgument &Arg : PackArgs) {
14619 if (!Arg.isPackExpansion()) {
14624 TemplateArgumentLoc ArgLoc;
14625 InventTemplateArgumentLoc(Arg, ArgLoc);
14628 SourceLocation Ellipsis;
14629 std::optional<unsigned> OrigNumExpansions;
14630 TemplateArgumentLoc Pattern =
14631 getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis,
14632 OrigNumExpansions);
14635 TemplateArgumentLoc OutPattern;
14636 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
14637 if (getDerived().TransformTemplateArgument(Pattern, OutPattern,
14642 std::optional<unsigned> NumExpansions =
14643 getSema().getFullyPackExpandedSize(OutPattern.getArgument());
14644 if (!NumExpansions) {
14657 return getDerived().RebuildSizeOfPackExpr(
14658 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
14661 TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
14664 TemporaryBase Rebase(*
this, E->getPackLoc(), getBaseEntity());
14665 typedef TemplateArgumentLocInventIterator<
14666 Derived,
const TemplateArgument*> PackLocIterator;
14667 if (TransformTemplateArguments(PackLocIterator(*
this, PackArgs.begin()),
14668 PackLocIterator(*
this, PackArgs.end()),
14669 TransformedPackArgs,
true))
14676 bool PartialSubstitution =
false;
14677 for (
auto &Loc : TransformedPackArgs.arguments()) {
14678 Args.push_back(Loc.getArgument());
14679 if (Loc.getArgument().isPackExpansion())
14680 PartialSubstitution =
true;
14683 if (PartialSubstitution)
14684 return getDerived().RebuildSizeOfPackExpr(
14685 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
14686 std::nullopt, Args);
14688 return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
14689 E->getPackLoc(), E->getRParenLoc(),
14690 Args.size(), std::nullopt);
14693template <
typename Derived>
14695TreeTransform<Derived>::TransformPackIndexingExpr(PackIndexingExpr *E) {
14696 if (!E->isValueDependent())
14700 ExprResult IndexExpr = getDerived().TransformExpr(E->getIndexExpr());
14701 if (IndexExpr.isInvalid())
14705 if (E->getExpressions().empty()) {
14706 Expr *Pattern = E->getPackIdExpression();
14708 getSema().collectUnexpandedParameterPacks(E->getPackIdExpression(),
14710 assert(!Unexpanded.empty() &&
"Pack expansion without parameter packs?");
14714 bool ShouldExpand =
true;
14715 bool RetainExpansion =
false;
14716 std::optional<unsigned> OrigNumExpansions;
14717 std::optional<unsigned> NumExpansions = OrigNumExpansions;
14718 if (getDerived().TryExpandParameterPacks(
14719 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
14720 ShouldExpand, RetainExpansion, NumExpansions))
14722 if (!ShouldExpand) {
14723 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
14724 ExprResult Pack = getDerived().TransformExpr(Pattern);
14725 if (Pack.isInvalid())
14727 return getDerived().RebuildPackIndexingExpr(
14728 E->getEllipsisLoc(), E->getRSquareLoc(), Pack.get(), IndexExpr.get(),
14731 for (
unsigned I = 0; I != *NumExpansions; ++I) {
14732 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
14733 ExprResult Out = getDerived().TransformExpr(Pattern);
14734 if (Out.isInvalid())
14736 if (Out.get()->containsUnexpandedParameterPack()) {
14737 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
14738 OrigNumExpansions);
14739 if (Out.isInvalid())
14742 ExpandedExprs.push_back(Out.get());
14746 if (RetainExpansion) {
14747 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
14749 ExprResult Out = getDerived().TransformExpr(Pattern);
14750 if (Out.isInvalid())
14753 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
14754 OrigNumExpansions);
14755 if (Out.isInvalid())
14757 ExpandedExprs.push_back(Out.get());
14762 if (getDerived().TransformExprs(E->getExpressions().data(),
14763 E->getExpressions().size(),
false,
14768 return getDerived().RebuildPackIndexingExpr(
14769 E->getEllipsisLoc(), E->getRSquareLoc(), E->getPackIdExpression(),
14770 IndexExpr.get(), ExpandedExprs,
14771 ExpandedExprs.size() == 0);
14774template<
typename Derived>
14776TreeTransform<Derived>::TransformSubstNonTypeTemplateParmPackExpr(
14777 SubstNonTypeTemplateParmPackExpr *E) {
14782template<
typename Derived>
14784TreeTransform<Derived>::TransformSubstNonTypeTemplateParmExpr(
14785 SubstNonTypeTemplateParmExpr *E) {
14790template<
typename Derived>
14792TreeTransform<Derived>::TransformFunctionParmPackExpr(FunctionParmPackExpr *E) {
14797template<
typename Derived>
14799TreeTransform<Derived>::TransformMaterializeTemporaryExpr(
14800 MaterializeTemporaryExpr *E) {
14801 return getDerived().TransformExpr(E->getSubExpr());
14804template<
typename Derived>
14806TreeTransform<Derived>::TransformCXXFoldExpr(CXXFoldExpr *E) {
14807 UnresolvedLookupExpr *
Callee =
nullptr;
14808 if (Expr *OldCallee = E->getCallee()) {
14809 ExprResult CalleeResult = getDerived().TransformExpr(OldCallee);
14810 if (CalleeResult.isInvalid())
14812 Callee = cast<UnresolvedLookupExpr>(CalleeResult.get());
14815 Expr *Pattern = E->getPattern();
14818 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
14819 assert(!Unexpanded.empty() &&
"Pack expansion without parameter packs?");
14823 bool Expand =
true;
14824 bool RetainExpansion =
false;
14825 std::optional<unsigned> OrigNumExpansions = E->getNumExpansions(),
14826 NumExpansions = OrigNumExpansions;
14827 if (getDerived().TryExpandParameterPacks(E->getEllipsisLoc(),
14828 Pattern->getSourceRange(),
14830 Expand, RetainExpansion,
14837 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
14840 E->getLHS() ? getDerived().TransformExpr(E->getLHS()) :
ExprResult();
14841 if (LHS.isInvalid())
14845 E->getRHS() ? getDerived().TransformExpr(E->getRHS()) :
ExprResult();
14846 if (RHS.isInvalid())
14849 if (!getDerived().AlwaysRebuild() &&
14850 LHS.get() == E->getLHS() && RHS.get() == E->getRHS())
14853 return getDerived().RebuildCXXFoldExpr(
14854 Callee, E->getBeginLoc(), LHS.get(), E->getOperator(),
14855 E->getEllipsisLoc(), RHS.get(), E->getEndLoc(), NumExpansions);
14861 if (NumExpansions && SemaRef.
getLangOpts().BracketDepth < NumExpansions) {
14862 SemaRef.
Diag(E->getEllipsisLoc(),
14863 clang::diag::err_fold_expression_limit_exceeded)
14864 << *NumExpansions << SemaRef.
getLangOpts().BracketDepth
14865 << E->getSourceRange();
14866 SemaRef.
Diag(E->getEllipsisLoc(), diag::note_bracket_depth);
14875 bool LeftFold = E->isLeftFold();
14879 if (!LeftFold && RetainExpansion) {
14880 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
14882 ExprResult Out = getDerived().TransformExpr(Pattern);
14883 if (Out.isInvalid())
14886 Result = getDerived().RebuildCXXFoldExpr(
14887 Callee, E->getBeginLoc(), Out.get(), E->getOperator(),
14888 E->getEllipsisLoc(),
Result.get(), E->getEndLoc(), OrigNumExpansions);
14893 for (
unsigned I = 0; I != *NumExpansions; ++I) {
14894 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(
14895 getSema(), LeftFold ? I : *NumExpansions - I - 1);
14896 ExprResult Out = getDerived().TransformExpr(Pattern);
14897 if (Out.isInvalid())
14900 if (Out.get()->containsUnexpandedParameterPack()) {
14902 Result = getDerived().RebuildCXXFoldExpr(
14903 Callee, E->getBeginLoc(), LeftFold ?
Result.get() : Out.get(),
14904 E->getOperator(), E->getEllipsisLoc(),
14905 LeftFold ? Out.get() :
Result.get(), E->getEndLoc(),
14906 OrigNumExpansions);
14907 }
else if (
Result.isUsable()) {
14909 Expr *LHS = LeftFold ?
Result.get() : Out.get();
14910 Expr *RHS = LeftFold ? Out.get() :
Result.get();
14912 UnresolvedSet<16> Functions;
14913 Functions.append(
Callee->decls_begin(),
Callee->decls_end());
14914 Result = getDerived().RebuildCXXOperatorCallExpr(
14916 E->getEllipsisLoc(),
Callee->getBeginLoc(),
Callee->requiresADL(),
14917 Functions, LHS, RHS);
14919 Result = getDerived().RebuildBinaryOperator(E->getEllipsisLoc(),
14920 E->getOperator(), LHS, RHS);
14931 if (LeftFold && RetainExpansion) {
14932 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
14934 ExprResult Out = getDerived().TransformExpr(Pattern);
14935 if (Out.isInvalid())
14938 Result = getDerived().RebuildCXXFoldExpr(
14939 Callee, E->getBeginLoc(),
Result.get(), E->getOperator(),
14940 E->getEllipsisLoc(), Out.get(), E->getEndLoc(), OrigNumExpansions);
14948 return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
14954template <
typename Derived>
14956TreeTransform<Derived>::TransformCXXParenListInitExpr(CXXParenListInitExpr *E) {
14959 if (TransformExprs(InitExprs.data(), InitExprs.size(),
true,
14963 return getDerived().RebuildParenListExpr(E->getBeginLoc(), TransformedInits,
14967template<
typename Derived>
14969TreeTransform<Derived>::TransformCXXStdInitializerListExpr(
14970 CXXStdInitializerListExpr *E) {
14971 return getDerived().TransformExpr(E->getSubExpr());
14974template<
typename Derived>
14976TreeTransform<Derived>::TransformObjCStringLiteral(ObjCStringLiteral *E) {
14980template<
typename Derived>
14982TreeTransform<Derived>::TransformObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
14986template<
typename Derived>
14988TreeTransform<Derived>::TransformObjCBoxedExpr(ObjCBoxedExpr *E) {
14989 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14990 if (SubExpr.isInvalid())
14993 if (!getDerived().AlwaysRebuild() &&
14994 SubExpr.get() == E->getSubExpr())
14997 return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
15000template<
typename Derived>
15002TreeTransform<Derived>::TransformObjCArrayLiteral(ObjCArrayLiteral *E) {
15005 bool ArgChanged =
false;
15006 if (getDerived().TransformExprs(E->getElements(), E->getNumElements(),
15007 false, Elements, &ArgChanged))
15010 if (!getDerived().AlwaysRebuild() && !ArgChanged)
15013 return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(),
15018template<
typename Derived>
15020TreeTransform<Derived>::TransformObjCDictionaryLiteral(
15021 ObjCDictionaryLiteral *E) {
15024 bool ArgChanged =
false;
15025 for (
unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
15026 ObjCDictionaryElement OrigElement = E->getKeyValueElement(I);
15028 if (OrigElement.isPackExpansion()) {
15031 getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded);
15032 getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded);
15033 assert(!Unexpanded.empty() &&
"Pack expansion without parameter packs?");
15037 bool Expand =
true;
15038 bool RetainExpansion =
false;
15039 std::optional<unsigned> OrigNumExpansions = OrigElement.NumExpansions;
15040 std::optional<unsigned> NumExpansions = OrigNumExpansions;
15041 SourceRange PatternRange(OrigElement.Key->getBeginLoc(),
15042 OrigElement.Value->getEndLoc());
15043 if (getDerived().TryExpandParameterPacks(OrigElement.EllipsisLoc,
15044 PatternRange, Unexpanded, Expand,
15045 RetainExpansion, NumExpansions))
15052 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
15053 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
15054 if (Key.isInvalid())
15057 if (Key.get() != OrigElement.Key)
15061 if (
Value.isInvalid())
15064 if (
Value.get() != OrigElement.Value)
15067 ObjCDictionaryElement Expansion = {
15068 Key.get(),
Value.get(), OrigElement.EllipsisLoc, NumExpansions
15070 Elements.push_back(Expansion);
15080 for (
unsigned I = 0; I != *NumExpansions; ++I) {
15081 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
15082 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
15083 if (Key.isInvalid())
15087 if (
Value.isInvalid())
15090 ObjCDictionaryElement Element = {
15091 Key.get(),
Value.get(), SourceLocation(), NumExpansions
15097 if (Key.get()->containsUnexpandedParameterPack() ||
15098 Value.get()->containsUnexpandedParameterPack())
15099 Element.EllipsisLoc = OrigElement.EllipsisLoc;
15101 Elements.push_back(Element);
15111 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
15112 if (Key.isInvalid())
15115 if (Key.get() != OrigElement.Key)
15120 = getDerived().TransformExpr(OrigElement.Value);
15121 if (
Value.isInvalid())
15124 if (
Value.get() != OrigElement.Value)
15127 ObjCDictionaryElement Element = {Key.get(),
Value.get(), SourceLocation(),
15129 Elements.push_back(Element);
15132 if (!getDerived().AlwaysRebuild() && !ArgChanged)
15135 return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
15139template<
typename Derived>
15141TreeTransform<Derived>::TransformObjCEncodeExpr(ObjCEncodeExpr *E) {
15142 TypeSourceInfo *EncodedTypeInfo
15143 = getDerived().TransformType(E->getEncodedTypeSourceInfo());
15144 if (!EncodedTypeInfo)
15147 if (!getDerived().AlwaysRebuild() &&
15148 EncodedTypeInfo == E->getEncodedTypeSourceInfo())
15151 return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
15153 E->getRParenLoc());
15156template<
typename Derived>
15158TransformObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
15163 return getDerived().TransformExpr(E->getSubExpr());
15166template<
typename Derived>
15168TransformObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
15169 TypeSourceInfo *TSInfo
15170 = getDerived().TransformType(E->getTypeInfoAsWritten());
15178 if (!getDerived().AlwaysRebuild() &&
15179 TSInfo == E->getTypeInfoAsWritten() &&
15180 Result.get() == E->getSubExpr())
15184 E->getBridgeKeywordLoc(), TSInfo,
15188template <
typename Derived>
15189ExprResult TreeTransform<Derived>::TransformObjCAvailabilityCheckExpr(
15190 ObjCAvailabilityCheckExpr *E) {
15194template<
typename Derived>
15196TreeTransform<Derived>::TransformObjCMessageExpr(ObjCMessageExpr *E) {
15198 bool ArgChanged =
false;
15200 Args.reserve(E->getNumArgs());
15201 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(),
false, Args,
15207 TypeSourceInfo *ReceiverTypeInfo
15208 = getDerived().TransformType(E->getClassReceiverTypeInfo());
15209 if (!ReceiverTypeInfo)
15213 if (!getDerived().AlwaysRebuild() &&
15214 ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
15219 E->getSelectorLocs(SelLocs);
15220 return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
15223 E->getMethodDecl(),
15230 if (!E->getMethodDecl())
15235 E->getSelectorLocs(SelLocs);
15236 return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
15239 E->getReceiverType(),
15240 E->getMethodDecl(),
15248 "Only class and instance messages may be instantiated");
15250 = getDerived().TransformExpr(E->getInstanceReceiver());
15251 if (Receiver.isInvalid())
15255 if (!getDerived().AlwaysRebuild() &&
15256 Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
15261 E->getSelectorLocs(SelLocs);
15262 return getDerived().RebuildObjCMessageExpr(Receiver.get(),
15265 E->getMethodDecl(),
15271template<
typename Derived>
15273TreeTransform<Derived>::TransformObjCSelectorExpr(ObjCSelectorExpr *E) {
15277template<
typename Derived>
15279TreeTransform<Derived>::TransformObjCProtocolExpr(ObjCProtocolExpr *E) {
15283template<
typename Derived>
15285TreeTransform<Derived>::TransformObjCIvarRefExpr(ObjCIvarRefExpr *E) {
15288 if (
Base.isInvalid())
15294 if (!getDerived().AlwaysRebuild() &&
15295 Base.get() == E->getBase())
15298 return getDerived().RebuildObjCIvarRefExpr(
Base.get(), E->getDecl(),
15300 E->isArrow(), E->isFreeIvar());
15303template<
typename Derived>
15305TreeTransform<Derived>::TransformObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
15308 if (!E->isObjectReceiver())
15313 if (
Base.isInvalid())
15319 if (!getDerived().AlwaysRebuild() &&
15320 Base.get() == E->getBase())
15323 if (E->isExplicitProperty())
15324 return getDerived().RebuildObjCPropertyRefExpr(
Base.get(),
15325 E->getExplicitProperty(),
15328 return getDerived().RebuildObjCPropertyRefExpr(
Base.get(),
15330 E->getImplicitPropertyGetter(),
15331 E->getImplicitPropertySetter(),
15335template<
typename Derived>
15337TreeTransform<Derived>::TransformObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
15340 if (
Base.isInvalid())
15344 ExprResult Key = getDerived().TransformExpr(E->getKeyExpr());
15345 if (Key.isInvalid())
15349 if (!getDerived().AlwaysRebuild() &&
15350 Key.get() == E->getKeyExpr() &&
Base.get() == E->getBaseExpr())
15353 return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(),
15354 Base.get(), Key.get(),
15355 E->getAtIndexMethodDecl(),
15356 E->setAtIndexMethodDecl());
15359template<
typename Derived>
15361TreeTransform<Derived>::TransformObjCIsaExpr(ObjCIsaExpr *E) {
15364 if (
Base.isInvalid())
15368 if (!getDerived().AlwaysRebuild() &&
15369 Base.get() == E->getBase())
15372 return getDerived().RebuildObjCIsaExpr(
Base.get(), E->getIsaMemberLoc(),
15377template<
typename Derived>
15379TreeTransform<Derived>::TransformShuffleVectorExpr(ShuffleVectorExpr *E) {
15380 bool ArgumentChanged =
false;
15382 SubExprs.reserve(E->getNumSubExprs());
15383 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(),
false,
15384 SubExprs, &ArgumentChanged))
15387 if (!getDerived().AlwaysRebuild() &&
15391 return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
15393 E->getRParenLoc());
15396template<
typename Derived>
15398TreeTransform<Derived>::TransformConvertVectorExpr(ConvertVectorExpr *E) {
15399 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
15400 if (SrcExpr.isInvalid())
15403 TypeSourceInfo *
Type = getDerived().TransformType(E->getTypeSourceInfo());
15407 if (!getDerived().AlwaysRebuild() &&
15408 Type == E->getTypeSourceInfo() &&
15409 SrcExpr.get() == E->getSrcExpr())
15412 return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(),
15413 SrcExpr.get(), Type,
15414 E->getRParenLoc());
15417template<
typename Derived>
15419TreeTransform<Derived>::TransformBlockExpr(BlockExpr *E) {
15420 BlockDecl *oldBlock = E->getBlockDecl();
15423 BlockScopeInfo *blockScope = SemaRef.
getCurBlock();
15426 blockScope->TheDecl->setBlockMissingReturnType(
15427 oldBlock->blockMissingReturnType());
15432 const FunctionProtoType *exprFunctionType = E->getFunctionType();
15435 Sema::ExtParameterInfoBuilder extParamInfos;
15436 if (getDerived().TransformFunctionTypeParams(
15437 E->getCaretLocation(), oldBlock->parameters(),
nullptr,
15438 exprFunctionType->getExtParameterInfosOrNull(), paramTypes, ¶ms,
15440 getSema().ActOnBlockError(E->getCaretLocation(),
nullptr);
15444 QualType exprResultType =
15445 getDerived().TransformType(exprFunctionType->getReturnType());
15447 auto epi = exprFunctionType->getExtProtoInfo();
15448 epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size());
15451 getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi);
15455 if (!params.empty())
15456 blockScope->TheDecl->setParams(params);
15458 if (!oldBlock->blockMissingReturnType()) {
15459 blockScope->HasImplicitReturnType =
false;
15460 blockScope->ReturnType = exprResultType;
15464 StmtResult body = getDerived().TransformStmt(E->getBody());
15465 if (body.isInvalid()) {
15466 getSema().ActOnBlockError(E->getCaretLocation(),
nullptr);
15474 for (
const auto &I : oldBlock->captures()) {
15475 VarDecl *oldCapture = I.getVariable();
15478 if (oldCapture->isParameterPack())
15481 VarDecl *newCapture =
15482 cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
15484 assert(blockScope->CaptureMap.count(newCapture));
15490 assert((!blockScope->isCXXThisCaptured() || oldBlock->capturesCXXThis()) &&
15491 "this pointer isn't captured in the old block");
15499template<
typename Derived>
15501TreeTransform<Derived>::TransformAsTypeExpr(AsTypeExpr *E) {
15502 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
15503 if (SrcExpr.isInvalid())
15506 QualType
Type = getDerived().TransformType(E->getType());
15508 return SemaRef.
BuildAsTypeExpr(SrcExpr.get(), Type, E->getBuiltinLoc(),
15509 E->getRParenLoc());
15512template<
typename Derived>
15514TreeTransform<Derived>::TransformAtomicExpr(AtomicExpr *E) {
15515 bool ArgumentChanged =
false;
15517 SubExprs.reserve(E->getNumSubExprs());
15518 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(),
false,
15519 SubExprs, &ArgumentChanged))
15522 if (!getDerived().AlwaysRebuild() &&
15526 return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs,
15527 E->getOp(), E->getRParenLoc());
15534template<
typename Derived>
15538 getDerived().getBaseEntity());
15541template<
typename Derived>
15545 getDerived().getBaseEntity());
15548template<
typename Derived>
15551 bool WrittenAsLValue,
15554 Sigil, getDerived().getBaseEntity());
15557template<
typename Derived>
15563 getDerived().getBaseEntity());
15566template<
typename Derived>
15574 ProtocolLAngleLoc, Protocols,
15575 ProtocolLocs, ProtocolRAngleLoc,
15579template<
typename Derived>
15591 TypeArgsRAngleLoc, ProtocolLAngleLoc,
15592 Protocols, ProtocolLocs, ProtocolRAngleLoc,
15597template<
typename Derived>
15604template <
typename Derived>
15607 Expr *SizeExpr,
unsigned IndexTypeQuals,
SourceRange BracketsRange) {
15608 if (SizeExpr || !Size)
15610 IndexTypeQuals, BracketsRange,
15611 getDerived().getBaseEntity());
15619 for (
const auto &
T : Types)
15631 IndexTypeQuals, BracketsRange,
15632 getDerived().getBaseEntity());
15635template <
typename Derived>
15638 Expr *SizeExpr,
unsigned IndexTypeQuals,
SourceRange BracketsRange) {
15639 return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, SizeExpr,
15640 IndexTypeQuals, BracketsRange);
15643template <
typename Derived>
15647 return getDerived().RebuildArrayType(ElementType, SizeMod,
nullptr,
nullptr,
15648 IndexTypeQuals, BracketsRange);
15651template <
typename Derived>
15654 unsigned IndexTypeQuals,
SourceRange BracketsRange) {
15655 return getDerived().RebuildArrayType(ElementType, SizeMod,
nullptr,
15657 IndexTypeQuals, BracketsRange);
15660template <
typename Derived>
15663 unsigned IndexTypeQuals,
SourceRange BracketsRange) {
15664 return getDerived().RebuildArrayType(ElementType, SizeMod,
nullptr,
15666 IndexTypeQuals, BracketsRange);
15669template <
typename Derived>
15676template <
typename Derived>
15678 unsigned NumElements,
15684template <
typename Derived>
15691template<
typename Derived>
15693 unsigned NumElements,
15696 NumElements,
true);
15703template<
typename Derived>
15711template <
typename Derived>
15713 QualType ElementType,
unsigned NumRows,
unsigned NumColumns) {
15718template <
typename Derived>
15726template<
typename Derived>
15732 getDerived().getBaseLocation(),
15733 getDerived().getBaseEntity(),
15737template<
typename Derived>
15742template<
typename Derived>
15745 assert(D &&
"no decl found");
15749 if (
auto *UPD = dyn_cast<UsingPackDecl>(D)) {
15753 if (UPD->expansions().empty()) {
15754 getSema().Diag(Loc, diag::err_using_pack_expansion_empty)
15755 << UPD->isCXXClassMember() << UPD;
15764 for (
auto *E : UPD->expansions()) {
15765 QualType ThisT = RebuildUnresolvedUsingType(Loc, E);
15770 else if (
T.isNull())
15774 "mismatched resolved types in using pack expansion");
15776 return T.isNull() ? FallbackT :
T;
15777 }
else if (
auto *Using = dyn_cast<UsingDecl>(D)) {
15778 assert(Using->hasTypename() &&
15779 "UnresolvedUsingTypenameDecl transformed to non-typename using");
15782 assert(++Using->shadow_begin() == Using->shadow_end());
15791 assert(isa<UnresolvedUsingTypenameDecl>(D) &&
15792 "UnresolvedUsingTypenameDecl transformed to non-using decl");
15794 cast<UnresolvedUsingTypenameDecl>(D));
15798template <
typename Derived>
15804template<
typename Derived>
15810template <
typename Derived>
15815template <
typename Derived>
15821 FullySubstituted, Expansions);
15824template<
typename Derived>
15831template<
typename Derived>
15839template<
typename Derived>
15845template<
typename Derived>
15853template <
typename Derived>
15864template <
typename Derived>
15870template<
typename Derived>
15879template<
typename Derived>
15887 bool AllowInjectedClassName) {
15891 getSema().ActOnTemplateName(
nullptr, SS, TemplateKWLoc,
15894 AllowInjectedClassName);
15895 return Template.
get();
15898template<
typename Derived>
15905 bool AllowInjectedClassName) {
15908 SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
15909 Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
15911 getSema().ActOnTemplateName(
15913 false, Template, AllowInjectedClassName);
15914 return Template.
get();
15917template <
typename Derived>
15922 bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
15943 if (Op == OO_Subscript) {
15944 if (!
First->getType()->isOverloadableType() &&
15946 return getSema().CreateBuiltinArraySubscriptExpr(
First, CalleeLoc, Second,
15948 }
else if (Op == OO_Arrow) {
15951 if (
First->getType()->isDependentType())
15955 }
else if (Second ==
nullptr || isPostIncDec) {
15956 if (!
First->getType()->isOverloadableType() ||
15957 (Op == OO_Amp && getSema().isQualifiedMemberAccess(
First))) {
15964 return getSema().CreateBuiltinUnaryOp(OpLoc, Opc,
First);
15967 if (!
First->getType()->isOverloadableType() &&
15983 unsigned NumArgs = 1 + (Second !=
nullptr);
15986 if (NumArgs == 1 || isPostIncDec) {
15996 OpLoc, Opc, Functions, Args[0], Args[1], RequiresADL);
16003template<
typename Derived>
16018 ->template getAs<RecordType>())){
16021 Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType,
16022 CCLoc, TildeLoc, Destroyed);
16034 if (!ScopeType->getType()->getAs<
TagType>()) {
16035 getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
16036 diag::err_expected_class_or_namespace)
16037 << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
16045 return getSema().BuildMemberReferenceExpr(
Base, BaseType,
16046 OperatorLoc, isArrow,
16054template<
typename Derived>
16062 for (
unsigned I = 0; I < NumParams; ++I) {
16063 if (I != ContextParamPos) {
16069 Params.push_back(std::make_pair(StringRef(), QualType()));
16072 getSema().ActOnCapturedRegionStart(Loc,
nullptr,
16073 S->getCapturedRegionKind(), Params);
16076 Sema::CompoundScopeRAII CompoundScope(getSema());
16077 Body = getDerived().TransformStmt(S->getCapturedStmt());
16080 if (Body.isInvalid()) {
16081 getSema().ActOnCapturedRegionError();
16085 return getSema().ActOnCapturedRegionEnd(Body.get());
static Decl::Kind getKind(const Decl *D)
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
llvm::MachO::Target Target
llvm::MachO::Record Record
This file defines OpenMP AST classes for clauses.
Defines some OpenMP-specific enums and functions.
This file declares semantic analysis for OpenACC constructs and clauses.
This file declares semantic analysis for OpenMP constructs and clauses.
This file declares semantic analysis for SYCL constructs.
Defines the Objective-C statement AST node classes.
This file defines OpenACC AST classes for statement-level contructs.
This file defines OpenMP AST classes for executable directives and clauses.
QualType getUsingType(const UsingShadowDecl *Found, QualType Underlying) const
TranslationUnitDecl * getTranslationUnitDecl() const
unsigned getIntWidth(QualType T) const
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType) const
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, bool IsPack=false, ConceptDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, ArrayRef< TemplateArgumentLoc > Args) const
DeclarationNameTable DeclarationNames
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
QualType getPackExpansionType(QualType Pattern, std::optional< unsigned > NumExpansions, bool ExpectPackInType=true)
Form a pack expansion type with the given pattern.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
QualType getMacroQualifiedType(QualType UnderlyingTy, const IdentifierInfo *MacroII) const
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
CanQualType UnsignedLongTy
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
CanQualType PseudoObjectTy
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
CanQualType UnsignedInt128Ty
CanQualType UnsignedCharTy
CanQualType UnsignedIntTy
CanQualType UnsignedLongLongTy
CanQualType UnsignedShortTy
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final) const
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
QualType getTypeOfType(QualType QT, TypeOfKind Kind) const
getTypeOfType - Unlike many "get<Type>" functions, we don't unique TypeOfType nodes.
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, std::optional< unsigned > PackIndex) const
Retrieve a substitution-result type.
QualType getConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns) const
Return the unique reference to the matrix type of the specified element type and size.
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
SourceLocation getEndLoc() const LLVM_READONLY
ArrayTypeTrait getTrait() const
Expr * getDimensionExpression() const
TypeSourceInfo * getQueriedTypeSourceInfo() const
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getRParenLoc() const
TypeLoc getValueLoc() const
SourceLocation getKWLoc() const
SourceLocation getLParenLoc() const
Attr - This represents one attribute.
attr::Kind getKind() const
SourceLocation getLocation() const
Represents an attribute applied to a statement.
Type source information for an attributed type.
const Attr * getAttr() const
The type attribute.
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
TypeLoc getEquivalentTypeLoc() const
void setAttr(const Attr *A)
attr::Kind getAttrKind() const
An attributed type is a type to which a type attribute has been applied.
QualType getModifiedType() const
std::optional< NullabilityKind > getImmediateNullability() const
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
ArrayRef< TemplateArgument > getTypeConstraintArguments() const
ConceptDecl * getTypeConstraintConcept() const
AutoTypeKeyword getKeyword() const
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
bool isAssignmentOp() const
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
void setIsVariadic(bool value)
TypeLoc getInnerLoc() const
Represents a C++2a __builtin_bit_cast(T, v) expression.
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getBeginLoc() const LLVM_READONLY
Represents binding an expression to a temporary.
CXXCatchStmt - This represents a C++ catch block.
Represents a call to a C++ constructor.
SourceRange getParenOrBraceRange() const
Expr * getArg(unsigned Arg)
Return the specified argument.
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getBeginLoc() const LLVM_READONLY
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Represents a C++ constructor within a class.
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
Represents a call to an inherited base class constructor from an inheriting constructor.
Abstract class common to all of the C++ "named"/"keyword" casts.
SourceLocation getOperatorLoc() const
Retrieve the location of the cast operator keyword, e.g., static_cast.
SourceRange getAngleBrackets() const LLVM_READONLY
SourceLocation getRParenLoc() const
Retrieve the location of the closing parenthesis.
Represents a C++ struct/union/class.
unsigned getLambdaDependencyKind() const
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type.
Represents a C++ nested-name-specifier or a global scope specifier.
char * location_data() const
Retrieve the data associated with the source-location information.
SourceRange getRange() const
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
unsigned location_size() const
Retrieve the size of the data associated with source-location information.
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'type...
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
SourceLocation getLParenLoc() const
Retrieve the location of the left parentheses ('(') that precedes the argument list.
bool isListInitialization() const
Determine whether this expression models list-initialization.
TypeSourceInfo * getTypeSourceInfo() const
Retrieve the type source information for the type being constructed.
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (')') that follows the argument list.
unsigned getNumArgs() const
Retrieve the number of arguments.
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
Represents the body of a CapturedStmt, and serves as its DeclContext.
unsigned getNumParams() const
unsigned getContextParamPosition() const
ImplicitParamDecl * getParam(unsigned i) const
This captures a statement into a function.
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
SourceLocation getBegin() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
Declaration of a C++20 concept.
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
const TypeClass * getTypePtr() const
Expr * getCountExpr() const
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
The results of name lookup within a DeclContext.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
void addDecl(Decl *D)
Add the declaration D into this context.
A reference to a declared variable, function, enum, etc.
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Decl - This represents one declaration (or definition), e.g.
bool isInvalidDecl() const
SourceLocation getLocation() const
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
The name of a declaration.
@ CXXConversionFunctionName
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it has not been deduced.
A qualified reference to a name whose declaration cannot yet be resolved.
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source location information.
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
unsigned getNumTemplateArgs() const
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
TemplateArgumentLoc const * getTemplateArgs() const
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Represents a dependent template name that cannot be resolved prior to template instantiation.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
unsigned getNumArgs() const
SourceLocation getTemplateNameLoc() const
SourceLocation getLAngleLoc() const
void setTemplateKeywordLoc(SourceLocation Loc)
SourceLocation getTemplateKeywordLoc() const
void setElaboratedKeywordLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
SourceLocation getRAngleLoc() const
SourceLocation getElaboratedKeywordLoc() const
void setLAngleLoc(SourceLocation Loc)
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
void setTemplateNameLoc(SourceLocation Loc)
Represents a template specialization type whose template cannot be resolved, e.g.
Designation - Represent a full designation, which is a sequence of designators.
static Designator CreateArrayRangeDesignator(Expr *Start, Expr *End, SourceLocation LBracketLoc, SourceLocation EllipsisLoc)
Creates a GNU array-range designator.
static Designator CreateArrayDesignator(Expr *Index, SourceLocation LBracketLoc)
Creates an array designator.
static Designator CreateFieldDesignator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc)
Creates a field designator.
bool hasErrorOccurred() const
SourceLocation getElaboratedKeywordLoc() const
NestedNameSpecifierLoc getQualifierLoc() const
void setElaboratedKeywordLoc(SourceLocation Loc)
TypeLoc getNamedTypeLoc() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Represents a type that was referred to using an elaborated type keyword, e.g., struct S,...
RAII object that enters a new expression evaluation context.
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to.
This represents one expression.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
Represents a function declaration or definition.
QualType getReturnType() const
QualType getCallResultType() const
Determine the type of an expression that calls this function.
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Represents a prototype with parameter type info, e.g.
param_type_iterator param_type_begin() const
const ExtParameterInfo * getExtParameterInfosOrNull() const
Return a pointer to the beginning of the array of extra parameter information, if present,...
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
ExtProtoInfo getExtProtoInfo() const
ArrayRef< QualType > getParamTypes() const
unsigned getNumParams() const
SourceLocation getLocalRangeEnd() const
void setLocalRangeBegin(SourceLocation L)
void setLParenLoc(SourceLocation Loc)
SourceRange getExceptionSpecRange() const
void setParam(unsigned i, ParmVarDecl *VD)
ArrayRef< ParmVarDecl * > getParams() const
void setRParenLoc(SourceLocation Loc)
void setLocalRangeEnd(SourceLocation L)
void setExceptionSpecRange(SourceRange R)
TypeLoc getReturnLoc() const
SourceLocation getLocalRangeBegin() const
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
QualType getReturnType() const
AssociationTy< false > Association
One of these records is kept for each identifier that is lexed.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Represents an implicitly-generated value initialization of an object of a given type.
const TypeClass * getTypePtr() const
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Represents the declaration of a label.
Describes the capture of a variable or of this, or of a C++1y init-capture.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
const LambdaCapture * capture_iterator
An iterator that walks over the captures of the lambda, both implicit and explicit.
Represents the results of name lookup.
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
@ NotFound
No entity found met the criteria.
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
@ Found
Name lookup found a single declaration that met the criteria.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Represents a C++ namespace alias.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
SourceLocation getLocalEndLoc() const
Retrieve the location of the end of this component of the nested-name-specifier.
SourceLocation getEndLoc() const
Retrieve the location of the end of this nested-name-specifier.
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
@ NamespaceAlias
A namespace alias, stored as a NamespaceAliasDecl*.
@ TypeSpec
A type, stored as a Type*.
@ TypeSpecWithTemplate
A type that was preceded by the 'template' keyword, stored as a Type*.
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Identifier
An identifier, stored as an IdentifierInfo*.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace, stored as a NamespaceDecl*.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
This is a basic class for representing single OpenMP clause.
This is a basic class for representing single OpenMP executable directive.
bool hasAssociatedStmt() const
Returns true if directive has associated statement.
OpenMPDirectiveKind getDirectiveKind() const
const Stmt * getAssociatedStmt() const
Returns statement associated with the directive.
SourceLocation getBeginLoc() const
Returns starting location of directive kind.
const Stmt * getRawStmt() const
ArrayRef< OMPClause * > clauses() const
OpenMPDirectiveKind getMappedDirective() const
SourceLocation getEndLoc() const
Returns ending location of directive.
This represents clauses with a list of expressions that are mappable.
ObjCIvarDecl - Represents an ObjC instance variable.
@ SuperInstance
The receiver is the instance of the superclass object.
@ Instance
The receiver is an object instance.
@ SuperClass
The receiver is a superclass.
@ Class
The receiver is a class.
ObjCMethodDecl - Represents an instance or class method declaration.
bool isInstanceMethod() const
Represents one property declaration in an Objective-C interface.
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Represents the declaration of an Objective-C type parameter.
@ Array
An index into an array.
@ Identifier
A field in a dependent type, known only by its name.
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
Wrapper for void* pointer.
static OpaquePtr make(QualType P)
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
This is the base type for all OpenACC Clauses.
static OpenACCDefaultClause * Create(const ASTContext &C, OpenACCDefaultClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
static OpenACCIfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCNumGangsClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > IntExprs, SourceLocation EndLoc)
static OpenACCNumWorkersClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCSelfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCVectorLengthClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
SourceLocation getNameLoc() const
Gets the location of the name.
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
TemplateArgumentLoc const * getTemplateArgs() const
llvm::iterator_range< decls_iterator > decls() const
unsigned getNumTemplateArgs() const
DeclarationName getName() const
Gets the name looked up.
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Represents a C++11 pack expansion that produces a sequence of expressions.
void setEllipsisLoc(SourceLocation Loc)
SourceLocation getEllipsisLoc() const
TypeLoc getPatternLoc() const
Represents a pack expansion of types.
std::optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
ParenExpr - This represents a parethesized expression, e.g.
SourceLocation getLParen() const
Get the location of the left parentheses '('.
SourceLocation getRParen() const
Get the location of the right parentheses ')'.
Represents a parameter to a function.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
unsigned getFunctionScopeDepth() const
void setSigilLoc(SourceLocation Loc)
TypeLoc getPointeeLoc() const
SourceLocation getSigilLoc() const
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
Stores the type being destroyed by a pseudo-destructor expression.
const IdentifierInfo * getIdentifier() const
SourceLocation getLocation() const
TypeSourceInfo * getTypeSourceInfo() const
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Represents a template name that was expressed as a qualified name.
Wrapper of type source information for a type with non-trivial direct qualifiers.
The collection of all-type qualifiers we support.
void removeObjCLifetime()
static Qualifiers fromCVRMask(unsigned CVR)
bool hasObjCLifetime() const
LangAS getAddressSpace() const
Represents a struct/union/class.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeTypeAsWritten() const
Represents the body of a requires-expression.
static RequiresExprBodyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc)
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
static RequiresExpr * Create(ASTContext &C, SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation RBraceLoc)
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
Represents a __leave statement.
Smart pointer class that efficiently represents Objective-C method names.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
ArrayRef< Expr * > getIntExprs()
SourceLocation getEndLoc() const
void setLParenLoc(SourceLocation EndLoc)
void setConditionDetails(Expr *ConditionExpr)
const Expr * getConditionExpr() const
SourceLocation getLParenLoc() const
SourceLocation getBeginLoc() const
void setDefaultDetails(OpenACCDefaultClauseKind DefKind)
void setEndLoc(SourceLocation EndLoc)
void setIntExprDetails(ArrayRef< Expr * > IntExprs)
OpenACCDefaultClauseKind getDefaultClauseKind() const
StmtResult ActOnEndStmtDirective(OpenACCDirectiveKind K, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult AssocStmt)
Called after the directive has been completely parsed, including the declaration group or associated ...
ExprResult ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, Expr *Length, SourceLocation RBLoc)
Checks and creates an Array Section used in an OpenACC construct/clause.
OMPClause * ActOnOpenMPNocontextClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'nocontext' clause.
OMPClause * ActOnOpenMPXDynCGroupMemClause(Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_dyn_cgroup_mem' clause.
OMPClause * ActOnOpenMPSafelenClause(Expr *Length, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'safelen' clause.
OMPClause * ActOnOpenMPDefaultClause(llvm::omp::DefaultKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'default' clause.
OMPClause * ActOnOpenMPFilterClause(Expr *ThreadID, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'filter' clause.
OMPClause * ActOnOpenMPFullClause(SourceLocation StartLoc, SourceLocation EndLoc)
Called on well-form 'full' clauses.
OMPClause * ActOnOpenMPDetachClause(Expr *Evt, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'detach' clause.
OMPClause * ActOnOpenMPUseClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'use' clause.
OMPClause * ActOnOpenMPPrivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'private' clause.
OMPClause * ActOnOpenMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc=SourceLocation(), Expr *NumForLoops=nullptr)
Called on well-formed 'ordered' clause.
OMPClause * ActOnOpenMPReductionClause(ArrayRef< Expr * > VarList, OpenMPReductionClauseModifier Modifier, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions=std::nullopt)
Called on well-formed 'reduction' clause.
OMPClause * ActOnOpenMPIsDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'is_device_ptr' clause.
OMPClause * ActOnOpenMPHasDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'has_device_addr' clause.
OMPClause * ActOnOpenMPPartialClause(Expr *FactorExpr, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'partial' clauses.
OMPClause * ActOnOpenMPLastprivateClause(ArrayRef< Expr * > VarList, OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, SourceLocation ColonLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'lastprivate' clause.
OMPClause * ActOnOpenMPFirstprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'firstprivate' clause.
OMPClause * ActOnOpenMPPriorityClause(Expr *Priority, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'priority' clause.
OMPClause * ActOnOpenMPDistScheduleClause(OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Called on well-formed 'dist_schedule' clause.
OMPClause * ActOnOpenMPAllocateClause(Expr *Allocator, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation ColonLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocate' clause.
OMPClause * ActOnOpenMPNontemporalClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'nontemporal' clause.
OMPClause * ActOnOpenMPBindClause(OpenMPBindClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'bind' clause.
OMPClause * ActOnOpenMPSharedClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'shared' clause.
OMPClause * ActOnOpenMPCopyinClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'copyin' clause.
OMPClause * ActOnOpenMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'destroy' clause.
OMPClause * ActOnOpenMPAffinityClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, Expr *Modifier, ArrayRef< Expr * > Locators)
Called on well-formed 'affinity' clause.
OMPClause * ActOnOpenMPDependClause(const OMPDependClause::DependDataTy &Data, Expr *DepModifier, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'depend' clause.
OMPClause * ActOnOpenMPDoacrossClause(OpenMPDoacrossClauseModifier DepType, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'doacross' clause.
OMPClause * ActOnOpenMPGrainsizeClause(OpenMPGrainsizeClauseModifier Modifier, Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'grainsize' clause.
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, SourceLocation ColonLocSecond, Expr *Length, Expr *Stride, SourceLocation RBLoc)
OMPClause * ActOnOpenMPFromClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers=std::nullopt)
Called on well-formed 'from' clause.
OMPClause * ActOnOpenMPToClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers=std::nullopt)
Called on well-formed 'to' clause.
ExprResult ActOnOMPIteratorExpr(Scope *S, SourceLocation IteratorKwLoc, SourceLocation LLoc, SourceLocation RLoc, ArrayRef< OMPIteratorData > Data)
OMPClause * ActOnOpenMPUsesAllocatorClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< UsesAllocatorsData > Data)
Called on well-formed 'uses_allocators' clause.
OMPClause * ActOnOpenMPAllocatorClause(Expr *Allocator, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocator' clause.
OMPClause * ActOnOpenMPInclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'inclusive' clause.
OMPClause * ActOnOpenMPOrderClause(OpenMPOrderClauseModifier Modifier, OpenMPOrderClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Called on well-formed 'order' clause.
OMPClause * ActOnOpenMPSizesClause(ArrayRef< Expr * > SizeExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'sizes' clause.
OMPClause * ActOnOpenMPDeviceClause(OpenMPDeviceClauseModifier Modifier, Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'device' clause.
OMPClause * ActOnOpenMPNumThreadsClause(Expr *NumThreads, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'num_threads' clause.
StmtResult ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, OpenMPDirectiveKind CancelRegion, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc, OpenMPDirectiveKind PrevMappedDirective=llvm::omp::OMPD_unknown)
OMPClause * ActOnOpenMPFlushClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'flush' pseudo clause.
OMPClause * ActOnOpenMPNumTeamsClause(Expr *NumTeams, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'num_teams' clause.
OMPClause * ActOnOpenMPMessageClause(Expr *MS, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'message' clause.
OMPClause * ActOnOpenMPMapClause(Expr *IteratorModifier, ArrayRef< OpenMPMapModifierKind > MapTypeModifiers, ArrayRef< SourceLocation > MapTypeModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, bool NoDiagnose=false, ArrayRef< Expr * > UnresolvedMappers=std::nullopt)
Called on well-formed 'map' clause.
OMPClause * ActOnOpenMPTaskReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions=std::nullopt)
Called on well-formed 'task_reduction' clause.
OMPClause * ActOnOpenMPScheduleClause(OpenMPScheduleClauseModifier M1, OpenMPScheduleClauseModifier M2, OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Called on well-formed 'schedule' clause.
OMPClause * ActOnOpenMPSimdlenClause(Expr *Length, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'simdlen' clause.
OMPClause * ActOnOpenMPUseDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'use_device_ptr' clause.
OMPClause * ActOnOpenMPProcBindClause(llvm::omp::ProcBindKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'proc_bind' clause.
OMPClause * ActOnOpenMPXBareClause(SourceLocation StartLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_bare' clause.
StmtResult ActOnOpenMPCanonicalLoop(Stmt *AStmt)
Called for syntactical loops (ForStmt or CXXForRangeStmt) associated to an OpenMP loop directive.
OMPClause * ActOnOpenMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'hint' clause.
ExprResult ActOnOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, SourceLocation RParenLoc, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > Brackets)
OMPClause * ActOnOpenMPAtClause(OpenMPAtClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'at' clause.
OMPClause * ActOnOpenMPInitClause(Expr *InteropVar, OMPInteropInfo &InteropInfo, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'init' clause.
OMPClause * ActOnOpenMPUseDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'use_device_addr' clause.
OMPClause * ActOnOpenMPFinalClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'final' clause.
OMPClause * ActOnOpenMPNumTasksClause(OpenMPNumTasksClauseModifier Modifier, Expr *NumTasks, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'num_tasks' clause.
OMPClause * ActOnOpenMPSeverityClause(OpenMPSeverityClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'severity' clause.
OMPClause * ActOnOpenMPLinearClause(ArrayRef< Expr * > VarList, Expr *Step, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind LinKind, SourceLocation LinLoc, SourceLocation ColonLoc, SourceLocation StepModifierLoc, SourceLocation EndLoc)
Called on well-formed 'linear' clause.
OMPClause * ActOnOpenMPDefaultmapClause(OpenMPDefaultmapClauseModifier M, OpenMPDefaultmapClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Called on well-formed 'defaultmap' clause.
OMPClause * ActOnOpenMPAlignedClause(ArrayRef< Expr * > VarList, Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Called on well-formed 'aligned' clause.
OMPClause * ActOnOpenMPDepobjClause(Expr *Depobj, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'depobj' pseudo clause.
OMPClause * ActOnOpenMPNovariantsClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'novariants' clause.
OMPClause * ActOnOpenMPCopyprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'copyprivate' clause.
OMPClause * ActOnOpenMPCollapseClause(Expr *NumForLoops, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'collapse' clause.
OMPClause * ActOnOpenMPAlignClause(Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'align' clause.
OMPClause * ActOnOpenMPXAttributeClause(ArrayRef< const Attr * > Attrs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_attribute' clause.
OMPClause * ActOnOpenMPInReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions=std::nullopt)
Called on well-formed 'in_reduction' clause.
OMPClause * ActOnOpenMPExclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'exclusive' clause.
OMPClause * ActOnOpenMPThreadLimitClause(Expr *ThreadLimit, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'thread_limit' clause.
OMPClause * ActOnOpenMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation NameModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Called on well-formed 'if' clause.
ExprResult BuildUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
RAII object used to change the argument pack substitution index within a Sema object.
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
A RAII object to enter scope of a compound statement.
A helper class for building up ExtParameterInfos.
const FunctionProtoType::ExtParameterInfo * getPointerOrNull(unsigned numParams)
Return a pointer (suitable for setting in an ExtProtoInfo) to the ExtParameterInfo array we've built ...
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Sema - This implements semantic analysis and AST building for C.
QualType BuildParenType(QualType T)
Build a paren type including T.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
bool CheckSpecifiedExceptionType(QualType &T, SourceRange Range)
CheckSpecifiedExceptionType - Check if the given type is valid in an exception specification.
ExprResult BuildOperatorCoawaitCall(SourceLocation Loc, Expr *E, UnresolvedLookupExpr *Lookup)
Build a call to 'operator co_await' if there is a suitable operator for the given expression.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend)
Check that the expression co_await promise.final_suspend() shall not be potentially-throwing.
QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace, SourceLocation AttrLoc)
BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an expression is uninstantiated.
ExprResult ActOnConstantExpression(ExprResult Res)
StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, ArrayRef< Token > AsmToks, StringRef AsmString, unsigned NumOutputs, unsigned NumInputs, ArrayRef< StringRef > Constraints, ArrayRef< StringRef > Clobbers, ArrayRef< Expr * > Exprs, SourceLocation EndLoc)
StmtResult BuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs)
ExprResult BuildCoyieldExpr(SourceLocation KwLoc, Expr *E)
ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand)
QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc)
StmtResult BuildAttributedStmt(SourceLocation AttrsLoc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
@ IER_DoesNotExist
The symbol does not exist.
@ IER_Dependent
The name is a dependent name, so the results will differ from one instantiation to the next.
@ IER_Error
An error occurred.
@ IER_Exists
The symbol exists.
void ActOnStartStmtExpr()
void ActOnStmtExprError()
StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, Stmt *First, Expr *collection, SourceLocation RParenLoc)
VarDecl * buildCoroutinePromise(SourceLocation Loc)
QualType BuildObjCObjectType(QualType BaseType, SourceLocation Loc, SourceLocation TypeArgsLAngleLoc, ArrayRef< TypeSourceInfo * > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc, bool FailOnError, bool Rebuilding)
Build an Objective-C object pointer type.
ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr=false)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
@ Boolean
A boolean condition, from 'if', 'while', 'for', or 'do'.
@ Switch
An integral condition for a 'switch' statement.
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
ExprResult BuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Operand, SourceLocation RParenLoc)
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
ExprResult BuildObjCDictionaryLiteral(SourceRange SR, MutableArrayRef< ObjCDictionaryElement > Elements)
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor,...
StmtResult BuildCoreturnStmt(SourceLocation KwLoc, Expr *E, bool IsImplicit=false)
ExprResult ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, ParsedType &ObjectType, bool &MayBePseudoDestructor)
ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val)
QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc)
Build an ext-vector type.
ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation EqualOrColonLoc, bool GNUSyntax, ExprResult Init)
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false, ArrayRef< const Expr * > StopAt=std::nullopt)
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, bool *NoArrowOperatorFound=nullptr)
BuildOverloadedArrowExpr - Build a call to an overloaded operator-> (if one exists),...
ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, Expr *Awaiter, bool IsImplicit=false)
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw)
ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, bool ArrayForm, Expr *Operand)
ActOnCXXDelete - Parsed a C++ 'delete' expression.
ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a C++ typeid expression with a type operand.
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow)
Perform conversions on the LHS of a member access expression.
ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, bool IsAddressOfOperand, const Scope *S, TypeSourceInfo **RecoveryTSI=nullptr)
BuildQualifiedDeclarationNameExpr - Build a C++ qualified declaration name, generally during template...
DiagnosticsEngine & getDiagnostics() const
concepts::TypeRequirement * BuildTypeRequirement(TypeSourceInfo *Type)
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, std::optional< unsigned > NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
ExprResult checkPseudoObjectAssignment(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opcode, Expr *LHS, Expr *RHS)
StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
ParsedType getDestructorName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext)
ASTContext & getASTContext() const
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input, bool IsAfterAmp=false)
ExprResult BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, QualType ReceiverType, SourceLocation SuperLoc, Selector Sel, ObjCMethodDecl *Method, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args, bool isImplicit=false)
Build an Objective-C class message expression.
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true, bool AllowRewrittenCandidates=true, FunctionDecl *DefaultedFn=nullptr)
Create a binary operation that may resolve to an overloaded operator.
StmtResult ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
Expr * recreateSyntacticForm(PseudoObjectExpr *E)
Given a pseudo-object expression, recreate what it looks like syntactically without the attendant Opa...
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
ExprResult BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, QualType AllocType, TypeSourceInfo *AllocTypeInfo, std::optional< Expr * > ArraySize, SourceRange DirectInitRange, Expr *Initializer)
ExprResult BuildObjCBridgedCast(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, TypeSourceInfo *TSInfo, Expr *SubExpr)
bool isAcceptableTagRedeclaration(const TagDecl *Previous, TagTypeKind NewTag, bool isDefinition, SourceLocation NewTagLoc, const IdentifierInfo *Name)
Determine whether a tag with a given kind is acceptable as a redeclaration of the given tag declarati...
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc)
Build a bit-precise integer type.
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool PredicateIsExpr, void *ControllingExprOrType, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
ControllingExprOrType is either a TypeSourceInfo * or an Expr *.
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg Catch, Stmt *Finally)
const LangOptions & getLangOpts() const
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, std::optional< unsigned > NumExpansions)
bool isPotentialImplicitMemberAccess(const CXXScopeSpec &SS, LookupResult &R, bool IsAddressOfOperand)
Check whether an expression might be an implicit class member access.
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
ExprResult BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
ExprResult BuildCXXTypeConstructExpr(TypeSourceInfo *Type, SourceLocation LParenLoc, MultiExprArg Exprs, SourceLocation RParenLoc, bool ListInitialization)
StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body)
FinishObjCForCollectionStmt - Attach the body to a objective-C foreach statement.
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
ExprResult ConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
ConvertVectorExpr - Handle __builtin_convertvector.
ExprResult BuildObjCEncodeExpression(SourceLocation AtLoc, TypeSourceInfo *EncodedTypeInfo, SourceLocation RParenLoc)
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc, TypeSourceInfo **TSI, bool DeducedTSTContext)
ExprResult BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc)
DeclContext * getCurLexicalContext() const
ExprResult BuildUnresolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, UnresolvedLookupExpr *Lookup)
NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK)
Given a non-tag type declaration, returns an enum useful for indicating what kind of non-tag type thi...
ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
bool buildCoroutineParameterMoves(SourceLocation Loc)
ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty, SourceLocation RParenLoc, Expr *Op)
ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a Microsoft __uuidof expression with a type operand.
sema::FunctionScopeInfo * getCurFunction() const
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
Expr * BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit)
Build a CXXThisExpr and mark it referenced in the current context.
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *input, bool RequiresADL=true)
Create a unary operation that may resolve to an overloaded operator.
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
VarDecl * BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id)
Perform semantic analysis for the variable declaration that occurs within a C++ catch clause,...
bool BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, bool EnteringContext, CXXScopeSpec &SS, NamedDecl *ScopeLookupResult, bool ErrorRecoveryLookup, bool *IsCorrectedToColon=nullptr, bool OnlyNamespace=false)
Build a new nested-name-specifier for "identifier::", as described by ActOnCXXNestedNameSpecifier.
ExprResult BuildPackIndexingExpr(Expr *PackExpression, SourceLocation EllipsisLoc, Expr *IndexExpr, SourceLocation RSquareLoc, ArrayRef< Expr * > ExpandedExprs={}, bool EmptyPack=false)
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
ExprResult BuildCXXNoexceptExpr(SourceLocation KeyLoc, Expr *Operand, SourceLocation RParen)
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *DestExp)
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, CXXConstructionKind ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
@ TryCapture_ExplicitByVal
@ TryCapture_ExplicitByRef
ExprResult BuildAsTypeExpr(Expr *E, QualType DestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Create a new AsTypeExpr node (bitcast) from the arguments.
ExprResult checkPseudoObjectRValue(Expr *E)
ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, FieldDecl *Field, DeclAccessPair FoundDecl, const DeclarationNameInfo &MemberNameInfo)
bool CheckRebuiltStmtAttributes(ArrayRef< const Attr * > Attrs)
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?: operation.
QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted=false, ArrayRef< QualType > Expansions={})
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)
Builds an expression which might be an implicit member expression.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the '@' prefixed parenthesized expression.
concepts::ExprRequirement * BuildExprRequirement(Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement ReturnTypeRequirement)
QualType BuildAtomicType(QualType T, SourceLocation Loc)
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, bool AllowRecovery=false)
ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
ExprResult BuildPseudoDestructorExpr(Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc, SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType)
QualType BuildPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a pointer type.
StmtResult BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt, SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End, Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc, BuildForRangeKind Kind, ArrayRef< MaterializeTemporaryExpr * > LifetimeExtendTemps={})
BuildCXXForRangeStmt - Build or instantiate a C++11 for-range statement.
StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body, SourceLocation WhileLoc, SourceLocation CondLParen, Expr *Cond, SourceLocation CondRParen)
StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc)
ExprResult BuiltinShuffleVector(CallExpr *TheCall)
BuiltinShuffleVector - Handle __builtin_shufflevector.
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
QualType BuildDecltypeType(Expr *E, bool AsUnevaluated=true)
If AsUnevaluated is false, E is treated as though it were an evaluated context, such as when building...
QualType BuildUnaryTransformType(QualType BaseType, UTTKind UKind, SourceLocation Loc)
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, Expr *IndexExpr, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
Build an ObjC subscript pseudo-object expression, given that that's supported by the runtime.
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
VarDecl * BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, bool Invalid=false)
Build a type-check a new Objective-C exception variable declaration.
ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
ExprResult BuildCXXThrow(SourceLocation OpLoc, Expr *Ex, bool IsThrownVarInScope)
QualType BuildArrayType(QualType T, ArraySizeModifier ASM, Expr *ArraySize, unsigned Quals, SourceRange Brackets, DeclarationName Entity)
Build an array type.
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
QualType BuildReadPipeType(QualType T, SourceLocation Loc)
Build a Read-only Pipe type.
concepts::NestedRequirement * BuildNestedRequirement(Expr *E)
QualType BuildObjCTypeParamType(const ObjCTypeParamDecl *Decl, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc, bool FailOnError=false)
Build an Objective-C type parameter type.
QualType BuildWritePipeType(QualType T, SourceLocation Loc)
Build a Write-only Pipe type.
@ BFRK_Rebuild
Instantiation or recovery rebuild of a for-range statement.
ExprResult CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs)
void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt)
ActOnCaseStmtBody - This installs a statement as the body of a case.
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
QualType BuildTypeofExprType(Expr *E, TypeOfKind Kind)
ExprResult BuildArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, TypeSourceInfo *TSInfo, Expr *DimExpr, SourceLocation RParen)
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns, SourceLocation AttrLoc)
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen, Decl *Parm, Stmt *Body)
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, MultiExprArg ArgExprs, SourceLocation RLoc)
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc.
ExprResult BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, SourceLocation RParenLoc, MultiExprArg Args, AtomicExpr::AtomicOp Op, AtomicArgumentOrder ArgOrder=AtomicArgumentOrder::API)
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
static ConditionResult ConditionError()
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody)
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
StmtResult ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock, ArrayRef< Stmt * > Handlers)
ActOnCXXTryBlock - Takes a try compound-statement and a number of handlers and creates a try statemen...
QualType BuildCountAttributedArrayType(QualType WrappedTy, Expr *CountExpr)
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements)
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS, SourceLocation DotDotDotLoc, ExprResult RHS, SourceLocation ColonLoc)
ExprResult BuildInstanceMessage(Expr *Receiver, QualType ReceiverType, SourceLocation SuperLoc, Selector Sel, ObjCMethodDecl *Method, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args, bool isImplicit=false)
Build an Objective-C instance message expression.
QualType BuildMemberPointerType(QualType T, QualType Class, SourceLocation Loc, DeclarationName Entity)
Build a member pointer type T Class::*.
QualType BuildBlockPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a block pointer type.
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
ExprResult CreateBuiltinMatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, SourceLocation RBLoc)
StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, bool IsVolatile, unsigned NumOutputs, unsigned NumInputs, IdentifierInfo **Names, MultiExprArg Constraints, MultiExprArg Exprs, Expr *AsmString, MultiExprArg Clobbers, unsigned NumLabels, SourceLocation RParenLoc)
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, std::optional< unsigned > Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs=std::nullopt)
static bool MayBeDependent(SourceLocIdentKind Kind)
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
SourceLocation getBegin() const
Stmt - This represents one statement.
StmtClass getStmtClass() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
A structure for storing an already-substituted template template parameter pack.
Wrapper for substituted template type parameters.
Represents the declaration of a struct/union/class/enum.
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
const TemplateArgumentLoc * operator->() const
pointer(TemplateArgumentLoc Arg)
Simple iterator that traverses the template arguments in a container that provides a getArgLoc() memb...
TemplateArgumentLoc operator*() const
TemplateArgumentLocContainerIterator operator++(int)
friend bool operator!=(const TemplateArgumentLocContainerIterator &X, const TemplateArgumentLocContainerIterator &Y)
TemplateArgumentLocContainerIterator()
TemplateArgumentLoc value_type
TemplateArgumentLocContainerIterator(ArgLocContainer &Container, unsigned Index)
friend bool operator==(const TemplateArgumentLocContainerIterator &X, const TemplateArgumentLocContainerIterator &Y)
TemplateArgumentLocContainerIterator & operator++()
std::input_iterator_tag iterator_category
TemplateArgumentLoc reference
pointer operator->() const
const TemplateArgumentLoc * operator->() const
pointer(TemplateArgumentLoc Arg)
Iterator adaptor that invents template argument location information for each of the template argumen...
TemplateArgumentLocInventIterator & operator++()
pointer operator->() const
std::iterator_traits< InputIterator >::difference_type difference_type
reference operator*() const
TemplateArgumentLocInventIterator operator++(int)
friend bool operator==(const TemplateArgumentLocInventIterator &X, const TemplateArgumentLocInventIterator &Y)
TemplateArgumentLocInventIterator(TreeTransform< Derived > &Self, InputIterator Iter)
friend bool operator!=(const TemplateArgumentLocInventIterator &X, const TemplateArgumentLocInventIterator &Y)
std::input_iterator_tag iterator_category
TemplateArgumentLoc reference
TemplateArgumentLoc value_type
Location wrapper for a TemplateArgument.
const TemplateArgument & getArgument() const
SourceLocation getTemplateNameLoc() const
TypeSourceInfo * getTypeSourceInfo() const
SourceRange getSourceRange() const LLVM_READONLY
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Expr * getSourceExpression() const
Represents a template argument.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
QualType getAsType() const
Retrieve the type for a type template argument.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
bool isNull() const
Determine whether this template name is NULL.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
Stores a list of template parameters for a TemplateDecl and its derived classes.
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
void setTemplateKeywordLoc(SourceLocation Loc)
void setTemplateNameLoc(SourceLocation Loc)
void setLAngleLoc(SourceLocation Loc)
SourceLocation getTemplateNameLoc() const
void setRAngleLoc(SourceLocation Loc)
Represents a type template specialization; the template must be a class template, a type alias templa...
Wrapper for template type parameters.
The top declaration context.
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void reserve(size_t Requested)
Ensures that this buffer has at least as much capacity as described.
void TypeWasModifiedSafely(QualType T)
Tell the TypeLocBuilder that the type it is storing has been modified in some safe way that doesn't a...
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Base wrapper for a particular "section" of type source info.
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
QualType getType() const
Get the type for which this source info wrapper provides information.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
unsigned getFullDataSize() const
Returns the size of the type source info data block.
SourceLocation getTemplateKeywordLoc() const
Get the SourceLocation of the template keyword (if any).
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
ElaboratedTypeKeyword getKeyword() const
The base class of the type hierarchy.
bool isPointerType() const
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isEnumeralType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool canHaveNullability(bool ResultIfUnknown=true) const
Determine whether the given type can have a nullability specifier applied to it, i....
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool isFunctionType() const
bool isObjCObjectPointerType() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
Base class for declarations which introduce a typedef-name.
Wrapper for source info for typedefs.
TypedefNameDecl * getTypedefNameDecl() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Expr * getSubExpr() const
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix)
Retrieve the unary opcode that corresponds to the given overloaded operator.
Represents a C++ unqualified-id that has been parsed.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent)
CXXRecordDecl * getNamingClass()
Gets the 'naming class' (in the sense of C++0x [class.access.base]p5) of the lookup.
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
A set of unresolved declarations.
void addDecl(NamedDecl *D)
A set of unresolved declarations.
Represents the dependent type named by a dependently-scoped typename using declaration,...
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
@ CInit
C-style initialization with assignment.
@ CallInit
Call-style initialization (C++98)
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack.
A requires-expression requirement which queries the validity and properties of an expression ('simple...
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
bool isExprSubstitutionFailure() const
const ReturnTypeRequirement & getReturnTypeRequirement() const
SourceLocation getNoexceptLoc() const
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
const ASTConstraintSatisfaction & getConstraintSatisfaction() const
bool hasInvalidConstraint() const
Expr * getConstraintExpr() const
StringRef getInvalidConstraintEntity()
A static requirement that can be used in a requires-expression to check properties of types and expre...
A requires-expression requirement which queries the existence of a type name or type template special...
bool isSubstitutionFailure() const
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
TypeSourceInfo * getType() const
CXXRecordDecl * Lambda
The class that describes the lambda.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
const AstTypeMatcher< FunctionType > functionType
Matches FunctionType nodes.
bool Inc(InterpState &S, CodePtr OpPC)
1) Pops a pointer from the stack 2) Load the value from the pointer 3) Writes the value increased by ...
bool Comp(InterpState &S, CodePtr OpPC)
1) Pops the value from the stack.
llvm::PointerUnion< const Decl *, const Expr * > DeclTy
The JSON file list parser is used to communicate input to InstallAPI.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
ArrayTypeTrait
Names for the array type traits.
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
OpenMPDefaultmapClauseModifier
OpenMP modifiers for 'defaultmap' clause.
OpenMPOrderClauseModifier
OpenMP modifiers for 'order' clause.
IfStatementKind
In an if statement, this denotes whether the statement is a constexpr or consteval if statement.
@ OK_ObjCProperty
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
OpenMPAtClauseKind
OpenMP attributes for 'at' clause.
@ LCK_ByCopy
Capturing by copy (a.k.a., by value)
@ LCK_ByRef
Capturing by reference.
@ LCK_StarThis
Capturing the *this object by copy.
OpenMPReductionClauseModifier
OpenMP modifiers for 'reduction' clause.
TypeOfKind
The kind of 'typeof' expression we're after.
OpenMPScheduleClauseModifier
OpenMP modifiers for 'schedule' clause.
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
OpenMPDoacrossClauseModifier
OpenMP dependence types for 'doacross' clause.
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
@ Property
The type of a property.
@ Result
The result type of a method or function.
OpenMPBindClauseKind
OpenMP bindings for the 'bind' clause.
ArraySizeModifier
Capture whether this is a normal array (e.g.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
OpenMPLastprivateModifier
OpenMP 'lastprivate' clause modifier.
OpenMPGrainsizeClauseModifier
OpenMPNumTasksClauseModifier
ActionResult< Expr * > ExprResult
TagTypeKind
The kind of a tag type.
bool transformOMPMappableExprListClause(TreeTransform< Derived > &TT, OMPMappableExprListClause< T > *C, llvm::SmallVectorImpl< Expr * > &Vars, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperIdInfo, llvm::SmallVectorImpl< Expr * > &UnresolvedMappers)
bool isOpenMPLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a directive with an associated loop construct.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
OpenMPSeverityClauseKind
OpenMP attributes for 'severity' clause.
ActionResult< Stmt * > StmtResult
OpenMPDefaultmapClauseKind
OpenMP attributes for 'defaultmap' clause.
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
const FunctionProtoType * T
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl * >, SourceLocation > UnexpandedParameterPack
OpenMPDeviceClauseModifier
OpenMP modifiers for 'device' clause.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
@ None
No keyword precedes the qualified type name.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
OpenMPOrderClauseKind
OpenMP attributes for 'order' clause.
TypeTrait
Names for traits that operate specifically on types.
@ Parens
New-expression has a C++98 paren-delimited initializer.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_Uninstantiated
not instantiated yet
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_Dynamic
throw(T1, T2)
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
static QualType TransformTypeSpecType(TypeLocBuilder &TLB, TyLoc T)
MutableArrayRef< Expr * > MultiExprArg
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
TypeSourceInfo * getNamedTypeInfo() const
getNamedTypeInfo - Returns the source type info associated to the name.
Holds information about the various types of exception specification.
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
ExceptionSpecificationType Type
The kind of exception specification this is.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
const ExtParameterInfo * ExtParameterInfos
This structure contains most locations needed for by an OMPVarListClause.
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
@ BuildingDeductionGuides
We are building deduction guides for a class.
Keeps information about an identifier in a nested-name-spec.
Location information for a TemplateArgument.