Skip to content

Commit 0519cee

Browse files
committed
C++/C#: Sync identical files.
1 parent ccc9e09 commit 0519cee

File tree

8 files changed

+100
-8
lines changed

8 files changed

+100
-8
lines changed

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/IR.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,16 @@ class IRPropertyProvider extends TIRPropertyProvider {
7777
* Gets the value of the property named `key` for the specified operand.
7878
*/
7979
string getOperandProperty(Operand operand, string key) { none() }
80+
81+
/**
82+
* Holds if the instruction `instr` should be included when printing
83+
* the IR instructions.
84+
*/
85+
predicate shouldPrintInstruction(Instruction instr) { any() }
86+
87+
/**
88+
* Holds if the operand `operand` should be included when printing the an
89+
* instruction's operand list.
90+
*/
91+
predicate shouldPrintOperand(Operand operand) { any() }
8092
}

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/PrintIR.qll

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ private predicate shouldPrintFunction(Language::Declaration decl) {
4242
exists(PrintIRConfiguration config | config.shouldPrintFunction(decl))
4343
}
4444

45+
private predicate shouldPrintInstruction(Instruction i) {
46+
exists(IRPropertyProvider provider | provider.shouldPrintInstruction(i))
47+
}
48+
49+
private predicate shouldPrintOperand(Operand operand) {
50+
exists(IRPropertyProvider provider | provider.shouldPrintOperand(operand))
51+
}
52+
4553
private string getAdditionalInstructionProperty(Instruction instr, string key) {
4654
exists(IRPropertyProvider provider | result = provider.getInstructionProperty(instr, key))
4755
}
@@ -84,7 +92,9 @@ private string getOperandPropertyString(Operand operand) {
8492
private newtype TPrintableIRNode =
8593
TPrintableIRFunction(IRFunction irFunc) { shouldPrintFunction(irFunc.getFunction()) } or
8694
TPrintableIRBlock(IRBlock block) { shouldPrintFunction(block.getEnclosingFunction()) } or
87-
TPrintableInstruction(Instruction instr) { shouldPrintFunction(instr.getEnclosingFunction()) }
95+
TPrintableInstruction(Instruction instr) {
96+
shouldPrintInstruction(instr) and shouldPrintFunction(instr.getEnclosingFunction())
97+
}
8898

8999
/**
90100
* A node to be emitted in the IR graph.
@@ -252,7 +262,8 @@ private class PrintableInstruction extends PrintableIRNode, TPrintableInstructio
252262
private string getOperandsString() {
253263
result =
254264
concat(Operand operand |
255-
operand = instr.getAnOperand()
265+
operand = instr.getAnOperand() and
266+
shouldPrintOperand(operand)
256267
|
257268
operand.getDumpString() + getOperandPropertyString(operand), ", "
258269
order by

cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/IR.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,16 @@ class IRPropertyProvider extends TIRPropertyProvider {
7777
* Gets the value of the property named `key` for the specified operand.
7878
*/
7979
string getOperandProperty(Operand operand, string key) { none() }
80+
81+
/**
82+
* Holds if the instruction `instr` should be included when printing
83+
* the IR instructions.
84+
*/
85+
predicate shouldPrintInstruction(Instruction instr) { any() }
86+
87+
/**
88+
* Holds if the operand `operand` should be included when printing the an
89+
* instruction's operand list.
90+
*/
91+
predicate shouldPrintOperand(Operand operand) { any() }
8092
}

cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/PrintIR.qll

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ private predicate shouldPrintFunction(Language::Declaration decl) {
4242
exists(PrintIRConfiguration config | config.shouldPrintFunction(decl))
4343
}
4444

45+
private predicate shouldPrintInstruction(Instruction i) {
46+
exists(IRPropertyProvider provider | provider.shouldPrintInstruction(i))
47+
}
48+
49+
private predicate shouldPrintOperand(Operand operand) {
50+
exists(IRPropertyProvider provider | provider.shouldPrintOperand(operand))
51+
}
52+
4553
private string getAdditionalInstructionProperty(Instruction instr, string key) {
4654
exists(IRPropertyProvider provider | result = provider.getInstructionProperty(instr, key))
4755
}
@@ -84,7 +92,9 @@ private string getOperandPropertyString(Operand operand) {
8492
private newtype TPrintableIRNode =
8593
TPrintableIRFunction(IRFunction irFunc) { shouldPrintFunction(irFunc.getFunction()) } or
8694
TPrintableIRBlock(IRBlock block) { shouldPrintFunction(block.getEnclosingFunction()) } or
87-
TPrintableInstruction(Instruction instr) { shouldPrintFunction(instr.getEnclosingFunction()) }
95+
TPrintableInstruction(Instruction instr) {
96+
shouldPrintInstruction(instr) and shouldPrintFunction(instr.getEnclosingFunction())
97+
}
8898

8999
/**
90100
* A node to be emitted in the IR graph.
@@ -252,7 +262,8 @@ private class PrintableInstruction extends PrintableIRNode, TPrintableInstructio
252262
private string getOperandsString() {
253263
result =
254264
concat(Operand operand |
255-
operand = instr.getAnOperand()
265+
operand = instr.getAnOperand() and
266+
shouldPrintOperand(operand)
256267
|
257268
operand.getDumpString() + getOperandPropertyString(operand), ", "
258269
order by

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,16 @@ class IRPropertyProvider extends TIRPropertyProvider {
7777
* Gets the value of the property named `key` for the specified operand.
7878
*/
7979
string getOperandProperty(Operand operand, string key) { none() }
80+
81+
/**
82+
* Holds if the instruction `instr` should be included when printing
83+
* the IR instructions.
84+
*/
85+
predicate shouldPrintInstruction(Instruction instr) { any() }
86+
87+
/**
88+
* Holds if the operand `operand` should be included when printing the an
89+
* instruction's operand list.
90+
*/
91+
predicate shouldPrintOperand(Operand operand) { any() }
8092
}

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ private predicate shouldPrintFunction(Language::Declaration decl) {
4242
exists(PrintIRConfiguration config | config.shouldPrintFunction(decl))
4343
}
4444

