[clang] [HLSL] Add ByteAddressBuffer definition to HLSLExternalSemaSource #113477 (PR #116699)
Helena Kotas via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 22 22:40:28 PST 2024
================
@@ -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
More information about the cfe-commits
mailing list