From acd812b5b8bc4dff1d0190539f63641fed98b307 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Wed, 18 Sep 2024 13:11:18 +0200 Subject: [PATCH] Rust: DO NOT MERGE: patch cfg implementation --- .../controlflow/internal/ControlFlowGraphImpl.qll | 13 +++++-------- .../codeql/rust/elements/internal/FunctionImpl.qll | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll b/rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll index 5f49d7177546e..7b9d89dddf2a6 100644 --- a/rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll +++ b/rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll @@ -69,16 +69,16 @@ class FunctionTree extends StandardPostOrderTree instanceof Function { class BlockExprTree extends StandardPostOrderTree instanceof BlockExpr { override ControlFlowTree getChildNode(int i) { - result = super.getStatement(i) + result = super.getStmtList().getStatement(i) or - not exists(super.getStatement(i)) and - (exists(super.getStatement(i - 1)) or i = 0) and - result = super.getTail() + not exists(super.getStmtList().getStatement(i)) and + (exists(super.getStmtList().getStatement(i - 1)) or i = 0) and + result = super.getStmtList().getTailExpr() } } class CallExprTree extends StandardPostOrderTree instanceof CallExpr { - override ControlFlowTree getChildNode(int i) { result = super.getArg(i) } + override ControlFlowTree getChildNode(int i) { result = super.getArgList().getArg(i) } } class BinaryOpExprTree extends StandardPostOrderTree instanceof BinaryExpr { @@ -124,6 +124,3 @@ class LetExprTree extends StandardPostOrderTree instanceof LetExpr { class LiteralExprTree extends LeafTree instanceof LiteralExpr { } class PathExprTree extends LeafTree instanceof PathExpr { } - -// A leaf tree for unimplemented nodes in the AST. -class UnimplementedTree extends LeafTree instanceof Unimplemented { } diff --git a/rust/ql/lib/codeql/rust/elements/internal/FunctionImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/FunctionImpl.qll index 1d29ec56637e6..c7ec1fc436982 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/FunctionImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/FunctionImpl.qll @@ -25,6 +25,6 @@ module Impl { * ``` */ class Function extends Generated::Function { - override string toString() { result = this.getName() } + override string toString() { result = this.getName().toString() } } }