Skip to content

Commit 2266e28

Browse files
authored
Merge pull request github#13262 from michaelnebel/flowsummary/refactorgetcomponentstack
C#: Re-factor getComponent.
2 parents b9ffa11 + 915042a commit 2266e28

File tree

9 files changed

+67
-109
lines changed

9 files changed

+67
-109
lines changed

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

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,28 +166,21 @@ module Public {
166166
SummaryComponentStack return(ReturnKind rk) { result = singleton(SummaryComponent::return(rk)) }
167167
}
168168

169-
private predicate noComponentSpecific(SummaryComponent sc) {
170-
not exists(getComponentSpecific(sc))
171-
}
172-
173169
/** Gets a textual representation of this component used for flow summaries. */
174170
private string getComponent(SummaryComponent sc) {
175171
result = getComponentSpecific(sc)
176172
or
177-
noComponentSpecific(sc) and
178-
(
179-
exists(ArgumentPosition pos |
180-
sc = TParameterSummaryComponent(pos) and
181-
result = "Parameter[" + getArgumentPosition(pos) + "]"
182-
)
183-
or
184-
exists(ParameterPosition pos |
185-
sc = TArgumentSummaryComponent(pos) and
186-
result = "Argument[" + getParameterPosition(pos) + "]"
187-
)
188-
or
189-
sc = TReturnSummaryComponent(getReturnValueKind()) and result = "ReturnValue"
173+
exists(ArgumentPosition pos |
174+
sc = TParameterSummaryComponent(pos) and
175+
result = "Parameter[" + getArgumentPosition(pos) + "]"
176+
)
177+
or
178+
exists(ParameterPosition pos |
179+
sc = TArgumentSummaryComponent(pos) and
180+
result = "Argument[" + getParameterPosition(pos) + "]"
190181
)
182+
or
183+
sc = TReturnSummaryComponent(getReturnValueKind()) and result = "ReturnValue"
191184
}
192185

193186
/** Gets a textual representation of this stack used for flow summaries. */

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ string getComponentSpecific(SummaryComponent sc) {
198198
or
199199
exists(ReturnKind rk |
200200
sc = TReturnSummaryComponent(rk) and
201-
result = "ReturnValue[" + rk + "]" and
202-
not rk instanceof NormalReturnKind
201+
not rk = getReturnValueKind() and
202+
result = "ReturnValue[" + rk + "]"
203203
)
204204
}
205205

go/ql/lib/semmle/go/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,28 +166,21 @@ module Public {
166166
SummaryComponentStack return(ReturnKind rk) { result = singleton(SummaryComponent::return(rk)) }
167167
}
168168

169-
private predicate noComponentSpecific(SummaryComponent sc) {
170-
not exists(getComponentSpecific(sc))
171-
}
172-
173169
/** Gets a textual representation of this component used for flow summaries. */
174170
private string getComponent(SummaryComponent sc) {
175171
result = getComponentSpecific(sc)
176172
or
177-
noComponentSpecific(sc) and
178-
(
179-
exists(ArgumentPosition pos |
180-
sc = TParameterSummaryComponent(pos) and
181-
result = "Parameter[" + getArgumentPosition(pos) + "]"
182-
)
183-
or
184-
exists(ParameterPosition pos |
185-
sc = TArgumentSummaryComponent(pos) and
186-
result = "Argument[" + getParameterPosition(pos) + "]"
187-
)
188-
or
189-
sc = TReturnSummaryComponent(getReturnValueKind()) and result = "ReturnValue"
173+
exists(ArgumentPosition pos |
174+
sc = TParameterSummaryComponent(pos) and
175+
result = "Parameter[" + getArgumentPosition(pos) + "]"
176+
)
177+
or
178+
exists(ParameterPosition pos |
179+
sc = TArgumentSummaryComponent(pos) and
180+
result = "Argument[" + getParameterPosition(pos) + "]"
190181
)
182+
or
183+
sc = TReturnSummaryComponent(getReturnValueKind()) and result = "ReturnValue"
191184
}
192185

193186
/** Gets a textual representation of this stack used for flow summaries. */

go/ql/lib/semmle/go/dataflow/internal/FlowSummaryImplSpecific.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ private string getContentSpecific(Content c) {
111111
string getComponentSpecific(SummaryComponent sc) {
112112
exists(Content c | sc = TContentSummaryComponent(c) and result = getContentSpecific(c))
113113
or
114-
exists(ReturnKind rk, int n | n = rk.getIndex() |
114+
exists(ReturnKind rk |
115115
sc = TReturnSummaryComponent(rk) and
116-
result = "ReturnValue[" + n + "]" and
117-
n != 0
116+
not rk = getReturnValueKind() and
117+
result = "ReturnValue[" + rk.getIndex() + "]"
118118
)
119119
}
120120

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

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,28 +166,21 @@ module Public {
166166
SummaryComponentStack return(ReturnKind rk) { result = singleton(SummaryComponent::return(rk)) }
167167
}
168168

169-
private predicate noComponentSpecific(SummaryComponent sc) {
170-
not exists(getComponentSpecific(sc))
171-
}
172-
173169
/** Gets a textual representation of this component used for flow summaries. */
174170
private string getComponent(SummaryComponent sc) {
175171
result = getComponentSpecific(sc)
176172
or
177-
noComponentSpecific(sc) and
178-
(
179-
exists(ArgumentPosition pos |
180-
sc = TParameterSummaryComponent(pos) and
181-
result = "Parameter[" + getArgumentPosition(pos) + "]"
182-
)
183-
or
184-
exists(ParameterPosition pos |
185-
sc = TArgumentSummaryComponent(pos) and
186-
result = "Argument[" + getParameterPosition(pos) + "]"
187-
)
188-
or
189-
sc = TReturnSummaryComponent(getReturnValueKind()) and result = "ReturnValue"
173+
exists(ArgumentPosition pos |
174+
sc = TParameterSummaryComponent(pos) and
175+
result = "Parameter[" + getArgumentPosition(pos) + "]"
176+
)
177+
or
178+
exists(ParameterPosition pos |
179+
sc = TArgumentSummaryComponent(pos) and
180+
result = "Argument[" + getParameterPosition(pos) + "]"
190181
)
182+
or
183+
sc = TReturnSummaryComponent(getReturnValueKind()) and result = "ReturnValue"
191184
}
192185

193186
/** Gets a textual representation of this stack used for flow summaries. */

python/ql/lib/semmle/python/dataflow/new/internal/FlowSummaryImpl.qll

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,28 +166,21 @@ module Public {
166166
SummaryComponentStack return(ReturnKind rk) { result = singleton(SummaryComponent::return(rk)) }
167167
}
168168

169-
private predicate noComponentSpecific(SummaryComponent sc) {
170-
not exists(getComponentSpecific(sc))
171-
}
172-
173169
/** Gets a textual representation of this component used for flow summaries. */
174170
private string getComponent(SummaryComponent sc) {
175171
result = getComponentSpecific(sc)
176172
or
177-
noComponentSpecific(sc) and
178-
(
179-
exists(ArgumentPosition pos |
180-
sc = TParameterSummaryComponent(pos) and
181-
result = "Parameter[" + getArgumentPosition(pos) + "]"
182-
)
183-
or
184-
exists(ParameterPosition pos |
185-
sc = TArgumentSummaryComponent(pos) and
186-
result = "Argument[" + getParameterPosition(pos) + "]"
187-
)
188-
or
189-
sc = TReturnSummaryComponent(getReturnValueKind()) and result = "ReturnValue"
173+
exists(ArgumentPosition pos |
174+
sc = TParameterSummaryComponent(pos) and
175+
result = "Parameter[" + getArgumentPosition(pos) + "]"
176+
)
177+
or
178+
exists(ParameterPosition pos |
179+
sc = TArgumentSummaryComponent(pos) and
180+
result = "Argument[" + getParameterPosition(pos) + "]"
190181
)
182+
or
183+
sc = TReturnSummaryComponent(getReturnValueKind()) and result = "ReturnValue"
191184
}
192185

193186
/** Gets a textual representation of this stack used for flow summaries. */

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

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,28 +166,21 @@ module Public {
166166
SummaryComponentStack return(ReturnKind rk) { result = singleton(SummaryComponent::return(rk)) }
167167
}
168168

169-
private predicate noComponentSpecific(SummaryComponent sc) {
170-
not exists(getComponentSpecific(sc))
171-
}
172-
173169
/** Gets a textual representation of this component used for flow summaries. */
174170
private string getComponent(SummaryComponent sc) {
175171
result = getComponentSpecific(sc)
176172
or
177-
noComponentSpecific(sc) and
178-
(
179-
exists(ArgumentPosition pos |
180-
sc = TParameterSummaryComponent(pos) and
181-
result = "Parameter[" + getArgumentPosition(pos) + "]"
182-
)
183-
or
184-
exists(ParameterPosition pos |
185-
sc = TArgumentSummaryComponent(pos) and
186-
result = "Argument[" + getParameterPosition(pos) + "]"
187-
)
188-
or
189-
sc = TReturnSummaryComponent(getReturnValueKind()) and result = "ReturnValue"
173+
exists(ArgumentPosition pos |
174+
sc = TParameterSummaryComponent(pos) and
175+
result = "Parameter[" + getArgumentPosition(pos) + "]"
176+
)
177+
or
178+
exists(ParameterPosition pos |
179+
sc = TArgumentSummaryComponent(pos) and
180+
result = "Argument[" + getParameterPosition(pos) + "]"
190181
)
182+
or
183+
sc = TReturnSummaryComponent(getReturnValueKind()) and result = "ReturnValue"
191184
}
192185

193186
/** Gets a textual representation of this stack used for flow summaries. */

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

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,28 +166,21 @@ module Public {
166166
SummaryComponentStack return(ReturnKind rk) { result = singleton(SummaryComponent::return(rk)) }
167167
}
168168

169-
private predicate noComponentSpecific(SummaryComponent sc) {
170-
not exists(getComponentSpecific(sc))
171-
}
172-
173169
/** Gets a textual representation of this component used for flow summaries. */
174170
private string getComponent(SummaryComponent sc) {
175171
result = getComponentSpecific(sc)
176172
or
177-
noComponentSpecific(sc) and
178-
(
179-
exists(ArgumentPosition pos |
180-
sc = TParameterSummaryComponent(pos) and
181-
result = "Parameter[" + getArgumentPosition(pos) + "]"
182-
)
183-
or
184-
exists(ParameterPosition pos |
185-
sc = TArgumentSummaryComponent(pos) and
186-
result = "Argument[" + getParameterPosition(pos) + "]"
187-
)
188-
or
189-
sc = TReturnSummaryComponent(getReturnValueKind()) and result = "ReturnValue"
173+
exists(ArgumentPosition pos |
174+
sc = TParameterSummaryComponent(pos) and
175+
result = "Parameter[" + getArgumentPosition(pos) + "]"
176+
)
177+
or
178+
exists(ParameterPosition pos |
179+
sc = TArgumentSummaryComponent(pos) and
180+
result = "Argument[" + getParameterPosition(pos) + "]"
190181
)
182+
or
183+
sc = TReturnSummaryComponent(getReturnValueKind()) and result = "ReturnValue"
191184
}
192185

193186
/** Gets a textual representation of this stack used for flow summaries. */

swift/ql/lib/codeql/swift/dataflow/internal/FlowSummaryImplSpecific.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ string getComponentSpecific(SummaryComponent sc) {
117117
or
118118
exists(ReturnKind rk |
119119
sc = TReturnSummaryComponent(rk) and
120-
result = "ReturnValue[" + rk + "]" and
121-
not rk instanceof NormalReturnKind
120+
not rk = getReturnValueKind() and
121+
result = "ReturnValue" + "[" + rk + "]"
122122
)
123123
}
124124

0 commit comments

Comments
 (0)