Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove unnecessary methods
  • Loading branch information
msridhar committed Jan 6, 2026
commit 08a8fc33113cb2b9b1a034d803c78fd965a7afb5
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.uber.nullaway.NullabilityUtil;
import com.uber.nullaway.dataflow.cfg.NullAwayCFGBuilder;
import com.uber.nullaway.handlers.Handler;
import java.util.HashMap;
import javax.annotation.processing.ProcessingEnvironment;
import org.checkerframework.nullaway.dataflow.analysis.AbstractValue;
import org.checkerframework.nullaway.dataflow.analysis.Analysis;
Expand Down Expand Up @@ -293,7 +294,7 @@ ControlFlowGraph getControlFlowGraph(TreePath path, Context context, T transfer)
(RunOnceForwardAnalysisImpl<A, S, T>)
dataflow(enclosingPath, context, transfer, false).getAnalysis();
Verify.verify(analysis.isRunning(), "Expected analysis to be running for %s", enclosing);
return analysis.getStoreBefore(exprPath.getLeaf());
return analysis.getStoreBefore(exprPath.getLeaf(), new HashMap<>());
}

<A extends AbstractValue<A>, S extends Store<S>, T extends ForwardTransferFunction<A, S>>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
package com.uber.nullaway.dataflow;

import com.google.common.base.Verify;
import com.sun.source.tree.Tree;
import java.util.Set;
import org.checkerframework.nullaway.dataflow.analysis.AbstractValue;
import org.checkerframework.nullaway.dataflow.analysis.AnalysisResult;
import org.checkerframework.nullaway.dataflow.analysis.ForwardAnalysisImpl;
import org.checkerframework.nullaway.dataflow.analysis.ForwardTransferFunction;
import org.checkerframework.nullaway.dataflow.analysis.Store;
import org.checkerframework.nullaway.dataflow.analysis.TransferInput;
import org.checkerframework.nullaway.dataflow.cfg.ControlFlowGraph;
import org.checkerframework.nullaway.dataflow.cfg.block.Block;
import org.checkerframework.nullaway.dataflow.cfg.node.Node;
import org.jspecify.annotations.Nullable;

/**
* A ForwardAnalysis implementation that overrides {@link #performAnalysis(ControlFlowGraph)} to
Expand Down Expand Up @@ -40,50 +32,4 @@ public void performAnalysis(ControlFlowGraph cfg) {
analysisPerformed = true;
}
}

/**
* Gets the store before the given tree for a currently-running analysis. If the analysis has
* completed running, use {@code getResult()}.
*
* <p>TODO remove this API if/when a similar API is added inside the Checker Framework
*
* @param tree the tree
* @return the store before the given tree, or {@code null} if the tree is not in the CFG
*/
public @Nullable S getStoreBefore(Tree tree) {
Verify.verify(
isRunning(), "getStoreBefore called when analysis is not running (tree=%s)", tree);
Set<Node> nodes = getNodesForTree(tree);
if (nodes != null) {
return getStoreBefore(nodes);
} else {
return null;
}
}

private @Nullable S getStoreBefore(Set<Node> nodes) {
S merge = null;
for (Node aNode : nodes) {
S s = getStoreBefore(aNode);
if (merge == null) {
merge = s;
} else if (s != null) {
merge = merge.leastUpperBound(s);
}
}
return merge;
}

private @Nullable S getStoreBefore(Node node) {
Block block = node.getBlock();
if (block == null) {
return null;
}
TransferInput<V, S> prevStore = getInput(block);
if (prevStore == null) {
return null;
}
return AnalysisResult.runAnalysisFor(
node, BeforeOrAfter.BEFORE, prevStore, getNodeValues(), null);
}
}