https://github.com/melver updated https://github.com/llvm/llvm-project/pull/156840
>From 14c75441e84aa32e4f5876598b9a2c59d4ecbe65 Mon Sep 17 00:00:00 2001 From: Marco Elver <el...@google.com> Date: Mon, 8 Sep 2025 21:32:21 +0200 Subject: [PATCH] fixup! fix for incomplete types Created using spr 1.3.8-beta.1 --- clang/lib/CodeGen/CGExpr.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 288b41bc42203..455de644daf00 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -1289,6 +1289,7 @@ void CodeGenFunction::EmitAllocTokenHint(llvm::CallBase *CB, // Check if QualType contains a pointer. Implements a simple DFS to // recursively check if a type contains a pointer type. llvm::SmallPtrSet<const RecordDecl *, 4> VisitedRD; + bool IncompleteType = false; auto TypeContainsPtr = [&](auto &&self, QualType T) -> bool { QualType CanonicalType = T.getCanonicalType(); if (CanonicalType->isPointerType()) @@ -1312,6 +1313,10 @@ void CodeGenFunction::EmitAllocTokenHint(llvm::CallBase *CB, return self(self, AT->getElementType()); // The type is a struct, class, or union. if (const RecordDecl *RD = CanonicalType->getAsRecordDecl()) { + if (!RD->isCompleteDefinition()) { + IncompleteType = true; + return false; + } if (!VisitedRD.insert(RD).second) return false; // already visited // Check all fields. @@ -1333,6 +1338,8 @@ void CodeGenFunction::EmitAllocTokenHint(llvm::CallBase *CB, return false; }; const bool ContainsPtr = TypeContainsPtr(TypeContainsPtr, AllocType); + if (!ContainsPtr && IncompleteType) + return nullptr; auto *ContainsPtrC = Builder.getInt1(ContainsPtr); auto *ContainsPtrMD = MDB.createConstant(ContainsPtrC); _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits