Skip to content

[AST] Dump decl attributes #77937

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

Merged
merged 1 commit into from
Dec 4, 2024
Merged

[AST] Dump decl attributes #77937

merged 1 commit into from
Dec 4, 2024

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Dec 3, 2024

Previously only some random decl attributes were included in the dump with the source spelling (e.g. @objc), or some affected how the decl is dumped. But the full attribute list has not been dumped. Dumping attributes are useful for debugging attribute handling.

@rintaro
Copy link
Member Author

rintaro commented Dec 3, 2024

@swift-ci Please smoke test

Previously only some random decl attributes were included in the dump
with the source spelling (e.g. @objc), or some affected how the decl is
dumped. But the full attribute list has not been dumped. Dumping
attributes are useful for debugging attribute handling.
@rintaro
Copy link
Member Author

rintaro commented Dec 4, 2024

@swift-ci Please smoke test

// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/astgen.ast.raw > %t/astgen.ast

// RUN: %diff -u %t/astgen.ast %t/cpp-parser.ast

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SwiftParser/ASTGen has better recovery so AST might be different in invalid cases. It's not worth to emit the same AST.
Specifically, e.g. C++ parser discards the whole attribute for @_silgen_name("whatever", extra) because of the extra argument. But ASTGen recovers it.

@rintaro rintaro marked this pull request as ready for review December 4, 2024 06:53
printFoot(); \
}

TRIVIAL_ATTR_PRINTER(Actor, actor)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to use SIMPLE_DECL_ATTR here? LLVM has convertToSnakeFromCamelCase FWIW which could be used to convert the class name

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh, I didn't know convertToSnakeFromCamelCase. ... it seems to convert ObjCMembers to obj_c_members? which makes sense, but since we use objc_, I'd go without it for now. Unfortunate.

@rintaro rintaro merged commit 5945a89 into swiftlang:main Dec 4, 2024
3 checks passed
@rintaro rintaro deleted the ast-dump-attrs branch December 4, 2024 19:20
allevato added a commit to allevato/swift that referenced this pull request Jan 27, 2025
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