Skip to content

Commit b794627

Browse files
committed
Go: Re-factor getComponent.
1 parent b7a8660 commit b794627

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,10 @@ 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
178173
(
179174
exists(ArgumentPosition pos |
180175
sc = TParameterSummaryComponent(pos) and
@@ -185,9 +180,9 @@ module Public {
185180
sc = TArgumentSummaryComponent(pos) and
186181
result = "Argument[" + getParameterPosition(pos) + "]"
187182
)
188-
or
189-
sc = TReturnSummaryComponent(getReturnValueKind()) and result = "ReturnValue"
190183
)
184+
or
185+
sc = TReturnSummaryComponent(getReturnValueKind()) and result = "ReturnValue"
191186
}
192187

193188
/** 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

0 commit comments

Comments
 (0)