Skip to content

[Clang importer] Consider attributes on the typedef name for an anonymous tag #42604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

DougGregor
Copy link
Member

In C, one can provide a typedef name for an anonymous tag declaration in
one shot, e.g.,

typedef struct {
  double x, y
} Point;

In this case, there are effectively two declarations at the C level:
the typedef and the struct. The Clang importer was only taking
attributes from the anonymous struct (i.e., the tag) and not from the
typedef. However, any attributes put before the typedef should apply
as well... so consider those, too.

For now, only do this for swift_attr attributes, because we're
seeing this primarily with Sendable annotations. In the future, we
can look to generalizing it, but that could have source-breaking
consequences.

Fixes rdar://91632960.

…mous tag.

In C, one can provide a typedef name for an anonymous tag declaration in
one shot, e.g.,

    typedef struct {
      double x, y
    } Point;

In this case, there are effectively two declarations at the C level:
the typedef and the struct. The Clang importer was only taking
attributes from the anonymous struct (i.e., the tag) and not from the
typedef. However, any attributes put before the `typedef` should apply
as well... so consider those, too.

For now, only do this for `swift_attr` attributes, because we're
seeing this primarily with `Sendable` annotations. In the future, we
can look to generalizing it, but that could have source-breaking
consequences.

Fixes rdar://91632960.
@DougGregor DougGregor requested a review from a team as a code owner April 23, 2022 00:45
@DougGregor
Copy link
Member Author

@swift-ci please test

@hborla hborla merged commit 6600e5c into swiftlang:release/5.7-04182022 Apr 23, 2022
@DougGregor DougGregor deleted the clang-importer-anonymous-tag-typedef-attrs-5.7-04182022 branch April 23, 2022 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants