@@ -1215,23 +1215,7 @@ unsigned CGMSHLSLRuntime::AddTypeAnnotation(QualType Ty,
1215
1215
AddTypeAnnotation (GetHLSLResourceResultType (Ty), dxilTypeSys, arrayEltSize);
1216
1216
// Resources don't count towards cbuffer size.
1217
1217
return 0 ;
1218
- } else if (const RecordType *RT = paramTy->getAsStructureType ()) {
1219
- RecordDecl *RD = RT->getDecl ();
1220
- llvm::StructType *ST = CGM.getTypes ().ConvertRecordDeclType (RD);
1221
- // Skip if already created.
1222
- if (DxilStructAnnotation *annotation = dxilTypeSys.GetStructAnnotation (ST)) {
1223
- unsigned structSize = annotation->GetCBufferSize ();
1224
- return structSize;
1225
- }
1226
- DxilStructAnnotation *annotation = dxilTypeSys.AddStructAnnotation (ST,
1227
- GetNumTemplateArgsForRecordDecl (RT->getDecl ()));
1228
- DxilPayloadAnnotation *payloadAnnotation = nullptr ;
1229
- if (ValidatePayloadDecl (RT->getDecl (), *m_pHLModule->GetShaderModel (), CGM.getDiags (), CGM.getCodeGenOpts ()))
1230
- payloadAnnotation = dxilTypeSys.AddPayloadAnnotation (ST);
1231
- unsigned size = ConstructStructAnnotation (annotation, payloadAnnotation, RD, dxilTypeSys);
1232
- // Resources don't count towards cbuffer size.
1233
- return IsHLSLResourceType (Ty) ? 0 : size;
1234
- } else if (const RecordType *RT = dyn_cast<RecordType>(paramTy)) {
1218
+ } else if (const RecordType *RT = paramTy->getAs <RecordType>()) {
1235
1219
// For this pointer.
1236
1220
RecordDecl *RD = RT->getDecl ();
1237
1221
llvm::StructType *ST = CGM.getTypes ().ConvertRecordDeclType (RD);
@@ -1245,7 +1229,9 @@ unsigned CGMSHLSLRuntime::AddTypeAnnotation(QualType Ty,
1245
1229
DxilPayloadAnnotation* payloadAnnotation = nullptr ;
1246
1230
if (ValidatePayloadDecl (RT->getDecl (), *m_pHLModule->GetShaderModel (), CGM.getDiags (), CGM.getCodeGenOpts ()))
1247
1231
payloadAnnotation = dxilTypeSys.AddPayloadAnnotation (ST);
1248
- return ConstructStructAnnotation (annotation, payloadAnnotation, RD, dxilTypeSys);
1232
+ unsigned size = ConstructStructAnnotation (annotation, payloadAnnotation, RD, dxilTypeSys);
1233
+ // Resources don't count towards cbuffer size.
1234
+ return IsHLSLResourceType (Ty) ? 0 : size;
1249
1235
} else if (IsStringType (Ty)) {
1250
1236
// string won't be included in cbuffer
1251
1237
return 0 ;
@@ -3177,10 +3163,7 @@ static void CollectScalarTypes(std::vector<QualType> &ScalarTys, QualType Ty) {
3177
3163
CollectScalarTypes (ScalarTys, EltTy);
3178
3164
}
3179
3165
} else {
3180
- const RecordType *RT = Ty->getAsStructureType ();
3181
- // For CXXRecord.
3182
- if (!RT)
3183
- RT = Ty->getAs <RecordType>();
3166
+ const RecordType *RT = Ty->getAs <RecordType>();
3184
3167
RecordDecl *RD = RT->getDecl ();
3185
3168
for (FieldDecl *field : RD->fields ())
3186
3169
CollectScalarTypes (ScalarTys, field->getType ());
@@ -3994,7 +3977,7 @@ void CGMSHLSLRuntime::FlattenValToInitList(CodeGenFunction &CGF, SmallVector<Val
3994
3977
elts.emplace_back (Builder.CreateLoad (val));
3995
3978
eltTys.emplace_back (Ty);
3996
3979
} else {
3997
- RecordDecl *RD = Ty->getAsStructureType ()->getDecl ();
3980
+ const RecordDecl *RD = Ty->getAs <RecordType> ()->getDecl ();
3998
3981
const CGRecordLayout& RL = CGF.getTypes ().getCGRecordLayout (RD);
3999
3982
4000
3983
// Take care base.
@@ -4124,10 +4107,7 @@ static void AddMissingCastOpsInInitList(SmallVector<Value *, 4> &elts, SmallVect
4124
4107
// Skip hlsl object.
4125
4108
idx++;
4126
4109
} else {
4127
- const RecordType *RT = Ty->getAsStructureType ();
4128
- // For CXXRecord.
4129
- if (!RT)
4130
- RT = Ty->getAs <RecordType>();
4110
+ const RecordType *RT = Ty->getAs <RecordType>();
4131
4111
RecordDecl *RD = RT->getDecl ();
4132
4112
// Take care base.
4133
4113
if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
@@ -4210,10 +4190,7 @@ static void StoreInitListToDestPtr(Value *DestPtr,
4210
4190
} else {
4211
4191
Constant *zero = Builder.getInt32 (0 );
4212
4192
4213
- const RecordType *RT = Type->getAsStructureType ();
4214
- // For CXXRecord.
4215
- if (!RT)
4216
- RT = Type->getAs <RecordType>();
4193
+ const RecordType *RT = Type->getAs <RecordType>();
4217
4194
RecordDecl *RD = RT->getDecl ();
4218
4195
const CGRecordLayout &RL = Types.getCGRecordLayout (RD);
4219
4196
// Take care base.
@@ -5353,7 +5330,7 @@ void CGMSHLSLRuntime::FlattenAggregatePtrToGepList(
5353
5330
EltTyList.push_back (Type);
5354
5331
return ;
5355
5332
}
5356
- const clang::RecordType *RT = Type->getAsStructureType ();
5333
+ const clang::RecordType *RT = Type->getAs <RecordType> ();
5357
5334
RecordDecl *RD = RT->getDecl ();
5358
5335
5359
5336
const CGRecordLayout &RL = CGF.getTypes ().getCGRecordLayout (RD);
@@ -5802,7 +5779,7 @@ void CGMSHLSLRuntime::EmitHLSLSplat(
5802
5779
} else if (StructType *ST = dyn_cast<StructType>(Ty)) {
5803
5780
DXASSERT (!dxilutil::IsHLSLObjectType (ST), " cannot cast to hlsl object, Sema should reject" );
5804
5781
5805
- const clang::RecordType *RT = Type->getAsStructureType ();
5782
+ const clang::RecordType *RT = Type->getAs <RecordType> ();
5806
5783
RecordDecl *RD = RT->getDecl ();
5807
5784
5808
5785
const CGRecordLayout &RL = CGF.getTypes ().getCGRecordLayout (RD);
0 commit comments