Skip to content

Commit 7e99426

Browse files
committed
C#: Address review comments
1 parent 243b92b commit 7e99426

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

csharp/ql/lib/semmle/code/cil/CallableReturns.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private module Cached {
2525
cached
2626
predicate alwaysThrowsException(Method m, Type t) {
2727
alwaysThrowsMethod(m) and
28-
forex(Throw ex | ex = m.getImplementation().getAnInstruction() | t = ex.getExpr().getType())
28+
forex(Throw ex | ex = m.getImplementation().getAnInstruction() | t = ex.getExceptionType())
2929
}
3030
}
3131

csharp/ql/lib/semmle/code/cil/ControlFlow.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,12 @@ class ControlFlowNode extends @cil_controlflow_node {
128128
/** Gets the method containing this control flow node. */
129129
MethodImplementation getImplementation() { none() }
130130

131-
/** Gets the type of the item pushed onto the stack, if any. */
131+
/**
132+
* Gets the type of the item pushed onto the stack, if any.
133+
*
134+
* If called via `ControlFlowNode::getOperand(i).getType()`, consider using
135+
* `ControlFlowNode::getOperandType(i)` instead.
136+
*/
132137
cached
133138
Type getType() { none() }
134139

csharp/ql/lib/semmle/code/cil/InstructionGroups.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ class Return extends Instruction, @cil_ret {
242242
class Throw extends Instruction, DotNet::Throw, @cil_throw_any {
243243
override Expr getExpr() { result = this.getOperand(0) }
244244

245+
/** Gets the type of the exception being thrown. */
246+
Type getExceptionType() { result = this.getOperandType(0) }
247+
245248
override predicate canFlowNext() { none() }
246249
}
247250

0 commit comments

Comments
 (0)