CodeQL library for C#
codeql/csharp-all 0.9.2-dev (changelog, source)
Search

Class Handler

A handler is a piece of code that can be executed out of sequence, for example when an instruction generates an exception or leaves a finally block.

Each handler has a scope representing the block of instructions guarded by this handler (corresponding to a C# try { ... } block), and a block of instructions to execute when the handler is triggered (corresponding to a catch or finally block).

Handlers are entry points (EntryPoint) so that they can provide values on the stack, for example the value of the current exception. This is why some handlers have a push count of 1.

Either a finally handler (FinallyHandler), filter handler (FilterHandler), catch handler (CatchHandler), or a fault handler (FaultHandler).

Import path

import semmle.code.cil.Handler

Direct supertypes

Indirect supertypes

Known direct subtypes

Predicates

getASuccessorType

Gets a successor to this node, of type type, if any.

getCaughtType

Gets the type of the caught exception, if any.

getHandlerStart

Gets the first instruction in the catch/finally block.

getImplementation

Gets the method containing this control flow node.

getIndex

Gets the 0-based index of this handler. Handlers are evaluated in this sequence.

getLocation
getTryEnd

Gets the last instruction in the try block of this handler.

getTryStart

Gets the first instruction in the try block of this handler.

isInScope

Holds if the instruction i is in the scope of this handler.

toString

Inherited predicates

fromLibrary

Holds if this element is from an assembly.

from Element
fromSource

Holds if this element is from source code.

from Element
getALocation

Gets a location of this element, which can include locations in both DLLs and source files.

from Element
getAPredecessor

Gets a predecessor of this node, if any.

from ControlFlowNode
getAPrimaryQlClass

Gets the name of a primary CodeQL class to which this element belongs.

from Element
getASuccessor

Gets a successor of this node, if any.

from ControlFlowNode
getAnOperand

Gets an operand of this instruction, if any.

from ControlFlowNode
getFalseSuccessor

Gets a false successor of this node, if any.

from ControlFlowNode
getFile

Gets the file containing this element.

from Element
getLanguage

Gets the “language” of this program element, as defined by the extension of the filename. For example, C# has language “cs”, and Visual Basic has language “vb”.

from Element
getOperand

Gets an instruction that supplies the ith operand to this instruction. Note that this can be multi-valued.

from ControlFlowNode
getOperandType

Gets the type of the ith operand. Unlike getOperand(i).getType(), this predicate takes into account when there are multiple possible operands with different types.

from ControlFlowNode
getParentExpr

Gets an expression that consumes the output of this instruction on the stack.

from ControlFlowNode
getPopCount

Gets the number of items this node pops from the stack.

from ControlFlowNode
getPrimaryQlClasses

Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.

from Element
getPushCount

Gets the number of items this node pushes onto the stack. This value is either 0 or 1, except for the instruction dup which pushes 2 values onto the stack.

from ControlFlowNode
getStackSizeAfter

Gets the stack size after this instruction.

from ControlFlowNode
getStackSizeBefore

Gets the stack size before this instruction.

from EntryPoint
getTrueSuccessor

Gets a true successor of this node, if any.

from ControlFlowNode
getType

Gets the type of the item pushed onto the stack, if any.

from ControlFlowNode
isBranch

Holds if this control flow node has more than one successor.

from ControlFlowNode
isJoin

Holds if this control flow node has more than one predecessor.

from ControlFlowNode
toStringWithTypes

Gets the full textual representation of this element, including type information.

from Element