[clang] [HLSL] Add implicit resource element type concepts to AST (PR #112600)

Damyan Pepper via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 6 18:27:48 PST 2024


================
@@ -323,30 +324,127 @@ struct TemplateParameterListBuilder {
         S.Context, Builder.Record->getDeclContext(), SourceLocation(),
         SourceLocation(), /* TemplateDepth */ 0, Position,
         &S.Context.Idents.get(Name, tok::TokenKind::identifier),
-        /* Typename */ false,
-        /* ParameterPack */ false);
+        /* Typename */ true,
+        /* ParameterPack */ false,
+        /* HasTypeConstraint*/ false);
     if (!DefaultValue.isNull())
       Decl->setDefaultArgument(
           S.Context, S.getTrivialTemplateArgumentLoc(DefaultValue, QualType(),
                                                      SourceLocation()));
-
     Params.emplace_back(Decl);
     return *this;
   }
 
-  BuiltinTypeDeclBuilder &finalizeTemplateArgs() {
+  /*
+  The concept specialization expression (CSE) constructed below is constructed
+  so that it matches the CSE that is constructed when parsing
+  the below C++ code:
+
+  template<typename T>
+  concept is_typed_resource_element_compatible =sizeof(T) <= 16;
+
+  template<typename element_type> requires
+  is_typed_resource_element_compatible<element_type>
+
+  struct RWBuffer {
+      element_type Val;
----------------
damyanp wrote:

I don't think that the code in this comment really matches the AST that's being built.

RWBuffer doesn't have a member of type element_type, for example.  

I _think_ that this function is just building up the AST that corresponds to the `requires is_typed_resource_element_compatible<element_Type>` part?

The AST nodes for ` template<typename T> concept is_typed_resource_element_compatible =sizeof(T) <= 16;`
itself is created in constructTypedBufferConceptDecl?

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


More information about the cfe-commits mailing list