@@ -674,6 +674,10 @@ class TreeTransform {
674
674
Qualifiers ThisTypeQuals,
675
675
Fn TransformExceptionSpec);
676
676
677
+ template <typename Fn>
678
+ QualType TransformAttributedType(TypeLocBuilder &TLB, AttributedTypeLoc TL,
679
+ Fn TransformModifiedType);
680
+
677
681
bool TransformExceptionSpec(SourceLocation Loc,
678
682
FunctionProtoType::ExceptionSpecInfo &ESI,
679
683
SmallVectorImpl<QualType> &Exceptions,
@@ -7050,12 +7054,12 @@ TreeTransform<Derived>::TransformElaboratedType(TypeLocBuilder &TLB,
7050
7054
return Result;
7051
7055
}
7052
7056
7053
- template<typename Derived>
7057
+ template <typename Derived>
7058
+ template <typename Fn>
7054
7059
QualType TreeTransform<Derived>::TransformAttributedType(
7055
- TypeLocBuilder &TLB,
7056
- AttributedTypeLoc TL) {
7060
+ TypeLocBuilder &TLB, AttributedTypeLoc TL, Fn TransformModifiedTypeFn) {
7057
7061
const AttributedType *oldType = TL.getTypePtr();
7058
- QualType modifiedType = getDerived().TransformType (TLB, TL.getModifiedLoc());
7062
+ QualType modifiedType = TransformModifiedTypeFn (TLB, TL.getModifiedLoc());
7059
7063
if (modifiedType.isNull())
7060
7064
return QualType();
7061
7065
@@ -7099,6 +7103,15 @@ QualType TreeTransform<Derived>::TransformAttributedType(
7099
7103
return result;
7100
7104
}
7101
7105
7106
+ template <typename Derived>
7107
+ QualType TreeTransform<Derived>::TransformAttributedType(TypeLocBuilder &TLB,
7108
+ AttributedTypeLoc TL) {
7109
+ return getDerived().TransformAttributedType(
7110
+ TLB, TL, [&](TypeLocBuilder &TLB, TypeLoc ModifiedLoc) -> QualType {
7111
+ return getDerived().TransformType(TLB, ModifiedLoc);
7112
+ });
7113
+ }
7114
+
7102
7115
template <typename Derived>
7103
7116
QualType TreeTransform<Derived>::TransformBTFTagAttributedType(
7104
7117
TypeLocBuilder &TLB, BTFTagAttributedTypeLoc TL) {
@@ -13600,32 +13613,56 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
13600
13613
// transformed parameters.
13601
13614
TypeSourceInfo *NewCallOpTSI = nullptr;
13602
13615
{
13603
- TypeSourceInfo *OldCallOpTSI = E->getCallOperator()->getTypeSourceInfo();
13604
- auto OldCallOpFPTL =
13605
- OldCallOpTSI->getTypeLoc().getAs<FunctionProtoTypeLoc>();
13616
+ auto OldCallOpTypeLoc =
13617
+ E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
13618
+
13619
+ auto TransformFunctionProtoTypeLoc =
13620
+ [this](TypeLocBuilder &TLB, FunctionProtoTypeLoc FPTL) -> QualType {
13621
+ SmallVector<QualType, 4> ExceptionStorage;
13622
+ TreeTransform *This = this; // Work around gcc.gnu.org/PR56135.
13623
+ return this->TransformFunctionProtoType(
13624
+ TLB, FPTL, nullptr, Qualifiers(),
13625
+ [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
13626
+ return This->TransformExceptionSpec(FPTL.getBeginLoc(), ESI,
13627
+ ExceptionStorage, Changed);
13628
+ });
13629
+ };
13606
13630
13631
+ QualType NewCallOpType;
13607
13632
TypeLocBuilder NewCallOpTLBuilder;
13608
- SmallVector<QualType, 4> ExceptionStorage;
13609
- TreeTransform *This = this; // Work around gcc.gnu.org/PR56135.
13610
- QualType NewCallOpType = TransformFunctionProtoType(
13611
- NewCallOpTLBuilder, OldCallOpFPTL, nullptr, Qualifiers(),
13612
- [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
13613
- return This->TransformExceptionSpec(OldCallOpFPTL.getBeginLoc(), ESI,
13614
- ExceptionStorage, Changed);
13615
- });
13633
+
13634
+ if (auto ATL = OldCallOpTypeLoc.getAs<AttributedTypeLoc>()) {
13635
+ NewCallOpType = this->TransformAttributedType(
13636
+ NewCallOpTLBuilder, ATL,
13637
+ [&](TypeLocBuilder &TLB, TypeLoc TL) -> QualType {
13638
+ return TransformFunctionProtoTypeLoc(
13639
+ TLB, TL.castAs<FunctionProtoTypeLoc>());
13640
+ });
13641
+ } else {
13642
+ auto FPTL = OldCallOpTypeLoc.castAs<FunctionProtoTypeLoc>();
13643
+ NewCallOpType = TransformFunctionProtoTypeLoc(NewCallOpTLBuilder, FPTL);
13644
+ }
13645
+
13616
13646
if (NewCallOpType.isNull())
13617
13647
return ExprError();
13618
13648
NewCallOpTSI =
13619
13649
NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context, NewCallOpType);
13620
13650
}
13621
13651
13652
+ ArrayRef<ParmVarDecl *> Params;
13653
+ if (auto ATL = NewCallOpTSI->getTypeLoc().getAs<AttributedTypeLoc>()) {
13654
+ Params = ATL.getModifiedLoc().castAs<FunctionProtoTypeLoc>().getParams();
13655
+ } else {
13656
+ auto FPTL = NewCallOpTSI->getTypeLoc().castAs<FunctionProtoTypeLoc>();
13657
+ Params = FPTL.getParams();
13658
+ }
13659
+
13622
13660
getSema().CompleteLambdaCallOperator(
13623
13661
NewCallOperator, E->getCallOperator()->getLocation(),
13624
13662
E->getCallOperator()->getInnerLocStart(),
13625
13663
E->getCallOperator()->getTrailingRequiresClause(), NewCallOpTSI,
13626
13664
E->getCallOperator()->getConstexprKind(),
13627
- E->getCallOperator()->getStorageClass(),
13628
- NewCallOpTSI->getTypeLoc().castAs<FunctionProtoTypeLoc>().getParams(),
13665
+ E->getCallOperator()->getStorageClass(), Params,
13629
13666
E->hasExplicitResultType());
13630
13667
13631
13668
getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
0 commit comments