[PATCH] D135721: [HLSL] Added HLSL this as a reference

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 7 06:43:25 PST 2022


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you!



================
Comment at: clang/test/AST/HLSL/RWBuffer-AST.hlsl:49-50
 // CHECK-NEXT: ArraySubscriptExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' lvalue
-// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type *' lvalue ->h 0x{{[0-9A-Fa-f]+}}
-// CHECK-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'const RWBuffer<element_type> *' implicit this
+// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type *' lvalue .h 0x{{[0-9A-Fa-f]+}}
+// CHECK-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'const RWBuffer<element_type>' lvalue implicit this
 // CHECK-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'unsigned int' ParmVar 0x{{[0-9A-Fa-f]+}} 'Idx' 'unsigned int'
----------------
beanz wrote:
> aaron.ballman wrote:
> > `// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type *' lvalue .h 0x{{[0-9A-Fa-f]+}}`
> > 
> > I'm confused by this -- it says the type of the expression is `element_type *` but that it uses `.` as an operator instead of `->`. One of these seems like it is wrong, but perhaps I'm missing something.
> Isn't that the type of the member not the type of the `this`? This example seems to result in a pointer `MemberExpr` with a `.` access: https://godbolt.org/z/j9f5nP4s6
> 
> This is a little awkward because we have a pointer member inside this struct even though pointers are illegal in HLSL source :(
> Isn't that the type of the member not the type of the this? This example seems to result in a pointer MemberExpr with a . access: https://godbolt.org/z/j9f5nP4s6

Oh yeah, that is correct, it's the member type not the base object type. I was reading the AST dumping code incorrectly when I peeked at it, this is fine (for the moment; it'd be good to fix the illegal pointer bits but that's orthogonal).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135721/new/

https://reviews.llvm.org/D135721



More information about the cfe-commits mailing list