Skip to content

Commit 0215ea3

Browse files
authored
Merge pull request #21426 from owen-mc/cpp/validate-constructor-summary-models
C++: Add model validation for constructor summary models
2 parents 219fe03 + e0e5319 commit 0215ea3

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

cpp/ql/lib/semmle/code/cpp/dataflow/ExternalFlow.qll

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,26 @@ module CsvValidation {
353353
)
354354
}
355355

356+
private string getIncorrectConstructorSummaryOutput() {
357+
exists(string namespace, string type, string name, string output |
358+
type = name or
359+
type = name + "<" + any(string s)
360+
|
361+
summaryModel(namespace, type, _, name, _, _, _, output, _, _, _) and
362+
output.matches("ReturnValue%") and
363+
result =
364+
"Constructor model for " + namespace + "." + type +
365+
" should use `Argument[this]` in the output, not `ReturnValue`."
366+
)
367+
}
368+
356369
/** Holds if some row in a CSV-based flow model appears to contain typos. */
357370
query predicate invalidModelRow(string msg) {
358371
msg =
359372
[
360373
getInvalidModelSignature(), getInvalidModelInput(), getInvalidModelOutput(),
361-
getInvalidModelSubtype(), getInvalidModelColumnCount(), KindVal::getInvalidModelKind()
374+
getInvalidModelSubtype(), getInvalidModelColumnCount(), KindVal::getInvalidModelKind(),
375+
getIncorrectConstructorSummaryOutput()
362376
]
363377
}
364378
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ module ModelValidation {
239239
)
240240
}
241241

242-
string getIncorrectConstructorSummaryOutput() {
242+
private string getIncorrectConstructorSummaryOutput() {
243243
exists(string namespace, string type, string name, string output |
244244
type = name or
245245
type = name + "<" + any(string s)

java/ql/lib/semmle/code/java/dataflow/ExternalFlow.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ module ModelValidation {
367367
)
368368
}
369369

370-
string getIncorrectConstructorSummaryOutput() {
370+
private string getIncorrectConstructorSummaryOutput() {
371371
exists(string namespace, string type, string name, string output |
372372
summaryModel(namespace, type, _, name, _, _, _, output, _, _, _)
373373
|

0 commit comments

Comments
 (0)