@@ -80,7 +80,7 @@ class RaisingNode extends ControlFlowNode {
8080 or
8181 this .getNode ( ) instanceof Print and result = theIOErrorType ( )
8282 or
83- exists ( ExceptFlowNode except |
83+ exists ( ExceptFlowNodeWithPointsTo except |
8484 except = this .getAnExceptionalSuccessor ( ) and
8585 except .handles_objectapi ( result ) and
8686 result = this .innateException_objectapi ( )
@@ -107,7 +107,7 @@ class RaisingNode extends ControlFlowNode {
107107 or
108108 this .getNode ( ) instanceof Print and result = ClassValue:: ioError ( )
109109 or
110- exists ( ExceptFlowNode except |
110+ exists ( ExceptFlowNodeWithPointsTo except |
111111 except = this .getAnExceptionalSuccessor ( ) and
112112 except .handles ( result ) and
113113 result = this .innateException ( )
@@ -200,8 +200,8 @@ class RaisingNode extends ControlFlowNode {
200200 succ = this .getAnExceptionalSuccessor ( ) and
201201 (
202202 /* An 'except' that handles raised and there is no more previous handler */
203- succ .( ExceptFlowNode ) .handles_objectapi ( raised ) and
204- not exists ( ExceptFlowNode other , StmtList s , int i , int j |
203+ succ .( ExceptFlowNodeWithPointsTo ) .handles_objectapi ( raised ) and
204+ not exists ( ExceptFlowNodeWithPointsTo other , StmtList s , int i , int j |
205205 not other = succ and
206206 other .handles_objectapi ( raised ) and
207207 s .getItem ( i ) = succ .getNode ( ) and
@@ -211,7 +211,7 @@ class RaisingNode extends ControlFlowNode {
211211 )
212212 or
213213 /* Any successor that is not an 'except', provided that 'raised' is not handled by a different successor. */
214- not this .getAnExceptionalSuccessor ( ) .( ExceptFlowNode ) .handles_objectapi ( raised ) and
214+ not this .getAnExceptionalSuccessor ( ) .( ExceptFlowNodeWithPointsTo ) .handles_objectapi ( raised ) and
215215 not succ instanceof ExceptFlowNode
216216 )
217217 }
@@ -223,8 +223,8 @@ class RaisingNode extends ControlFlowNode {
223223 succ = this .getAnExceptionalSuccessor ( ) and
224224 (
225225 /* An 'except' that handles raised and there is no more previous handler */
226- succ .( ExceptFlowNode ) .handles ( raised ) and
227- not exists ( ExceptFlowNode other , StmtList s , int i , int j |
226+ succ .( ExceptFlowNodeWithPointsTo ) .handles ( raised ) and
227+ not exists ( ExceptFlowNodeWithPointsTo other , StmtList s , int i , int j |
228228 not other = succ and
229229 other .handles ( raised ) and
230230 s .getItem ( i ) = succ .getNode ( ) and
@@ -234,7 +234,7 @@ class RaisingNode extends ControlFlowNode {
234234 )
235235 or
236236 /* Any successor that is not an 'except', provided that 'raised' is not handled by a different successor. */
237- not this .getAnExceptionalSuccessor ( ) .( ExceptFlowNode ) .handles ( raised ) and
237+ not this .getAnExceptionalSuccessor ( ) .( ExceptFlowNodeWithPointsTo ) .handles ( raised ) and
238238 not succ instanceof ExceptFlowNode
239239 )
240240 }
@@ -248,7 +248,7 @@ class RaisingNode extends ControlFlowNode {
248248 raised .isLegalExceptionType ( ) and
249249 raised = this .getARaisedType_objectapi ( ) and
250250 this .isExceptionalExit ( s ) and
251- not this .getAnExceptionalSuccessor ( ) .( ExceptFlowNode ) .handles_objectapi ( raised )
251+ not this .getAnExceptionalSuccessor ( ) .( ExceptFlowNodeWithPointsTo ) .handles_objectapi ( raised )
252252 }
253253
254254 /**
@@ -260,7 +260,7 @@ class RaisingNode extends ControlFlowNode {
260260 raised .isLegalExceptionType ( ) and
261261 raised = this .getARaisedType ( ) and
262262 this .isExceptionalExit ( s ) and
263- not this .getAnExceptionalSuccessor ( ) .( ExceptFlowNode ) .handles ( raised )
263+ not this .getAnExceptionalSuccessor ( ) .( ExceptFlowNodeWithPointsTo ) .handles ( raised )
264264 }
265265}
266266
@@ -368,36 +368,9 @@ predicate scope_raises_unknown(Scope s) {
368368 )
369369}
370370
371- /** The ControlFlowNode for an 'except' statement. */
372- class ExceptFlowNode extends ControlFlowNode {
373- ExceptFlowNode ( ) { this .getNode ( ) instanceof ExceptStmt }
374-
375- /**
376- * Gets the type handled by this exception handler.
377- * `ExceptionType` in `except ExceptionType as e:`
378- */
379- ControlFlowNodeWithPointsTo getType ( ) {
380- exists ( ExceptStmt ex |
381- this .getBasicBlock ( ) .dominates ( result .getBasicBlock ( ) ) and
382- ex = this .getNode ( ) and
383- result = ex .getType ( ) .getAFlowNode ( )
384- )
385- }
386-
387- /**
388- * Gets the name assigned to the handled exception, if any.
389- * `e` in `except ExceptionType as e:`
390- */
391- ControlFlowNode getName ( ) {
392- exists ( ExceptStmt ex |
393- this .getBasicBlock ( ) .dominates ( result .getBasicBlock ( ) ) and
394- ex = this .getNode ( ) and
395- result = ex .getName ( ) .getAFlowNode ( )
396- )
397- }
398-
371+ class ExceptFlowNodeWithPointsTo extends ControlFlowNodeWithPointsTo {
399372 private predicate handledObject_objectapi ( Object obj , ClassObject cls , ControlFlowNode origin ) {
400- this .getType ( ) .refersTo ( obj , cls , origin )
373+ this .( ExceptFlowNode ) . getType ( ) . ( ControlFlowNodeWithPointsTo ) .refersTo ( obj , cls , origin )
401374 or
402375 exists ( Object tup | this .handledObject_objectapi ( tup , theTupleType ( ) , _) |
403376 element_from_tuple_objectapi ( tup ) .refersTo ( obj , cls , origin )
@@ -407,7 +380,7 @@ class ExceptFlowNode extends ControlFlowNode {
407380 private predicate handledObject ( Value val , ClassValue cls , ControlFlowNode origin ) {
408381 val .getClass ( ) = cls and
409382 (
410- this .getType ( ) .pointsTo ( val , origin )
383+ this .( ExceptFlowNode ) . getType ( ) . ( ControlFlowNodeWithPointsTo ) .pointsTo ( val , origin )
411384 or
412385 exists ( TupleValue tup | this .handledObject ( tup , ClassValue:: tuple ( ) , _) |
413386 val = tup .getItem ( _) and origin = val .getOrigin ( )
@@ -452,29 +425,6 @@ class ExceptFlowNode extends ControlFlowNode {
452425 }
453426}
454427
455- /** The ControlFlowNode for an 'except*' statement. */
456- class ExceptGroupFlowNode extends ControlFlowNode {
457- ExceptGroupFlowNode ( ) { this .getNode ( ) instanceof ExceptGroupStmt }
458-
459- /**
460- * Gets the type handled by this exception handler.
461- * `ExceptionType` in `except* ExceptionType as e:`
462- */
463- ControlFlowNode getType ( ) {
464- this .getBasicBlock ( ) .dominates ( result .getBasicBlock ( ) ) and
465- result = this .getNode ( ) .( ExceptGroupStmt ) .getType ( ) .getAFlowNode ( )
466- }
467-
468- /**
469- * Gets the name assigned to the handled exception, if any.
470- * `e` in `except* ExceptionType as e:`
471- */
472- ControlFlowNode getName ( ) {
473- this .getBasicBlock ( ) .dominates ( result .getBasicBlock ( ) ) and
474- result = this .getNode ( ) .( ExceptGroupStmt ) .getName ( ) .getAFlowNode ( )
475- }
476- }
477-
478428private ControlFlowNodeWithPointsTo element_from_tuple_objectapi ( Object tuple ) {
479429 exists ( Tuple t | t = tuple .getOrigin ( ) and result = t .getAnElt ( ) .getAFlowNode ( ) )
480430}
0 commit comments