@@ -316,7 +316,6 @@ private module Initializers {
316316
317317private module Exceptions {
318318 private import semmle.code.csharp.commons.Assertions
319- private import semmle.code.csharp.frameworks.System
320319
321320 private class Overflowable extends UnaryOperation {
322321 Overflowable ( ) {
@@ -327,7 +326,7 @@ private module Exceptions {
327326
328327 /** Holds if `cfe` is a control flow element that may throw an exception. */
329328 predicate mayThrowException ( ControlFlowElement cfe ) {
330- exists ( cfe .( TriedControlFlowElement ) .getAThrownException ( ) )
329+ cfe .( TriedControlFlowElement ) .mayThrowException ( )
331330 or
332331 cfe instanceof Assertion
333332 }
@@ -340,66 +339,43 @@ private module Exceptions {
340339 }
341340
342341 /**
343- * Gets an exception class that is potentially thrown by this element, if any .
342+ * Holds if this element may potentially throw an exception .
344343 */
345- Class getAThrownException ( ) {
346- this instanceof Overflowable and
347- result instanceof SystemOverflowExceptionClass
344+ predicate mayThrowException ( ) {
345+ this instanceof Overflowable
348346 or
349- this .( CastExpr ) .getType ( ) instanceof IntegralType and
350- result instanceof SystemOverflowExceptionClass
347+ this .( CastExpr ) .getType ( ) instanceof IntegralType
351348 or
352- invalidCastCandidate ( this ) and
353- result instanceof SystemInvalidCastExceptionClass
349+ invalidCastCandidate ( this )
354350 or
355- this instanceof Call and
356- result instanceof SystemExceptionClass
351+ this instanceof Call
357352 or
358353 this =
359354 any ( MemberAccess ma |
360355 not ma .isConditional ( ) and
361- ma .getQualifier ( ) = any ( Expr e | not e instanceof TypeAccess ) and
362- result instanceof SystemNullReferenceExceptionClass
356+ ma .getQualifier ( ) = any ( Expr e | not e instanceof TypeAccess )
363357 )
364358 or
365- this instanceof DelegateCreation and
366- result instanceof SystemOutOfMemoryExceptionClass
359+ this instanceof DelegateCreation
367360 or
368- this instanceof ArrayCreation and
369- result instanceof SystemOutOfMemoryExceptionClass
361+ this instanceof ArrayCreation
370362 or
371363 this =
372364 any ( AddOperation ae |
373- ae .getType ( ) instanceof StringType and
374- result instanceof SystemOutOfMemoryExceptionClass
365+ ae .getType ( ) instanceof StringType
375366 or
376- ae .getType ( ) instanceof IntegralType and
377- result instanceof SystemOverflowExceptionClass
367+ ae .getType ( ) instanceof IntegralType
378368 )
379369 or
380- this =
381- any ( SubOperation se |
382- se .getType ( ) instanceof IntegralType and
383- result instanceof SystemOverflowExceptionClass
384- )
370+ this = any ( SubOperation se | se .getType ( ) instanceof IntegralType )
385371 or
386- this =
387- any ( MulOperation me |
388- me .getType ( ) instanceof IntegralType and
389- result instanceof SystemOverflowExceptionClass
390- )
372+ this = any ( MulOperation me | me .getType ( ) instanceof IntegralType )
391373 or
392- this =
393- any ( DivOperation de |
394- not de .getDenominator ( ) .getValue ( ) .toFloat ( ) != 0 and
395- result instanceof SystemDivideByZeroExceptionClass
396- )
374+ this = any ( DivOperation de | not de .getDenominator ( ) .getValue ( ) .toFloat ( ) != 0 )
397375 or
398- this instanceof RemOperation and
399- result instanceof SystemDivideByZeroExceptionClass
376+ this instanceof RemOperation
400377 or
401- this instanceof DynamicExpr and
402- result instanceof SystemExceptionClass
378+ this instanceof DynamicExpr
403379 }
404380 }
405381
0 commit comments