Skip to content

Commit 3bb249f

Browse files
committed
C++: Ensure we always have 'Position's even if there are no calls in the DB.
1 parent b678112 commit 3bb249f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

+14-1
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,23 @@ class IndirectionPosition extends Position, TIndirectionPosition {
459459
}
460460

461461
newtype TPosition =
462-
TDirectPosition(int argumentIndex) { exists(any(CallInstruction c).getArgument(argumentIndex)) } or
462+
TDirectPosition(int argumentIndex) {
463+
exists(any(CallInstruction c).getArgument(argumentIndex))
464+
or
465+
// Handle the rare case where the is a function definition but no call to
466+
// the function.
467+
exists(any(Cpp::Function f).getParameter(argumentIndex))
468+
} or
463469
TIndirectionPosition(int argumentIndex, int indirectionIndex) {
464470
Ssa::hasIndirectOperand(any(CallInstruction call).getArgumentOperand(argumentIndex),
465471
indirectionIndex)
472+
or
473+
// Handle the rare case where the is a function definition but no call to
474+
// the function.
475+
exists(Cpp::Function f, Cpp::Parameter p |
476+
p = f.getParameter(argumentIndex) and
477+
indirectionIndex = [1 .. Ssa::getMaxIndirectionsForType(p.getUnspecifiedType()) - 1]
478+
)
466479
}
467480

468481
private newtype TReturnKind =

0 commit comments

Comments
 (0)