Search in sources :

Example 96 with ProgramState

use of org.sonar.java.se.ProgramState in project sonar-java by SonarSource.

the class BytecodeEGWalker method enqueue.

void enqueue(ProgramPoint pp, ProgramState programState) {
    int nbOfExecution = programState.numberOfTimeVisited(pp);
    if (nbOfExecution > MAX_EXEC_PROGRAM_POINT) {
        return;
    }
    ProgramState ps = programState.visitedPoint(pp, nbOfExecution + 1);
    ExplodedGraph.Node cachedNode = explodedGraph.node(pp, ps);
    cachedNode.addParent(node, null);
    if (cachedNode.isNew()) {
        workList.addFirst(cachedNode);
    }
}
Also used : ExplodedGraph(org.sonar.java.se.ExplodedGraph) ProgramState(org.sonar.java.se.ProgramState) TypedConstraint(org.sonar.java.se.constraint.TypedConstraint) Constraint(org.sonar.java.se.constraint.Constraint) ProgramPoint(org.sonar.java.se.ProgramPoint) BooleanConstraint(org.sonar.java.se.constraint.BooleanConstraint) ObjectConstraint(org.sonar.java.se.constraint.ObjectConstraint)

Example 97 with ProgramState

use of org.sonar.java.se.ProgramState in project sonar-java by SonarSource.

the class BytecodeEGWalker method branchingState.

