[clang] [Clang][Sema] set declaration invalid earlier to prevent crash in calculating record layout (PR #87173)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 1 18:04:28 PDT 2024
================
@@ -3899,6 +3899,9 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state,
SemaRef.Diag(OwnedTagDecl->getLocation(), DiagID)
<< SemaRef.Context.getTypeDeclType(OwnedTagDecl);
D.setInvalidType(true);
+ OwnedTagDecl->setCompleteDefinition(false);
+ OwnedTagDecl->setInvalidDecl();
+ OwnedTagDecl->setCompleteDefinition();
----------------
shafik wrote:
`GetDeclSpecTypeForDeclarator` is called from two places `GetTypeForDeclaratorCast(...)` and where that is called `D.isInvalidType()` is checked. It is also called from `GetTypeForDeclarator(...)` and the checking of after that call is a bit more varied. I am wondering if we are being sloppy in one of those calls.
https://github.com/llvm/llvm-project/pull/87173
More information about the cfe-commits
mailing list