@@ -2,7 +2,7 @@ private import semmle.code.binary.ast.instructions as Raw
22private import codeql.controlflow.SuccessorType
33private import semmle.code.binary.ast.ir.internal.Tags
44private import InstructionTag
5- private import VariableTag
5+ private import TempVariableTag
66private import Instruction
77private import semmle.code.binary.ast.ir.internal.Opcode as Opcode
88private import codeql.util.Either
@@ -109,13 +109,17 @@ TranslatedCilInstruction getTranslatedCilInstruction(Raw::CilInstruction raw) {
109109abstract class TranslatedElement extends TTranslatedElement {
110110 abstract predicate hasInstruction ( Opcode opcode , InstructionTag tag , Option< Variable > :: Option v ) ;
111111
112- predicate hasTempVariable ( VariableTag tag ) { none ( ) }
112+ predicate hasTempVariable ( TempVariableTag tag ) { none ( ) }
113113
114114 predicate hasJumpCondition ( InstructionTag tag , Opcode:: ConditionKind kind ) { none ( ) }
115115
116- predicate hasSynthVariable ( SynthRegisterTag tag ) { none ( ) }
116+ predicate hasLocalVariable ( LocalVariableTag tag ) { none ( ) }
117117
118- Variable getVariable ( VariableTag tag ) { result = TTempVariable ( this , tag ) }
118+ final Variable getLocalVariable ( LocalVariableTag tag ) {
119+ result = TLocalVariable ( this .getEnclosingFunction ( ) , tag )
120+ }
121+
122+ Variable getVariable ( TempVariableTag tag ) { result = TTempVariable ( this , tag ) }
119123
120124 final Instruction getInstruction ( InstructionTag tag ) { result = MkInstruction ( this , tag ) }
121125
@@ -143,10 +147,17 @@ abstract class TranslatedElement extends TTranslatedElement {
143147 abstract string getDumpId ( ) ;
144148
145149 TranslatedFunction getStaticCallTarget ( InstructionTag tag ) { none ( ) }
150+
151+ abstract TranslatedFunction getEnclosingFunction ( ) ;
146152}
147153
148154predicate hasInstruction ( TranslatedElement te , InstructionTag tag ) { te .hasInstruction ( _, tag , _) }
149155
150- predicate hasTempVariable ( TranslatedElement te , VariableTag tag ) { te .hasTempVariable ( tag ) }
156+ predicate hasTempVariable ( TranslatedElement te , TempVariableTag tag ) { te .hasTempVariable ( tag ) }
151157
152- predicate hasSynthVariable ( SynthRegisterTag tag ) { any ( TranslatedElement te ) .hasSynthVariable ( tag ) }
158+ predicate hasLocalVariable ( TranslatedFunction tf , LocalVariableTag tag ) {
159+ exists ( TranslatedElement te |
160+ te .getEnclosingFunction ( ) = tf and
161+ te .hasLocalVariable ( tag )
162+ )
163+ }
0 commit comments