public BugInstance addFieldOrMethodValueSource(OpcodeStack.Item item) { addOptionalAnnotation(getFieldOrMethodValueSource(item)); return this; }
public BugInstance addSourceForTopStackValue(ClassContext classContext, Method method, Location location) { BugAnnotation b = getSourceForTopStackValue(classContext, method, location); return this.addOptionalAnnotation(b); }
public BugInstance addValueSource(OpcodeStack.Item item, Method method, int pc) { addOptionalAnnotation(getValueSource(item, method, pc)); return this; }
/** * @param seen * @param item */ private void reportVacuousBitOperation(int seen, OpcodeStack.Item item) { if (item.getConstant() == null) { accumulator .accumulateBug( new BugInstance(this, "INT_VACUOUS_BIT_OPERATION", NORMAL_PRIORITY) .addClassAndMethod(this) .addString(Const.getOpcodeName(seen)) .addOptionalAnnotation( LocalVariableAnnotation.getLocalVariableAnnotation(getMethod(), item, getPC())), this); } }
BugAnnotation variableAnnotation = ValueNumberSourceInfo.findAnnotationFromValueNumber(method, location, valueNumber, vnaFrame, "VALUE_OF"); warning.addOptionalAnnotation(variableAnnotation); } catch (DataflowAnalysisException e) { AnalysisContext.logError("error", e);
.addOptionalAnnotation(possibleTarget).addSourceLine(this); pendingBugs.add(bug); if (priorityLoweredBecauseOfIfNonnullTest) {
.addOptionalAnnotation(valueSource);
bugInstance.addField(storedField).describe("FIELD_STORED"); bugInstance.addOptionalAnnotation(variableAnnotation); if (variableAnnotation instanceof FieldAnnotation) { bugInstance.describe("FIELD_CONTAINS_VALUE");
method).addOptionalAnnotation(variable); bugAccumulator.accumulateBug(warning, SourceLineAnnotation.fromVisitedInstruction(classContext, method, location));
.addClassAndMethod(classContext.getJavaClass(), method).addMethod(m) .describe(MethodAnnotation.METHOD_CALLED).addParameterAnnotation(i, description) .addOptionalAnnotation(variableAnnotation).addSourceLine(classContext, method, location);
if (unconditionalDerefLocationSet.size() > 1) { bug = new BugInstance(this, "NP_GUARANTEED_DEREF", NORMAL_PRIORITY).addClassAndMethod(this); bug.addOptionalAnnotation(variableAnnotation); bug.addSourceLine(tested).describe("SOURCE_LINE_KNOWN_NULL"); for (Location dereferenced : unconditionalDerefLocationSet) { bug.addOptionalAnnotation(variableAnnotation); for (Location dereferenced : unconditionalDerefLocationSet) { bug.addSourceLine(getClassContext(), getMethod(), dereferenced).describe("SOURCE_LINE_DEREF");
.addOptionalAnnotation(variableAnnotation), sourceLineAnnotation);
.addClassAndMethod(methodGen, sourceFile) .addCalledMethod(methodGen, (InvokeInstruction) ins) .addOptionalAnnotation( ValueNumberSourceInfo.findAnnotationFromValueNumber(method, location, objectVN, vnFrame, "INVOKED_ON")), SourceLineAnnotation.fromVisitedInstruction( .addFoundAndExpectedType(actualType, expectedType) .addCalledMethod(methodGen, (InvokeInstruction) ins) .addOptionalAnnotation( ValueNumberSourceInfo.findAnnotationFromValueNumber(method, location, objectVN, vnFrame, "INVOKED_ON")) .addOptionalAnnotation( ValueNumberSourceInfo.findAnnotationFromValueNumber(method, location, argVN, vnFrame, "ARGUMENT")) .addEqualsMethodUsed(targets);
.addOptionalAnnotation(calledMethodAnnotation); if ("DMI_DOH".equals(type)) { bug.addString("Use \"== null\" to check for a value being null"); .addFoundAndExpectedType(rhsType_, lhsType_) .addSomeSourceForTopTwoStackValues(classContext, method, location) .addOptionalAnnotation(calledMethodAnnotation, MethodAnnotation.METHOD_CALLED), SourceLineAnnotation.fromVisitedInstruction(this.classContext, methodGen, sourceFile, location.getHandle())); return; .addClassAndMethod(methodGen, sourceFile).addFoundAndExpectedType(rhsType_, lhsType_) .addSomeSourceForTopTwoStackValues(classContext, method, location) .addOptionalAnnotation(calledMethodAnnotation, MethodAnnotation.METHOD_CALLED), SourceLineAnnotation.fromVisitedInstruction(this.classContext, methodGen, sourceFile, location.getHandle())); } else if (result == IncompatibleTypes.INCOMPATIBLE_CLASSES) { .addClassAndMethod(methodGen, sourceFile).addFoundAndExpectedType(rhsType_, lhsType_) .addSomeSourceForTopTwoStackValues(classContext, method, location).addEqualsMethodUsed(targets) .addOptionalAnnotation(calledMethodAnnotation, MethodAnnotation.METHOD_CALLED), SourceLineAnnotation.fromVisitedInstruction(this.classContext, methodGen, sourceFile, location.getHandle())); .addSomeSourceForTopTwoStackValues(classContext, method, location) .addEqualsMethodUsed(DescriptorFactory.createClassDescriptorFromSignature(lhsType_.getSignature())) .addOptionalAnnotation(calledMethodAnnotation, MethodAnnotation.METHOD_CALLED), SourceLineAnnotation.fromVisitedInstruction(this.classContext, methodGen, sourceFile, location.getHandle())); } else if (result == IncompatibleTypes.UNRELATED_INTERFACES) { .addSomeSourceForTopTwoStackValues(classContext, method, location)
private void examinePutfieldInstruction(Location location, PUTFIELD ins, ConstantPoolGen cpg) throws DataflowAnalysisException { IsNullValueFrame frame = invDataflow.getFactAtLocation(location); if (!frame.isValid()) { return; } IsNullValue tos = frame.getTopValue(); if (tos.isDefinitelyNull()) { XField field = XFactory.createXField(ins, cpg); NullnessAnnotation annotation = AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase() .getResolvedAnnotation(field, false); if (annotation == NullnessAnnotation.NONNULL) { BugAnnotation variableAnnotation = null; try { ValueNumberFrame vnaFrame = classContext.getValueNumberDataflow(method).getFactAtLocation(location); ValueNumber valueNumber = vnaFrame.getTopValue(); variableAnnotation = ValueNumberSourceInfo.findAnnotationFromValueNumber(method, location, valueNumber, vnaFrame, "VALUE_OF"); } catch (DataflowAnalysisException e) { AnalysisContext.logError("error", e); } catch (CFGBuilderException e) { AnalysisContext.logError("error", e); } BugInstance warning = new BugInstance(this, "NP_STORE_INTO_NONNULL_FIELD", tos.isDefinitelyNull() ? HIGH_PRIORITY : NORMAL_PRIORITY).addClassAndMethod(classContext.getJavaClass(), method).addField(field) .addOptionalAnnotation(variableAnnotation).addSourceLine(classContext, method, location); bugReporter.reportBug(warning); } } }
.addReferencedField(this).addOptionalAnnotation(possibleMatch).addSourceLine(this));
public BugInstance addSourceForTopStackValue(ClassContext classContext, Method method, Location location) { BugAnnotation b = getSourceForTopStackValue(classContext, method, location); return this.addOptionalAnnotation(b); }
public BugInstance addValueSource(OpcodeStack.Item item, Method method, int pc) { addOptionalAnnotation(getValueSource(item, method, pc)); return this; }
public BugInstance addFieldOrMethodValueSource(OpcodeStack.Item item) { addOptionalAnnotation(getFieldOrMethodValueSource(item)); return this; }
/** * @param seen * @param item */ private void reportVacuousBitOperation(int seen, OpcodeStack.Item item) { if (item.getConstant() == null) { accumulator .accumulateBug( new BugInstance(this, "INT_VACUOUS_BIT_OPERATION", NORMAL_PRIORITY) .addClassAndMethod(this) .addString(OPCODE_NAMES[seen]) .addOptionalAnnotation( LocalVariableAnnotation.getLocalVariableAnnotation(getMethod(), item, getPC())), this); } }