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

Extracted call/cast replacement into separate pass #1499

Merged
merged 2 commits into from
Apr 5, 2024

Conversation

oxisto
Copy link
Member

@oxisto oxisto commented Apr 3, 2024

Multiple languages, such as Go and C++ support "functional style casts", in the form of int(5). During the frontend parsing, they are indistinguishable from function calls. Therefore, we need to do a cleanup after all types are known but before other passes are invoked that replace those calls with casts. The proposed solution is to include a new language trait HasFuntionalCasts and to move the logic from the GoExtraPass into a separate, language-neutral one.

Fixes #1487

@oxisto oxisto requested a review from konradweiss as a code owner April 3, 2024 19:02
@oxisto oxisto requested a review from peckto as a code owner April 4, 2024 18:23
@oxisto
Copy link
Member Author

oxisto commented Apr 4, 2024

@KuechA thanks for the initial check. I did some additional cleanup and introduced a new annotation that can be put on passes, that they are only executed if the target (e.g. a translation unit) of the pass has a specific language trait.

Copy link
Contributor

@KuechA KuechA left a comment

Choose a reason for hiding this comment

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

We could rename the package de.fraunhofer.aisec.cpg.passes.order to something like executionConfig since the annotations do not only concern the order of passes but also if they are executed at all.

@oxisto
Copy link
Member Author

oxisto commented Apr 5, 2024

We could rename the package de.fraunhofer.aisec.cpg.passes.order to something like executionConfig since the annotations do not only concern the order of passes but also if they are executed at all.

I had a similar thought, although I will do this in an extra PR.

Multiple languages, such as Go and C++ support "functional style casts", in the form of int(5). During the frontend parsing, they are indistinguishable from function calls. Therefore, we need to do a cleanup after all types are known but before other passes are invoked that replace those calls with casts. The proposed solution is to include a new language trait HasFuntionalCasts and to move the logic from the GoExtraPass into a separate, language-neutral one.

Fixes #1487
@oxisto oxisto enabled auto-merge (squash) April 5, 2024 06:15
Copy link

sonarcloud bot commented Apr 5, 2024

@oxisto oxisto merged commit c66aad6 into main Apr 5, 2024
3 checks passed
@oxisto oxisto deleted the extracted-call-cast-pass branch April 5, 2024 07:12
maximiliankaul pushed a commit that referenced this pull request Apr 18, 2024
* Extracted call/cast replacement into separate pass

Multiple languages, such as Go and C++ support "functional style casts", in the form of int(5). During the frontend parsing, they are indistinguishable from function calls. Therefore, we need to do a cleanup after all types are known but before other passes are invoked that replace those calls with casts. The proposed solution is to include a new language trait HasFuntionalCasts and to move the logic from the GoExtraPass into a separate, language-neutral one.

Fixes #1487

* Added annotation to pass that requires a language trait
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.

Extract handling of "functional style casts" into separate pass
2 participants