Skip to content

Commit 14c7544

Browse files
committed
fixup! fix for incomplete types
Created using spr 1.3.8-beta.1
1 parent 33d18b2 commit 14c7544

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,7 @@ void CodeGenFunction::EmitAllocTokenHint(llvm::CallBase *CB,
12891289
// Check if QualType contains a pointer. Implements a simple DFS to
12901290
// recursively check if a type contains a pointer type.
12911291
llvm::SmallPtrSet<const RecordDecl *, 4> VisitedRD;
1292+
bool IncompleteType = false;
12921293
auto TypeContainsPtr = [&](auto &&self, QualType T) -> bool {
12931294
QualType CanonicalType = T.getCanonicalType();
12941295
if (CanonicalType->isPointerType())
@@ -1312,6 +1313,10 @@ void CodeGenFunction::EmitAllocTokenHint(llvm::CallBase *CB,
13121313
return self(self, AT->getElementType());
13131314
// The type is a struct, class, or union.
13141315
if (const RecordDecl *RD = CanonicalType->getAsRecordDecl()) {
1316+
if (!RD->isCompleteDefinition()) {
1317+
IncompleteType = true;
1318+
return false;
1319+
}
13151320
if (!VisitedRD.insert(RD).second)
13161321
return false; // already visited
13171322
// Check all fields.
@@ -1333,6 +1338,8 @@ void CodeGenFunction::EmitAllocTokenHint(llvm::CallBase *CB,
13331338
return false;
13341339
};
13351340
const bool ContainsPtr = TypeContainsPtr(TypeContainsPtr, AllocType);
1341+
if (!ContainsPtr && IncompleteType)
1342+
return nullptr;
13361343
auto *ContainsPtrC = Builder.getInt1(ContainsPtr);
13371344
auto *ContainsPtrMD = MDB.createConstant(ContainsPtrC);
13381345

0 commit comments

Comments
 (0)