@VisibleForTesting
ProgramState branchingState(Instruction terminator, ProgramState programState) {
    ProgramState.Pop pop;
    ProgramState ps;
    List<ProgramState.SymbolicValueSymbol> symbolicValueSymbols;
    switch(terminator.opcode) {
        case IFEQ:
        case IFNE:
        case IFLT:
        case IFGE:
        case IFGT:
        case IFLE:
            pop = programState.unstackValue(1);
            SymbolicValue svZero = new SymbolicValue();
            symbolicValueSymbols = ImmutableList.of(new ProgramState.SymbolicValueSymbol(svZero, null), pop.valuesAndSymbols.get(0));
            List<ProgramState> programStates = svZero.setConstraint(pop.state, DivisionByZeroCheck.ZeroConstraint.ZERO).stream().flatMap(s -> svZero.setConstraint(s, BooleanConstraint.FALSE).stream()).collect(Collectors.toList());
            Preconditions.checkState(programStates.size() == 1);
            ps = programStates.get(0);
            break;
        case IF_ICMPEQ:
        case IF_ICMPNE:
        case IF_ICMPLT:
        case IF_ICMPGE:
        case IF_ICMPGT:
        case IF_ICMPLE:
        case IF_ACMPEQ:
        case IF_ACMPNE:
            pop = programState.unstackValue(2);
            symbolicValueSymbols = pop.valuesAndSymbols;
            ps = pop.state;
            break;
        case IFNULL:
        case IFNONNULL:
            pop = programState.unstackValue(1);
            symbolicValueSymbols = ImmutableList.of(new ProgramState.SymbolicValueSymbol(SymbolicValue.NULL_LITERAL, null), pop.valuesAndSymbols.get(0));
            ps = pop.state;
            break;
        default:
            throw new IllegalStateException("Unexpected terminator " + terminator);
    }
    return ps.stackValue(constraintManager.createBinarySymbolicValue(terminator, symbolicValueSymbols));
}
Also used : ASTORE(org.objectweb.asm.Opcodes.ASTORE) ATHROW(org.objectweb.asm.Opcodes.ATHROW) DMUL(org.objectweb.asm.Opcodes.DMUL) F2D(org.objectweb.asm.Opcodes.F2D) LSHR(org.objectweb.asm.Opcodes.LSHR) IF_ICMPEQ(org.objectweb.asm.Opcodes.IF_ICMPEQ) F2I(org.objectweb.asm.Opcodes.F2I) IINC(org.objectweb.asm.Opcodes.IINC) IFGT(org.objectweb.asm.Opcodes.IFGT) LSHL(org.objectweb.asm.Opcodes.LSHL) IAND(org.objectweb.asm.Opcodes.IAND) DCMPL(org.objectweb.asm.Opcodes.DCMPL) LSTORE(org.objectweb.asm.Opcodes.LSTORE) TypedConstraint(org.sonar.java.se.constraint.TypedConstraint) DCMPG(org.objectweb.asm.Opcodes.DCMPG) IFNULL(org.objectweb.asm.Opcodes.IFNULL) FLOAD(org.objectweb.asm.Opcodes.FLOAD) INSTANCEOF(org.objectweb.asm.Opcodes.INSTANCEOF) IALOAD(org.objectweb.asm.Opcodes.IALOAD) DUP2_X2(org.objectweb.asm.Opcodes.DUP2_X2) DUP2_X1(org.objectweb.asm.Opcodes.DUP2_X1) PUTFIELD(org.objectweb.asm.Opcodes.PUTFIELD) IFEQ(org.objectweb.asm.Opcodes.IFEQ) Lists(com.google.common.collect.Lists) INVOKESTATIC(org.objectweb.asm.Opcodes.INVOKESTATIC) ACONST_NULL(org.objectweb.asm.Opcodes.ACONST_NULL) MethodBehavior(org.sonar.java.se.xproc.MethodBehavior) DALOAD(org.objectweb.asm.Opcodes.DALOAD) INEG(org.objectweb.asm.Opcodes.INEG) MONITORENTER(org.objectweb.asm.Opcodes.MONITORENTER) TABLESWITCH(org.objectweb.asm.Opcodes.TABLESWITCH) ICONST_5(org.objectweb.asm.Opcodes.ICONST_5) IMUL(org.objectweb.asm.Opcodes.IMUL) LOR(org.objectweb.asm.Opcodes.LOR) DASTORE(org.objectweb.asm.Opcodes.DASTORE) ICONST_4(org.objectweb.asm.Opcodes.ICONST_4) Opcodes(org.objectweb.asm.Opcodes) ICONST_3(org.objectweb.asm.Opcodes.ICONST_3) ICONST_2(org.objectweb.asm.Opcodes.ICONST_2) IFGE(org.objectweb.asm.Opcodes.IFGE) ICONST_1(org.objectweb.asm.Opcodes.ICONST_1) ICONST_0(org.objectweb.asm.Opcodes.ICONST_0) LADD(org.objectweb.asm.Opcodes.LADD) F2L(org.objectweb.asm.Opcodes.F2L) Printer(org.objectweb.asm.util.Printer) LREM(org.objectweb.asm.Opcodes.LREM) Preconditions(com.google.common.base.Preconditions) INVOKESPECIAL(org.objectweb.asm.Opcodes.INVOKESPECIAL) DNEG(org.objectweb.asm.Opcodes.DNEG) LDIV(org.objectweb.asm.Opcodes.LDIV) LLOAD(org.objectweb.asm.Opcodes.LLOAD) LCMP(org.objectweb.asm.Opcodes.LCMP) IXOR(org.objectweb.asm.Opcodes.IXOR) DSUB(org.objectweb.asm.Opcodes.DSUB) IFLE(org.objectweb.asm.Opcodes.IFLE) Loggers(org.sonar.api.utils.log.Loggers) LASTORE(org.objectweb.asm.Opcodes.LASTORE) FSTORE(org.objectweb.asm.Opcodes.FSTORE) INVOKEVIRTUAL(org.objectweb.asm.Opcodes.INVOKEVIRTUAL) Collectors(java.util.stream.Collectors) GETFIELD(org.objectweb.asm.Opcodes.GETFIELD) FNEG(org.objectweb.asm.Opcodes.FNEG) I2L(org.objectweb.asm.Opcodes.I2L) CASTORE(org.objectweb.asm.Opcodes.CASTORE) Instruction(org.sonar.java.bytecode.cfg.Instruction) GOTO(org.objectweb.asm.Opcodes.GOTO) I2S(org.objectweb.asm.Opcodes.I2S) Constraint(org.sonar.java.se.constraint.Constraint) ARETURN(org.objectweb.asm.Opcodes.ARETURN) IFLT(org.objectweb.asm.Opcodes.IFLT) IUSHR(org.objectweb.asm.Opcodes.IUSHR) Symbols(org.sonar.java.resolve.Symbols) IF_ACMPEQ(org.objectweb.asm.Opcodes.IF_ACMPEQ) LRETURN(org.objectweb.asm.Opcodes.LRETURN) DivisionByZeroCheck(org.sonar.java.se.checks.DivisionByZeroCheck) ConstraintManager(org.sonar.java.se.constraint.ConstraintManager) ImmutableList(com.google.common.collect.ImmutableList) SymbolicValue(org.sonar.java.se.symbolicvalues.SymbolicValue) LinkedList(java.util.LinkedList) BytecodeCFG(org.sonar.java.bytecode.cfg.BytecodeCFG) NOP(org.objectweb.asm.Opcodes.NOP) SquidClassLoader(org.sonar.java.bytecode.loader.SquidClassLoader) MONITOREXIT(org.objectweb.asm.Opcodes.MONITOREXIT) Type(org.sonar.plugins.java.api.semantic.Type) ISUB(org.objectweb.asm.Opcodes.ISUB) ARRAYLENGTH(org.objectweb.asm.Opcodes.ARRAYLENGTH) DUP_X2(org.objectweb.asm.Opcodes.DUP_X2) DUP_X1(org.objectweb.asm.Opcodes.DUP_X1) AASTORE(org.objectweb.asm.Opcodes.AASTORE) SemanticModel(org.sonar.java.resolve.SemanticModel) BALOAD(org.objectweb.asm.Opcodes.BALOAD) PUTSTATIC(org.objectweb.asm.Opcodes.PUTSTATIC) ProgramPoint(org.sonar.java.se.ProgramPoint) CheckForNull(javax.annotation.CheckForNull) LMUL(org.objectweb.asm.Opcodes.LMUL) INVOKEINTERFACE(org.objectweb.asm.Opcodes.INVOKEINTERFACE) BASTORE(org.objectweb.asm.Opcodes.BASTORE) IF_ICMPNE(org.objectweb.asm.Opcodes.IF_ICMPNE) AALOAD(org.objectweb.asm.Opcodes.AALOAD) BooleanConstraint(org.sonar.java.se.constraint.BooleanConstraint) ExceptionUtils(org.sonar.java.se.ExceptionUtils) FCONST_0(org.objectweb.asm.Opcodes.FCONST_0) FCONST_1(org.objectweb.asm.Opcodes.FCONST_1) FCONST_2(org.objectweb.asm.Opcodes.FCONST_2) DCONST_0(org.objectweb.asm.Opcodes.DCONST_0) SIPUSH(org.objectweb.asm.Opcodes.SIPUSH) Set(java.util.Set) IF_ICMPLT(org.objectweb.asm.Opcodes.IF_ICMPLT) DLOAD(org.objectweb.asm.Opcodes.DLOAD) DUP(org.objectweb.asm.Opcodes.DUP) FCMPG(org.objectweb.asm.Opcodes.FCMPG) LAND(org.objectweb.asm.Opcodes.LAND) FCMPL(org.objectweb.asm.Opcodes.FCMPL) LCONST_0(org.objectweb.asm.Opcodes.LCONST_0) SASTORE(org.objectweb.asm.Opcodes.SASTORE) LALOAD(org.objectweb.asm.Opcodes.LALOAD) DCONST_1(org.objectweb.asm.Opcodes.DCONST_1) LCONST_1(org.objectweb.asm.Opcodes.LCONST_1) IOR(org.objectweb.asm.Opcodes.IOR) ObjectConstraint(org.sonar.java.se.constraint.ObjectConstraint) DSTORE(org.objectweb.asm.Opcodes.DSTORE) CALOAD(org.objectweb.asm.Opcodes.CALOAD) FMUL(org.objectweb.asm.Opcodes.FMUL) LONG_OR_DOUBLE(org.sonar.java.bytecode.se.BytecodeEGWalker.StackValueCategoryConstraint.LONG_OR_DOUBLE) I2B(org.objectweb.asm.Opcodes.I2B) IFNE(org.objectweb.asm.Opcodes.IFNE) IREM(org.objectweb.asm.Opcodes.IREM) I2C(org.objectweb.asm.Opcodes.I2C) I2D(org.objectweb.asm.Opcodes.I2D) SWAP(org.objectweb.asm.Opcodes.SWAP) I2F(org.objectweb.asm.Opcodes.I2F) IADD(org.objectweb.asm.Opcodes.IADD) ISTORE(org.objectweb.asm.Opcodes.ISTORE) Pair(org.sonar.java.se.Pair) LOOKUPSWITCH(org.objectweb.asm.Opcodes.LOOKUPSWITCH) IF_ICMPLE(org.objectweb.asm.Opcodes.IF_ICMPLE) INVOKEDYNAMIC(org.objectweb.asm.Opcodes.INVOKEDYNAMIC) LinkedHashSet(java.util.LinkedHashSet) Nullable(javax.annotation.Nullable) Logger(org.sonar.api.utils.log.Logger) IDIV(org.objectweb.asm.Opcodes.IDIV) DREM(org.objectweb.asm.Opcodes.DREM) POP(org.objectweb.asm.Opcodes.POP) SALOAD(org.objectweb.asm.Opcodes.SALOAD) ISHR(org.objectweb.asm.Opcodes.ISHR) NEWARRAY(org.objectweb.asm.Opcodes.NEWARRAY) DADD(org.objectweb.asm.Opcodes.DADD) RelationalSymbolicValue(org.sonar.java.se.symbolicvalues.RelationalSymbolicValue) ICONST_M1(org.objectweb.asm.Opcodes.ICONST_M1) ISHL(org.objectweb.asm.Opcodes.ISHL) BehaviorCache(org.sonar.java.se.xproc.BehaviorCache) LNEG(org.objectweb.asm.Opcodes.LNEG) IRETURN(org.objectweb.asm.Opcodes.IRETURN) DDIV(org.objectweb.asm.Opcodes.DDIV) ALOAD(org.objectweb.asm.Opcodes.ALOAD) FALOAD(org.objectweb.asm.Opcodes.FALOAD) GETSTATIC(org.objectweb.asm.Opcodes.GETSTATIC) LSUB(org.objectweb.asm.Opcodes.LSUB) D2F(org.objectweb.asm.Opcodes.D2F) D2I(org.objectweb.asm.Opcodes.D2I) D2L(org.objectweb.asm.Opcodes.D2L) L2D(org.objectweb.asm.Opcodes.L2D) NEW(org.objectweb.asm.Opcodes.NEW) BytecodeCFGMethodVisitor(org.sonar.java.bytecode.cfg.BytecodeCFGMethodVisitor) MULTIANEWARRAY(org.objectweb.asm.Opcodes.MULTIANEWARRAY) FADD(org.objectweb.asm.Opcodes.FADD) BIPUSH(org.objectweb.asm.Opcodes.BIPUSH) IASTORE(org.objectweb.asm.Opcodes.IASTORE) FREM(org.objectweb.asm.Opcodes.FREM) List(java.util.List) FDIV(org.objectweb.asm.Opcodes.FDIV) DRETURN(org.objectweb.asm.Opcodes.DRETURN) LXOR(org.objectweb.asm.Opcodes.LXOR) FASTORE(org.objectweb.asm.Opcodes.FASTORE) IFNONNULL(org.objectweb.asm.Opcodes.IFNONNULL) FSUB(org.objectweb.asm.Opcodes.FSUB) LUSHR(org.objectweb.asm.Opcodes.LUSHR) IF_ACMPNE(org.objectweb.asm.Opcodes.IF_ACMPNE) ProgramState(org.sonar.java.se.ProgramState) Deque(java.util.Deque) IF_ICMPGT(org.objectweb.asm.Opcodes.IF_ICMPGT) ExplodedGraphWalker(org.sonar.java.se.ExplodedGraphWalker) LDC(org.objectweb.asm.Opcodes.LDC) CHECKCAST(org.objectweb.asm.Opcodes.CHECKCAST) DUP2(org.objectweb.asm.Opcodes.DUP2) ExplodedGraph(org.sonar.java.se.ExplodedGraph) L2F(org.objectweb.asm.Opcodes.L2F) ANEWARRAY(org.objectweb.asm.Opcodes.ANEWARRAY) L2I(org.objectweb.asm.Opcodes.L2I) RETURN(org.objectweb.asm.Opcodes.RETURN) ILOAD(org.objectweb.asm.Opcodes.ILOAD) FRETURN(org.objectweb.asm.Opcodes.FRETURN) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) POP2(org.objectweb.asm.Opcodes.POP2) IF_ICMPGE(org.objectweb.asm.Opcodes.IF_ICMPGE) ProgramState(org.sonar.java.se.ProgramState) SymbolicValue(org.sonar.java.se.symbolicvalues.SymbolicValue) RelationalSymbolicValue(org.sonar.java.se.symbolicvalues.RelationalSymbolicValue) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 98 with ProgramState

