Skip to content

Commit f83c345

Browse files
committed
Switch allocation size expression analysis to unconverted result expression.
1 parent 64cf090 commit f83c345

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

cpp/ql/src/experimental/library/ArrayLengthAnalysis.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,11 @@ private predicate allocation(Instruction array, Length length, int delta) {
219219
(
220220
exists(Expr lengthExpr |
221221
deconstructMallocSizeExpr(alloc.getSizeExpr(), lengthExpr, delta) and
222-
length.(VNLength).getInstruction().getConvertedResultExpression() = lengthExpr
222+
length.(VNLength).getInstruction().getUnconvertedResultExpression() = lengthExpr
223223
)
224224
or
225225
not exists(int d | deconstructMallocSizeExpr(alloc.getSizeExpr(), _, d)) and
226-
length.(VNLength).getInstruction().getConvertedResultExpression() = alloc.getSizeExpr() and
226+
length.(VNLength).getInstruction().getUnconvertedResultExpression() = alloc.getSizeExpr() and
227227
delta = 0
228228
)
229229
)

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
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 |
34
| test.cpp:21:8:21:8 | Load: a | VNLength(Chi: ptr) | -1 | ZeroOffset | 0 |
45
| test.cpp:23:8:23:8 | Load: a | VNLength(Chi: ptr) | 1 | ZeroOffset | 0 |
56
| 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 |
68
| 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 |
710
| 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 |
812
| test.cpp:34:8:34:12 | Convert: array to pointer conversion | ZeroLength | 100 | ZeroOffset | 0 |
913
| 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 |
1015
| test.cpp:44:8:44:8 | Load: a | VNLength(InitializeParameter: count) | 0 | ZeroOffset | 2 |
1116
| test.cpp:53:10:53:10 | Load: a | VNLength(InitializeParameter: count) | 0 | ZeroOffset | 2 |
1217
| test.cpp:56:10:56:10 | Load: a | VNLength(InitializeParameter: count) | 0 | ZeroOffset | 3 |

0 commit comments

Comments
 (0)