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

Implement a throw or raise statement #1733

Merged
merged 34 commits into from
Oct 18, 2024
Merged

Implement a throw or raise statement #1733

merged 34 commits into from
Oct 18, 2024

Conversation

maximiliankaul
Copy link
Contributor

@maximiliankaul maximiliankaul commented Sep 26, 2024

This PR implements a new ThrowStatement

  • Check the new node. Does it work for all supported languages?
  • Implement EOG
  • Implement DFG
  • Implement all other relevant passes (are there any?)
  • Implement fluent tests

The language specific implementations will be handled in separate PRs:

  • C++ currently uses a UnaryOperator
  • Implement for Python Python: raise #1741
  • Implement for other languages

@maximiliankaul maximiliankaul self-assigned this Sep 26, 2024
Copy link

sonarcloud bot commented Sep 27, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
29.6% Coverage on New Code (required ≥ 75%)

See analysis details on SonarCloud

@maximiliankaul maximiliankaul changed the title Add a RaiseStatement Implement a throw or raise statement Sep 27, 2024
@maximiliankaul maximiliankaul removed their assignment Sep 27, 2024
@maximiliankaul maximiliankaul added the graph-changing This change breaks the current graph structure, i.e. it changes semantic of properties and edges label Sep 27, 2024
@KuechA KuechA mentioned this pull request Oct 2, 2024
maximiliankaul and others added 12 commits October 4, 2024 16:02
* Rename `findSymbols` into `lookupSymbolByName`

This PR renames `findSymbols` into `lookupSymbolByName` as a more appropriate name, because it lookups a symbol by its name.

Fixes #1767

* Update cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/ScopeManager.kt

Co-authored-by: KuechA <[email protected]>

* Added documentation

---------

Co-authored-by: KuechA <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Added language trait `HasImplicit Receiver`

This is needed in preparation for #1777 to better handle access to fields/members of a class when an implicit receiver is used.
* Add new function `lookupUniqueTypeSymbolByName`

This adds two new functions `ScopeManager.lookupUniqueTypeSymbolByName` and `Reference.doesReferToType`. This harmonizes a lot of boilerplate code in type resolver, cxx extra pass and resolve ambuigity pass, which were all trying to achieve the same thing.

Fixes #1766

* Fixed issue with Go test, more robust handling of wrapped references

* Addressed code review
… nodes (#1783)

* Make sure to move `typeObservers` from old to new node when replacing nodes

* Added doc for typeobservers
Named expressions in Python use `:=` as operator. Therefore we need to include it in the language definition. Otherwise, the `access` value of a reference will not be set correctly.
@KuechA
Copy link
Contributor

KuechA commented Oct 9, 2024

We should keep in mind to enable throwing/raising the exception when handling the with statement once this feature is available and #1757 is merged.

Copy link

codecov bot commented Oct 10, 2024

Codecov Report

Attention: Patch coverage is 67.79661% with 19 lines in your changes missing coverage. Please review.

Project coverage is 74.99%. Comparing base (e956427) to head (0be08ca).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...hofer/aisec/cpg/graph/statements/ThrowStatement.kt 48.27% 14 Missing and 1 partial ⚠️
...in/de/fraunhofer/aisec/cpg/graph/builder/Fluent.kt 66.66% 0 Missing and 2 partials ⚠️
.../de/fraunhofer/aisec/cpg/graph/StatementBuilder.kt 83.33% 1 Missing ⚠️
...hofer/aisec/cpg/passes/EvaluationOrderGraphPass.kt 93.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
...n/kotlin/de/fraunhofer/aisec/cpg/passes/DFGPass.kt 82.53% <100.00%> (+0.95%) ⬆️
.../de/fraunhofer/aisec/cpg/graph/StatementBuilder.kt 73.33% <83.33%> (-13.71%) ⬇️
...hofer/aisec/cpg/passes/EvaluationOrderGraphPass.kt 90.79% <93.33%> (+0.15%) ⬆️
...in/de/fraunhofer/aisec/cpg/graph/builder/Fluent.kt 87.21% <66.66%> (-0.26%) ⬇️
...hofer/aisec/cpg/graph/statements/ThrowStatement.kt 48.27% <48.27%> (ø)

... and 119 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@maximiliankaul maximiliankaul marked this pull request as ready for review October 10, 2024 13:08
@KuechA
Copy link
Contributor

KuechA commented Oct 10, 2024

The changes itself look ok to me, but the test coverage is a bit low. Easy fixes could be: Try different throws (with and without parentException, with and without exception). It would also make sense to cover the EOG by having some try/catch surrounding the throw

@KuechA KuechA merged commit a12951b into main Oct 18, 2024
4 of 5 checks passed
@KuechA KuechA deleted the mk/raiseStmt branch October 18, 2024 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
graph-changing This change breaks the current graph structure, i.e. it changes semantic of properties and edges
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants