|
8 | 8 | */
|
9 | 9 |
|
10 | 10 | import cpp
|
11 |
| -import semmle.code.cpp.controlflow.SSA |
12 | 11 |
|
13 | 12 | from
|
14 |
| - Variable E, ArrayExpr useExpr, ArrayType defExpr, VariableDeclarationEntry def, VariableAccess use |
| 13 | + Variable var, ArrayExpr useExpr, VariableDeclarationEntry def, ArrayType defLine, VariableAccess use |
15 | 14 | where
|
16 |
| - def = defExpr.getATypeNameUse() and |
17 |
| - E = def.getDeclaration() and |
| 15 | + def = defLine.getATypeNameUse() and |
| 16 | + var = def.getDeclaration() and |
18 | 17 | use = useExpr.getArrayBase() and
|
19 |
| - E = use.getTarget() and |
20 |
| - useExpr.getArrayOffset().getType() instanceof UInt16_t and |
21 |
| - defExpr.getArraySize() <= 256 |
22 |
| -select useExpr, "Using a UInt16_t to acess the array $@ of size " + defExpr.getArraySize() + ".", E, |
23 |
| - E.getName() |
| 18 | + var = use.getTarget() and ( |
| 19 | + (useExpr.getArrayOffset().getType() instanceof UInt16_t and |
| 20 | + defLine.getArraySize() <= 256) or |
| 21 | + (useExpr.getArrayOffset().getType() instanceof UInt32_t and |
| 22 | + defLine.getArraySize() <= 900) or |
| 23 | + (useExpr.getArrayOffset().getType() instanceof UInt64_t and |
| 24 | + defLine.getArraySize() <= 1000) |
| 25 | + ) |
| 26 | +select useExpr, "Using a " + useExpr.getArrayOffset().getType() +" to acess the array $@ of size " + defLine.getArraySize() + ".", var, |
| 27 | + var.getName() |
0 commit comments