use of org.sonar.java.se.ProgramState in project sonar-java by SonarSource.

the class BytecodeEGWalker method handleMethodInvocation.

private boolean handleMethodInvocation(Instruction instruction) {
    boolean isStatic = instruction.opcode == Opcodes.INVOKESTATIC;
    int arity = isStatic ? instruction.arity() : (instruction.arity() + 1);
    ProgramState.Pop pop = programState.unstackValue(arity);
    Preconditions.checkState(pop.values.size() == arity, "Arguments mismatch for INVOKE");
    // TODO use constraintManager.createMethodSymbolicValue to create relational SV for equals
    programState = pop.state;
    SymbolicValue returnSV = instruction.hasReturnValue() ? constraintManager.createSymbolicValue(instruction) : null;
    String signature = instruction.fieldOrMethod.completeSignature();
    MethodBehavior methodInvokedBehavior = behaviorCache.get(signature);
    enqueueUncheckedExceptions();
    // FIXME : empty yields here should not happen, for now act as if behavior was not resolved.
    if (methodInvokedBehavior != null && methodInvokedBehavior.isComplete() && !methodInvokedBehavior.yields().isEmpty()) {
        List<SymbolicValue> stack = Lists.reverse(pop.values);
        if (!isStatic) {
            // remove "thisSV" from stack before trying to apply any yield, as it should not match with arguments
            stack = stack.subList(1, stack.size());
        }
        List<SymbolicValue> arguments = stack;
        methodInvokedBehavior.happyPathYields().forEach(yield -> yield.statesAfterInvocation(arguments, Collections.emptyList(), programState, () -> returnSV).forEach(ps -> {
            checkerDispatcher.methodYield = yield;
            if (ps.peekValue() != null) {
                ps = setDoubleOrLong(ps, ps.peekValue(), instruction.isLongOrDoubleValue());
            }
            checkerDispatcher.addTransition(ps);
            checkerDispatcher.methodYield = null;
        }));
        methodInvokedBehavior.exceptionalPathYields().forEach(yield -> {
            Type exceptionType = yield.exceptionType(semanticModel);
            yield.statesAfterInvocation(arguments, Collections.emptyList(), programState, () -> constraintManager.createExceptionalSymbolicValue(exceptionType)).forEach(ps -> {
                ps.storeExitValue();
                enqueueExceptionHandlers(exceptionType, ps);
            });
        });
        return true;
    }
    if (methodInvokedBehavior != null) {
        methodInvokedBehavior.getDeclaredExceptions().forEach(exception -> {
            Type exceptionType = semanticModel.getClassType(exception);
            ProgramState ps = programState.stackValue(constraintManager.createExceptionalSymbolicValue(exceptionType));
            enqueueExceptionHandlers(exceptionType, ps);
        });
    }
    if (instruction.hasReturnValue()) {
        programState = programState.stackValue(returnSV);
        programState = setDoubleOrLong(returnSV, instruction.isLongOrDoubleValue());
    }
    return false;
}
Also used : ASTORE(org.objectweb.asm.Opcodes.ASTORE) ATHROW(org.objectweb.asm.Opcodes.ATHROW) DMUL(org.objectweb.asm.Opcodes.DMUL) F2D(org.objectweb.asm.Opcodes.F2D) LSHR(org.objectweb.asm.Opcodes.LSHR) IF_ICMPEQ(org.objectweb.asm.Opcodes.IF_ICMPEQ) F2I(org.objectweb.asm.Opcodes.F2I) IINC(org.objectweb.asm.Opcodes.IINC) IFGT(org.objectweb.asm.Opcodes.IFGT) LSHL(org.objectweb.asm.Opcodes.LSHL) IAND(org.objectweb.asm.Opcodes.IAND) DCMPL(org.objectweb.asm.Opcodes.DCMPL) LSTORE(org.objectweb.asm.Opcodes.LSTORE) TypedConstraint(org.sonar.java.se.constraint.TypedConstraint) DCMPG(org.objectweb.asm.Opcodes.DCMPG) IFNULL(org.objectweb.asm.Opcodes.IFNULL) FLOAD(org.objectweb.asm.Opcodes.FLOAD) INSTANCEOF(org.objectweb.asm.Opcodes.INSTANCEOF) IALOAD(org.objectweb.asm.Opcodes.IALOAD) DUP2_X2(org.objectweb.asm.Opcodes.DUP2_X2) DUP2_X1(org.objectweb.asm.Opcodes.DUP2_X1) PUTFIELD(org.objectweb.asm.Opcodes.PUTFIELD) IFEQ(org.objectweb.asm.Opcodes.IFEQ) Lists(com.google.common.collect.Lists) INVOKESTATIC(org.objectweb.asm.Opcodes.INVOKESTATIC) ACONST_NULL(org.objectweb.asm.Opcodes.ACONST_NULL) MethodBehavior(org.sonar.java.se.xproc.MethodBehavior) DALOAD(org.objectweb.asm.Opcodes.DALOAD) INEG(org.objectweb.asm.Opcodes.INEG) MONITORENTER(org.objectweb.asm.Opcodes.MONITORENTER) TABLESWITCH(org.objectweb.asm.Opcodes.TABLESWITCH) ICONST_5(org.objectweb.asm.Opcodes.ICONST_5) IMUL(org.objectweb.asm.Opcodes.IMUL) LOR(org.objectweb.asm.Opcodes.LOR) DASTORE(org.objectweb.asm.Opcodes.DASTORE) ICONST_4(org.objectweb.asm.Opcodes.ICONST_4) Opcodes(org.objectweb.asm.Opcodes) ICONST_3(org.objectweb.asm.Opcodes.ICONST_3) ICONST_2(org.objectweb.asm.Opcodes.ICONST_2) IFGE(org.objectweb.asm.Opcodes.IFGE) ICONST_1(org.objectweb.asm.Opcodes.ICONST_1) ICONST_0(org.objectweb.asm.Opcodes.ICONST_0) LADD(org.objectweb.asm.Opcodes.LADD) F2L(org.objectweb.asm.Opcodes.F2L) Printer(org.objectweb.asm.util.Printer) LREM(org.objectweb.asm.Opcodes.LREM) Preconditions(com.google.common.base.Preconditions) INVOKESPECIAL(org.objectweb.asm.Opcodes.INVOKESPECIAL) DNEG(org.objectweb.asm.Opcodes.DNEG) LDIV(org.objectweb.asm.Opcodes.LDIV) LLOAD(org.objectweb.asm.Opcodes.LLOAD) LCMP(org.objectweb.asm.Opcodes.LCMP) IXOR(org.objectweb.asm.Opcodes.IXOR) DSUB(org.objectweb.asm.Opcodes.DSUB) IFLE(org.objectweb.asm.Opcodes.IFLE) Loggers(org.sonar.api.utils.log.Loggers) LASTORE(org.objectweb.asm.Opcodes.LASTORE) FSTORE(org.objectweb.asm.Opcodes.FSTORE) INVOKEVIRTUAL(org.objectweb.asm.Opcodes.INVOKEVIRTUAL) Collectors(java.util.stream.Collectors) GETFIELD(org.objectweb.asm.Opcodes.GETFIELD) FNEG(org.objectweb.asm.Opcodes.FNEG) I2L(org.objectweb.asm.Opcodes.I2L) CASTORE(org.objectweb.asm.Opcodes.CASTORE) Instruction(org.sonar.java.bytecode.cfg.Instruction) GOTO(org.objectweb.asm.Opcodes.GOTO) I2S(org.objectweb.asm.Opcodes.I2S) Constraint(org.sonar.java.se.constraint.Constraint) ARETURN(org.objectweb.asm.Opcodes.ARETURN) IFLT(org.objectweb.asm.Opcodes.IFLT) IUSHR(org.objectweb.asm.Opcodes.IUSHR) Symbols(org.sonar.java.resolve.Symbols) IF_ACMPEQ(org.objectweb.asm.Opcodes.IF_ACMPEQ) LRETURN(org.objectweb.asm.Opcodes.LRETURN) DivisionByZeroCheck(org.sonar.java.se.checks.DivisionByZeroCheck) ConstraintManager(org.sonar.java.se.constraint.ConstraintManager) ImmutableList(com.google.common.collect.ImmutableList) SymbolicValue(org.sonar.java.se.symbolicvalues.SymbolicValue) LinkedList(java.util.LinkedList) BytecodeCFG(org.sonar.java.bytecode.cfg.BytecodeCFG) NOP(org.objectweb.asm.Opcodes.NOP) SquidClassLoader(org.sonar.java.bytecode.loader.SquidClassLoader) MONITOREXIT(org.objectweb.asm.Opcodes.MONITOREXIT) Type(org.sonar.plugins.java.api.semantic.Type) ISUB(org.objectweb.asm.Opcodes.ISUB) ARRAYLENGTH(org.objectweb.asm.Opcodes.ARRAYLENGTH) DUP_X2(org.objectweb.asm.Opcodes.DUP_X2) DUP_X1(org.objectweb.asm.Opcodes.DUP_X1) AASTORE(org.objectweb.asm.Opcodes.AASTORE) SemanticModel(org.sonar.java.resolve.SemanticModel) BALOAD(org.objectweb.asm.Opcodes.BALOAD) PUTSTATIC(org.objectweb.asm.Opcodes.PUTSTATIC) ProgramPoint(org.sonar.java.se.ProgramPoint) CheckForNull(javax.annotation.CheckForNull) LMUL(org.objectweb.asm.Opcodes.LMUL) INVOKEINTERFACE(org.objectweb.asm.Opcodes.INVOKEINTERFACE) BASTORE(org.objectweb.asm.Opcodes.BASTORE) IF_ICMPNE(org.objectweb.asm.Opcodes.IF_ICMPNE) AALOAD(org.objectweb.asm.Opcodes.AALOAD) BooleanConstraint(org.sonar.java.se.constraint.BooleanConstraint) ExceptionUtils(org.sonar.java.se.ExceptionUtils) FCONST_0(org.objectweb.asm.Opcodes.FCONST_0) FCONST_1(org.objectweb.asm.Opcodes.FCONST_1) FCONST_2(org.objectweb.asm.Opcodes.FCONST_2) DCONST_0(org.objectweb.asm.Opcodes.DCONST_0) SIPUSH(org.objectweb.asm.Opcodes.SIPUSH) Set(java.util.Set) IF_ICMPLT(org.objectweb.asm.Opcodes.IF_ICMPLT) DLOAD(org.objectweb.asm.Opcodes.DLOAD) DUP(org.objectweb.asm.Opcodes.DUP) FCMPG(org.objectweb.asm.Opcodes.FCMPG) LAND(org.objectweb.asm.Opcodes.LAND) FCMPL(org.objectweb.asm.Opcodes.FCMPL) LCONST_0(org.objectweb.asm.Opcodes.LCONST_0) SASTORE(org.objectweb.asm.Opcodes.SASTORE) LALOAD(org.objectweb.asm.Opcodes.LALOAD) DCONST_1(org.objectweb.asm.Opcodes.DCONST_1) LCONST_1(org.objectweb.asm.Opcodes.LCONST_1) IOR(org.objectweb.asm.Opcodes.IOR) ObjectConstraint(org.sonar.java.se.constraint.ObjectConstraint) DSTORE(org.objectweb.asm.Opcodes.DSTORE) CALOAD(org.objectweb.asm.Opcodes.CALOAD) FMUL(org.objectweb.asm.Opcodes.FMUL) LONG_OR_DOUBLE(org.sonar.java.bytecode.se.BytecodeEGWalker.StackValueCategoryConstraint.LONG_OR_DOUBLE) I2B(org.objectweb.asm.Opcodes.I2B) IFNE(org.objectweb.asm.Opcodes.IFNE) IREM(org.objectweb.asm.Opcodes.IREM) I2C(org.objectweb.asm.Opcodes.I2C) I2D(org.objectweb.asm.Opcodes.I2D) SWAP(org.objectweb.asm.Opcodes.SWAP) I2F(org.objectweb.asm.Opcodes.I2F) IADD(org.objectweb.asm.Opcodes.IADD) ISTORE(org.objectweb.asm.Opcodes.ISTORE) Pair(org.sonar.java.se.Pair) LOOKUPSWITCH(org.objectweb.asm.Opcodes.LOOKUPSWITCH) IF_ICMPLE(org.objectweb.asm.Opcodes.IF_ICMPLE) INVOKEDYNAMIC(org.objectweb.asm.Opcodes.INVOKEDYNAMIC) LinkedHashSet(java.util.LinkedHashSet) Nullable(javax.annotation.Nullable) Logger(org.sonar.api.utils.log.Logger) IDIV(org.objectweb.asm.Opcodes.IDIV) DREM(org.objectweb.asm.Opcodes.DREM) POP(org.objectweb.asm.Opcodes.POP) SALOAD(org.objectweb.asm.Opcodes.SALOAD) ISHR(org.objectweb.asm.Opcodes.ISHR) NEWARRAY(org.objectweb.asm.Opcodes.NEWARRAY) DADD(org.objectweb.asm.Opcodes.DADD) RelationalSymbolicValue(org.sonar.java.se.symbolicvalues.RelationalSymbolicValue) ICONST_M1(org.objectweb.asm.Opcodes.ICONST_M1) ISHL(org.objectweb.asm.Opcodes.ISHL) BehaviorCache(org.sonar.java.se.xproc.BehaviorCache) LNEG(org.objectweb.asm.Opcodes.LNEG) IRETURN(org.objectweb.asm.Opcodes.IRETURN) DDIV(org.objectweb.asm.Opcodes.DDIV) ALOAD(org.objectweb.asm.Opcodes.ALOAD) FALOAD(org.objectweb.asm.Opcodes.FALOAD) GETSTATIC(org.objectweb.asm.Opcodes.GETSTATIC) LSUB(org.objectweb.asm.Opcodes.LSUB) D2F(org.objectweb.asm.Opcodes.D2F) D2I(org.objectweb.asm.Opcodes.D2I) D2L(org.objectweb.asm.Opcodes.D2L) L2D(org.objectweb.asm.Opcodes.L2D) NEW(org.objectweb.asm.Opcodes.NEW) BytecodeCFGMethodVisitor(org.sonar.java.bytecode.cfg.BytecodeCFGMethodVisitor) MULTIANEWARRAY(org.objectweb.asm.Opcodes.MULTIANEWARRAY) FADD(org.objectweb.asm.Opcodes.FADD) BIPUSH(org.objectweb.asm.Opcodes.BIPUSH) IASTORE(org.objectweb.asm.Opcodes.IASTORE) FREM(org.objectweb.asm.Opcodes.FREM) List(java.util.List) FDIV(org.objectweb.asm.Opcodes.FDIV) DRETURN(org.objectweb.asm.Opcodes.DRETURN) LXOR(org.objectweb.asm.Opcodes.LXOR) FASTORE(org.objectweb.asm.Opcodes.FASTORE) IFNONNULL(org.objectweb.asm.Opcodes.IFNONNULL) FSUB(org.objectweb.asm.Opcodes.FSUB) LUSHR(org.objectweb.asm.Opcodes.LUSHR) IF_ACMPNE(org.objectweb.asm.Opcodes.IF_ACMPNE) ProgramState(org.sonar.java.se.ProgramState) Deque(java.util.Deque) IF_ICMPGT(org.objectweb.asm.Opcodes.IF_ICMPGT) ExplodedGraphWalker(org.sonar.java.se.ExplodedGraphWalker) LDC(org.objectweb.asm.Opcodes.LDC) CHECKCAST(org.objectweb.asm.Opcodes.CHECKCAST) DUP2(org.objectweb.asm.Opcodes.DUP2) ExplodedGraph(org.sonar.java.se.ExplodedGraph) L2F(org.objectweb.asm.Opcodes.L2F) ANEWARRAY(org.objectweb.asm.Opcodes.ANEWARRAY) L2I(org.objectweb.asm.Opcodes.L2I) RETURN(org.objectweb.asm.Opcodes.RETURN) ILOAD(org.objectweb.asm.Opcodes.ILOAD) FRETURN(org.objectweb.asm.Opcodes.FRETURN) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) POP2(org.objectweb.asm.Opcodes.POP2) IF_ICMPGE(org.objectweb.asm.Opcodes.IF_ICMPGE) Type(org.sonar.plugins.java.api.semantic.Type) MethodBehavior(org.sonar.java.se.xproc.MethodBehavior) ProgramState(org.sonar.java.se.ProgramState) SymbolicValue(org.sonar.java.se.symbolicvalues.SymbolicValue) RelationalSymbolicValue(org.sonar.java.se.symbolicvalues.RelationalSymbolicValue) TypedConstraint(org.sonar.java.se.constraint.TypedConstraint) Constraint(org.sonar.java.se.constraint.Constraint) ProgramPoint(org.sonar.java.se.ProgramPoint) BooleanConstraint(org.sonar.java.se.constraint.BooleanConstraint) ObjectConstraint(org.sonar.java.se.constraint.ObjectConstraint)

