|
54 | 54 | import org.checkerframework.dataflow.cfg.block.Block.BlockType;
|
55 | 55 | import org.checkerframework.dataflow.cfg.block.ConditionalBlock;
|
56 | 56 | import org.checkerframework.dataflow.cfg.block.ExceptionBlock;
|
57 |
| -import org.checkerframework.dataflow.cfg.block.SingleSuccessorBlock; |
58 | 57 | import org.checkerframework.dataflow.cfg.node.AssignmentNode;
|
59 | 58 | import org.checkerframework.dataflow.cfg.node.ClassNameNode;
|
60 | 59 | import org.checkerframework.dataflow.cfg.node.FieldAccessNode;
|
|
66 | 65 | import org.checkerframework.dataflow.cfg.node.ReturnNode;
|
67 | 66 | import org.checkerframework.dataflow.cfg.node.SuperNode;
|
68 | 67 | import org.checkerframework.dataflow.cfg.node.ThisNode;
|
69 |
| -import org.checkerframework.dataflow.cfg.node.TypeCastNode; |
70 | 68 | import org.checkerframework.dataflow.expression.FieldAccess;
|
71 | 69 | import org.checkerframework.dataflow.expression.JavaExpression;
|
72 | 70 | import org.checkerframework.dataflow.expression.LocalVariable;
|
@@ -986,36 +984,6 @@ private boolean returnTypeIsMustCallAliasWithUntrackable(MethodInvocationNode no
|
986 | 984 | return !mustCallAliasArguments.isEmpty();
|
987 | 985 | }
|
988 | 986 |
|
989 |
| - /** |
990 |
| - * Checks if {@code node} is either directly enclosed by a {@link TypeCastNode}, by looking at the |
991 |
| - * successor block in the CFG. In this case the enclosing operator is a "no-op" that evaluates to |
992 |
| - * the same value as {@code node}. This method is only used within {@link |
993 |
| - * #propagateObligationsToSuccessorBlocks(ControlFlowGraph, Set, Block, Set, Deque)} to ensure |
994 |
| - * Obligations are propagated to cast nodes properly. It relies on the assumption that a {@link |
995 |
| - * TypeCastNode} will only appear in a CFG as the first node in a block. |
996 |
| - * |
997 |
| - * @param node the CFG node |
998 |
| - * @return {@code true} if {@code node} is in a {@link SingleSuccessorBlock} {@code b}, the first |
999 |
| - * {@link Node} in {@code b}'s successor block is a {@link TypeCastNode}, and {@code node} is |
1000 |
| - * an operand of the successor node; {@code false} otherwise |
1001 |
| - */ |
1002 |
| - private boolean inCast(Node node) { |
1003 |
| - if (!(node.getBlock() instanceof SingleSuccessorBlock)) { |
1004 |
| - return false; |
1005 |
| - } |
1006 |
| - Block successorBlock = ((SingleSuccessorBlock) node.getBlock()).getSuccessor(); |
1007 |
| - if (successorBlock != null) { |
1008 |
| - List<Node> succNodes = successorBlock.getNodes(); |
1009 |
| - if (succNodes.size() > 0) { |
1010 |
| - Node succNode = succNodes.get(0); |
1011 |
| - if (succNode instanceof TypeCastNode) { |
1012 |
| - return ((TypeCastNode) succNode).getOperand().equals(node); |
1013 |
| - } |
1014 |
| - } |
1015 |
| - } |
1016 |
| - return false; |
1017 |
| - } |
1018 |
| - |
1019 | 987 | /**
|
1020 | 988 | * Transfer ownership of any locals passed as arguments to {@code @Owning} parameters at a method
|
1021 | 989 | * or constructor call by removing the Obligations corresponding to those locals.
|
@@ -2073,17 +2041,6 @@ private void propagateObligationsToSuccessorBlock(
|
2073 | 2041 | }
|
2074 | 2042 | }
|
2075 | 2043 |
|
2076 |
| - // Always propagate the Obligation to the successor if current block represents |
2077 |
| - // code nested in a cast. Without this logic, the analysis may report a false |
2078 |
| - // positive when the Obligation represents a temporary variable for a nested |
2079 |
| - // expression, as the temporary may not appear in the successor store and hence |
2080 |
| - // seems to be going out of scope. The temporary will be handled with special |
2081 |
| - // logic; casts are unwrapped at various points in the analysis. |
2082 |
| - if (currentBlockNodes.size() == 1 && inCast(currentBlockNodes.get(0))) { |
2083 |
| - successorObligations.add(obligation); |
2084 |
| - continue; |
2085 |
| - } |
2086 |
| - |
2087 | 2044 | // At this point, a consistency check will definitely occur, unless the
|
2088 | 2045 | // obligation was derived from a MustCallAlias parameter. If it was, an error is
|
2089 | 2046 | // immediately issued, because such a parameter should not go out of scope
|
|
0 commit comments