Skip to content

Commit 065043b

Browse files
authored
Merge pull request github#7588 from owen-mc/add-specific-needs-reference-predicates
Dataflow: Add language-specific NeedsReference predicates
2 parents e967b8a + d41c55c commit 065043b

File tree

6 files changed

+30
-6
lines changed

6 files changed

+30
-6
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,13 +921,15 @@ module Private {
921921

922922
private predicate inputNeedsReference(string c) {
923923
c = "Argument" or
924-
parseArg(c, _)
924+
parseArg(c, _) or
925+
inputNeedsReferenceSpecific(c)
925926
}
926927

927928
private predicate outputNeedsReference(string c) {
928929
c = "Argument" or
929930
parseArg(c, _) or
930-
c = "ReturnValue"
931+
c = "ReturnValue" or
932+
outputNeedsReferenceSpecific(c)
931933
}
932934

933935
private predicate sourceElementRef(InterpretNode ref, string output, string kind) {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ string getParameterPositionCsv(ParameterPosition pos) { result = pos.toString()
171171
/** Gets the textual representation of an argument position in the format used for flow summaries. */
172172
string getArgumentPositionCsv(ArgumentPosition pos) { result = pos.toString() }
173173

174+
/** Holds if input specification component `c` needs a reference. */
175+
predicate inputNeedsReferenceSpecific(string c) { none() }
176+
177+
/** Holds if output specification component `c` needs a reference. */
178+
predicate outputNeedsReferenceSpecific(string c) { none() }
179+
174180
class SourceOrSinkElement = Element;
175181

176182
/** Gets the return kind corresponding to specification `"ReturnValue"`. */

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,13 +921,15 @@ module Private {
921921

922922
private predicate inputNeedsReference(string c) {
923923
c = "Argument" or
924-
parseArg(c, _)
924+
parseArg(c, _) or
925+
inputNeedsReferenceSpecific(c)
925926
}
926927

927928
private predicate outputNeedsReference(string c) {
928929
c = "Argument" or
929930
parseArg(c, _) or
930-
c = "ReturnValue"
931+
c = "ReturnValue" or
932+
outputNeedsReferenceSpecific(c)
931933
}
932934

933935
private predicate sourceElementRef(InterpretNode ref, string output, string kind) {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ string getParameterPositionCsv(ParameterPosition pos) { result = pos.toString()
102102
/** Gets the textual representation of an argument position in the format used for flow summaries. */
103103
string getArgumentPositionCsv(ArgumentPosition pos) { result = pos.toString() }
104104

105+
/** Holds if input specification component `c` needs a reference. */
106+
predicate inputNeedsReferenceSpecific(string c) { none() }
107+
108+
/** Holds if output specification component `c` needs a reference. */
109+
predicate outputNeedsReferenceSpecific(string c) { none() }
110+
105111
class SourceOrSinkElement = Top;
106112

107113
/**

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,13 +921,15 @@ module Private {
921921

922922
private predicate inputNeedsReference(string c) {
923923
c = "Argument" or
924-
parseArg(c, _)
924+
parseArg(c, _) or
925+
inputNeedsReferenceSpecific(c)
925926
}
926927

927928
private predicate outputNeedsReference(string c) {
928929
c = "Argument" or
929930
parseArg(c, _) or
930-
c = "ReturnValue"
931+
c = "ReturnValue" or
932+
outputNeedsReferenceSpecific(c)
931933
}
932934

933935
private predicate sourceElementRef(InterpretNode ref, string output, string kind) {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ string getParameterPositionCsv(ParameterPosition pos) { result = pos.toString()
9999
/** Gets the textual representation of an argument position in the format used for flow summaries. */
100100
string getArgumentPositionCsv(ArgumentPosition pos) { result = pos.toString() }
101101

102+
/** Holds if input specification component `c` needs a reference. */
103+
predicate inputNeedsReferenceSpecific(string c) { none() }
104+
105+
/** Holds if output specification component `c` needs a reference. */
106+
predicate outputNeedsReferenceSpecific(string c) { none() }
107+
102108
/** Gets the return kind corresponding to specification `"ReturnValue"`. */
103109
NormalReturnKind getReturnValueKind() { any() }
104110

0 commit comments

Comments
 (0)