Skip to content

Commit 32c8ceb

Browse files
committed
C++: Make the new nodes parameter nodes.
1 parent 3c83217 commit 32c8ceb

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

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

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,31 +1821,41 @@ class SummaryParameterNode extends AbstractParameterNode, FlowSummaryNode {
18211821
}
18221822
}
18231823

1824-
pragma[noinline]
1825-
private predicate indirectPositionHasArgumentIndexAndIndex(
1826-
IndirectionPosition pos, int argumentIndex, int indirectionIndex
1827-
) {
1828-
pos.getArgumentIndex() = argumentIndex and
1829-
pos.getIndirectionIndex() = indirectionIndex
1830-
}
1824+
private class DirectBodyLessParameterNode extends AbstractExplicitParameterNode,
1825+
BodyLessParameterNodeImpl
1826+
{
1827+
DirectBodyLessParameterNode() { indirectionIndex = 0 }
18311828

1832-
pragma[noinline]
1833-
private predicate indirectParameterNodeHasArgumentIndexAndIndex(
1834-
IndirectParameterNode node, int argumentIndex, int indirectionIndex
1835-
) {
1836-
node.hasInstructionAndIndirectionIndex(_, indirectionIndex) and
1837-
node.getArgumentIndex() = argumentIndex
1829+
override predicate isParameterOf(DataFlowCallable f, ParameterPosition pos) {
1830+
exists(Function func |
1831+
this.getFunction() = func and
1832+
f.asSourceCallable() = func and
1833+
func.getParameter(pos.(DirectPosition).getIndex()) = p
1834+
)
1835+
}
1836+
1837+
override Parameter getParameter() { result = p }
18381838
}
18391839

1840-
/** A synthetic parameter to model the pointed-to object of a pointer parameter. */
1841-
class ParameterIndirectionNode extends ParameterNode instanceof IndirectParameterNode {
1840+
private class IndirectBodyLessParameterNode extends AbstractIndirectParameterNode,
1841+
BodyLessParameterNodeImpl
1842+
{
1843+
IndirectBodyLessParameterNode() { not this instanceof DirectBodyLessParameterNode }
1844+
18421845
override predicate isParameterOf(DataFlowCallable f, ParameterPosition pos) {
1843-
IndirectParameterNode.super.getEnclosingCallable() = f.getUnderlyingCallable() and
1844-
exists(int argumentIndex, int indirectionIndex |
1845-
indirectPositionHasArgumentIndexAndIndex(pos, argumentIndex, indirectionIndex) and
1846-
indirectParameterNodeHasArgumentIndexAndIndex(this, argumentIndex, indirectionIndex)
1846+
exists(Function func, int argumentPosition |
1847+
this.getFunction() = func and
1848+
f.asSourceCallable() = func and
1849+
indirectPositionHasArgumentIndexAndIndex(pos, argumentPosition, indirectionIndex) and
1850+
func.getParameter(argumentPosition) = p
18471851
)
18481852
}
1853+
1854+
override int getIndirectionIndex() {
1855+
result = BodyLessParameterNodeImpl.super.getIndirectionIndex()
1856+
}
1857+
1858+
override Parameter getParameter() { result = p }
18491859
}
18501860

18511861
/**

0 commit comments

Comments
 (0)