@@ -57,19 +57,27 @@ private Class getRootType(FieldAccess fa) {
57
57
)
58
58
}
59
59
60
+ /**
61
+ * Gets the size of `v`. This predicate does not have a result when the
62
+ * unspecified type of `v` is a `ReferenceType`.
63
+ */
64
+ private int getVariableSize ( Variable v ) {
65
+ exists ( Type t |
66
+ t = v .getUnspecifiedType ( ) and
67
+ not t instanceof ReferenceType and
68
+ result = t .getSize ( )
69
+ )
70
+ }
71
+
60
72
/**
61
73
* Gets the size of the buffer access at `va`.
62
74
*/
63
75
private int getSize ( VariableAccess va ) {
64
76
exists ( Variable v | va .getTarget ( ) = v |
65
77
// If `v` is not a field then the size of the buffer is just
66
78
// the size of the type of `v`.
67
- exists ( Type t |
68
- t = v .getUnspecifiedType ( ) and
69
- not v instanceof Field and
70
- not t instanceof ReferenceType and
71
- result = t .getSize ( )
72
- )
79
+ not v instanceof Field and
80
+ result = getVariableSize ( v )
73
81
or
74
82
exists ( Class c , int trueSize |
75
83
// Otherwise, we find the "outermost" object and compute the size
@@ -92,7 +100,7 @@ private int getSize(VariableAccess va) {
92
100
// buffer is `12 - 4 = 8`.
93
101
c = getRootType ( va ) and
94
102
// we calculate the size based on the last field, to avoid including any padding after it
95
- trueSize = max ( Field f | | f .getOffsetInClass ( c ) + f . getUnspecifiedType ( ) . getSize ( ) ) and
103
+ trueSize = max ( Field f | | f .getOffsetInClass ( c ) + getVariableSize ( f ) ) and
96
104
result = trueSize - v .( Field ) .getOffsetInClass ( c )
97
105
)
98
106
)
0 commit comments