Skip to content

Commit 9ffdf3b

Browse files
authored
Merge pull request #254 from dave-bartolomeo/dave/InstructionToString
C++: Make `Instruction.toString()` less expensive
2 parents 89183bd + 3709195 commit 9ffdf3b

File tree

4 files changed

+370
-340
lines changed

4 files changed

+370
-340
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ class Instruction extends Construction::TInstruction {
133133
}
134134

135135
final string toString() {
136+
result = getOpcode().toString() + ": " + getAST().toString()
137+
}
138+
139+
/**
140+
* Gets a string showing the result, opcode, and operands of the instruction, equivalent to what
141+
* would be printed by PrintIR.ql. For example:
142+
*
143+
* `mu0_28(int) = Store r0_26, r0_27`
144+
*/
145+
final string getDumpString() {
136146
result = getResultString() + " = " + getOperationString() + " " + getOperandsString()
137147
}
138148

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ class Instruction extends Construction::TInstruction {
133133
}
134134

135135
final string toString() {
136+
result = getOpcode().toString() + ": " + getAST().toString()
137+
}
138+
139+
/**
140+
* Gets a string showing the result, opcode, and operands of the instruction, equivalent to what
141+
* would be printed by PrintIR.ql. For example:
142+
*
143+
* `mu0_28(int) = Store r0_26, r0_27`
144+
*/
145+
final string getDumpString() {
136146
result = getResultString() + " = " + getOperationString() + " " + getOperandsString()
137147
}
138148

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ class Instruction extends Construction::TInstruction {
133133
}
134134

135135
final string toString() {
136+
result = getOpcode().toString() + ": " + getAST().toString()
137+
}
138+
139+
/**
140+
* Gets a string showing the result, opcode, and operands of the instruction, equivalent to what
141+
* would be printed by PrintIR.ql. For example:
142+
*
143+
* `mu0_28(int) = Store r0_26, r0_27`
144+
*/
145+
final string getDumpString() {
136146
result = getResultString() + " = " + getOperationString() + " " + getOperandsString()
137147
}
138148

0 commit comments

Comments
 (0)