Skip to content

Commit 2729b40

Browse files
committed
C++: Adapt to changes in FlowSummaryImpl
1 parent a7e8c4e commit 2729b40

File tree

5 files changed

+17
-35
lines changed

5 files changed

+17
-35
lines changed

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

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,40 +1058,22 @@ private predicate interpretSummary(
10581058

10591059
// adapter class for converting Mad summaries to `SummarizedCallable`s
10601060
private class SummarizedCallableAdapter extends SummarizedCallable {
1061-
SummarizedCallableAdapter() { interpretSummary(this, _, _, _, _, _) }
1061+
string input_;
1062+
string output_;
1063+
string kind;
1064+
Provenance p_;
1065+
string model_;
10621066

1063-
private predicate relevantSummaryElementManual(
1064-
string input, string output, string kind, string model
1065-
) {
1066-
exists(Provenance provenance |
1067-
interpretSummary(this, input, output, kind, provenance, model) and
1068-
provenance.isManual()
1069-
)
1070-
}
1071-
1072-
private predicate relevantSummaryElementGenerated(
1073-
string input, string output, string kind, string model
1074-
) {
1075-
exists(Provenance provenance |
1076-
interpretSummary(this, input, output, kind, provenance, model) and
1077-
provenance.isGenerated()
1078-
)
1079-
}
1067+
SummarizedCallableAdapter() { interpretSummary(this, input_, output_, kind, p_, model_) }
10801068

10811069
override predicate propagatesFlow(
1082-
string input, string output, boolean preservesValue, string model
1070+
string input, string output, boolean preservesValue, Provenance p, boolean isExact, string model
10831071
) {
1084-
exists(string kind |
1085-
this.relevantSummaryElementManual(input, output, kind, model)
1086-
or
1087-
not this.relevantSummaryElementManual(_, _, _, _) and
1088-
this.relevantSummaryElementGenerated(input, output, kind, model)
1089-
|
1090-
if kind = "value" then preservesValue = true else preservesValue = false
1091-
)
1092-
}
1093-
1094-
override predicate hasProvenance(Provenance provenance) {
1095-
interpretSummary(this, _, _, _, provenance, _)
1072+
input = input_ and
1073+
output = output_ and
1074+
(if kind = "value" then preservesValue = true else preservesValue = false) and
1075+
p = p_ and
1076+
isExact = true and
1077+
model = model_
10961078
}
10971079
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ module Input implements InputSig<Location, DataFlowImplSpecific::CppDataFlow> {
2020

2121
class SinkBase = Void;
2222

23+
predicate callableFromSource(SummarizedCallableBase c) { exists(c.getBlock()) }
24+
2325
ArgumentPosition callbackSelfParameterPosition() { result = TDirectPosition(-1) }
2426

2527
ReturnKind getStandardReturnValueKind() { result = getReturnValueKind("") }

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ private newtype TDataFlowCall =
11441144
}
11451145

11461146
private predicate summarizedCallableIsManual(SummarizedCallable sc) {
1147-
sc.asSummarizedCallable().applyManualModel()
1147+
sc.asSummarizedCallable().hasManualModel()
11481148
}
11491149

11501150
/**

cpp/ql/src/utils/modelgenerator/internal/CaptureModels.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ private module SummaryModelGeneratorInput implements SummaryModelGeneratorInputS
310310
}
311311

312312
private predicate hasManualSummaryModel(Callable api) {
313-
api = any(FlowSummaryImpl::Public::SummarizedCallable sc | sc.applyManualModel()) or
313+
api = any(FlowSummaryImpl::Public::SummarizedCallable sc | sc.hasManualModel()) or
314314
api = any(FlowSummaryImpl::Public::NeutralSummaryCallable sc | sc.hasManualModel())
315315
}
316316

cpp/ql/test/library-tests/dataflow/external-models/steps.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@
33
| test.cpp:21:27:21:27 | x | test.cpp:21:10:21:25 | call to ymlStepGenerated |
44
| test.cpp:25:35:25:35 | x | test.cpp:25:11:25:33 | call to ymlStepManual_with_body |
55
| test.cpp:28:35:28:35 | 0 | test.cpp:28:11:28:33 | call to ymlStepManual_with_body |
6-
| test.cpp:32:38:32:38 | 0 | test.cpp:32:11:32:36 | call to ymlStepGenerated_with_body |
7-
| test.cpp:35:38:35:38 | x | test.cpp:35:11:35:36 | call to ymlStepGenerated_with_body |
86
| windows.cpp:27:36:27:38 | *cmd | windows.cpp:27:17:27:34 | **call to CommandLineToArgvA |

0 commit comments

Comments
 (0)