45+
private predicate shouldPrintInstruction(Instruction i) {
46+
exists(IRPropertyProvider provider | provider.shouldPrintInstruction(i))
47+
}
48+
49+
private predicate shouldPrintOperand(Operand operand) {
50+
exists(IRPropertyProvider provider | provider.shouldPrintOperand(operand))
51+
}
52+
4553
private string getAdditionalInstructionProperty(Instruction instr, string key) {
4654
exists(IRPropertyProvider provider | result = provider.getInstructionProperty(instr, key))
4755
}
@@ -84,7 +92,9 @@ private string getOperandPropertyString(Operand operand) {
8492
private newtype TPrintableIRNode =
8593
TPrintableIRFunction(IRFunction irFunc) { shouldPrintFunction(irFunc.getFunction()) } or
8694
TPrintableIRBlock(IRBlock block) { shouldPrintFunction(block.getEnclosingFunction()) } or
87-
TPrintableInstruction(Instruction instr) { shouldPrintFunction(instr.getEnclosingFunction()) }
95+
TPrintableInstruction(Instruction instr) {
96+
shouldPrintInstruction(instr) and shouldPrintFunction(instr.getEnclosingFunction())
97+
}
8898

8999
/**
90100
* A node to be emitted in the IR graph.
@@ -252,7 +262,8 @@ private class PrintableInstruction extends PrintableIRNode, TPrintableInstructio
252262
private string getOperandsString() {
253263
result =
254264
concat(Operand operand |
255-
operand = instr.getAnOperand()
265+
operand = instr.getAnOperand() and
266+
shouldPrintOperand(operand)
256267
|
257268
operand.getDumpString() + getOperandPropertyString(operand), ", "
258269
order by

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/IR.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,16 @@ class IRPropertyProvider extends TIRPropertyProvider {
7777
* Gets the value of the property named `key` for the specified operand.
7878
*/
7979
string getOperandProperty(Operand operand, string key) { none() }
80+
81+
/**
82+
* Holds if the instruction `instr` should be included when printing
83+
* the IR instructions.
84+
*/
85+
predicate shouldPrintInstruction(Instruction instr) { any() }
86+
87+
/**
88+
* Holds if the operand `operand` should be included when printing the an
89+
* instruction's operand list.
90+
*/
91+
predicate shouldPrintOperand(Operand operand) { any() }
8092
}

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/PrintIR.qll

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ private predicate shouldPrintFunction(Language::Declaration decl) {
4242
exists(PrintIRConfiguration config | config.shouldPrintFunction(decl))
4343
}
4444

45+
private predicate shouldPrintInstruction(Instruction i) {
46+
exists(IRPropertyProvider provider | provider.shouldPrintInstruction(i))
47+
}
48+
49+
private predicate shouldPrintOperand(Operand operand) {
50+
exists(IRPropertyProvider provider | provider.shouldPrintOperand(operand))
51+
}
52+
4553
private string getAdditionalInstructionProperty(Instruction instr, string key) {
4654
exists(IRPropertyProvider provider | result = provider.getInstructionProperty(instr, key))
4755
}
@@ -84,7 +92,9 @@ private string getOperandPropertyString(Operand operand) {
8492
private newtype TPrintableIRNode =
8593
TPrintableIRFunction(IRFunction irFunc) { shouldPrintFunction(irFunc.getFunction()) } or
8694
TPrintableIRBlock(IRBlock block) { shouldPrintFunction(block.getEnclosingFunction()) } or
87-
TPrintableInstruction(Instruction instr) { shouldPrintFunction(instr.getEnclosingFunction()) }
95+
TPrintableInstruction(Instruction instr) {
96+
shouldPrintInstruction(instr) and shouldPrintFunction(instr.getEnclosingFunction())
97+
}
8898

8999
/**
90100
* A node to be emitted in the IR graph.
@@ -252,7 +262,8 @@ private class PrintableInstruction extends PrintableIRNode, TPrintableInstructio
252262
private string getOperandsString() {
253263
result =
254264
concat(Operand operand |
255-
operand = instr.getAnOperand()
265+
operand = instr.getAnOperand() and
266+
shouldPrintOperand(operand)
256267
|
257268
operand.getDumpString() + getOperandPropertyString(operand), ", "
258269
order by

0 commit comments

Comments
 (0)