@@ -100,11 +100,46 @@ class YearFieldAssignmentAccess extends YearFieldAssignment{
100100}
101101
102102/**
103- *
103+ * A year field assignment, by a unary operator ie `x++`.
104104 */
105105class YearFieldAssignmentUnary extends YearFieldAssignment instanceof UnaryArithmeticOperation {
106106 YearFieldAssignmentUnary ( ) {
107- this .getOperand ( ) instanceof YearFieldAccess and
107+ this .getOperand ( ) instanceof YearFieldAccess
108+ }
109+ }
110+
111+ class MonthOrDayFieldAccess extends FieldAccess {
112+ MonthOrDayFieldAccess ( ) {
113+ this instanceof MonthFieldAccess
114+ or
115+ this instanceof DayFieldAccess
116+ }
117+ }
118+
119+ /**
120+ * A static assignment to the day or month access
121+ *
122+ * ```
123+ * a.day = 28;
124+ * ```
125+ */
126+ class GoodExpr extends YearFieldAssignment {
127+ GoodExpr ( ) {
128+ exists ( Variable var , VariableAccess va , YearFieldAccess yfa |
129+ // yfa = this.getYearAccess() and
130+ yfa .getQualifier ( ) = va and
131+ var .getAnAccess ( ) = va and
132+ exists ( MonthOrDayFieldAccess mfa , AssignExpr ae , int val |
133+ mfa .getQualifier ( ) = var .getAnAccess ( ) and
134+ mfa .isModified ( ) and
135+ (
136+ mfa .getBasicBlock ( ) = yfa .getBasicBlock ( ) .getASuccessor * ( ) or
137+ yfa .getBasicBlock ( ) = mfa .getBasicBlock ( ) .getASuccessor + ( )
138+ ) and
139+ ae = mfa .getEnclosingElement ( ) and
140+ ae .getAnOperand ( ) .getValue ( ) .toInt ( ) = val
141+ )
142+ )
108143 }
109144}
110145
0 commit comments