Skip to content

Commit e752e45

Browse files
committed
C#: Improved CIL instruction types to pass type consistency checks
1 parent 4f9b747 commit e752e45

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

csharp/ql/src/semmle/code/cil/Instructions.qll

+8-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ module Opcodes {
167167
class Neg extends UnaryExpr, @cil_neg {
168168
override string getOpcodeName() { result = "neg" }
169169

170-
override NumericType getType() { result = getOperand(0).getType() }
170+
override NumericType getType() {
171+
result = getOperand().getType()
172+
or
173+
getOperand().getType() instanceof Enum and result instanceof IntType
174+
}
171175
}
172176

173177
// Binary operations
@@ -1176,7 +1180,9 @@ module Opcodes {
11761180
class Localloc extends Expr, @cil_localloc {
11771181
override string getOpcodeName() { result = "localloc" }
11781182

1179-
override int getPopCount() { result = 1 } // ??
1183+
override int getPopCount() { result = 1 }
1184+
1185+
override PointerType getType() { result.getReferentType() instanceof ByteType }
11801186
}
11811187

11821188
class Readonly extends Instruction, @cil_readonly {

0 commit comments

Comments
 (0)