@@ -3014,12 +3014,13 @@ void SemaHLSL::processExplicitBindingsOnDecl(VarDecl *VD) {
3014
3014
static bool CastInitializer (Sema &S, ASTContext &Ctx, Expr *E,
3015
3015
llvm::SmallVectorImpl<Expr *> &List,
3016
3016
llvm::SmallVectorImpl<QualType> &DestTypes) {
3017
- if (List.size () >= DestTypes.size ())
3018
- return false ;
3019
- InitializedEntity Entity =
3020
- InitializedEntity::InitializeParameter (Ctx, DestTypes[List.size ()], false );
3021
- ExprResult Res =
3022
- S.PerformCopyInitialization (Entity, E->getBeginLoc (), E);
3017
+ if (List.size () >= DestTypes.size ()) {
3018
+ List.push_back (E);
3019
+ return true ;
3020
+ }
3021
+ InitializedEntity Entity = InitializedEntity::InitializeParameter (
3022
+ Ctx, DestTypes[List.size ()], false );
3023
+ ExprResult Res = S.PerformCopyInitialization (Entity, E->getBeginLoc (), E);
3023
3024
if (Res.isInvalid ())
3024
3025
return false ;
3025
3026
Expr *Init = Res.get ();
@@ -3028,18 +3029,16 @@ static bool CastInitializer(Sema &S, ASTContext &Ctx, Expr *E,
3028
3029
}
3029
3030
3030
3031
static void BuildInitializerList (Sema &S, ASTContext &Ctx, Expr *E,
3031
- llvm::SmallVectorImpl<Expr *> &List,
3032
- llvm::SmallVectorImpl<QualType> &DestTypes,
3033
- bool &ExcessInits) {
3034
- if (List.size () >= DestTypes.size ()) {
3032
+ llvm::SmallVectorImpl<Expr *> &List,
3033
+ llvm::SmallVectorImpl<QualType> &DestTypes,
3034
+ bool &ExcessInits) {
3035
+ if (List.size () >= DestTypes.size ())
3035
3036
ExcessInits = true ;
3036
- return ;
3037
- }
3038
3037
3039
3038
// If this is an initialization list, traverse the sub initializers.
3040
3039
if (auto *Init = dyn_cast<InitListExpr>(E)) {
3041
3040
for (auto *SubInit : Init->inits ())
3042
- BuildIntializerList (S, Ctx, SubInit, List, DestTypes, ExcessInits);
3041
+ BuildInitializerList (S, Ctx, SubInit, List, DestTypes, ExcessInits);
3043
3042
return ;
3044
3043
}
3045
3044
@@ -3053,10 +3052,8 @@ static void BuildInitializerList(Sema &S, ASTContext &Ctx, Expr *E,
3053
3052
if (auto *ATy = Ty->getAs <VectorType>()) {
3054
3053
uint64_t Size = ATy->getNumElements ();
3055
3054
3056
- if (List.size () + Size > DestTypes.size ()) {
3055
+ if (List.size () + Size > DestTypes.size ())
3057
3056
ExcessInits = true ;
3058
- return ;
3059
- }
3060
3057
QualType SizeTy = Ctx.getSizeType ();
3061
3058
uint64_t SizeTySize = Ctx.getTypeSize (SizeTy);
3062
3059
for (uint64_t I = 0 ; I < Size; ++I) {
@@ -3067,8 +3064,7 @@ static void BuildInitializerList(Sema &S, ASTContext &Ctx, Expr *E,
3067
3064
E, E->getBeginLoc (), Idx, E->getEndLoc ());
3068
3065
if (ElExpr.isInvalid ())
3069
3066
return ;
3070
- if (!CastInitializer (S, Ctx, ElExpr.get (), List, DestTypes))
3071
- return ;
3067
+ CastInitializer (S, Ctx, ElExpr.get (), List, DestTypes);
3072
3068
}
3073
3069
return ;
3074
3070
}
@@ -3084,7 +3080,7 @@ static void BuildInitializerList(Sema &S, ASTContext &Ctx, Expr *E,
3084
3080
E, E->getBeginLoc (), Idx, E->getEndLoc ());
3085
3081
if (ElExpr.isInvalid ())
3086
3082
return ;
3087
- BuildIntializerList (S, Ctx, ElExpr.get (), List, DestTypes, ExcessInits);
3083
+ BuildInitializerList (S, Ctx, ElExpr.get (), List, DestTypes, ExcessInits);
3088
3084
}
3089
3085
return ;
3090
3086
}
@@ -3097,7 +3093,7 @@ static void BuildInitializerList(Sema &S, ASTContext &Ctx, Expr *E,
3097
3093
E, false , E->getBeginLoc (), CXXScopeSpec (), FD, Found, NameInfo);
3098
3094
if (Res.isInvalid ())
3099
3095
return ;
3100
- BuildIntializerList (S, Ctx, Res.get (), List, DestTypes, ExcessInits);
3096
+ BuildInitializerList (S, Ctx, Res.get (), List, DestTypes, ExcessInits);
3101
3097
}
3102
3098
}
3103
3099
}
@@ -3109,6 +3105,7 @@ static Expr *GenerateInitLists(ASTContext &Ctx, QualType Ty,
3109
3105
}
3110
3106
llvm::SmallVector<Expr *> Inits;
3111
3107
assert (!isa<MatrixType>(Ty) && " Matrix types not yet supported in HLSL" );
3108
+ Ty = Ty.getDesugaredType (Ctx);
3112
3109
if (Ty->isVectorType () || Ty->isConstantArrayType ()) {
3113
3110
QualType ElTy;
3114
3111
uint64_t Size = 0 ;
@@ -3151,7 +3148,7 @@ bool SemaHLSL::TransformInitList(const InitializedEntity &Entity,
3151
3148
llvm::SmallVector<Expr *, 16 > ArgExprs;
3152
3149
bool ExcessInits = false ;
3153
3150
for (Expr *Arg : Init->inits ())
3154
- BuildIntializerList (SemaRef, Ctx, Arg, ArgExprs, DestTypes, ExcessInits);
3151
+ BuildInitializerList (SemaRef, Ctx, Arg, ArgExprs, DestTypes, ExcessInits);
3155
3152
3156
3153
if (DestTypes.size () != ArgExprs.size () || ExcessInits) {
3157
3154
int TooManyOrFew = ExcessInits ? 1 : 0 ;
0 commit comments