castOperatorImplicit

Coverity Documentation

Version
latest

Matches casts that are implicit to the code; that is, not explicitly stated.

This pattern only matches nodes of type expression.

Properties

castOperatorImplicit produces a record that contains the following properties:

Name Type Description
kind enum castKind Always `implicit`; see castKind
operandExpression expression The expression being cast

Inherits properties from:

Example

For the following snippet of Java:


Java code follows
Object o = "Example";

... there is an implicit cast between the string literal and the class Object. To detect such a cast, you could use the following CodeXM pattern:


CXM code follows
    pattern implicitCastFromString {
        castOperatorImplicit {
            .operandExpression == expression {
                .type == classType { .simpleName == "String"}
            }
        }
    };