From 41549d3dfca46ecd640cd9227689b10dc95b27c7 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Thu, 24 Jul 2025 15:06:09 +0800 Subject: [PATCH] [CHERI] Fix an assertion failure when in containsCapabilities when a member is an incomplete record. This can only arise when an error has already occurred earlier in parsing. --- clang/lib/AST/ASTContext.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 56447b56e8db1..cf63876cb08d3 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -13558,9 +13558,14 @@ bool ASTContext::containsCapabilities(const RecordDecl *RD) const { const QualType Ty = i->getType(); if (Ty->isCHERICapabilityType(*this)) return true; - if (const RecordType *RT = Ty->getAs()) + if (const RecordType *RT = Ty->getAs()) { + if (RT->isIncompleteType()) + // This can only occur when an error has occurred earlier, so it + // isn't too important what we return. + return false; if (containsCapabilities(RT->getDecl())) return true; + } if (Ty->isArrayType() && containsCapabilities(Ty)) return true; }