Factor comparison into compatibleContents

This commit is contained in:
Asger F
2022-09-15 14:32:53 +02:00
parent 85d0c63ec7
commit 6abf77d40d
2 changed files with 10 additions and 9 deletions

View File

@@ -41,7 +41,7 @@ private module Cached {
exists(TypeTrackerContentSet loadContents |
step = LoadStep(pragma[only_bind_into](loadContents)) and
tt = MkTypeTracker(hasCall, storeContents) and
storeContents.getAStoreContent() = loadContents.getAReadContent() and
compatibleContents(storeContents, loadContents) and
result = noContentTypeTracker(hasCall)
)
or
@@ -76,7 +76,7 @@ private module Cached {
exists(TypeTrackerContentSet storeContents |
step = StoreStep(pragma[only_bind_into](storeContents)) and
tbt = MkTypeBackTracker(hasReturn, loadContents) and
storeContents.getAStoreContent() = loadContents.getAReadContent() and
compatibleContents(storeContents, loadContents) and
result = noContentTypeBackTracker(hasReturn)
)
or

View File

@@ -15,17 +15,18 @@ class Node = DataFlowPublic::Node;
class TypeTrackingNode = DataFlowPublic::LocalSourceNode;
private newtype TOptionalTypeTrackerContent =
MkAttribute(string name) { name = any(Ast::SetterMethodCall c).getTargetName() } or
MkContent(DataFlowPublic::Content content) or
MkNoContent()
class TypeTrackerContent = DataFlowPublic::Content;
class TypeTrackerContentSet = DataFlowPublic::ContentSet;
class OptionalTypeTrackerContentSet = DataFlowPublic::OptionalContentSet;
/**
* Holds if a value stored with `storeContents` can be read back with `loadContents`.
*/
pragma[inline]
predicate compatibleContents(TypeTrackerContentSet storeContents, TypeTrackerContentSet loadContents) {
storeContents.getAStoreContent() = loadContents.getAReadContent()
}
/** Gets the "no content set" value to use for a type tracker not inside any content. */
OptionalTypeTrackerContentSet noContentSet() { result.isNoContentSet() }