@@ -3060,12 +3060,13 @@ void SemaHLSL::processExplicitBindingsOnDecl(VarDecl *VD) {
3060
3060
static bool CastInitializer (Sema &S, ASTContext &Ctx, Expr *E,
3061
3061
llvm::SmallVectorImpl<Expr *> &List,
3062
3062
llvm::SmallVectorImpl<QualType> &DestTypes) {
3063
- if (List.size () >= DestTypes.size ())
3064
- return false ;
3065
- InitializedEntity Entity =
3066
- InitializedEntity::InitializeParameter (Ctx, DestTypes[List.size ()], false );
3067
- ExprResult Res =
3068
- S.PerformCopyInitialization (Entity, E->getBeginLoc (), E);
3063
+ if (List.size () >= DestTypes.size ()) {
3064
+ List.push_back (E);
3065
+ return true ;
3066
+ }
3067
+ InitializedEntity Entity = InitializedEntity::InitializeParameter (
3068
+ Ctx, DestTypes[List.size ()], false );
3069
+ ExprResult Res = S.PerformCopyInitialization (Entity, E->getBeginLoc (), E);
3069
3070
if (Res.isInvalid ())
3070
3071
return false ;
3071
3072
Expr *Init = Res.get ();
@@ -3074,18 +3075,16 @@ static bool CastInitializer(Sema &S, ASTContext &Ctx, Expr *E,
3074
3075
}
3075
3076
3076
3077
static void BuildInitializerList (Sema &S, ASTContext &Ctx, Expr *E,
3077
- llvm::SmallVectorImpl<Expr *> &List,
3078
- llvm::SmallVectorImpl<QualType> &DestTypes,
3079
- bool &ExcessInits) {
3080
- if (List.size () >= DestTypes.size ()) {
3078
+ llvm::SmallVectorImpl<Expr *> &List,
3079
+ llvm::SmallVectorImpl<QualType> &DestTypes,
3080
+ bool &ExcessInits) {
3081
+ if (List.size () >= DestTypes.size ())
3081
3082
ExcessInits = true ;
3082
- return ;
3083
- }
3084
3083
3085
3084
// If this is an initialization list, traverse the sub initializers.
3086
3085
if (auto *Init = dyn_cast<InitListExpr>(E)) {
3087
3086
for (auto *SubInit : Init->inits ())
3088
- BuildIntializerList (S, Ctx, SubInit, List, DestTypes, ExcessInits);
3087
+ BuildInitializerList (S, Ctx, SubInit, List, DestTypes, ExcessInits);
3089
3088
return ;
3090
3089
}
3091
3090
@@ -3099,10 +3098,8 @@ static void BuildInitializerList(Sema &S, ASTContext &Ctx, Expr *E,
3099
3098
if (auto *ATy = Ty->getAs <VectorType>()) {
3100
3099
uint64_t Size = ATy->getNumElements ();
3101
3100
3102
- if (List.size () + Size > DestTypes.size ()) {
3101
+ if (List.size () + Size > DestTypes.size ())
3103
3102
ExcessInits = true ;
3104
- return ;
3105
- }
3106
3103
QualType SizeTy = Ctx.getSizeType ();
3107
3104
uint64_t SizeTySize = Ctx.getTypeSize (SizeTy);
3108
3105
for (uint64_t I = 0 ; I < Size; ++I) {
@@ -3113,8 +3110,7 @@ static void BuildInitializerList(Sema &S, ASTContext &Ctx, Expr *E,
3113
3110
E, E->getBeginLoc (), Idx, E->getEndLoc ());
3114
3111
if (ElExpr.isInvalid ())
3115
3112
return ;
3116
- if (!CastInitializer (S, Ctx, ElExpr.get (), List, DestTypes))
3117
- return ;
3113
+ CastInitializer (S, Ctx, ElExpr.get (), List, DestTypes);
3118
3114
}
3119
3115
return ;
3120
3116
}
@@ -3130,7 +3126,7 @@ static void BuildInitializerList(Sema &S, ASTContext &Ctx, Expr *E,
3130
3126
E, E->getBeginLoc (), Idx, E->getEndLoc ());
3131
3127
if (ElExpr.isInvalid ())
3132
3128
return ;
3133
- BuildIntializerList (S, Ctx, ElExpr.get (), List, DestTypes, ExcessInits);
3129
+ BuildInitializerList (S, Ctx, ElExpr.get (), List, DestTypes, ExcessInits);
3134
3130
}
3135
3131
return ;
3136
3132
}
@@ -3143,7 +3139,7 @@ static void BuildInitializerList(Sema &S, ASTContext &Ctx, Expr *E,
3143
3139
E, false , E->getBeginLoc (), CXXScopeSpec (), FD, Found, NameInfo);
3144
3140
if (Res.isInvalid ())
3145
3141
return ;
3146
- BuildIntializerList (S, Ctx, Res.get (), List, DestTypes, ExcessInits);
3142
+ BuildInitializerList (S, Ctx, Res.get (), List, DestTypes, ExcessInits);
3147
3143
}
3148
3144
}
3149
3145
}
@@ -3155,6 +3151,7 @@ static Expr *GenerateInitLists(ASTContext &Ctx, QualType Ty,
3155
3151
}
3156
3152
llvm::SmallVector<Expr *> Inits;
3157
3153
assert (!isa<MatrixType>(Ty) && " Matrix types not yet supported in HLSL" );
3154
+ Ty = Ty.getDesugaredType (Ctx);
3158
3155
if (Ty->isVectorType () || Ty->isConstantArrayType ()) {
3159
3156
QualType ElTy;
3160
3157
uint64_t Size = 0 ;
@@ -3197,7 +3194,7 @@ bool SemaHLSL::TransformInitList(const InitializedEntity &Entity,
3197
3194
llvm::SmallVector<Expr *, 16 > ArgExprs;
3198
3195
bool ExcessInits = false ;
3199
3196
for (Expr *Arg : Init->inits ())
3200
- BuildIntializerList (SemaRef, Ctx, Arg, ArgExprs, DestTypes, ExcessInits);
3197
+ BuildInitializerList (SemaRef, Ctx, Arg, ArgExprs, DestTypes, ExcessInits);
3201
3198
3202
3199
if (DestTypes.size () != ArgExprs.size () || ExcessInits) {
3203
3200
int TooManyOrFew = ExcessInits ? 1 : 0 ;
0 commit comments