Skip to content

Commit 7f2aa81

Browse files
author
Robert Marsh
authored
Merge pull request #4498 from dbartol/dbartol/PrintCallTargets
C++: Print static call target for `Call` instruction in dumps
2 parents a806a4f + 6a6eadc commit 7f2aa81

File tree

12 files changed

+375
-345
lines changed

12 files changed

+375
-345
lines changed

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,12 @@ class SwitchInstruction extends Instruction {
15011501
class CallInstruction extends Instruction {
15021502
CallInstruction() { getOpcode() instanceof Opcode::Call }
15031503

1504+
final override string getImmediateString() {
1505+
result = getStaticCallTarget().toString()
1506+
or
1507+
not exists(getStaticCallTarget()) and result = "?"
1508+
}
1509+
15041510
/**
15051511
* Gets the operand the specifies the target function of the call.
15061512
*/

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,12 @@ class SwitchInstruction extends Instruction {
15011501
class CallInstruction extends Instruction {
15021502
CallInstruction() { getOpcode() instanceof Opcode::Call }
15031503

1504+
final override string getImmediateString() {
1505+
result = getStaticCallTarget().toString()
1506+
or
1507+
not exists(getStaticCallTarget()) and result = "?"
1508+
}
1509+
15041510
/**
15051511
* Gets the operand the specifies the target function of the call.
15061512
*/

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,12 @@ class SwitchInstruction extends Instruction {
15011501
class CallInstruction extends Instruction {
15021502
CallInstruction() { getOpcode() instanceof Opcode::Call }
15031503

1504+
final override string getImmediateString() {
1505+
result = getStaticCallTarget().toString()
1506+
or
1507+
not exists(getStaticCallTarget()) and result = "?"
1508+
}
1509+
15041510
/**
15051511
* Gets the operand the specifies the target function of the call.
15061512
*/

cpp/ql/test/library-tests/ir/ir/raw_ir.expected

Lines changed: 158 additions & 158 deletions
Large diffs are not rendered by default.

cpp/ql/test/library-tests/ir/ssa/aliased_ssa_ir.expected

Lines changed: 29 additions & 29 deletions
Large diffs are not rendered by default.

cpp/ql/test/library-tests/ir/ssa/aliased_ssa_ir_unsound.expected

Lines changed: 29 additions & 29 deletions
Large diffs are not rendered by default.

cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_ir.expected

Lines changed: 29 additions & 29 deletions
Large diffs are not rendered by default.

cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_ir_unsound.expected

Lines changed: 29 additions & 29 deletions
Large diffs are not rendered by default.

cpp/ql/test/library-tests/valuenumbering/GlobalValueNumbering/ir_gvn.expected

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ test.cpp:
202202
# 29| valnum = m29_10, r29_8
203203
# 30| r30_1(glval<unknown>) = FunctionAddress[change_global02] :
204204
# 30| valnum = unique
205-
# 30| v30_2(void) = Call : func:r30_1
205+
# 30| v30_2(void) = Call[change_global02] : func:r30_1
206206
# 30| m30_3(unknown) = ^CallSideEffect : ~m25_4
207207
# 30| valnum = unique
208208
# 30| m30_4(unknown) = Chi : total:m25_4, partial:m30_3
@@ -538,7 +538,7 @@ test.cpp:
538538
# 77| valnum = r77_1, r79_1, r80_6
539539
# 77| r77_2(glval<unknown>) = FunctionAddress[getAValue] :
540540
# 77| valnum = unique
541-
# 77| r77_3(int) = Call : func:r77_2
541+
# 77| r77_3(int) = Call[getAValue] : func:r77_2
542542
# 77| valnum = unique
543543
# 77| m77_4(unknown) = ^CallSideEffect : ~m75_4
544544
# 77| valnum = unique
@@ -585,7 +585,7 @@ test.cpp:
585585
# 80| Block 1
586586
# 80| r80_1(glval<unknown>) = FunctionAddress[getAValue] :
587587
# 80| valnum = unique
588-
# 80| r80_2(int) = Call : func:r80_1
588+
# 80| r80_2(int) = Call[getAValue] : func:r80_1
589589
# 80| valnum = unique
590590
# 80| m80_3(unknown) = ^CallSideEffect : ~m77_5
591591
# 80| valnum = unique

csharp/ql/src/experimental/ir/implementation/raw/Instruction.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,12 @@ class SwitchInstruction extends Instruction {
15011501
class CallInstruction extends Instruction {
15021502
CallInstruction() { getOpcode() instanceof Opcode::Call }
15031503

1504+
final override string getImmediateString() {
1505+
result = getStaticCallTarget().toString()
1506+
or
1507+
not exists(getStaticCallTarget()) and result = "?"
1508+
}
1509+
15041510
/**
15051511
* Gets the operand the specifies the target function of the call.
15061512
*/

0 commit comments

Comments
 (0)