Search in sources :

Example 1 with Types

use of org.sonar.java.resolve.Types in project sonar-java by SonarSource.

the class ExplodedGraphWalker method executeTypeCast.

private void executeTypeCast(TypeCastTree typeCast) {
    Type type = typeCast.type().symbolType();
    if (type.isPrimitive()) {
        JavaType expType = (JavaType) typeCast.expression().symbolType();
        // create SV to consume factory if any
        SymbolicValue castSV = constraintManager.createSymbolicValue(typeCast);
        // if exp type is a primitive and subtype of cast type, we can reuse the same symbolic value
        if (!expType.isPrimitive() || !new Types().isSubtype(expType, (JavaType) type)) {
            ProgramState.Pop unstack = programState.unstackValue(1);
            programState = unstack.state;
            programState = programState.stackValue(castSV);
        }
    }
}
Also used : Types(org.sonar.java.resolve.Types) JavaType(org.sonar.java.resolve.JavaType) Type(org.sonar.plugins.java.api.semantic.Type) JavaType(org.sonar.java.resolve.JavaType) SymbolicValue(org.sonar.java.se.symbolicvalues.SymbolicValue) RelationalSymbolicValue(org.sonar.java.se.symbolicvalues.RelationalSymbolicValue)

Aggregations

JavaType (org.sonar.java.resolve.JavaType)1 Types (org.sonar.java.resolve.Types)1 RelationalSymbolicValue (org.sonar.java.se.symbolicvalues.RelationalSymbolicValue)1 SymbolicValue (org.sonar.java.se.symbolicvalues.SymbolicValue)1 Type (org.sonar.plugins.java.api.semantic.Type)1