variableReference

Coverity Documentation

Version
latest

Matches locations where an expression references a variable.

This pattern only matches nodes of type expression.

Properties

variableReference produces a record that contains the following properties:

Name Type Description
isFinal bool true if this variable is declared as final
qualifiedName string The name of the variable, with scope information
scope enum variableScopeenum The scope of the variable: One of `static`, `local`, or `tryResource`; see variableScopeEnum
simpleName string The name of the variable, without scope information
variable symbol The symbol that represents this variable

Inherits properties from:

Example

The following CodeXM pattern matches all variable references to final static variables:


CXM code follows
    pattern variableReferenceStaticFinal {
        variableReference {
            .scope == `global`;
            .isFinal == true;
        }
    };