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 1515
1616import java
1717
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+
1838/**
1939 * Exceptions of type `rt` thrown from within statement `s` are caught by an inner try block
2040 * and are therefore not propagated to the outer try block `t`.
2141 */
2242private 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 )
2646 )
2747}
2848
You can’t perform that action at this time.
0 commit comments