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

Rust: insert CallExprBase in the hierarchy #17730

Merged
merged 5 commits into from
Oct 11, 2024
Merged

Conversation

redsun82
Copy link
Contributor

@redsun82 redsun82 commented Oct 10, 2024

As both CallExpr and MethodCallExpr are generated, this required additions to the annotation machinery:

  • the ability to replace a base (in this case, Expr -> CallExprBase)
  • the ability to drop fields (in this case, the fields in CallExprBase, to avoid them being repeated in the derived classes)

@redsun82 redsun82 requested review from hvitved and aibaars October 10, 2024 12:46
@redsun82 redsun82 requested a review from a team as a code owner October 10, 2024 12:46
@github-actions github-actions bot added the Rust Pull requests that update Rust code label Oct 10, 2024
rust/schema/annotations.py Show resolved Hide resolved
@@ -185,8 +185,15 @@ class _:
```
"""

class FunctionOrMethodCallExpr(Expr):
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the name FunctionOrMethodCallExpr is a bit long. Perhaps shorted to CallExprBase ?

Copy link
Contributor Author

@redsun82 redsun82 Oct 10, 2024

Choose a reason for hiding this comment

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

I considered that, though I did not like breaking the -Expr postfixing. On the other hand I find CallBaseExpr confusing though. I also considered AnyCallExpr, which I might be persuaded to. I like the explicitness of FunctionOrMethodCallExpr that makes it clear what it is without having to go to its docs, but I do agree it's a bit long. Any thoughts on this @hvitved?

Copy link
Contributor

Choose a reason for hiding this comment

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

Should ClosureExpr's also share the same base-class ?If so the name FunctionOrMethodCallOrClosureExpr would definitely get a bit too specific for my taste ;-)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I prefer CallExprBase, despite breaking the suffix Expr invariant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, renaming now to CallExprBase. ClosureExpr is a function object (that may land or be referenced in CallExpr::expr), not a call, so it should not come beneath this class.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes of course.

@@ -20,6 +20,7 @@
import codeql.rust.elements.BoxPat
import codeql.rust.elements.BreakExpr
import codeql.rust.elements.CallExpr
import codeql.rust.elements.CallExprBase

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.CallExpr
.
Redundant import, the module is already imported inside
codeql.rust.elements.MethodCallExpr
.
private import internal.CallExprBaseImpl
import codeql.rust.elements.ArgList
import codeql.rust.elements.Attr
import codeql.rust.elements.Expr

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.ArgList
.
@redsun82 redsun82 changed the title Rust: insert FunctionOrMethodCallExpr in the hierarchy Rust: insert CallExprBase in the hierarchy Oct 11, 2024
@redsun82 redsun82 merged commit 854d766 into main Oct 11, 2024
23 of 24 checks passed
@redsun82 redsun82 deleted the redsun82/codegen-annotate branch October 11, 2024 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants