in jar-infer/jar-infer-lib/src/main/java/com/uber/nullaway/jarinfer/DefinitelyDerefedParams.java [188:226]
private void checkForUseOfParams(
Set<Integer> derefedParamList, int numParam, int firstParamIndex, ISSABasicBlock node) {
if (!node.isEntryBlock() && !node.isExitBlock()) { // entry and exit are dummy basic blocks
LOG(DEBUG, "DEBUG", ">> bb: " + node.getNumber());
// Iterate over all instructions in BB
for (int i = node.getFirstInstructionIndex(); i <= node.getLastInstructionIndex(); i++) {
SSAInstruction instr = ir.getInstructions()[i];
if (instr == null) { // Some instructions are null (padding NoOps)
continue;
}
LOG(DEBUG, "DEBUG", "\tinst: " + instr.toString());
int derefValueNumber = -1;
if (instr instanceof SSAGetInstruction && !((SSAGetInstruction) instr).isStatic()) {
derefValueNumber = ((SSAGetInstruction) instr).getRef();
} else if (instr instanceof SSAPutInstruction && !((SSAPutInstruction) instr).isStatic()) {
derefValueNumber = ((SSAPutInstruction) instr).getRef();
} else if (instr instanceof SSAAbstractInvokeInstruction) {
SSAAbstractInvokeInstruction callInst = (SSAAbstractInvokeInstruction) instr;
String sign = callInst.getDeclaredTarget().getSignature();
if (((SSAAbstractInvokeInstruction) instr).isStatic()) {
// All supported Null testing APIs are static methods
if (NULL_TEST_APIS.containsKey(sign)) {
derefValueNumber = callInst.getUse(NULL_TEST_APIS.get(sign));
}
} else {
Preconditions.checkArgument(
!NULL_TEST_APIS.containsKey(sign),
"Add support for non-static NULL_TEST_APIS : " + sign);
derefValueNumber = ((SSAAbstractInvokeInstruction) instr).getReceiver();
}
}
if (derefValueNumber >= firstParamIndex && derefValueNumber <= numParam) {
LOG(DEBUG, "DEBUG", "\t\tderefed param : " + derefValueNumber);
// Translate from WALA 1-indexed params, to 0-indexed
derefedParamList.add(derefValueNumber - 1);
}
}
}
}