Example 99 with ProgramState

use of org.sonar.java.se.ProgramState in project sonar-java by SonarSource.

the class BytecodeEGWalker method startingStates.

@VisibleForTesting
Iterable<ProgramState> startingStates(String signature, ProgramState currentState, boolean isStaticMethod) {
    // TODO : deal with parameter annotations, equals methods etc.
    int parameterIdx = 0;
    ProgramState state = currentState;
    if (!isStaticMethod) {
        // Add a sv for "this"
        SymbolicValue thisSV = constraintManager.createSymbolicValue((Instruction) null);
        state = currentState.addConstraint(thisSV, ObjectConstraint.NOT_NULL).addConstraint(thisSV, new TypedConstraint(signature.substring(0, signature.indexOf('#')))).put(0, thisSV);
        parameterIdx = 1;
    }
    org.objectweb.asm.Type[] argumentTypes = org.objectweb.asm.Type.getArgumentTypes(signature.substring(signature.indexOf('(')));
    for (org.objectweb.asm.Type argumentType : argumentTypes) {
        SymbolicValue sv = constraintManager.createSymbolicValue((Instruction) null);
        methodBehavior.addParameter(sv);
        state = state.put(parameterIdx, sv);
        state = setDoubleOrLong(state, sv, argumentType.getSize() == 2);
        parameterIdx += argumentType.getSize();
    }
    return Collections.singletonList(state);
}
Also used : Type(org.sonar.plugins.java.api.semantic.Type) ProgramState(org.sonar.java.se.ProgramState) TypedConstraint(org.sonar.java.se.constraint.TypedConstraint) SymbolicValue(org.sonar.java.se.symbolicvalues.SymbolicValue) RelationalSymbolicValue(org.sonar.java.se.symbolicvalues.RelationalSymbolicValue) TypedConstraint(org.sonar.java.se.constraint.TypedConstraint) Constraint(org.sonar.java.se.constraint.Constraint) ProgramPoint(org.sonar.java.se.ProgramPoint) BooleanConstraint(org.sonar.java.se.constraint.BooleanConstraint) ObjectConstraint(org.sonar.java.se.constraint.ObjectConstraint) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 100 with ProgramState

