Skip to content

Commit 795b767

Browse files
committed
add link to the source variable in the alert-message for java/implicit-cast-in-compound-assignment
1 parent 2256c4c commit 795b767

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

java/ql/src/Likely Bugs/Arithmetic/InformationLoss.ql

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ class DangerousAssignOpExpr extends AssignOp {
2727

2828
predicate problematicCasting(Type t, Expr e) { e.getType().(NumType).widerThan(t) }
2929

30-
from DangerousAssignOpExpr a, Expr e
30+
from DangerousAssignOpExpr a, Expr e, Variable v
3131
where
3232
e = a.getSource() and
33-
problematicCasting(a.getDest().getType(), e)
33+
problematicCasting(a.getDest().getType(), e) and
34+
v = a.getDest().(VarAccess).getVariable()
3435
select a,
35-
"Implicit cast of source type " + e.getType().getName() + " to narrower destination type " +
36-
a.getDest().getType().getName() + "."
36+
"Implicit cast of source $@ to narrower destination type " + a.getDest().getType().getName() + ".",
37+
v, "type " + e.getType().getName()
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
| Test.java:68:5:68:25 | ...+=... | Implicit cast of source type long to narrower destination type int. |
2-
| Test.java:87:4:87:9 | ...+=... | Implicit cast of source type long to narrower destination type int. |
1+
| Test.java:68:5:68:25 | ...+=... | Implicit cast of source $@ to narrower destination type int. | Test.java:64:4:64:13 | int i | type long |
2+
| Test.java:87:4:87:9 | ...+=... | Implicit cast of source $@ to narrower destination type int. | Test.java:81:4:81:13 | int i | type long |

0 commit comments

Comments
 (0)