mirror of
https://github.com/github/codeql.git
synced 2026-04-22 15:25:18 +02:00
C++: Add an 'EdgeKind' column to 'getExceptionSuccessorInstruction'.
This commit is contained in:
@@ -914,10 +914,10 @@ abstract class TranslatedElement extends TTranslatedElement {
|
||||
* Gets the instruction to which control should flow if an exception is thrown
|
||||
* within this element. This will generally return first `catch` block of the
|
||||
* nearest enclosing `try`, or the `Unwind` instruction for the function if
|
||||
* there is no enclosing `try`.
|
||||
* there is no enclosing `try`. The successor edge kind is specified by `kind`.
|
||||
*/
|
||||
Instruction getExceptionSuccessorInstruction() {
|
||||
result = this.getParent().getExceptionSuccessorInstruction()
|
||||
Instruction getExceptionSuccessorInstruction(EdgeKind kind) {
|
||||
result = this.getParent().getExceptionSuccessorInstruction(kind)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2566,7 +2566,7 @@ abstract class TranslatedThrowExpr extends TranslatedNonConstantExpr {
|
||||
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
|
||||
tag = ThrowTag() and
|
||||
kind instanceof ExceptionEdge and
|
||||
result = this.getParent().getExceptionSuccessorInstruction()
|
||||
result = this.getParent().getExceptionSuccessorInstruction(any(GotoEdge edge))
|
||||
}
|
||||
|
||||
override Instruction getResult() { none() }
|
||||
|
||||
@@ -222,8 +222,9 @@ class TranslatedFunction extends TranslatedRootElement, TTranslatedFunction {
|
||||
)
|
||||
}
|
||||
|
||||
final override Instruction getExceptionSuccessorInstruction() {
|
||||
result = this.getInstruction(UnwindTag())
|
||||
final override Instruction getExceptionSuccessorInstruction(EdgeKind kind) {
|
||||
result = this.getInstruction(UnwindTag()) and
|
||||
kind instanceof GotoEdge
|
||||
}
|
||||
|
||||
final override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {
|
||||
|
||||
@@ -563,13 +563,12 @@ class TranslatedTryStmt extends TranslatedStmt {
|
||||
// The last catch clause flows to the exception successor of the parent
|
||||
// of the `try`, because the exception successor of the `try` itself is
|
||||
// the first catch clause.
|
||||
kind instanceof GotoEdge and
|
||||
handler = this.getHandler(stmt.getNumberOfCatchClauses() - 1) and
|
||||
result = this.getParent().getExceptionSuccessorInstruction()
|
||||
result = this.getParent().getExceptionSuccessorInstruction(kind)
|
||||
}
|
||||
|
||||
final override Instruction getExceptionSuccessorInstruction() {
|
||||
result = this.getHandler(0).getFirstInstruction(any(GotoEdge edge))
|
||||
final override Instruction getExceptionSuccessorInstruction(EdgeKind kind) {
|
||||
result = this.getHandler(0).getFirstInstruction(kind)
|
||||
}
|
||||
|
||||
private TranslatedElement getHandler(int index) { result = stmt.getTranslatedHandler(index) }
|
||||
@@ -635,10 +634,10 @@ abstract class TranslatedHandler extends TranslatedStmt {
|
||||
child = this.getBlock() and result = this.getParent().getChildSuccessor(this, kind)
|
||||
}
|
||||
|
||||
override Instruction getExceptionSuccessorInstruction() {
|
||||
override Instruction getExceptionSuccessorInstruction(EdgeKind kind) {
|
||||
// A throw from within a `catch` block flows to the handler for the parent of
|
||||
// the `try`.
|
||||
result = this.getParent().getParent().getExceptionSuccessorInstruction()
|
||||
result = this.getParent().getParent().getExceptionSuccessorInstruction(kind)
|
||||
}
|
||||
|
||||
TranslatedStmt getBlock() { result = getTranslatedStmt(stmt.getBlock()) }
|
||||
|
||||
Reference in New Issue
Block a user