@@ -103,7 +103,8 @@ std::string CIRGenTypes::getRecordTypeName(const clang::RecordDecl *recordDecl,
103
103
policy.SuppressTagKeyword = true ;
104
104
105
105
if (recordDecl->getIdentifier ())
106
- astContext.getRecordType (recordDecl).print (outStream, policy);
106
+ QualType (astContext.getCanonicalTagType (recordDecl))
107
+ .print (outStream, policy);
107
108
else if (auto *typedefNameDecl = recordDecl->getTypedefNameForAnonDecl ())
108
109
typedefNameDecl->printQualifiedName (outStream, policy);
109
110
else
@@ -138,7 +139,7 @@ isSafeToConvert(const RecordDecl *rd, CIRGenTypes &cgt,
138
139
if (!alreadyChecked.insert (rd).second )
139
140
return true ;
140
141
141
- const Type *key = cgt.getASTContext ().getTagDeclType (rd).getTypePtr ();
142
+ const Type *key = cgt.getASTContext ().getCanonicalTagType (rd).getTypePtr ();
142
143
143
144
// If this type is already laid out, converting it is a noop.
144
145
if (cgt.isRecordLayoutComplete (key))
@@ -182,7 +183,8 @@ isSafeToConvert(QualType qt, CIRGenTypes &cgt,
182
183
183
184
// If this is a record, check it.
184
185
if (const auto *rt = qt->getAs <RecordType>())
185
- return isSafeToConvert (rt->getDecl (), cgt, alreadyChecked);
186
+ return isSafeToConvert (rt->getOriginalDecl ()->getDefinitionOrSelf (), cgt,
187
+ alreadyChecked);
186
188
187
189
// If this is an array, check the elements, which are embedded inline.
188
190
if (const auto *at = cgt.getASTContext ().getAsArrayType (qt))
@@ -210,7 +212,7 @@ static bool isSafeToConvert(const RecordDecl *rd, CIRGenTypes &cgt) {
210
212
mlir::Type CIRGenTypes::convertRecordDeclType (const clang::RecordDecl *rd) {
211
213
// TagDecl's are not necessarily unique, instead use the (clang) type
212
214
// connected to the decl.
213
- const Type *key = astContext.getTagDeclType (rd).getTypePtr ();
215
+ const Type *key = astContext.getCanonicalTagType (rd).getTypePtr ();
214
216
cir::RecordType entry = recordDeclTypes[key];
215
217
216
218
// If we don't have an entry for this record yet, create one.
@@ -242,7 +244,10 @@ mlir::Type CIRGenTypes::convertRecordDeclType(const clang::RecordDecl *rd) {
242
244
for (const auto &base : cxxRecordDecl->bases ()) {
243
245
if (base.isVirtual ())
244
246
continue ;
245
- convertRecordDeclType (base.getType ()->castAs <RecordType>()->getDecl ());
247
+ convertRecordDeclType (base.getType ()
248
+ ->castAs <RecordType>()
249
+ ->getOriginalDecl ()
250
+ ->getDefinitionOrSelf ());
246
251
}
247
252
}
248
253
@@ -275,7 +280,8 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
275
280
276
281
// Process record types before the type cache lookup.
277
282
if (const auto *recordType = dyn_cast<RecordType>(type))
278
- return convertRecordDeclType (recordType->getDecl ());
283
+ return convertRecordDeclType (
284
+ recordType->getOriginalDecl ()->getDefinitionOrSelf ());
279
285
280
286
// Has the type already been processed?
281
287
TypeCacheTy::iterator tci = typeCache.find (ty);
@@ -457,7 +463,8 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
457
463
}
458
464
459
465
case Type::Enum: {
460
- const EnumDecl *ed = cast<EnumType>(ty)->getDecl ();
466
+ const EnumDecl *ed =
467
+ cast<EnumType>(ty)->getOriginalDecl ()->getDefinitionOrSelf ();
461
468
if (auto integerType = ed->getIntegerType (); !integerType.isNull ())
462
469
return convertType (integerType);
463
470
// Return a placeholder 'i32' type. This can be changed later when the
@@ -516,7 +523,7 @@ mlir::Type CIRGenTypes::convertTypeForMem(clang::QualType qualType,
516
523
// / Return record layout info for the given record decl.
517
524
const CIRGenRecordLayout &
518
525
CIRGenTypes::getCIRGenRecordLayout (const RecordDecl *rd) {
519
- const auto *key = astContext.getTagDeclType (rd).getTypePtr ();
526
+ const auto *key = astContext.getCanonicalTagType (rd).getTypePtr ();
520
527
521
528
// If we have already computed the layout, return it.
522
529
auto it = cirGenRecordLayouts.find (key);
@@ -548,7 +555,7 @@ bool CIRGenTypes::isZeroInitializable(clang::QualType t) {
548
555
}
549
556
550
557
if (const RecordType *rt = t->getAs <RecordType>()) {
551
- const RecordDecl *rd = rt->getDecl ();
558
+ const RecordDecl *rd = rt->getOriginalDecl ()-> getDefinitionOrSelf ();
552
559
return isZeroInitializable (rd);
553
560
}
554
561
@@ -623,8 +630,10 @@ void CIRGenTypes::updateCompletedType(const TagDecl *td) {
623
630
// declaration of enums, and C doesn't allow an incomplete forward
624
631
// declaration with a non-default type.
625
632
assert (
626
- !typeCache.count (ed->getTypeForDecl ()) ||
627
- (convertType (ed->getIntegerType ()) == typeCache[ed->getTypeForDecl ()]));
633
+ !typeCache.count (
634
+ ed->getASTContext ().getCanonicalTagType (ed)->getTypePtr ()) ||
635
+ (convertType (ed->getIntegerType ()) ==
636
+ typeCache[ed->getASTContext ().getCanonicalTagType (ed)->getTypePtr ()]));
628
637
// If necessary, provide the full definition of a type only used with a
629
638
// declaration so far.
630
639
assert (!cir::MissingFeatures::generateDebugInfo ());
@@ -639,7 +648,7 @@ void CIRGenTypes::updateCompletedType(const TagDecl *td) {
639
648
640
649
// Only complete if we converted it already. If we haven't converted it yet,
641
650
// we'll just do it lazily.
642
- if (recordDeclTypes.count (astContext.getTagDeclType (rd).getTypePtr ()))
651
+ if (recordDeclTypes.count (astContext.getCanonicalTagType (rd).getTypePtr ()))
643
652
convertRecordDeclType (rd);
644
653
645
654
// If necessary, provide the full definition of a type only used with a
0 commit comments