[clang] [HLSL] Add implicit resource element type concepts to AST (PR #112600)
Joshua Batista via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 7 14:35:37 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;
----------------
bob80905 wrote:
I agree that when parsing the C++ code in the comment, it produces more of the AST than the function is producing, but I still believe that including that extra context in the comments is helpful. The C++ code adds the structure "RWBuffer", and though it isn't being produced by `constructConceptSpecializationExpr`, it helps to know what code can be copy pasted into godbolt, for example, to see the AST that would be produced.
I had originally wanted to paste the AST that would be produced, but figured getting the source code would help explain the code better and also allow those who are interested to get the AST from the code.
The first point of the comment says that
"The concept specialization expression (CSE) constructed below is constructed
so that it matches the CSE that is constructed when parsing
the below C++ code:"
Which is still accurate. The code in the function isn't claiming to be responsible for the whole AST. I will reword it slightly for more clarity.
For your last 2 questions, yes I think your statements are accurate.
https://github.com/llvm/llvm-project/pull/112600
More information about the cfe-commits
mailing list