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

Overhaul of type propagation #1268

Merged
merged 48 commits into from
Aug 9, 2023
Merged

Overhaul of type propagation #1268

merged 48 commits into from
Aug 9, 2023

Conversation

oxisto
Copy link
Member

@oxisto oxisto commented Jul 29, 2023

This PR is a major overhaul of the existing type listeners. This should greatly improve type parsing. The PR is actually slightly too big, but unfortunately a lot of things were dependent on each other and could not be fixed in smaller steps.

Changes

  • Renamed TypeListener into TypeObserver and made its documentation a lot clearer
  • Looked carefully at every Node, to see whether we really need a TypeObserver and (hopefully) removed all loops in type propagation
  • Smaller changes and fixes to the type handling of the CXXLanguageFrontend
  • Replaced all usages of a BinaryOperator using the = operator with an AssignExpression. Creating a binary operator with = or a compound assignment will now throw a TranslationException
  • Added support for compound assignments using AssignExpression in the ValueEvaluator and MultiValueEvaluator
  • Removed the type cache that was used in parallel parsing. Now, the type system is active even if parallel parsing is used. This probably needs a bit more testing, if this does not lead to any concurrent modification errors, but for now it seems to be fine
  • With the removal of the type caching, I also got rid of the slightly weird _type variables and the setType function. Now only a type variable exists and a Kolin setter is used to inform the type observers.
  • Moved the creation of DFG edges of an InitializerListExpression back to the DFGPass instead of the class itself. It was moved there because of performance issues, which seem to be resolved now.
  • Introduced a new shortcut that allows to "invoke" a list of nodes using a Kotlin class and an index (which defaults to 0). This can be used to retrieve a certain index in a node list and cast it to a specific class - or return null if its not castable. For example: assign.lhs<DeclaredReferenceExpression>() will retrieve the first element in lhs of an AssignExpression and cast it to DeclaredReferenceExpression?.

Fixes

Fixes #204
Fixes #705
Fixes #1071
Fixes #1260
Fixes #1262
Fixes #1263
Fixes #1269
Fixes #1270

@oxisto oxisto force-pushed the new-type-propagation branch 3 times, most recently from e2a6c51 to a119c23 Compare July 31, 2023 19:39
@oxisto oxisto force-pushed the new-type-propagation branch from b447307 to 23eb330 Compare August 5, 2023 13:41
@oxisto oxisto marked this pull request as ready for review August 5, 2023 18:12
@oxisto oxisto force-pushed the new-type-propagation branch 3 times, most recently from 45fd258 to af60ff3 Compare August 7, 2023 09:13
@oxisto oxisto force-pushed the new-type-propagation branch 2 times, most recently from 6d6045b to 4c28ecb Compare August 8, 2023 07:36
Copy link
Contributor

@maximiliankaul maximiliankaul left a comment

Choose a reason for hiding this comment

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

Python: LGTM.
Other changes as far as I understand them 👍

@oxisto oxisto force-pushed the new-type-propagation branch from 7f2fb44 to ec24e91 Compare August 9, 2023 07:55
@oxisto oxisto enabled auto-merge (squash) August 9, 2023 07:57
@sonarcloud
Copy link

sonarcloud bot commented Aug 9, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 7 Code Smells

75.7% 75.7% Coverage
1.0% 1.0% Duplication

@oxisto oxisto merged commit 8b9b297 into main Aug 9, 2023
@oxisto oxisto deleted the new-type-propagation branch August 9, 2023 08:04
oxisto added a commit that referenced this pull request Aug 9, 2023
Co-authored-by: Alexander Kuechler <alexander.kuechler@aisec.fraunhofer.de>
Co-authored-by: Maximilian Kaul <maximilian.kaul@aisec.fraunhofer.de>
oxisto added a commit that referenced this pull request Aug 9, 2023
Co-authored-by: Alexander Kuechler <alexander.kuechler@aisec.fraunhofer.de>
Co-authored-by: Maximilian Kaul <maximilian.kaul@aisec.fraunhofer.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants