Skip to content

Reconcile changes from upstream PR to introduce CThisExpr #13568

Description

@rapidsna

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.

Metadata

Metadata

Labels

clang:bounds-safetyIssue relating to the experimental -fbounds-safety feature in Clang

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions