CodeQL library for Java
Search

Class Guard

A condition that can be evaluated to either true or false. This can either be an Expr of boolean type that isn’t a boolean literal, or a case of a switch statement, or a method access that acts as a precondition check.

Evaluating a switch case to true corresponds to taking that switch case, and evaluating it to false corresponds to taking some other branch.

Import path

import semmle.code.java.controlflow.Guards

Direct supertypes

Indirect supertypes

Known direct subtypes

    Predicates

    controls

    Holds if this guard evaluating to branch directly or indirectly controls the block controlled. That is, the evaluation of controlled is dominated by this guard evaluating to branch.

    directlyControls

    Holds if this guard evaluating to branch directly controls the block controlled. That is, the true- or false-successor of this guard (as given by branch) dominates controlled.

    getBasicBlock

    Gets the basic block containing this guard or the basic block containing the switch expression if the guard is a switch case.

    getEnclosingCallable

    Gets the immediately enclosing callable whose body contains this guard.

    getEnclosingStmt

    Gets the statement containing this guard.

    hasBranchEdge

    Holds if the evaluation of this guard to branch corresponds to the edge from bb1 to bb2.

    isEquality

    Holds if this guard is an equality test between e1 and e2. The test can be either ==, !=, .equals, or a switch case. If the test is negated, that is !=, then polarity is false, otherwise polarity is true.

    Inherited predicates

    getAPrimaryQlClass

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

    from Top
    getFile

    Gets the file associated with this element.

    from Top
    getLocation

    Gets the source location for this element.

    from Top
    getNumberOfCommentLines

    Gets the number of comment lines that this element ranges over.

    from Top
    getNumberOfLinesOfCode

    Gets the number of lines of code that this element ranges over.

    from Top
    getPrimaryQlClasses

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

    from Top
    getTotalNumberOfLines

    Gets the total number of lines that this element ranges over, including lines of code, comment and whitespace-only lines.

    from Top
    hasLocationInfo

    Holds if this element is at the specified location. The location spans column startcolumn of line startline to column endcolumn of line endline in file filepath. For more information, see Locations.

    from Top
    toString

    Gets a textual representation of this element.

    from Top

    Charpred