Skip to content

[CIR] Make AST attributes accessible via interfaces. #250

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 25 commits into from
Sep 18, 2023

Conversation

xlauko
Copy link
Collaborator

@xlauko xlauko commented Sep 2, 2023

  • Introduces CIR/Interfaces/ASTAttrInterfaces which model API of clang AST nodes, but allows to plugin custom attribute, making CIR dialect AST independent.

  • Extends hierarchy of DeclAttrs to model Decl attributes more faithfully.

  • Notably all CIRASTAttrs are now created uniformly using makeAstDeclAttr which builds corresponding Attribute based on clang::Decl.

@xlauko xlauko force-pushed the ast-attr-interfaces branch from 3dd6fec to ad0d916 Compare September 2, 2023 12:01
Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

This is great work @xlauko, I'm excited to see progress connecting our projects!

Direction looks good, thanks a lot of putting this PR up, first round of reviews are in inline comments!

let methods = [
InterfaceMethod< "", "bool", "isLambda", (ins), [{}],
/*defaultImplementation=*/ [{
return $_attr.getAstDecl()->isLambda();
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for mapping at length all the stuff we currently use from the AST. As we move into encoding some extra information directly into CIR, I believe we might slowly get rid of some of these, and this will naturally serve as documentation of how much AST we end up using all around.

Is there any nodes you've added for the sake of completeness or is all of this actually used in CIR? I'd suggest we keep this list only reflecting what we currently use, so we don't unnecessarily bloat out the interface with things we don't yet have a use case for.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was everything I needed to compile and pass tests. I only added additional intermediate Interfaces from AST hierarchy, which are empty in such case. Also to replicate API of ASTs I put methods to corresponding Interfaces, even though you do not use the interface directly, but inherit the method from base interface, e.g. NamedDecl provide getDeclName which you use only through VarDeclInterface.

Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

Thanks for applying a bunch of changes, few more comments!

@bcardosolopes
Copy link
Member

bcardosolopes commented Sep 7, 2023

Regarding clang-format: there's a mode where it only apply formatting changes to the actual changes you make, otherwise fixing random things in a file generate noise for reviewers because unrelated changes. It's fine to leave them around for this patch, but if you end up creating more content, please use that mode.

@xlauko
Copy link
Collaborator Author

xlauko commented Sep 8, 2023

Yeah, sorry for that, I was expecting everything else was formatted. I noticed that only after push.

@xlauko xlauko force-pushed the ast-attr-interfaces branch 5 times, most recently from 832d40f to 6c59cba Compare September 8, 2023 13:27
@xlauko
Copy link
Collaborator Author

xlauko commented Sep 8, 2023

@bcardosolopes Hopefully everything is fixed and rebased :) check-clang passes (at least on my machine) :D

Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

This is great, LGTM with some minor changes from inline comments.

@xlauko xlauko force-pushed the ast-attr-interfaces branch 3 times, most recently from 58623c4 to 6a650bb Compare September 15, 2023 11:53
@xlauko xlauko force-pushed the ast-attr-interfaces branch from 6a650bb to ac1f8b7 Compare September 18, 2023 06:18
@xlauko xlauko force-pushed the ast-attr-interfaces branch from ac1f8b7 to d022d25 Compare September 18, 2023 06:20
@xlauko
Copy link
Collaborator Author

xlauko commented Sep 18, 2023

@bcardosolopes I rebased to current main, fixing conflicts in missing bitfield tests. Nothing else changed, so feel free to merge.

@htyu htyu merged commit 2d8bd16 into llvm:main Sep 18, 2023
lanza pushed a commit that referenced this pull request Oct 27, 2023
- Introduces `CIR/Interfaces/ASTAttrInterfaces` which model API of clang
AST nodes, but allows to plugin custom attribute, making `CIR` dialect
AST independent.

- Extends hierarchy of `DeclAttr`s to model `Decl` attributes more
faithfully.
- Notably all `CIRASTAttr`s are now created uniformly using
`makeAstDeclAttr` which builds corresponding Attribute based on
`clang::Decl`.
lanza pushed a commit that referenced this pull request Dec 20, 2023
- Introduces `CIR/Interfaces/ASTAttrInterfaces` which model API of clang
AST nodes, but allows to plugin custom attribute, making `CIR` dialect
AST independent.

- Extends hierarchy of `DeclAttr`s to model `Decl` attributes more
faithfully.
- Notably all `CIRASTAttr`s are now created uniformly using
`makeAstDeclAttr` which builds corresponding Attribute based on
`clang::Decl`.
lanza pushed a commit that referenced this pull request Jan 29, 2024
- Introduces `CIR/Interfaces/ASTAttrInterfaces` which model API of clang
AST nodes, but allows to plugin custom attribute, making `CIR` dialect
AST independent.

- Extends hierarchy of `DeclAttr`s to model `Decl` attributes more
faithfully.
- Notably all `CIRASTAttr`s are now created uniformly using
`makeAstDeclAttr` which builds corresponding Attribute based on
`clang::Decl`.
lanza pushed a commit that referenced this pull request Mar 23, 2024
- Introduces `CIR/Interfaces/ASTAttrInterfaces` which model API of clang
AST nodes, but allows to plugin custom attribute, making `CIR` dialect
AST independent.

- Extends hierarchy of `DeclAttr`s to model `Decl` attributes more
faithfully.
- Notably all `CIRASTAttr`s are now created uniformly using
`makeAstDeclAttr` which builds corresponding Attribute based on
`clang::Decl`.
eZWALT pushed a commit to eZWALT/clangir that referenced this pull request Mar 24, 2024
- Introduces `CIR/Interfaces/ASTAttrInterfaces` which model API of clang
AST nodes, but allows to plugin custom attribute, making `CIR` dialect
AST independent.

- Extends hierarchy of `DeclAttr`s to model `Decl` attributes more
faithfully.
- Notably all `CIRASTAttr`s are now created uniformly using
`makeAstDeclAttr` which builds corresponding Attribute based on
`clang::Decl`.
eZWALT pushed a commit to eZWALT/clangir that referenced this pull request Mar 24, 2024
- Introduces `CIR/Interfaces/ASTAttrInterfaces` which model API of clang
AST nodes, but allows to plugin custom attribute, making `CIR` dialect
AST independent.

- Extends hierarchy of `DeclAttr`s to model `Decl` attributes more
faithfully.
- Notably all `CIRASTAttr`s are now created uniformly using
`makeAstDeclAttr` which builds corresponding Attribute based on
`clang::Decl`.
lanza pushed a commit that referenced this pull request Apr 29, 2024
- Introduces `CIR/Interfaces/ASTAttrInterfaces` which model API of clang
AST nodes, but allows to plugin custom attribute, making `CIR` dialect
AST independent.

- Extends hierarchy of `DeclAttr`s to model `Decl` attributes more
faithfully.
- Notably all `CIRASTAttr`s are now created uniformly using
`makeAstDeclAttr` which builds corresponding Attribute based on
`clang::Decl`.
lanza pushed a commit that referenced this pull request Apr 29, 2024
- Introduces `CIR/Interfaces/ASTAttrInterfaces` which model API of clang
AST nodes, but allows to plugin custom attribute, making `CIR` dialect
AST independent.

- Extends hierarchy of `DeclAttr`s to model `Decl` attributes more
faithfully.
- Notably all `CIRASTAttr`s are now created uniformly using
`makeAstDeclAttr` which builds corresponding Attribute based on
`clang::Decl`.
eZWALT pushed a commit to eZWALT/clangir that referenced this pull request Apr 29, 2024
- Introduces `CIR/Interfaces/ASTAttrInterfaces` which model API of clang
AST nodes, but allows to plugin custom attribute, making `CIR` dialect
AST independent.

- Extends hierarchy of `DeclAttr`s to model `Decl` attributes more
faithfully.
- Notably all `CIRASTAttr`s are now created uniformly using
`makeAstDeclAttr` which builds corresponding Attribute based on
`clang::Decl`.
lanza pushed a commit that referenced this pull request Apr 29, 2024
- Introduces `CIR/Interfaces/ASTAttrInterfaces` which model API of clang
AST nodes, but allows to plugin custom attribute, making `CIR` dialect
AST independent.

- Extends hierarchy of `DeclAttr`s to model `Decl` attributes more
faithfully.
- Notably all `CIRASTAttr`s are now created uniformly using
`makeAstDeclAttr` which builds corresponding Attribute based on
`clang::Decl`.
bruteforceboy pushed a commit to bruteforceboy/clangir that referenced this pull request Oct 2, 2024
- Introduces `CIR/Interfaces/ASTAttrInterfaces` which model API of clang
AST nodes, but allows to plugin custom attribute, making `CIR` dialect
AST independent.

- Extends hierarchy of `DeclAttr`s to model `Decl` attributes more
faithfully.
- Notably all `CIRASTAttr`s are now created uniformly using
`makeAstDeclAttr` which builds corresponding Attribute based on
`clang::Decl`.
Hugobros3 pushed a commit to shady-gang/clangir that referenced this pull request Oct 2, 2024
- Introduces `CIR/Interfaces/ASTAttrInterfaces` which model API of clang
AST nodes, but allows to plugin custom attribute, making `CIR` dialect
AST independent.

- Extends hierarchy of `DeclAttr`s to model `Decl` attributes more
faithfully.
- Notably all `CIRASTAttr`s are now created uniformly using
`makeAstDeclAttr` which builds corresponding Attribute based on
`clang::Decl`.
keryell pushed a commit to keryell/clangir that referenced this pull request Oct 19, 2024
- Introduces `CIR/Interfaces/ASTAttrInterfaces` which model API of clang
AST nodes, but allows to plugin custom attribute, making `CIR` dialect
AST independent.

- Extends hierarchy of `DeclAttr`s to model `Decl` attributes more
faithfully.
- Notably all `CIRASTAttr`s are now created uniformly using
`makeAstDeclAttr` which builds corresponding Attribute based on
`clang::Decl`.
lanza pushed a commit that referenced this pull request Nov 5, 2024
- Introduces `CIR/Interfaces/ASTAttrInterfaces` which model API of clang
AST nodes, but allows to plugin custom attribute, making `CIR` dialect
AST independent.

- Extends hierarchy of `DeclAttr`s to model `Decl` attributes more
faithfully.
- Notably all `CIRASTAttr`s are now created uniformly using
`makeAstDeclAttr` which builds corresponding Attribute based on
`clang::Decl`.
@xlauko xlauko deleted the ast-attr-interfaces branch February 7, 2025 12:28
lanza pushed a commit that referenced this pull request Mar 18, 2025
- Introduces `CIR/Interfaces/ASTAttrInterfaces` which model API of clang
AST nodes, but allows to plugin custom attribute, making `CIR` dialect
AST independent.

- Extends hierarchy of `DeclAttr`s to model `Decl` attributes more
faithfully.
- Notably all `CIRASTAttr`s are now created uniformly using
`makeAstDeclAttr` which builds corresponding Attribute based on
`clang::Decl`.
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.

3 participants