Skip to content

Commit 712418e

Browse files
authored
Merge pull request #7781 from hvitved/dataflow/summary-stack-bottom-less-nonlinear
Data flow: Reduce non-linear recursion in `SummaryComponentStack::bottom`
2 parents d4c4e75 + 6821639 commit 712418e

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ module Public {
9090
predicate contains(SummaryComponent c) { c = this.drop(_).head() }
9191

9292
/** Gets the bottom element of this stack. */
93-
SummaryComponent bottom() { result = this.drop(this.length() - 1).head() }
93+
SummaryComponent bottom() {
94+
this = TSingletonSummaryComponentStack(result) or result = this.tail().bottom()
95+
}
9496

9597
/** Gets a textual representation of this stack. */
9698
string toString() {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ module Public {
9090
predicate contains(SummaryComponent c) { c = this.drop(_).head() }
9191

9292
/** Gets the bottom element of this stack. */
93-
SummaryComponent bottom() { result = this.drop(this.length() - 1).head() }
93+
SummaryComponent bottom() {
94+
this = TSingletonSummaryComponentStack(result) or result = this.tail().bottom()
95+
}
9496

9597
/** Gets a textual representation of this stack. */
9698
string toString() {

ruby/ql/lib/codeql/ruby/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ module Public {
9090
predicate contains(SummaryComponent c) { c = this.drop(_).head() }
9191

9292
/** Gets the bottom element of this stack. */
93-
SummaryComponent bottom() { result = this.drop(this.length() - 1).head() }
93+
SummaryComponent bottom() {
94+
this = TSingletonSummaryComponentStack(result) or result = this.tail().bottom()
95+
}
9496

9597
/** Gets a textual representation of this stack. */
9698
string toString() {

0 commit comments

Comments
 (0)