You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow Field to be constrained within member predicates, not just in characteristic predicates within a class.
Context
In writing a ControlFlowReach class that mimics the dataflow interface, I'd like to define a status field that can be calculated in subclasses according to the source node and then used across member predicates like isSource, isSink, and isBarrier. However, the current limitation requiring Field to be constrained only within characteristic predicates prevents this.
Example Code
Here’s my ControlFlowReach class:
abstract class ControlFlowReach extends string {
bindingset[this]
ControlFlowReach() { any() }
predicate reaches(ControlFlowNode src, ControlFlowNode snk) {
isSource(src) and isSink(snk) and reach_internal(src, snk)
}
abstract predicate isSource(ControlFlowNode node);
abstract predicate isSink(ControlFlowNode node);
predicate isBarrier(ControlFlowNode node) { none() }
private predicate reach_internal(ControlFlowNode current, ControlFlowNode sink) {
not isBarrier(current) and
(current = sink or reach_internal(current.getASuccessor(), sink))
}
}
In the subclass SomeFlow, I define status to calculate a value based on the source node, which I then want to use in isSink and isBarrier.
class SomeFlow extends ControlFlowReach {
Expr status;
SomeFlow() {
this = "SomeFlow"
}
predicate isSource(ControlFlowNode node) {
// condition on node
and status = <value_based_on_node>
}
predicate isSink(ControlFlowNode node) {
// uses status
}
}
Issue
Based on the current design, even with isSource(src) and isSink(snk) in reaches(), the status field in isSink and isSource seems to take different values. The documentation notes that fields must be constrained in characteristic predicates and not in member predicates, but it’s unclear why this limitation exists.
Questions
Why must fields be constrained only in characteristic predicates and not in member predicates?
Why does status appear to have different values in isSink and isSource, even though they are called in reaches() under the condition isSource(src) and isSink(snk)?
Could this feature be added in the future, allowing fields to be constrained in member predicates for greater flexibility?
Thank you for considering this request.
The text was updated successfully, but these errors were encountered:
Feature Request
Summary
Allow Field to be constrained within member predicates, not just in characteristic predicates within a class.
Context
In writing a ControlFlowReach class that mimics the dataflow interface, I'd like to define a status field that can be calculated in subclasses according to the source node and then used across member predicates like isSource, isSink, and isBarrier. However, the current limitation requiring Field to be constrained only within characteristic predicates prevents this.
Example Code
Here’s my ControlFlowReach class:
In the subclass SomeFlow, I define status to calculate a value based on the source node, which I then want to use in isSink and isBarrier.
Issue
Based on the current design, even with
isSource(src) and isSink(snk)
inreaches()
, the status field in isSink and isSource seems to take different values. The documentation notes that fields must be constrained in characteristic predicates and not in member predicates, but it’s unclear why this limitation exists.Questions
reaches()
under the conditionisSource(src) and isSink(snk)
?Thank you for considering this request.
The text was updated successfully, but these errors were encountered: