Skip to content

Commit 90a7b9f

Browse files
committed
SE: support more assignements operators
1 parent 7410102 commit 90a7b9f

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

java-squid/src/main/java/org/sonar/java/se/ExplodedGraphWalker.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,19 @@ private void visit(Tree tree, @Nullable Tree terminator) {
313313
programState = programState.stackValue(constraintManager.createSymbolicValue(typeCast.expression()));
314314
}
315315
break;
316+
316317
case ASSIGNMENT:
318+
case MULTIPLY_ASSIGNMENT:
319+
case DIVIDE_ASSIGNMENT:
320+
case REMAINDER_ASSIGNMENT:
321+
case PLUS_ASSIGNMENT:
322+
case MINUS_ASSIGNMENT:
323+
case LEFT_SHIFT_ASSIGNMENT:
324+
case RIGHT_SHIFT_ASSIGNMENT:
325+
case UNSIGNED_RIGHT_SHIFT_ASSIGNMENT:
326+
case AND_ASSIGNMENT:
327+
case XOR_ASSIGNMENT:
328+
case OR_ASSIGNMENT:
317329
ExpressionTree variable = ((AssignmentExpressionTree) tree).variable();
318330
if (variable.is(Tree.Kind.IDENTIFIER)) {
319331
// FIXME restricted to identifiers for now.

java-squid/src/test/files/se/ConditionAlwaysTrueOrFalseCheck.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,4 +1242,13 @@ private void castNumbers(long n, long m) {
12421242
handleProper(truncatedProduct);
12431243
}
12441244
}
1245+
1246+
private void orEqualAssignement(boolean a) {
1247+
boolean foo = false;
1248+
foo |= a;
1249+
if(foo) {}
1250+
foo = false;
1251+
foo &= a;
1252+
if(foo) {} //false negative: Should be fixed by SONARJAVA-1391
1253+
}
12451254
}

0 commit comments

Comments
 (0)