use of org.sonar.java.se.ProgramState in project sonar-java by SonarSource.

the class BytecodeEGWalker method enqueueExceptionHandlers.

private void enqueueExceptionHandlers(Type exceptionType, ProgramState ps) {
    List<BytecodeCFG.Block> blocksCatchingException = programPosition.block.successors().stream().map(b -> (BytecodeCFG.Block) b).filter(BytecodeCFG.Block::isCatchBlock).filter(b -> isExceptionHandledByBlock(exceptionType, b)).collect(Collectors.toList());
    if (!blocksCatchingException.isEmpty()) {
        blocksCatchingException.forEach(b -> enqueue(new ProgramPoint(b), ps));
        if (isCatchExhaustive(exceptionType, blocksCatchingException)) {
            return;
        }
    }
    // exception was not handled or was handled only partially, enqueue exit block with exceptional SV
    Preconditions.checkState(ps.peekValue() instanceof SymbolicValue.ExceptionalSymbolicValue, "Exception shall be on top of the stack");
    ps.storeExitValue();
    enqueue(new ProgramPoint(exitBlock), ps);
}
Also used : ASTORE(org.objectweb.asm.Opcodes.ASTORE) ATHROW(org.objectweb.asm.Opcodes.ATHROW) DMUL(org.objectweb.asm.Opcodes.DMUL) F2D(org.objectweb.asm.Opcodes.F2D) LSHR(org.objectweb.asm.Opcodes.LSHR) IF_ICMPEQ(org.objectweb.asm.Opcodes.IF_ICMPEQ) F2I(org.objectweb.asm.Opcodes.F2I) IINC(org.objectweb.asm.Opcodes.IINC) IFGT(org.objectweb.asm.Opcodes.IFGT) LSHL(org.objectweb.asm.Opcodes.LSHL) IAND(org.objectweb.asm.Opcodes.IAND) DCMPL(org.objectweb.asm.Opcodes.DCMPL) LSTORE(org.objectweb.asm.Opcodes.LSTORE) TypedConstraint(org.sonar.java.se.constraint.TypedConstraint) DCMPG(org.objectweb.asm.Opcodes.DCMPG) IFNULL(org.objectweb.asm.Opcodes.IFNULL) FLOAD(org.objectweb.asm.Opcodes.FLOAD) INSTANCEOF(org.objectweb.asm.Opcodes.INSTANCEOF) IALOAD(org.objectweb.asm.Opcodes.IALOAD) DUP2_X2(org.objectweb.asm.Opcodes.DUP2_X2) DUP2_X1(org.objectweb.asm.Opcodes.DUP2_X1) PUTFIELD(org.objectweb.asm.Opcodes.PUTFIELD) IFEQ(org.objectweb.asm.Opcodes.IFEQ) Lists(com.google.common.collect.Lists) INVOKESTATIC(org.objectweb.asm.Opcodes.INVOKESTATIC) ACONST_NULL(org.objectweb.asm.Opcodes.ACONST_NULL) MethodBehavior(org.sonar.java.se.xproc.MethodBehavior) DALOAD(org.objectweb.asm.Opcodes.DALOAD) INEG(org.objectweb.asm.Opcodes.INEG) MONITORENTER(org.objectweb.asm.Opcodes.MONITORENTER) TABLESWITCH(org.objectweb.asm.Opcodes.TABLESWITCH) ICONST_5(org.objectweb.asm.Opcodes.ICONST_5) IMUL(org.objectweb.asm.Opcodes.IMUL) LOR(org.objectweb.asm.Opcodes.LOR) DASTORE(org.objectweb.asm.Opcodes.DASTORE) ICONST_4(org.objectweb.asm.Opcodes.ICONST_4) Opcodes(org.objectweb.asm.Opcodes) ICONST_3(org.objectweb.asm.Opcodes.ICONST_3) ICONST_2(org.objectweb.asm.Opcodes.ICONST_2) IFGE(org.objectweb.asm.Opcodes.IFGE) ICONST_1(org.objectweb.asm.Opcodes.ICONST_1) ICONST_0(org.objectweb.asm.Opcodes.ICONST_0) LADD(org.objectweb.asm.Opcodes.LADD) F2L(org.objectweb.asm.Opcodes.F2L) Printer(org.objectweb.asm.util.Printer) LREM(org.objectweb.asm.Opcodes.LREM) Preconditions(com.google.common.base.Preconditions) INVOKESPECIAL(org.objectweb.asm.Opcodes.INVOKESPECIAL) DNEG(org.objectweb.asm.Opcodes.DNEG) LDIV(org.objectweb.asm.Opcodes.LDIV) LLOAD(org.objectweb.asm.Opcodes.LLOAD) LCMP(org.objectweb.asm.Opcodes.LCMP) IXOR(org.objectweb.asm.Opcodes.IXOR) DSUB(org.objectweb.asm.Opcodes.DSUB) IFLE(org.objectweb.asm.Opcodes.IFLE) Loggers(org.sonar.api.utils.log.Loggers) LASTORE(org.objectweb.asm.Opcodes.LASTORE) FSTORE(org.objectweb.asm.Opcodes.FSTORE) INVOKEVIRTUAL(org.objectweb.asm.Opcodes.INVOKEVIRTUAL) Collectors(java.util.stream.Collectors) GETFIELD(org.objectweb.asm.Opcodes.GETFIELD) FNEG(org.objectweb.asm.Opcodes.FNEG) I2L(org.objectweb.asm.Opcodes.I2L) CASTORE(org.objectweb.asm.Opcodes.CASTORE) Instruction(org.sonar.java.bytecode.cfg.Instruction) GOTO(org.objectweb.asm.Opcodes.GOTO) I2S(org.objectweb.asm.Opcodes.I2S) Constraint(org.sonar.java.se.constraint.Constraint) ARETURN(org.objectweb.asm.Opcodes.ARETURN) IFLT(org.objectweb.asm.Opcodes.IFLT) IUSHR(org.objectweb.asm.Opcodes.IUSHR) Symbols(org.sonar.java.resolve.Symbols) IF_ACMPEQ(org.objectweb.asm.Opcodes.IF_ACMPEQ) LRETURN(org.objectweb.asm.Opcodes.LRETURN) DivisionByZeroCheck(org.sonar.java.se.checks.DivisionByZeroCheck) ConstraintManager(org.sonar.java.se.constraint.ConstraintManager) ImmutableList(com.google.common.collect.ImmutableList) SymbolicValue(org.sonar.java.se.symbolicvalues.SymbolicValue) LinkedList(java.util.LinkedList) BytecodeCFG(org.sonar.java.bytecode.cfg.BytecodeCFG) NOP(org.objectweb.asm.Opcodes.NOP) SquidClassLoader(org.sonar.java.bytecode.loader.SquidClassLoader) MONITOREXIT(org.objectweb.asm.Opcodes.MONITOREXIT) Type(org.sonar.plugins.java.api.semantic.Type) ISUB(org.objectweb.asm.Opcodes.ISUB) ARRAYLENGTH(org.objectweb.asm.Opcodes.ARRAYLENGTH) DUP_X2(org.objectweb.asm.Opcodes.DUP_X2) DUP_X1(org.objectweb.asm.Opcodes.DUP_X1) AASTORE(org.objectweb.asm.Opcodes.AASTORE) SemanticModel(org.sonar.java.resolve.SemanticModel) BALOAD(org.objectweb.asm.Opcodes.BALOAD) PUTSTATIC(org.objectweb.asm.Opcodes.PUTSTATIC) ProgramPoint(org.sonar.java.se.ProgramPoint) CheckForNull(javax.annotation.CheckForNull) LMUL(org.objectweb.asm.Opcodes.LMUL) INVOKEINTERFACE(org.objectweb.asm.Opcodes.INVOKEINTERFACE) BASTORE(org.objectweb.asm.Opcodes.BASTORE) IF_ICMPNE(org.objectweb.asm.Opcodes.IF_ICMPNE) AALOAD(org.objectweb.asm.Opcodes.AALOAD) BooleanConstraint(org.sonar.java.se.constraint.BooleanConstraint) ExceptionUtils(org.sonar.java.se.ExceptionUtils) FCONST_0(org.objectweb.asm.Opcodes.FCONST_0) FCONST_1(org.objectweb.asm.Opcodes.FCONST_1) FCONST_2(org.objectweb.asm.Opcodes.FCONST_2) DCONST_0(org.objectweb.asm.Opcodes.DCONST_0) SIPUSH(org.objectweb.asm.Opcodes.SIPUSH) Set(java.util.Set) IF_ICMPLT(org.objectweb.asm.Opcodes.IF_ICMPLT) DLOAD(org.objectweb.asm.Opcodes.DLOAD) DUP(org.objectweb.asm.Opcodes.DUP) FCMPG(org.objectweb.asm.Opcodes.FCMPG) LAND(org.objectweb.asm.Opcodes.LAND) FCMPL(org.objectweb.asm.Opcodes.FCMPL) LCONST_0(org.objectweb.asm.Opcodes.LCONST_0) SASTORE(org.objectweb.asm.Opcodes.SASTORE) LALOAD(org.objectweb.asm.Opcodes.LALOAD) DCONST_1(org.objectweb.asm.Opcodes.DCONST_1) LCONST_1(org.objectweb.asm.Opcodes.LCONST_1) IOR(org.objectweb.asm.Opcodes.IOR) ObjectConstraint(org.sonar.java.se.constraint.ObjectConstraint) DSTORE(org.objectweb.asm.Opcodes.DSTORE) CALOAD(org.objectweb.asm.Opcodes.CALOAD) FMUL(org.objectweb.asm.Opcodes.FMUL) LONG_OR_DOUBLE(org.sonar.java.bytecode.se.BytecodeEGWalker.StackValueCategoryConstraint.LONG_OR_DOUBLE) I2B(org.objectweb.asm.Opcodes.I2B) IFNE(org.objectweb.asm.Opcodes.IFNE) IREM(org.objectweb.asm.Opcodes.IREM) I2C(org.objectweb.asm.Opcodes.I2C) I2D(org.objectweb.asm.Opcodes.I2D) SWAP(org.objectweb.asm.Opcodes.SWAP) I2F(org.objectweb.asm.Opcodes.I2F) IADD(org.objectweb.asm.Opcodes.IADD) ISTORE(org.objectweb.asm.Opcodes.ISTORE) Pair(org.sonar.java.se.Pair) LOOKUPSWITCH(org.objectweb.asm.Opcodes.LOOKUPSWITCH) IF_ICMPLE(org.objectweb.asm.Opcodes.IF_ICMPLE) INVOKEDYNAMIC(org.objectweb.asm.Opcodes.INVOKEDYNAMIC) LinkedHashSet(java.util.LinkedHashSet) Nullable(javax.annotation.Nullable) Logger(org.sonar.api.utils.log.Logger) IDIV(org.objectweb.asm.Opcodes.IDIV) DREM(org.objectweb.asm.Opcodes.DREM) POP(org.objectweb.asm.Opcodes.POP) SALOAD(org.objectweb.asm.Opcodes.SALOAD) ISHR(org.objectweb.asm.Opcodes.ISHR) NEWARRAY(org.objectweb.asm.Opcodes.NEWARRAY) DADD(org.objectweb.asm.Opcodes.DADD) RelationalSymbolicValue(org.sonar.java.se.symbolicvalues.RelationalSymbolicValue) ICONST_M1(org.objectweb.asm.Opcodes.ICONST_M1) ISHL(org.objectweb.asm.Opcodes.ISHL) BehaviorCache(org.sonar.java.se.xproc.BehaviorCache) LNEG(org.objectweb.asm.Opcodes.LNEG) IRETURN(org.objectweb.asm.Opcodes.IRETURN) DDIV(org.objectweb.asm.Opcodes.DDIV) ALOAD(org.objectweb.asm.Opcodes.ALOAD) FALOAD(org.objectweb.asm.Opcodes.FALOAD) GETSTATIC(org.objectweb.asm.Opcodes.GETSTATIC) LSUB(org.objectweb.asm.Opcodes.LSUB) D2F(org.objectweb.asm.Opcodes.D2F) D2I(org.objectweb.asm.Opcodes.D2I) D2L(org.objectweb.asm.Opcodes.D2L) L2D(org.objectweb.asm.Opcodes.L2D) NEW(org.objectweb.asm.Opcodes.NEW) BytecodeCFGMethodVisitor(org.sonar.java.bytecode.cfg.BytecodeCFGMethodVisitor) MULTIANEWARRAY(org.objectweb.asm.Opcodes.MULTIANEWARRAY) FADD(org.objectweb.asm.Opcodes.FADD) BIPUSH(org.objectweb.asm.Opcodes.BIPUSH) IASTORE(org.objectweb.asm.Opcodes.IASTORE) FREM(org.objectweb.asm.Opcodes.FREM) List(java.util.List) FDIV(org.objectweb.asm.Opcodes.FDIV) DRETURN(org.objectweb.asm.Opcodes.DRETURN) LXOR(org.objectweb.asm.Opcodes.LXOR) FASTORE(org.objectweb.asm.Opcodes.FASTORE) IFNONNULL(org.objectweb.asm.Opcodes.IFNONNULL) FSUB(org.objectweb.asm.Opcodes.FSUB) LUSHR(org.objectweb.asm.Opcodes.LUSHR) IF_ACMPNE(org.objectweb.asm.Opcodes.IF_ACMPNE) ProgramState(org.sonar.java.se.ProgramState) Deque(java.util.Deque) IF_ICMPGT(org.objectweb.asm.Opcodes.IF_ICMPGT) ExplodedGraphWalker(org.sonar.java.se.ExplodedGraphWalker) LDC(org.objectweb.asm.Opcodes.LDC) CHECKCAST(org.objectweb.asm.Opcodes.CHECKCAST) DUP2(org.objectweb.asm.Opcodes.DUP2) ExplodedGraph(org.sonar.java.se.ExplodedGraph) L2F(org.objectweb.asm.Opcodes.L2F) ANEWARRAY(org.objectweb.asm.Opcodes.ANEWARRAY) L2I(org.objectweb.asm.Opcodes.L2I) RETURN(org.objectweb.asm.Opcodes.RETURN) ILOAD(org.objectweb.asm.Opcodes.ILOAD) FRETURN(org.objectweb.asm.Opcodes.FRETURN) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) POP2(org.objectweb.asm.Opcodes.POP2) IF_ICMPGE(org.objectweb.asm.Opcodes.IF_ICMPGE) ProgramPoint(org.sonar.java.se.ProgramPoint) SymbolicValue(org.sonar.java.se.symbolicvalues.SymbolicValue) RelationalSymbolicValue(org.sonar.java.se.symbolicvalues.RelationalSymbolicValue)

