Skip to content
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

Get rid of lambda within HIR::TupleStruct #707

Closed
philberty opened this issue Oct 5, 2021 · 0 comments · Fixed by #727
Closed

Get rid of lambda within HIR::TupleStruct #707

philberty opened this issue Oct 5, 2021 · 0 comments · Fixed by #727

Comments

@philberty
Copy link
Member

void iterate (std::function<bool (TupleField &)> cb)
{
for (auto &field : fields)
{
if (!cb (field))
return;
}
}

Lambda's like this need to be removed they make working with the IR's more complex for static analysis. To fix this issue you should be able to remove this lambda helper function and provide a method to return a reference to the values like

Create a new helper to access the elements:

std::vector<TupleField>& get_fields() { return fields; }
dafaust added a commit to dafaust/gccrs that referenced this issue Oct 7, 2021
dafaust added a commit to dafaust/gccrs that referenced this issue Oct 7, 2021
dkm pushed a commit to dkm/gccrs that referenced this issue Oct 8, 2021
This patch removes the lambda iterators used in various HIR objects.
These iterators make interacting with the IR for static analysis more
difficult. Instead, get_X () helpers are added for accessing elements,
and uses of the iterators replaced with for loops.

The following objects are adjusted in this patch:
- HIR::TupleExpr
- HIR::StructExprField
- HIR::StructStruct
- HIR::TupleStruct

Fixes: Rust-GCC#703, Rust-GCC#704, Rust-GCC#705, Rust-GCC#706, Rust-GCC#707
dafaust added a commit to dafaust/gccrs that referenced this issue Oct 11, 2021
This patch removes the lambda iterators used in various HIR objects.
These iterators make interacting with the IR for static analysis more
difficult. Instead, get_X () helpers are added for accessing elements,
and uses of the iterators replaced with for loops.

The following objects are adjusted in this patch:
- HIR::ArrayElemsValues
- HIR::TupleExpr
- HIR::StructExprField
- HIR::StructStruct
- HIR::TupleStruct

Fixes: Rust-GCC#703, Rust-GCC#704, Rust-GCC#705, Rust-GCC#706, Rust-GCC#707
dafaust added a commit to dafaust/gccrs that referenced this issue Oct 11, 2021
This patch removes the lambda iterators used in various HIR objects.
These iterators make interacting with the IR for static analysis more
difficult. Instead, get_X () helpers are added for accessing elements,
and uses of the iterators replaced with for loops.

The following objects are adjusted in this patch:
- HIR::ArrayElemsValues
- HIR::TupleExpr
- HIR::StructExprField
- HIR::StructStruct
- HIR::TupleStruct

Fixes: Rust-GCC#703, Rust-GCC#704, Rust-GCC#705, Rust-GCC#706, Rust-GCC#707
bors bot added a commit that referenced this issue Oct 13, 2021
710: Ensure for Coercion Sites we emit the code nessecary r=philberty a=philberty

Coercion sites in Rust can require extra code generation for
CallExpressions arguments for example. This ensures we detect
those cases and emit the extra code necessary. Please read the individual
commit messages for more detail on how this works.

Fixes #700 #708 #709  

727: Remove lambda iterators in various HIR classes r=philberty a=dafaust

(This is a revision of #726 with formatting fixes)

This patch removes the lambda iterators used in various HIR objects.
These iterators make interacting with the IR for static analysis more
difficult. Instead, get_X () helpers are added for accessing elements,
and uses of the iterators replaced with for loops.

The following objects are adjusted in this patch:
- HIR::ArrayElemsValues
- HIR::TupleExpr
- HIR::StructExprField
- HIR::StructStruct
- HIR::TupleStruct

Fixes: #703 
Fixes: #704 
Fixes: #705 
Fixes: #706 
Fixes: #707

Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Co-authored-by: David Faust <david.faust@oracle.com>
@bors bors bot closed this as completed in #727 Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant