Skip to content

Commit 9a3c2d3

Browse files
committed
Java: Update summary parsing to use this instead of -1 and adjust the model generator.
1 parent abd9f67 commit 9a3c2d3

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,16 @@ string getComponentSpecific(SummaryComponent sc) {
196196
exists(Content c | sc = TContentSummaryComponent(c) and result = getContentSpecific(c))
197197
}
198198

199+
bindingset[pos]
200+
private string positionToString(int pos) {
201+
if pos = -1 then result = "this" else result = pos.toString()
202+
}
203+
199204
/** Gets the textual representation of a parameter position in the format used for flow summaries. */
200-
string getParameterPosition(ParameterPosition pos) { result = pos.toString() }
205+
string getParameterPosition(ParameterPosition pos) { result = positionToString(pos) }
201206

202207
/** Gets the textual representation of an argument position in the format used for flow summaries. */
203-
string getArgumentPosition(ArgumentPosition pos) { result = pos.toString() }
208+
string getArgumentPosition(ArgumentPosition pos) { result = positionToString(pos) }
204209

205210
/** Holds if input specification component `c` needs a reference. */
206211
predicate inputNeedsReferenceSpecific(string c) { none() }
@@ -314,8 +319,16 @@ predicate interpretInputSpecific(string c, InterpretNode mid, InterpretNode n) {
314319

315320
/** Gets the argument position obtained by parsing `X` in `Parameter[X]`. */
316321
bindingset[s]
317-
ArgumentPosition parseParamBody(string s) { result = AccessPath::parseInt(s) }
322+
ArgumentPosition parseParamBody(string s) {
323+
result = AccessPath::parseInt(s)
324+
or
325+
s = "this" and result = -1
326+
}
318327

319328
/** Gets the parameter position obtained by parsing `X` in `Argument[X]`. */
320329
bindingset[s]
321-
ParameterPosition parseArgBody(string s) { result = AccessPath::parseInt(s) }
330+
ParameterPosition parseArgBody(string s) {
331+
result = AccessPath::parseInt(s)
332+
or
333+
s = "this" and result = -1
334+
}

java/ql/src/utils/modelgenerator/internal/CaptureModelsSpecific.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ predicate isRelevantType(J::Type t) {
189189
/**
190190
* Gets the CSV string representation of the qualifier.
191191
*/
192-
string qualifierString() { result = "Argument[-1]" }
192+
string qualifierString() { result = "Argument[this]" }
193193

194194
private string parameterAccess(J::Parameter p) {
195195
if

0 commit comments

Comments
 (0)