CodeQL library for C#
Search

Class NestedBreakCompletion

A nested completion for a loop that exists with a break.

This completion is added for technical reasons only: when a loop body can complete with a break completion, the loop itself completes normally. However, if we choose TSimpleCompletion as the completion of the loop, we lose the information that the last element actually completed with a break, meaning that the control flow edge out of the breaking node cannot be marked with a break label.

Example:

while (...) {
   ...
   break;
}
return;

The break on line 3 completes with a TBreakCompletion, therefore the while loop can complete with a NestedBreakCompletion, so we get an edge break --break--> return. (If we instead used a TSimpleCompletion, we would get a less precise edge break --normal--> return.)

Import path

import semmle.code.csharp.controlflow.internal.Completion

Direct supertypes

Indirect supertypes

Inherited fields

Predicates

getAMatchingSuccessorType

Gets a successor type that matches this completion.

getAnInnerCompatibleCompletion

Gets a completion that is compatible with the inner completion.

getInnerCompletion

Gets the inner completion. This is either the inner completion, when the completion is nested, or the completion itself.

getOuterCompletion

Gets the outer completion. This is either the outer completion, when the completion is nested, or the completion itself.

Inherited predicates

continuesLoop

Holds if this completion will continue a loop when it is the completion of a loop body.

from Completion
continuesLoop

Holds if this completion will continue a loop when it is the completion of a loop body.

from Completion
getNestLevel

Gets the level of this nested completion.

from NestedCompletion
isValidFor

Holds if this completion is valid for control flow element cfe.

from Completion
isValidFor

Holds if this completion is valid for control flow element cfe.

from Completion
toString

Gets a textual representation of this completion.

from NestedCompletion

Charpred