Skip to content

Commit 06f52c2

Browse files
committed
C++: Make the new nodes parameter nodes.
1 parent 98a3f2d commit 06f52c2

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
@@ -1828,31 +1828,41 @@ class SummaryParameterNode extends AbstractParameterNode, FlowSummaryNode {
18281828
}
18291829
}
18301830

1831-
pragma[noinline]
1832-
private predicate indirectPositionHasArgumentIndexAndIndex(
1833-
IndirectionPosition pos, int argumentIndex, int indirectionIndex
1834-
) {
1835-
pos.getArgumentIndex() = argumentIndex and
1836-
pos.getIndirectionIndex() = indirectionIndex
1837-
}
1831+
private class DirectBodyLessParameterNode extends AbstractExplicitParameterNode,
1832+
BodyLessParameterNodeImpl
1833+
{
1834+
DirectBodyLessParameterNode() { indirectionIndex = 0 }
18381835

1839-
pragma[noinline]
1840-
private predicate indirectParameterNodeHasArgumentIndexAndIndex(
1841-
IndirectParameterNode node, int argumentIndex, int indirectionIndex
1842-
) {
1843-
node.hasInstructionAndIndirectionIndex(_, indirectionIndex) and
1844-
node.getArgumentIndex() = argumentIndex
1836+
override predicate isParameterOf(DataFlowCallable f, ParameterPosition pos) {
1837+
exists(Function func |
1838+
this.getFunction() = func and
1839+
f.asSourceCallable() = func and
1840+
func.getParameter(pos.(DirectPosition).getIndex()) = p
1841+
)
1842+
}
1843+
1844+
override Parameter getParameter() { result = p }
18451845
}
18461846

1847-
/** A synthetic parameter to model the pointed-to object of a pointer parameter. */
1848-
class ParameterIndirectionNode extends ParameterNode instanceof IndirectParameterNode {
1847+
private class IndirectBodyLessParameterNode extends AbstractIndirectParameterNode,
1848+
BodyLessParameterNodeImpl
1849+
{
1850+
IndirectBodyLessParameterNode() { not this instanceof DirectBodyLessParameterNode }
1851+
18491852
override predicate isParameterOf(DataFlowCallable f, ParameterPosition pos) {
1850-
IndirectParameterNode.super.getEnclosingCallable() = f.getUnderlyingCallable() and
1851-
exists(int argumentIndex, int indirectionIndex |
1852-
indirectPositionHasArgumentIndexAndIndex(pos, argumentIndex, indirectionIndex) and
1853-
indirectParameterNodeHasArgumentIndexAndIndex(this, argumentIndex, indirectionIndex)
1853+
exists(Function func, int argumentPosition |
1854+
this.getFunction() = func and
1855+
f.asSourceCallable() = func and
1856+
indirectPositionHasArgumentIndexAndIndex(pos, argumentPosition, indirectionIndex) and
1857+
func.getParameter(argumentPosition) = p
18541858
)
18551859
}
1860+
1861+
override int getIndirectionIndex() {
1862+
result = BodyLessParameterNodeImpl.super.getIndirectionIndex()
1863+
}
1864+
1865+
override Parameter getParameter() { result = p }
18561866
}
18571867

18581868
/**

0 commit comments

Comments
 (0)