Skip to content

C#: Avoid CIL instructions with multiple types #7321

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

Merged
merged 3 commits into from
Dec 10, 2021

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Dec 6, 2021

Identified via #7231.

@github-actions github-actions bot added the C# label Dec 6, 2021
@hvitved hvitved marked this pull request as ready for review December 7, 2021 10:16
@hvitved hvitved requested a review from a team as a code owner December 7, 2021 10:16
Comment on lines +78 to +79
result.(PrimitiveType).getUnderlyingType().getConversionIndex() >
t2.(PrimitiveType).getUnderlyingType().getConversionIndex()
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this basically check if there's an implicit numeric conversion from t2 to t1? If so, don't we need to also cover other implicit conversions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this only covers implicit conversions. There is also a case for when one of the operands is null. I haven't run into other cases.

@@ -73,8 +73,8 @@ class ComparisonOperation extends BinaryExpr, @cil_comparison_operation {
class BinaryArithmeticExpr extends BinaryExpr, @cil_binary_arithmetic_operation {
override Type getType() {
exists(Type t0, Type t1 |
t0 = this.getOperand(0).getType().getUnderlyingType() and
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe adding a comment onto Expr::getType() mentioning that there's an alternative getOperandType which should be used instead of getOperand(X).getType() would be beneficial.

Should all instances be changed?

I found that ex.getExpr().getType() also calls getOperand(X).getType in

forex(Throw ex | ex = m.getImplementation().getAnInstruction() | t = ex.getExpr().getType())

@hvitved hvitved merged commit cf42427 into github:main Dec 10, 2021
@hvitved hvitved deleted the csharp/cil/unique-type branch December 10, 2021 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants