[clang] [HLSL] Add `[[hlsl::contained_type()]]` attribute (PR #108456)

Helena Kotas via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 12 20:25:43 PDT 2024


================
@@ -114,19 +115,30 @@ struct BuiltinTypeDeclBuilder {
                   AccessSpecifier Access = AccessSpecifier::AS_private) {
     if (Record->isCompleteDefinition())
       return *this;
+
+    TypeSourceInfo *ElementTypeTSI = nullptr;
+
     QualType Ty = Record->getASTContext().VoidPtrTy;
     if (Template) {
-      if (const auto *TTD = dyn_cast<TemplateTypeParmDecl>(
-              Template->getTemplateParameters()->getParam(0)))
+      if (const TemplateTypeParmDecl *TTD = dyn_cast<TemplateTypeParmDecl>(
+              Template->getTemplateParameters()->getParam(0))) {
         Ty = Record->getASTContext().getPointerType(
             QualType(TTD->getTypeForDecl(), 0));
+        QualType ElemType = QualType(TTD->getTypeForDecl(), 0);
+        ElementTypeTSI = S.getASTContext().getTrivialTypeSourceInfo(
+            ElemType, SourceLocation());
----------------
hekota wrote:

This SourceLocation actually does not get used, it is just there so we can create a TypeSourceInfo for the HLSLContainedTypeAttr. The implicit types do not have any source information. That will change once these types are declared in the implicit HLSL header.

https://github.com/llvm/llvm-project/pull/108456


More information about the cfe-commits mailing list