Skip to content

Commit 6e587f3

Browse files
committed
IR: Add VariableInstruction.getASTVariable
1 parent c1e3821 commit 6e587f3

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,11 @@ class VariableInstruction extends Instruction {
612612
override string getImmediateString() { result = var.toString() }
613613

614614
final IRVariable getIRVariable() { result = var }
615+
616+
/**
617+
* Gets the AST variable that this instruction's IR variable refers to, if one exists.
618+
*/
619+
final Language::Variable getASTVariable() { result = var.(IRUserVariable).getVariable() }
615620
}
616621

617622
class FieldInstruction extends Instruction {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,11 @@ class VariableInstruction extends Instruction {
612612
override string getImmediateString() { result = var.toString() }
613613

614614
final IRVariable getIRVariable() { result = var }
615+
616+
/**
617+
* Gets the AST variable that this instruction's IR variable refers to, if one exists.
618+
*/
619+
final Language::Variable getASTVariable() { result = var.(IRUserVariable).getVariable() }
615620
}
616621

617622
class FieldInstruction extends Instruction {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,11 @@ class VariableInstruction extends Instruction {
612612
override string getImmediateString() { result = var.toString() }
613613

614614
final IRVariable getIRVariable() { result = var }
615+
616+
/**
617+
* Gets the AST variable that this instruction's IR variable refers to, if one exists.
618+
*/
619+
final Language::Variable getASTVariable() { result = var.(IRUserVariable).getVariable() }
615620
}
616621

617622
class FieldInstruction extends Instruction {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,11 @@ class VariableInstruction extends Instruction {
612612
override string getImmediateString() { result = var.toString() }
613613

614614
final IRVariable getIRVariable() { result = var }
615+
616+
/**
617+
* Gets the AST variable that this instruction's IR variable refers to, if one exists.
618+
*/
619+
final Language::Variable getASTVariable() { result = var.(IRUserVariable).getVariable() }
615620
}
616621

617622
class FieldInstruction extends Instruction {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,11 @@ class VariableInstruction extends Instruction {
612612
override string getImmediateString() { result = var.toString() }
613613

614614
final IRVariable getIRVariable() { result = var }
615+
616+
/**
617+
* Gets the AST variable that this instruction's IR variable refers to, if one exists.
618+
*/
619+
final Language::Variable getASTVariable() { result = var.(IRUserVariable).getVariable() }
615620
}
616621

617622
class FieldInstruction extends Instruction {

0 commit comments

Comments
 (0)