@@ -260,35 +260,58 @@ class ExceptFlowNode extends ControlFlowNode {
260260 )
261261 }
262262
263- private predicate handledObject ( Object obj , ClassObject cls , ControlFlowNode origin ) {
263+ private predicate handledObject_objectapi ( Object obj , ClassObject cls , ControlFlowNode origin ) {
264264 this .getType ( ) .refersTo ( obj , cls , origin )
265265 or
266266 exists ( Object tup |
267- this .handledObject ( tup , theTupleType ( ) , _) |
268- element_from_tuple ( tup ) .refersTo ( obj , cls , origin )
267+ this .handledObject_objectapi ( tup , theTupleType ( ) , _) |
268+ element_from_tuple_objectapi ( tup ) .refersTo ( obj , cls , origin )
269+ )
270+ }
271+
272+ private predicate handledObject ( Value val , ClassValue cls , ControlFlowNode origin ) {
273+ val .getClass ( ) = cls and
274+ (
275+ this .getType ( ) .pointsTo ( val , origin )
276+ or
277+ exists ( TupleValue tup |
278+ this .handledObject ( tup , ClassValue:: tuple ( ) , _) |
279+ val = tup .getItem ( _) and origin = val .getOrigin ( )
280+ )
269281 )
270282 }
271283
272284 /** Gets the inferred type(s) that are handled by this node, splitting tuples if possible. */
273285 pragma [ noinline]
274- predicate handledException ( Object obj , ClassObject cls , ControlFlowNode origin ) {
275- this .handledObject ( obj , cls , origin ) and not cls = theTupleType ( )
286+ predicate handledException_objectapi ( Object obj , ClassObject cls , ControlFlowNode origin ) {
287+ this .handledObject_objectapi ( obj , cls , origin ) and not cls = theTupleType ( )
276288 or
277289 not exists ( this .getNode ( ) .( ExceptStmt ) .getType ( ) ) and obj = theBaseExceptionType ( ) and cls = theTypeType ( ) and
278290 origin = this
279291 }
292+
293+ /** Gets the inferred type(s) that are handled by this node, splitting tuples if possible. */
294+ pragma [ noinline]
295+ predicate handledException ( Value val , ClassValue cls , ControlFlowNode origin ) {
296+ this .handledObject ( val , cls , origin ) and not cls = ClassValue:: tuple ( )
297+ or
298+ not exists ( this .getNode ( ) .( ExceptStmt ) .getType ( ) ) and val = ClassValue:: baseException ( ) and cls = ClassValue:: type ( ) and
299+ origin = this
300+ }
301+
302+
280303
281304 /** Whether this `except` handles `cls` */
282305 predicate handles ( ClassObject cls ) {
283306 exists ( ClassObject handled |
284- this .handledException ( handled , _, _) |
307+ this .handledException_objectapi ( handled , _, _) |
285308 cls .getAnImproperSuperType ( ) = handled
286309 )
287310 }
288311
289312}
290313
291- private ControlFlowNode element_from_tuple ( Object tuple ) {
314+ private ControlFlowNode element_from_tuple_objectapi ( Object tuple ) {
292315 exists ( Tuple t |
293316 t = tuple .getOrigin ( ) and result = t .getAnElt ( ) .getAFlowNode ( )
294317 )
0 commit comments