|
14 | 14 |
|
15 | 15 | import python
|
16 | 16 |
|
17 |
| -predicate incorrect_except_order(ExceptStmt ex1, ClassObject cls1, ExceptStmt ex2, ClassObject cls2) { |
18 |
| - exists(int i, int j, Try t | |
19 |
| - ex1 = t.getHandler(i) and |
20 |
| - ex2 = t.getHandler(j) and i < j and |
21 |
| - cls1 = except_class(ex1) and |
22 |
| - cls2 = except_class(ex2) and |
23 |
| - cls1 = cls2.getASuperType() |
24 |
| - ) |
| 17 | +predicate incorrect_except_order(ExceptStmt ex1, ClassValue cls1, ExceptStmt ex2, ClassValue cls2) { |
| 18 | + exists(int i, int j, Try t | |
| 19 | + ex1 = t.getHandler(i) and |
| 20 | + ex2 = t.getHandler(j) and |
| 21 | + i < j and |
| 22 | + cls1 = except_class(ex1) and |
| 23 | + cls2 = except_class(ex2) and |
| 24 | + cls1 = cls2.getASuperType() |
| 25 | + ) |
25 | 26 | }
|
26 | 27 |
|
27 |
| -ClassObject except_class(ExceptStmt ex) { |
28 |
| - ex.getType().refersTo(result) |
29 |
| -} |
| 28 | +ClassValue except_class(ExceptStmt ex) { ex.getType().pointsTo(result) } |
30 | 29 |
|
31 |
| -from ExceptStmt ex1, ClassObject cls1, ExceptStmt ex2, ClassObject cls2 |
| 30 | +from ExceptStmt ex1, ClassValue cls1, ExceptStmt ex2, ClassValue cls2 |
32 | 31 | where incorrect_except_order(ex1, cls1, ex2, cls2)
|
33 |
| -select ex2, "Except block for $@ is unreachable; the more general $@ for $@ will always be executed in preference.", |
34 |
| - cls2, cls2.getName(), ex1, "except block", cls1, cls1.getName() |
| 32 | +select ex2, |
| 33 | + "Except block for $@ is unreachable; the more general $@ for $@ will always be executed in preference.", |
| 34 | + cls2, cls2.getName(), ex1, "except block", cls1, cls1.getName() |
0 commit comments