Skip to content

Commit d2e66a1

Browse files
committed
C++: Ignore addresses of 'InitializeDynamicAllocationInstruction' in 'unique' when converting between instructions and expression in dataflow.
1 parent 3df36ec commit d2e66a1

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/DataFlowUtil.qll

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,10 @@ private module GetConvertedResultExpression {
10661066
private import semmle.code.cpp.ir.implementation.raw.internal.TranslatedExpr
10671067
private import semmle.code.cpp.ir.implementation.raw.internal.InstructionTag
10681068

1069+
private Operand getAnInitializeDynamicAllocationInstructionAddress() {
1070+
result = any(InitializeDynamicAllocationInstruction init).getAllocationAddressOperand()
1071+
}
1072+
10691073
/**
10701074
* Gets the expression that should be returned as the result expression from `instr`.
10711075
*
@@ -1074,7 +1078,16 @@ private module GetConvertedResultExpression {
10741078
*/
10751079
Expr getConvertedResultExpression(Instruction instr, int n) {
10761080
// Only fully converted instructions has a result for `asConvertedExpr`
1077-
not conversionFlow(unique( | | getAUse(instr)), _, false, false) and
1081+
not conversionFlow(unique(Operand op |
1082+
// The address operand of a `InitializeDynamicAllocationInstruction` is
1083+
// special: we need to handle it during dataflow (since it's
1084+
// effectively a store to an indirection), but it doesn't appear in
1085+
// source syntax, so dataflow node <-> expression conversion shouldn't
1086+
// care about it.
1087+
op = getAUse(instr) and not op = getAnInitializeDynamicAllocationInstructionAddress()
1088+
|
1089+
op
1090+
), _, false, false) and
10781091
result = getConvertedResultExpressionImpl(instr) and
10791092
n = 0
10801093
or

0 commit comments

Comments
 (0)