Skip to content

Commit dd96095

Browse files
geoffw0MathiasVP
andauthored
Apply suggestions from code review
Co-authored-by: Mathias Vorreiter Pedersen <[email protected]>
1 parent 925ee82 commit dd96095

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
category: feature
33
---
4-
* Models-as-Data support has been added for C/C++. This feature allows flow sources, sinks and summaries to be expressed in compact strings as an alternative to modelling each source / sink / summary with explicit CodeQL. See `dataflow/ExternalFlow.qll` for documentation and specification of the model format, and `models/implementations/ZMQ.qll` for a simple example of models. Importing models from `.yml` is not yet supported.
4+
* Models-as-Data support has been added for C/C++. This feature allows flow sources, sinks and summaries to be expressed in compact strings as an alternative to modelling each source / sink / summary with explicit QL. See `dataflow/ExternalFlow.qll` for documentation and specification of the model format, and `models/implementations/ZMQ.qll` for a simple example of models. Importing models from `.yml` is not yet supported.

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ private newtype TReturnKind =
465465
// derive a possible return kind from the AST
466466
// (this approach includes functions declared that have no body; they may still have flow summaries)
467467
indirectionIndex =
468-
[0 .. max(Ssa::Function f |
468+
[0 .. max(Cpp::Function f |
469469
|
470470
Ssa::getMaxIndirectionsForType(f.getUnspecifiedType()) - 1 // -1 because a returned value is a prvalue not a glvalue
471471
)]
@@ -479,7 +479,7 @@ private newtype TReturnKind =
479479
or
480480
// derive a possible return argument from the AST
481481
indirectionIndex =
482-
[0 .. max(Ssa::Function f |
482+
[0 .. max(Cpp::Function f |
483483
|
484484
Ssa::getMaxIndirectionsForType(f.getParameter(argumentIndex).getUnspecifiedType()) - 1 // -1 because an argument is a prvalue not a glvalue
485485
)]
@@ -1007,7 +1007,7 @@ class CastNode extends Node {
10071007
}
10081008

10091009
cached
1010-
newtype TDataFlowCallable =
1010+
private newtype TDataFlowCallable =
10111011
TSourceCallable(Cpp::Declaration decl) {
10121012
not decl instanceof FlowSummaryImpl::Public::SummarizedCallable
10131013
} or
@@ -1031,8 +1031,17 @@ class DataFlowCallable extends TDataFlowCallable {
10311031
/** Gets a textual representation of this callable. */
10321032
string toString() { none() }
10331033

1034+
/**
1035+
* Gets the `Declaration` corresponding to this callable if it exists in the database.
1036+
* For summarized callables (which may not exist in the database), use `asSummarizedCallable`.
1037+
*/
10341038
Cpp::Declaration asSourceCallable() { this = TSourceCallable(result) }
10351039

1040+
/**
1041+
* Gets the underlying summarized callable, if
1042+
* this callable is generated from a models-as-data
1043+
* model.
1044+
*/
10361045
FlowSummaryImpl::Public::SummarizedCallable asSummarizedCallable() {
10371046
this = TSummarizedCallable(result)
10381047
}
@@ -1080,7 +1089,7 @@ class DataFlowExpr = Expr;
10801089
class DataFlowType = Type;
10811090

10821091
cached
1083-
newtype TDataFlowCall =
1092+
private newtype TDataFlowCall =
10841093
TNormalCall(CallInstruction call) or
10851094
TSummaryCall(
10861095
FlowSummaryImpl::Public::SummarizedCallable c, FlowSummaryImpl::Private::SummaryNode receiver

0 commit comments

Comments
 (0)