CFG cfg = classContext.getCFG(method);
ValueNumberDataflow vna = classContext.getValueNumberDataflow(method);
TypeDataflow typeDataflow = classContext.getTypeDataflow(method);
INullnessAnnotationDatabase db = AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase();
ParameterNullnessPropertyDatabase unconditionalDerefParamDatabase = AnalysisContext.currentAnalysisContext()
.getUnconditionalDerefParamDatabase();
Iterator<BasicBlock> bbIter = cfg.blockIterator();
ConstantPoolGen cpg = classContext.getConstantPoolGen();
ValueNumber valueNumberForThis = null;
if (!method.isStatic()) {
ValueNumberFrame frameAtEntry = vna.getStartFact(cfg.getEntry());
valueNumberForThis = frameAtEntry.getValue(0);
}
NullnessAnnotation methodAnnotation = getMethodNullnessAnnotation(classContext, method);
while (bbIter.hasNext()) {
BasicBlock basicBlock = bbIter.next();
if (basicBlock.isNullCheck()) {
InstructionHandle exceptionThrowerHandle = basicBlock.getExceptionThrower();
Instruction exceptionThrower = exceptionThrowerHandle.getInstruction();
ValueNumberFrame vnaFrame = vna.getStartFact(basicBlock);
if (!vnaFrame.isValid()) {
continue;
}
ValueNumber valueNumber = vnaFrame.getInstance(exceptionThrower, cpg);
Location location = new Location(exceptionThrowerHandle, basicBlock);
if (valueNumberForThis != valueNumber) {
derefs.add(location, valueNumber, PointerUsageRequiringNonNullValue.getPointerDereference());
}
}
}
for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
Location location = i.next();
InstructionHandle handle = location.getHandle();
Instruction ins = handle.getInstruction();
ValueNumberFrame valueNumberFrame = vna.getFactAtLocation(location);
TypeFrame typeFrame = typeDataflow.getFactAtLocation(location);
if (ins instanceof InvokeInstruction) {
InvokeInstruction inv = (InvokeInstruction) ins;
XMethod m = XFactory.createXMethod(inv, cpg);
SignatureParser sigParser = new SignatureParser(m.getSignature());
int numParams = sigParser.getNumParameters();
// Check nonnull annotations
for (int j = 0; j < numParams; j++) {
if (db.parameterMustBeNonNull(m, j)) {
int slot = sigParser.getSlotsFromTopOfStackForParameter(j);
ValueNumber valueNumber = valueNumberFrame.getStackValue(slot);
if (valueNumberForThis != valueNumber) {
derefs.add(location, valueNumber,
PointerUsageRequiringNonNullValue.getPassedAsNonNullParameter(m, j));