[clang] [BoundsSafety][Clang][Sema][AST] Introduce CThisExpr for C __counted_by attributes (PR #199241)

Henrik G. Olsson via cfe-commits cfe-commits at lists.llvm.org
Sat May 23 08:01:05 PDT 2026


================
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -ast-dump %s | FileCheck %s
+
+// Verifying that CThisExpr generation works for sturct fields
+struct Packet {
+    int size;
+    int *data __attribute__((counted_by(size)));
+};
+
+// CHECK: RecordDecl {{.*}} struct Packet definition
+// CHECK: FieldDecl {{.*}} size 'int'
+// CHECK: FieldDecl {{.*}} data 'int * __counted_by(this->size)':'int *'
----------------
hnrklssn wrote:

Asking the room: would there be any issues with these nodes printing as `this->size` despite that technically not being valid C, or is that used purely for compiler development?

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


More information about the cfe-commits mailing list