Aggregations

ProgramState (org.sonar.java.se.ProgramState)105 SymbolicValue (org.sonar.java.se.symbolicvalues.SymbolicValue)72 Test (org.junit.Test)71 Instruction (org.sonar.java.bytecode.cfg.Instruction)61 RelationalSymbolicValue (org.sonar.java.se.symbolicvalues.RelationalSymbolicValue)52 BinarySymbolicValue (org.sonar.java.se.symbolicvalues.BinarySymbolicValue)45 BooleanConstraint (org.sonar.java.se.constraint.BooleanConstraint)33 ObjectConstraint (org.sonar.java.se.constraint.ObjectConstraint)32 ProgramPoint (org.sonar.java.se.ProgramPoint)30 Constraint (org.sonar.java.se.constraint.Constraint)30 TypedConstraint (org.sonar.java.se.constraint.TypedConstraint)25 ConstraintsByDomain (org.sonar.java.se.constraint.ConstraintsByDomain)11 List (java.util.List)9 Collectors (java.util.stream.Collectors)8 Type (org.sonar.plugins.java.api.semantic.Type)8 VisibleForTesting (com.google.common.annotations.VisibleForTesting)7 ExplodedGraph (org.sonar.java.se.ExplodedGraph)7 MethodInvocationTree (org.sonar.plugins.java.api.tree.MethodInvocationTree)7 Lists (com.google.common.collect.Lists)6 ArrayList (java.util.ArrayList)6