File tree Expand file tree Collapse file tree 1 file changed +23
-3
lines changed
java/ql/src/Likely Bugs/Statements Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change 15
15
16
16
import java
17
17
18
+ pragma [ nomagic]
19
+ predicate mayThrow ( Stmt s , RefType rt ) {
20
+ s .( ThrowStmt ) .getExpr ( ) .getType ( ) = rt
21
+ or
22
+ exists ( Call call |
23
+ call .getEnclosingStmt ( ) = s and
24
+ call .getCallee ( ) .getAnException ( ) .getType ( ) = rt
25
+ )
26
+ }
27
+
28
+ pragma [ nomagic]
29
+ predicate caughtBy ( TryStmt try , Stmt s , RefType rt ) {
30
+ mayThrow ( s , rt ) and
31
+ s .getEnclosingStmt + ( ) = try .getBlock ( ) and
32
+ caughtType ( try , _) .hasSubtype * ( rt )
33
+ }
34
+
35
+ pragma [ nomagic]
36
+ predicate nestedTry ( TryStmt outer , TryStmt inner ) { inner .getEnclosingStmt + ( ) = outer .getBlock ( ) }
37
+
18
38
/**
19
39
* Exceptions of type `rt` thrown from within statement `s` are caught by an inner try block
20
40
* and are therefore not propagated to the outer try block `t`.
21
41
*/
22
42
private predicate caughtInside ( TryStmt t , Stmt s , RefType rt ) {
23
- exists ( TryStmt innerTry | innerTry . getEnclosingStmt + ( ) = t . getBlock ( ) |
24
- s . getEnclosingStmt + ( ) = innerTry . getBlock ( ) and
25
- caughtType ( innerTry , _ ) . hasSubtype * ( rt )
43
+ exists ( TryStmt innerTry |
44
+ nestedTry ( t , innerTry ) and
45
+ caughtBy ( innerTry , s , rt )
26
46
)
27
47
}
28
48
You can’t perform that action at this time.
0 commit comments