llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Call `ActOnFields` before late parsing in `ParseStructUnionBody`

Open rapidsna opened this issue 8 months ago • 1 comments

In Parser::ParseStructUnionBody, we have a downstream change that calls Actions.ActOnFields before late-parsed attributes are semantically checked (upstream does the opposite). This was intentional to allow offsetof expressions in counted_by attributes to reference the current field and struct.

This divergence means the RecordDecl for the struct containing the counted_by attribute is already marked complete when GetEnclosingNamedOrTopAnonRecord calls isCompleteDefinition() on it, requiring a downstream workaround to account for this. This only manifests when late parsing is enabled.

Upstreaming the ActOnFields ordering change would eliminate the divergence and allow the workaround to be removed.

Once upstreamed, removing the downstream workaround is tracked here: https://github.com/swiftlang/llvm-project/issues/12604

rapidsna avatar Mar 16 '26 23:03 rapidsna

Hi, I would like to try on this.

Pengxiang-Huang avatar Mar 16 '26 23:03 Pengxiang-Huang