@@ -1289,6 +1289,7 @@ void CodeGenFunction::EmitAllocTokenHint(llvm::CallBase *CB,
1289
1289
// Check if QualType contains a pointer. Implements a simple DFS to
1290
1290
// recursively check if a type contains a pointer type.
1291
1291
llvm::SmallPtrSet<const RecordDecl *, 4 > VisitedRD;
1292
+ bool IncompleteType = false ;
1292
1293
auto TypeContainsPtr = [&](auto &&self, QualType T) -> bool {
1293
1294
QualType CanonicalType = T.getCanonicalType ();
1294
1295
if (CanonicalType->isPointerType ())
@@ -1312,6 +1313,10 @@ void CodeGenFunction::EmitAllocTokenHint(llvm::CallBase *CB,
1312
1313
return self (self, AT->getElementType ());
1313
1314
// The type is a struct, class, or union.
1314
1315
if (const RecordDecl *RD = CanonicalType->getAsRecordDecl ()) {
1316
+ if (!RD->isCompleteDefinition ()) {
1317
+ IncompleteType = true ;
1318
+ return false ;
1319
+ }
1315
1320
if (!VisitedRD.insert (RD).second )
1316
1321
return false ; // already visited
1317
1322
// Check all fields.
@@ -1333,6 +1338,8 @@ void CodeGenFunction::EmitAllocTokenHint(llvm::CallBase *CB,
1333
1338
return false ;
1334
1339
};
1335
1340
const bool ContainsPtr = TypeContainsPtr (TypeContainsPtr, AllocType);
1341
+ if (!ContainsPtr && IncompleteType)
1342
+ return nullptr ;
1336
1343
auto *ContainsPtrC = Builder.getInt1 (ContainsPtr);
1337
1344
auto *ContainsPtrMD = MDB.createConstant (ContainsPtrC);
1338
1345
0 commit comments