Skip to content

Commit 9a8b3ba

Browse files
committed
C++: Respond to PR reviews.
1 parent 5bd7589 commit 9a8b3ba

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private newtype TIRDataFlowNode =
5353
exists(Ssa::FinalParameterUse use |
5454
use.getParameter() = p and
5555
use.getIndirectionIndex() = indirectionIndex and
56-
parameterIsDefined(p)
56+
parameterIsRedefined(p)
5757
)
5858
} or
5959
TFinalGlobalValue(Ssa::GlobalUse globalUse) or
@@ -66,7 +66,7 @@ private newtype TIRDataFlowNode =
6666
* Only parameters satisfying this predicate will generate a `FinalParameterNode` transferring
6767
* flow out of the function.
6868
*/
69-
private predicate parameterIsDefined(Parameter p) {
69+
private predicate parameterIsRedefined(Parameter p) {
7070
exists(Ssa::Def def |
7171
def.getSourceVariable().getBaseVariable().(Ssa::BaseIRVariable).getIRVariable().getAst() = p and
7272
def.getIndirectionIndex() = 0 and

cpp/ql/test/library-tests/dataflow/dataflow-tests/has-parameter-flow-out.ql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ module IRTest {
2828
private import semmle.code.cpp.ir.dataflow.DataFlow
2929
private import semmle.code.cpp.ir.dataflow.internal.DataFlowUtil
3030

31+
private string stars(int k) {
32+
k = [0 .. max(FinalParameterNode n | | n.getIndirectionIndex())] and
33+
(if k = 0 then result = "" else result = "*" + stars(k - 1))
34+
}
35+
3136
class IRParameterDefTest extends InlineExpectationsTest {
3237
IRParameterDefTest() { this = "IRParameterDefTest" }
3338

@@ -41,7 +46,7 @@ module IRTest {
4146
location = f.getLocation() and
4247
element = p.toString() and
4348
tag = "ir-def" and
44-
value = "**********".prefix(n.getIndirectionIndex()) + p.getName()
49+
value = stars(n.getIndirectionIndex()) + p.getName()
4550
)
4651
}
4752
}

0 commit comments

Comments
 (0)