Skip to content

Commit 4f2d236

Browse files
committed
Dataflow: Eliminate TypedContent.
1 parent 5373b4d commit 4f2d236

File tree

2 files changed

+8
-41
lines changed

2 files changed

+8
-41
lines changed

java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ module Impl<FullStateConfigSig Config> {
392392

393393
pragma[nomagic]
394394
private predicate storeEx(NodeEx node1, Content c, NodeEx node2, DataFlowType contentType, DataFlowType containerType) {
395-
store(pragma[only_bind_into](node1.asNode()), _, c, pragma[only_bind_into](node2.asNode()),
395+
store(pragma[only_bind_into](node1.asNode()), c, pragma[only_bind_into](node2.asNode()),
396396
contentType, containerType) and
397397
hasReadStep(c) and
398398
stepFilter(node1, node2)

java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -815,26 +815,20 @@ private module Cached {
815815
)
816816
}
817817

818-
private predicate store(
819-
Node node1, Content c, Node node2, DataFlowType contentType, DataFlowType containerType
820-
) {
821-
exists(ContentSet cs |
822-
c = cs.getAStoreContent() and storeSet(node1, cs, node2, contentType, containerType)
823-
)
824-
}
825-
826818
/**
827819
* Holds if data can flow from `node1` to `node2` via a direct assignment to
828-
* `f`.
820+
* `c`.
829821
*
830822
* This includes reverse steps through reads when the result of the read has
831823
* been stored into, in order to handle cases like `x.f1.f2 = y`.
832824
*/
833825
cached
834-
predicate store(Node node1, TypedContent tc, Content c, Node node2, DataFlowType contentType, DataFlowType containerType) {
835-
tc.getContent() = c and
836-
tc.getContainerType() = containerType and
837-
store(node1, c, node2, contentType, containerType)
826+
predicate store(
827+
Node node1, Content c, Node node2, DataFlowType contentType, DataFlowType containerType
828+
) {
829+
exists(ContentSet cs |
830+
c = cs.getAStoreContent() and storeSet(node1, cs, node2, contentType, containerType)
831+
)
838832
}
839833

840834
/**
@@ -934,9 +928,6 @@ private module Cached {
934928
TReturnCtxNoFlowThrough() or
935929
TReturnCtxMaybeFlowThrough(ReturnPosition pos)
936930

937-
cached
938-
newtype TTypedContent = MkTypedContent(Content c, DataFlowType t) { store(_, c, _, _, t) }
939-
940931
cached
941932
newtype TAccessPathFront =
942933
TFrontNil() or
@@ -1415,30 +1406,6 @@ class ApproxAccessPathFrontOption extends TApproxAccessPathFrontOption {
14151406
}
14161407
}
14171408

1418-
/** A `Content` tagged with the type of a containing object. */
1419-
class TypedContent extends MkTypedContent {
1420-
private Content c;
1421-
private DataFlowType t;
1422-
1423-
TypedContent() { this = MkTypedContent(c, t) }
1424-
1425-
/** Gets the content. */
1426-
Content getContent() { result = c }
1427-
1428-
/** Gets the container type. */
1429-
DataFlowType getContainerType() { result = t }
1430-
1431-
/** Gets a textual representation of this content. */
1432-
string toString() { result = c.toString() }
1433-
1434-
/**
1435-
* Holds if access paths with this `TypedContent` at their head always should
1436-
* be tracked at high precision. This disables adaptive access path precision
1437-
* for such access paths.
1438-
*/
1439-
predicate forceHighPrecision() { forceHighPrecision(c) }
1440-
}
1441-
14421409
/**
14431410
* The front of an access path. This is either a head or a nil.
14441411
*/

0 commit comments

Comments
 (0)