================
@@ -1474,6 +1474,11 @@ DeclContext *DeclContext::getPrimaryContext() {
case Decl::ObjCCategoryImpl:
return this;
+ case Decl::CXXRecord:
+ if (auto *OPD = dyn_cast<CXXRecordDecl>(this))
+ if (auto *Def = OPD->getDefinition())
+ return Def;
+ return this;
default:
----------------
hekota wrote:
Right, because the `TypeForDecl` is not set for `ByteAddressBuffer`. We need to
make sure it gets set, otherwise the decl is not valid and it is going to bite
us again someplace else.
We are creating the record in `BuiltinTypeDeclBuilder` constructor with
`DelayTypeCreation` flag. For template classes the type gets created in
`finalizeTemplateArgs` in the `ASTContext::getInjectedClassNameType` call, but
that does not happed for non-template classes. We need to make sure it gets
created and assigned, for example by adding `ASTContext::getTypeDeclType` call
to the `BuiltinTypeDeclBuilder` destructor:
```
~BuiltinTypeDeclBuilder() {
if (!Record->getTypeForDecl())
Record->getASTContext().getTypeDeclType(Record,
Record->getPreviousDecl());
... rest of the destructor code ....
}
```
https://github.com/llvm/llvm-project/pull/116699
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits