Skip to content

Commit a08d594

Browse files
committed
C++: Introduce TypeidInstruction base class
1 parent 54f11ca commit a08d594

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

cpp/ql/lib/semmle/code/cpp/ir/implementation/Opcode.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ private newtype TOpcode =
9393
TInlineAsm() or
9494
TUnreached() or
9595
TNewObj() or
96+
TTypeid() or
9697
TTypeidExpr() or
9798
TTypeidType()
9899

@@ -1284,6 +1285,15 @@ module Opcode {
12841285
final override string toString() { result = "NewObj" }
12851286
}
12861287

1288+
/**
1289+
* The `Opcode` for a `TypeidInstruction`.
1290+
*
1291+
* See the `TypeidInstruction` documentation for more details.
1292+
*/
1293+
class Typeid extends Opcode, TTypeid {
1294+
final override string toString() { result = "Typeid" }
1295+
}
1296+
12871297
/**
12881298
* The `Opcode` for a `TypeidExprInstruction`.
12891299
*

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,18 +2294,25 @@ class NewObjInstruction extends Instruction {
22942294
NewObjInstruction() { this.getOpcode() instanceof Opcode::NewObj }
22952295
}
22962296

2297+
/**
2298+
* An instruction that returns the type info for its operand.
2299+
*/
2300+
class TypeidInstruction extends Instruction {
2301+
TypeidInstruction() { this.getOpcode() instanceof Opcode::Typeid }
2302+
}
2303+
22972304
/**
22982305
* An instruction that returns the type info for its operand, where the
22992306
* operand occurs as an expression in the AST.
23002307
*/
2301-
class TypeidExprInstruction extends UnaryInstruction {
2308+
class TypeidExprInstruction extends TypeidInstruction, UnaryInstruction {
23022309
TypeidExprInstruction() { this.getOpcode() instanceof Opcode::TypeidExpr }
23032310
}
23042311

23052312
/**
23062313
* An instruction that returns the type info for its operand, where the
23072314
* operand occurs as a type in the AST.
23082315
*/
2309-
class TypeidTypeInstruction extends Instruction {
2316+
class TypeidTypeInstruction extends TypeidInstruction {
23102317
TypeidTypeInstruction() { this.getOpcode() instanceof Opcode::TypeidType }
23112318
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,18 +2294,25 @@ class NewObjInstruction extends Instruction {
22942294
NewObjInstruction() { this.getOpcode() instanceof Opcode::NewObj }
22952295
}
22962296

2297+
/**
2298+
* An instruction that returns the type info for its operand.
2299+
*/
2300+
class TypeidInstruction extends Instruction {
2301+
TypeidInstruction() { this.getOpcode() instanceof Opcode::Typeid }
2302+
}
2303+
22972304
/**
22982305
* An instruction that returns the type info for its operand, where the
22992306
* operand occurs as an expression in the AST.
23002307
*/
2301-
class TypeidExprInstruction extends UnaryInstruction {
2308+
class TypeidExprInstruction extends TypeidInstruction, UnaryInstruction {
23022309
TypeidExprInstruction() { this.getOpcode() instanceof Opcode::TypeidExpr }
23032310
}
23042311

23052312
/**
23062313
* An instruction that returns the type info for its operand, where the
23072314
* operand occurs as a type in the AST.
23082315
*/
2309-
class TypeidTypeInstruction extends Instruction {
2316+
class TypeidTypeInstruction extends TypeidInstruction {
23102317
TypeidTypeInstruction() { this.getOpcode() instanceof Opcode::TypeidType }
23112318
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,18 +2294,25 @@ class NewObjInstruction extends Instruction {
22942294
NewObjInstruction() { this.getOpcode() instanceof Opcode::NewObj }
22952295
}
22962296

2297+
/**
2298+
* An instruction that returns the type info for its operand.
2299+
*/
2300+
class TypeidInstruction extends Instruction {
2301+
TypeidInstruction() { this.getOpcode() instanceof Opcode::Typeid }
2302+
}
2303+
22972304
/**
22982305
* An instruction that returns the type info for its operand, where the
22992306
* operand occurs as an expression in the AST.
23002307
*/
2301-
class TypeidExprInstruction extends UnaryInstruction {
2308+
class TypeidExprInstruction extends TypeidInstruction, UnaryInstruction {
23022309
TypeidExprInstruction() { this.getOpcode() instanceof Opcode::TypeidExpr }
23032310
}
23042311

23052312
/**
23062313
* An instruction that returns the type info for its operand, where the
23072314
* operand occurs as a type in the AST.
23082315
*/
2309-
class TypeidTypeInstruction extends Instruction {
2316+
class TypeidTypeInstruction extends TypeidInstruction {
23102317
TypeidTypeInstruction() { this.getOpcode() instanceof Opcode::TypeidType }
23112318
}

0 commit comments

Comments
 (0)