Upstream PR: llvm#199241
Related upstream issue: llvm#197250
What upstream is changing
The PR introduces a new CThisExpr AST node — a C-side analogue of
CXXThisExpr — so that field references inside C bounds-safety and
thread-safety attribute arguments (e.g. __counted_by(size),
__sized_by(...), guarded_by(...)) are represented as a proper
MemberExpr with a CThisExpr base, instead of the current hack of
using a DeclRefExpr that points directly at a FieldDecl.
The upstream motivation is that a DeclRefExpr → FieldDecl is not a
legal AST shape and crashes type builders such as
BuildCountAttributedArrayOrPointerType.
Why this matters for swiftlang/llvm-project
Downstream has a full -fbounds-safety implementation which relies on the DeclRefExpr → FieldDecl AST shape. We will need to migrate those to the CThisExpr → MemberExpr shape.
Goal
Pull CThisExpr into swiftlang/llvm-project/next before the
upstream PR merges, so that our downstream field-reference representation is aligned with the direction upstream is taking, avoiding a large one-shot rebase later.
Upstream PR: llvm#199241
Related upstream issue: llvm#197250
What upstream is changing
The PR introduces a new
CThisExprAST node — a C-side analogue ofCXXThisExpr— so that field references inside C bounds-safety andthread-safety attribute arguments (e.g.
__counted_by(size),__sized_by(...),guarded_by(...)) are represented as a properMemberExprwith aCThisExprbase, instead of the current hack ofusing a
DeclRefExprthat points directly at aFieldDecl.The upstream motivation is that a
DeclRefExpr → FieldDeclis not alegal AST shape and crashes type builders such as
BuildCountAttributedArrayOrPointerType.Why this matters for swiftlang/llvm-project
Downstream has a full
-fbounds-safetyimplementation which relies on theDeclRefExpr → FieldDeclAST shape. We will need to migrate those to theCThisExpr → MemberExprshape.Goal
Pull
CThisExprintoswiftlang/llvm-project/nextbefore theupstream PR merges, so that our downstream field-reference representation is aligned with the direction upstream is taking, avoiding a large one-shot rebase later.