C#: Address review comments

This commit is contained in:
Tom Hvitved
2021-12-09 15:51:54 +01:00
parent 243b92b28c
commit 7e99426141
3 changed files with 10 additions and 2 deletions

View File

@@ -25,7 +25,7 @@ private module Cached {
cached
predicate alwaysThrowsException(Method m, Type t) {
alwaysThrowsMethod(m) and
forex(Throw ex | ex = m.getImplementation().getAnInstruction() | t = ex.getExpr().getType())
forex(Throw ex | ex = m.getImplementation().getAnInstruction() | t = ex.getExceptionType())
}
}

View File

@@ -128,7 +128,12 @@ class ControlFlowNode extends @cil_controlflow_node {
/** Gets the method containing this control flow node. */
MethodImplementation getImplementation() { none() }
/** Gets the type of the item pushed onto the stack, if any. */
/**
* Gets the type of the item pushed onto the stack, if any.
*
* If called via `ControlFlowNode::getOperand(i).getType()`, consider using
* `ControlFlowNode::getOperandType(i)` instead.
*/
cached
Type getType() { none() }

View File

@@ -242,6 +242,9 @@ class Return extends Instruction, @cil_ret {
class Throw extends Instruction, DotNet::Throw, @cil_throw_any {
override Expr getExpr() { result = this.getOperand(0) }
/** Gets the type of the exception being thrown. */
Type getExceptionType() { result = this.getOperandType(0) }
override predicate canFlowNext() { none() }
}