llvm / llvm/llvm-project

Call `ActOnFields` before late parsing in `ParseStructUnionBody`

Open
#186,914 1 comment 0 reactions 1 assignee Claimed by @Pengxiang-Huang View on GitHub
clang:bounds-safety
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.