Package edu.umd.cs.findbugs

Examples of edu.umd.cs.findbugs.LocalVariableAnnotation


        if (vnaFrame == null || vnaFrame.isBottom() || vnaFrame.isTop()) {
            return null;
        }

        LocalVariableAnnotation localAnnotation = null;
        for (int i = 0; i < vnaFrame.getNumLocals(); i++) {
            if (valueNumber.equals(vnaFrame.getValue(i))) {
                InstructionHandle handle = location.getHandle();
                InstructionHandle prev = handle.getPrev();
                if (prev == null) {
View Full Code Here


                }

            } catch (DataflowAnalysisException e2) {
            }
            if (variableAnnotation == null) {
                variableAnnotation = new LocalVariableAnnotation("?", -1, derefLocationSet.iterator().next().getHandle()
                        .getPosition());
            }

            if (PRUNE_GUARANTEED_DEREFERENCES) {
                PostDominatorsAnalysis postDomAnalysis = classContext.getNonExceptionPostDominatorsAnalysis(method);
View Full Code Here

                    if (containsNullness(method.getParameterAnnotations(i), CHECK_FOR_NULL)) {
                        NullnessAnnotation a = e.getValue();
                        BugInstance bug = new BugInstance(CheckRelaxingNullnessAnnotation.this,
                                "NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION", a.equals(NONNULL) ? HIGH_PRIORITY : NORMAL_PRIORITY);
                        bug.addClassAndMethod(xmethod);
                        LocalVariableAnnotation lva = null;
                        if (localVariables != null) {
                            for(LocalVariableNode lvn : localVariables) {
                                if (lvn.index == i+1) {
                                    lva = new LocalVariableAnnotation(lvn.name, i+1, 0);
                                    lva.setDescription(LocalVariableAnnotation.PARAMETER_NAMED_ROLE);
                                    break;
                                }
                            }
                        }
                        if (lva==null) {
                            lva = new LocalVariableAnnotation("?", i+1, 0);
                            lva.setDescription(LocalVariableAnnotation.PARAMETER_ROLE);
                        }
                        bug.add(lva);
                        bugReporter.reportBug(bug);
                        foundAny = true;
                    }
View Full Code Here

        BugInstance bugInstance = new BugInstance(this, type, priority).addClassAndMethod(classContext.getJavaClass(), method);
        bugInstance.add(cause);
        if (variable != null) {
            bugInstance.add(variable);
        } else {
            bugInstance.add(new LocalVariableAnnotation("?", -1, -1));
        }
        bugInstance.addSourceLine(classContext, method, location).describe("SOURCE_LINE_DEREF");

        if (FindBugsAnalysisFeatures.isRelaxedMode()) {
            WarningPropertyUtil.addPropertiesForDataMining(propertySet, classContext, method, location);
View Full Code Here

            int registerNumber = next.getRegisterNumber();
            if (f != null && f.equals(getXFieldOperand()) && registerNumber >= 0
                    && registerNumber == top.getFieldLoadedFromRegister() && (top.getPC() == -1 || top.getPC() > lastMethodCall)) {
                int priority = NORMAL_PRIORITY;

                LocalVariableAnnotation possibleMatch = LocalVariableAnnotation.findMatchingIgnoredParameter(getClassContext(),
                        getMethod(), getNameConstantOperand(), getSigConstantOperand());
                if (possibleMatch != null) {
                    priority--;
                } else {
                    possibleMatch = LocalVariableAnnotation.findUniqueBestMatchingParameter(getClassContext(), getMethod(),
View Full Code Here

                    register = opcode - ASTORE_0;
                } else if (opcode == ASTORE) {
                    register =  asUnsignedByte(code[handled + 1]);
                }
                if (register >= 0) {
                    LocalVariableAnnotation lva = LocalVariableAnnotation.getLocalVariableAnnotation(getMethod(), register, handled+2, handled+1);
                    String name = lva.getName();
                    if (DEBUG) {
                        System.out.println("Name: " + name);
                    }
                    if (name.startsWith("ignore") || name.startsWith("cant")) {
                        continue;
View Full Code Here

                                || !previousStores.get(getRegisterOperand())) {
                            priority = HIGH_PRIORITY;
                        }
                        previousStores.set(getRegisterOperand());
                        XClass c = getXClass();
                        LocalVariableAnnotation local = LocalVariableAnnotation.getLocalVariableAnnotation(getMethod(),
                                getRegisterOperand(), getPC(), getPC());
                        if (local.getName().equals("?")) {
                            priority++;
                        } else {
                            for (XField f : c.getXFields()) {
                                if (f.getName().equals(local.getName()) && (f.isStatic() || !getMethod().isStatic())) {
                                    bugReporter.reportBug(new BugInstance(this, "SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD",
                                            priority).addClassAndMethod(this).add(local).addField(f)
                                            .describe(FieldAnnotation.DID_YOU_MEAN_ROLE).addSourceLine(this));
                                    return;
View Full Code Here

                BitSet liveStoreSet = llsaDataflow.getAnalysis().getFactAtLocation(location);

                // Is store alive?
                boolean storeLive = llsaDataflow.getAnalysis().isStoreAlive(liveStoreSet, local);

                LocalVariableAnnotation lvAnnotation = LocalVariableAnnotation.getLocalVariableAnnotation(method, location, ins);

                String sourceFileName = javaClass.getSourceFileName();
                if (lvAnnotation.getName().equals("?")) {
                    if (sourceFileName.endsWith(".groovy")) {
                        continue;
                    }
                    if (method.getCode().getLocalVariableTable() != null) {
                        continue;
                    }
                }

                SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstruction(classContext, methodGen,
                        sourceFileName, location.getHandle());

                if (DEBUG) {
                    System.out.println("    Store at " + sourceLineAnnotation.getStartLine() + "@"
                            + location.getHandle().getPosition() + " is " + (storeLive ? "live" : "dead"));
                    System.out.println("Previous is: " + location.getHandle().getPrev());
                }

                // Note source lines of live stores.
                if (storeLive && sourceLineAnnotation.getStartLine() > 0) {
                    liveStoreSourceLineSet.set(sourceLineAnnotation.getStartLine());
                }

                String lvName = lvAnnotation.getName();
                if (lvName.charAt(0) == '$' || lvName.charAt(0) == '_') {
                    propertySet.addProperty(DeadLocalStoreProperty.SYNTHETIC_NAME);
                }
                if (EXCLUDED_LOCALS.contains(lvName)) {
                    continue;
View Full Code Here

        // Hopefully we can find the conflicted value in a local variable
        if (locationWhereDoomedValueIsObserved != null) {
            Method method = Global.getAnalysisCache().getMethodAnalysis(Method.class, xMethod.getMethodDescriptor());

            LocalVariableAnnotation localVariable = ValueNumberSourceInfo.findLocalAnnotationFromValueNumber(method,
                    locationWhereDoomedValueIsObserved, vn, vnaFrame);
            if (localVariable != null && !localVariable.equals(warning.getPrimaryLocalVariableAnnotation())) {
                localVariable.setDescription(localVariable.isSignificant() ? "LOCAL_VARIABLE_VALUE_DOOMED_NAMED"
                        : "LOCAL_VARIABLE_VALUE_DOOMED");
                warning.add(localVariable);

            }
            if (!sinkLocation.equals(locationToReport)) {
View Full Code Here

        MethodDescriptor methodDescriptor = xMethod.getMethodDescriptor();
        switch (sourceSinkInfo.getType()) {
        case PARAMETER:
            try {
                Method method = Global.getAnalysisCache().getMethodAnalysis(Method.class, methodDescriptor);
                LocalVariableAnnotation lva = LocalVariableAnnotation.getParameterLocalVariableAnnotation(method,
                        sourceSinkInfo.getLocal());
                lva.setDescription(lva.isSignificant() ? LocalVariableAnnotation.PARAMETER_VALUE_SOURCE_NAMED_ROLE
                        : LocalVariableAnnotation.PARAMETER_VALUE_SOURCE_ROLE);

                warning.add(lva);
            } catch (CheckedAnalysisException e) {
                warning.addSourceLine(methodDescriptor, sourceSinkInfo.getLocation()).describe("SOURCE_LINE_VALUE_SOURCE");
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.LocalVariableAnnotation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.