From 12f9e3a1ddd1011aed3039d93bbe0b2cce059218 Mon Sep 17 00:00:00 2001 From: Alex Denisov Date: Tue, 7 Nov 2023 18:04:20 +0100 Subject: [PATCH] Swlft: fix CFG for SingleValueStmtExpr --- .../swift/controlflow/internal/ControlFlowGraphImpl.qll | 9 +++++++++ .../CONSISTENCY/CfgConsistency.expected | 2 -- .../flowsources/CONSISTENCY/CfgConsistency.expected | 5 ----- 3 files changed, 9 insertions(+), 7 deletions(-) delete mode 100644 swift/ql/test/extractor-tests/generated/expr/SingleValueStmtExpr/CONSISTENCY/CfgConsistency.expected delete mode 100644 swift/ql/test/library-tests/dataflow/flowsources/CONSISTENCY/CfgConsistency.expected diff --git a/swift/ql/lib/codeql/swift/controlflow/internal/ControlFlowGraphImpl.qll b/swift/ql/lib/codeql/swift/controlflow/internal/ControlFlowGraphImpl.qll index 5a18c1db76f9..eef4b32f2d9b 100644 --- a/swift/ql/lib/codeql/swift/controlflow/internal/ControlFlowGraphImpl.qll +++ b/swift/ql/lib/codeql/swift/controlflow/internal/ControlFlowGraphImpl.qll @@ -1417,6 +1417,15 @@ module Exprs { } } + /** Control-flow for a `SingleValueStmtExpr`. See the QLDoc for `SingleValueStmtExpr` for the semantics of a `SingleValueStmtExpr`. */ + private class SingleValueStmtExprTree extends AstStandardPostOrderTree { + override SingleValueStmtExpr ast; + + final override ControlFlowElement getChildElement(int i) { + i = 0 and result.asAstNode() = ast.getStmt() + } + } + private class OpaqueValueExprTree extends AstLeafTree { override OpaqueValueExpr ast; } diff --git a/swift/ql/test/extractor-tests/generated/expr/SingleValueStmtExpr/CONSISTENCY/CfgConsistency.expected b/swift/ql/test/extractor-tests/generated/expr/SingleValueStmtExpr/CONSISTENCY/CfgConsistency.expected deleted file mode 100644 index 01748aa8e03e..000000000000 --- a/swift/ql/test/extractor-tests/generated/expr/SingleValueStmtExpr/CONSISTENCY/CfgConsistency.expected +++ /dev/null @@ -1,2 +0,0 @@ -deadEnd -| test.swift:1:8:1:13 | x | diff --git a/swift/ql/test/library-tests/dataflow/flowsources/CONSISTENCY/CfgConsistency.expected b/swift/ql/test/library-tests/dataflow/flowsources/CONSISTENCY/CfgConsistency.expected deleted file mode 100644 index eca8be91c8b9..000000000000 --- a/swift/ql/test/library-tests/dataflow/flowsources/CONSISTENCY/CfgConsistency.expected +++ /dev/null @@ -1,5 +0,0 @@ -deadEnd -| alamofire.swift:469:9:469:9 | stream | -| alamofire.swift:484:9:484:9 | stream | -| alamofire.swift:499:9:499:9 | stream | -| alamofire.swift:514:9:514:9 | stream |