in jar-infer/jar-infer-lib/src/main/java/com/uber/nullaway/jarinfer/DefinitelyDerefedParams.java [188:227]
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 && !ssaGetInstruction.isStatic()) {
derefValueNumber = ssaGetInstruction.getRef();
} else if (instr instanceof SSAPutInstruction ssaPutInstruction
&& !ssaPutInstruction.isStatic()) {
derefValueNumber = ssaPutInstruction.getRef();
} else if (instr instanceof SSAAbstractInvokeInstruction callInst) {
String sign = callInst.getDeclaredTarget().getSignature();
if (callInst.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 : %s",
sign);
derefValueNumber = callInst.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);
}
}
}
}