Skip to content

Commit bab893d

Browse files
committed
Address review.
1 parent c856552 commit bab893d

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

cpp/ql/src/experimental/semmle/code/cpp/rangeanalysis/ArrayLengthAnalysis.qll

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ private newtype TLength =
3939
or
4040
i instanceof CallInstruction
4141
or
42-
i instanceof VariableAddressInstruction
43-
or
44-
i instanceof FieldAddressInstruction
45-
or
4642
i.(LoadInstruction).getSourceAddress() instanceof VariableAddressInstruction
4743
or
4844
i.(LoadInstruction).getSourceAddress() instanceof FieldAddressInstruction
@@ -219,11 +215,11 @@ private predicate allocation(Instruction array, Length length, int delta) {
219215
(
220216
exists(Expr lengthExpr |
221217
deconstructMallocSizeExpr(alloc.getSizeExpr(), lengthExpr, delta) and
222-
length.(VNLength).getInstruction().getUnconvertedResultExpression() = lengthExpr
218+
length.(VNLength).getInstruction().getConvertedResultExpression() = lengthExpr
223219
)
224220
or
225221
not exists(int d | deconstructMallocSizeExpr(alloc.getSizeExpr(), _, d)) and
226-
length.(VNLength).getInstruction().getUnconvertedResultExpression() = alloc.getSizeExpr() and
222+
length.(VNLength).getInstruction().getConvertedResultExpression() = alloc.getSizeExpr() and
227223
delta = 0
228224
)
229225
)

cpp/ql/test/experimental/library-tests/rangeanalysis/arraylengthanalysis/ArrayLengthAnalysisTest.expected

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
| test.cpp:15:8:15:11 | Load: aptr | VNLength(InitializeParameter: count) | 0 | ZeroOffset | 0 |
22
| test.cpp:19:8:19:8 | Load: a | VNLength(Chi: ptr) | 0 | ZeroOffset | 0 |
3-
| test.cpp:19:8:19:8 | Load: a | VNLength(Convert: (unsigned long)...) | 0 | ZeroOffset | 0 |
43
| test.cpp:21:8:21:8 | Load: a | VNLength(Chi: ptr) | -1 | ZeroOffset | 0 |
54
| test.cpp:23:8:23:8 | Load: a | VNLength(Chi: ptr) | 1 | ZeroOffset | 0 |
65
| test.cpp:27:8:27:8 | Load: c | VNLength(Chi: ptr) | 0 | ZeroOffset | 0 |
7-
| test.cpp:27:8:27:8 | Load: c | VNLength(Convert: (unsigned long)...) | 0 | ZeroOffset | 0 |
86
| test.cpp:28:8:28:24 | Convert: (unsigned char *)... | VNLength(Chi: ptr) | 0 | ZeroOffset | 0 |
9-
| test.cpp:28:8:28:24 | Convert: (unsigned char *)... | VNLength(Convert: (unsigned long)...) | 0 | ZeroOffset | 0 |
107
| test.cpp:30:8:30:8 | Load: v | VNLength(Chi: ptr) | 0 | ZeroOffset | 0 |
11-
| test.cpp:30:8:30:8 | Load: v | VNLength(Convert: (unsigned long)...) | 0 | ZeroOffset | 0 |
128
| test.cpp:34:8:34:12 | Convert: array to pointer conversion | ZeroLength | 100 | ZeroOffset | 0 |
139
| test.cpp:37:10:37:10 | Load: b | VNLength(Chi: ptr) | 0 | ZeroOffset | 0 |
14-
| test.cpp:37:10:37:10 | Load: b | VNLength(Convert: (unsigned long)...) | 0 | ZeroOffset | 0 |
1510
| test.cpp:44:8:44:8 | Load: a | VNLength(InitializeParameter: count) | 0 | ZeroOffset | 2 |
1611
| test.cpp:53:10:53:10 | Load: a | VNLength(InitializeParameter: count) | 0 | ZeroOffset | 2 |
1712
| test.cpp:56:10:56:10 | Load: a | VNLength(InitializeParameter: count) | 0 | ZeroOffset | 3 |

0 commit comments

Comments
 (0)