Skip to content

Commit 35868d4

Browse files
author
Dave Bartolomeo
committed
C++/C#: Change dump of unmodeled use to m?
This is kind of inconsequential on its own, but will make the test diffs easier to understand once the next commit removes `UnmodeledDefinition`.
1 parent 8d41ce1 commit 35868d4

File tree

9 files changed

+1712
-1657
lines changed

9 files changed

+1712
-1657
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,18 @@ class Operand extends TOperand {
147147
* For example: `this:r3_5`
148148
*/
149149
final string getDumpString() {
150-
result = getDumpLabel() + getInexactSpecifier() + getAnyDef().getResultId()
150+
result = getDumpLabel() + getInexactSpecifier() + getDefinitionId()
151+
}
152+
153+
/**
154+
* Gets a string containing the identifier of the definition of this use, or `m?` if the
155+
* definition is not modeled in SSA.
156+
*/
157+
private string getDefinitionId() {
158+
exists(Instruction def |
159+
def = getAnyDef() and
160+
if def.isResultModeled() then result = def.getResultId() else result = "m?"
161+
)
151162
}
152163

153164
/**

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,18 @@ class Operand extends TOperand {
147147
* For example: `this:r3_5`
148148
*/
149149
final string getDumpString() {
150-
result = getDumpLabel() + getInexactSpecifier() + getAnyDef().getResultId()
150+
result = getDumpLabel() + getInexactSpecifier() + getDefinitionId()
151+
}
152+
153+
/**
154+
* Gets a string containing the identifier of the definition of this use, or `m?` if the
155+
* definition is not modeled in SSA.
156+
*/
157+
private string getDefinitionId() {
158+
exists(Instruction def |
159+
def = getAnyDef() and
160+
if def.isResultModeled() then result = def.getResultId() else result = "m?"
161+
)
151162
}
152163

153164
/**

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,18 @@ class Operand extends TOperand {
147147
* For example: `this:r3_5`
148148
*/
149149
final string getDumpString() {
150-
result = getDumpLabel() + getInexactSpecifier() + getAnyDef().getResultId()
150+
result = getDumpLabel() + getInexactSpecifier() + getDefinitionId()
151+
}
152+
153+
/**
154+
* Gets a string containing the identifier of the definition of this use, or `m?` if the
155+
* definition is not modeled in SSA.
156+
*/
157+
private string getDefinitionId() {
158+
exists(Instruction def |
159+
def = getAnyDef() and
160+
if def.isResultModeled() then result = def.getResultId() else result = "m?"
161+
)
151162
}
152163

153164
/**

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

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

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

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

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

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

csharp/ql/src/semmle/code/csharp/ir/implementation/raw/Operand.qll

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,18 @@ class Operand extends TOperand {
147147
* For example: `this:r3_5`
148148
*/
149149
final string getDumpString() {
150-
result = getDumpLabel() + getInexactSpecifier() + getAnyDef().getResultId()
150+
result = getDumpLabel() + getInexactSpecifier() + getDefinitionId()
151+
}
152+
153+
/**
154+
* Gets a string containing the identifier of the definition of this use, or `m?` if the
155+
* definition is not modeled in SSA.
156+
*/
157+
private string getDefinitionId() {
158+
exists(Instruction def |
159+
def = getAnyDef() and
160+
if def.isResultModeled() then result = def.getResultId() else result = "m?"
161+
)
151162
}
152163

153164
/**

csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/Operand.qll

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,18 @@ class Operand extends TOperand {
147147
* For example: `this:r3_5`
148148
*/
149149
final string getDumpString() {
150-
result = getDumpLabel() + getInexactSpecifier() + getAnyDef().getResultId()
150+
result = getDumpLabel() + getInexactSpecifier() + getDefinitionId()
151+
}
152+
153+
/**
154+
* Gets a string containing the identifier of the definition of this use, or `m?` if the
155+
* definition is not modeled in SSA.
156+
*/
157+
private string getDefinitionId() {
158+
exists(Instruction def |
159+
def = getAnyDef() and
160+
if def.isResultModeled() then result = def.getResultId() else result = "m?"
161+
)
151162
}
152163

153164
/**

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

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

0 commit comments

Comments
 (0)