Swift: autoformat for CFG library

This commit is contained in:
Robert Marsh
2024-01-05 21:28:07 +00:00
parent 86f59a1c13
commit 2d457e17d6
5 changed files with 18 additions and 17 deletions

View File

@@ -133,7 +133,9 @@ private module Cached {
private predicate predBB(BasicBlock succ, BasicBlock pred) { succBB(pred, succ) }
/** Holds if `bb` is an exit basic block that represents normal exit. */
private predicate normalExitBB(BasicBlock bb) { bb.getANode().(Impl::AnnotatedExitNode).isNormal() }
private predicate normalExitBB(BasicBlock bb) {
bb.getANode().(Impl::AnnotatedExitNode).isNormal()
}
/** Holds if `dom` is an immediate post-dominator of `bb`. */
cached
@@ -167,7 +169,9 @@ private predicate entryBB(BasicBlock bb) { bb.getFirstNode() instanceof EntryNod
class EntryBasicBlock extends BasicBlock {
EntryBasicBlock() { entryBB(this) }
override CfgScope getScope() { this.getFirstNode() = any(EntryNode node | node.getScope() = result) }
override CfgScope getScope() {
this.getFirstNode() = any(EntryNode node | node.getScope() = result)
}
}
/**

View File

@@ -63,9 +63,7 @@ class PatternCfgNode extends CfgNode {
class PropertyGetterCfgNode extends CfgNode {
PropertyGetterElement n;
PropertyGetterCfgNode() {
n = this.getAstNode()
}
PropertyGetterCfgNode() { n = this.getAstNode() }
Expr getRef() { result = n.getRef() }
@@ -78,9 +76,8 @@ class PropertyGetterCfgNode extends CfgNode {
class PropertySetterCfgNode extends CfgNode {
PropertySetterElement n;
PropertySetterCfgNode() {
n = this.getAstNode()
}
PropertySetterCfgNode() { n = this.getAstNode() }
AssignExpr getAssignExpr() { result = n.getAssignExpr() }
CfgNode getBase() { result.getAst() = n.getBase() }
@@ -93,9 +90,8 @@ class PropertySetterCfgNode extends CfgNode {
class PropertyObserverCfgNode extends CfgNode {
PropertyObserverElement n;
PropertyObserverCfgNode() {
n = this.getAstNode()
}
PropertyObserverCfgNode() { n = this.getAstNode() }
AssignExpr getAssignExpr() { result = n.getAssignExpr() }
CfgNode getBase() { result.getAst() = n.getBase() }
@@ -147,4 +143,4 @@ class EntryNode = Impl::EntryNode;
class ExitNode = Impl::ExitNode;
class AnnotatedExitNode = Impl::AnnotatedExitNode;
class AnnotatedExitNode = Impl::AnnotatedExitNode;

View File

@@ -28,7 +28,6 @@ class CfgScope extends Scope instanceof CfgScope::Range_ {
* Only nodes that can be reached from an entry point are included in the CFG.
*/
class ControlFlowNode extends Node {
/** Gets the AST node that this node corresponds to, if any. */
ControlFlowElement getNode() { none() }

View File

@@ -1,10 +1,11 @@
/**
* Provides the `CfgImpl` module that is used to construct the basic successor relation on control
* flow elements, and the `CfgInput` module that is used to construct `CgfImpl`.
*
*
* See `ControlFlowGraphImpl.qll` for the auxiliary classes and predicates that map AST elements to
* control flow elements and sequence their children.
*/
import swift
import codeql.controlflow.Cfg
import codeql.util.Unit
@@ -52,7 +53,7 @@ module CfgInput implements InputSig<Location> {
predicate isAbnormalExitType(SuccessorType t) {
t instanceof Cfg::SuccessorTypes::ExceptionSuccessor
}
/** Hold if `t` represents a conditional successor type. */
predicate successorTypeIsCondition(SuccessorType t) {
t instanceof Cfg::SuccessorTypes::BooleanSuccessor or
@@ -73,4 +74,4 @@ module CfgInput implements InputSig<Location> {
}
}
module CfgImpl = Make<Location, CfgInput>;
module CfgImpl = Make<Location, CfgInput>;

View File

@@ -46,7 +46,8 @@ private module ConditionalCompletionSplitting {
override string toString() { result = "ConditionalCompletion" }
}
private class ConditionalCompletionSplitImpl extends SplitImpl instanceof ConditionalCompletionSplit {
private class ConditionalCompletionSplitImpl extends SplitImpl instanceof ConditionalCompletionSplit
{
override ConditionalCompletionSplitKind getKind() { any() }
override predicate hasEntry(ControlFlowElement pred, ControlFlowElement succ, Completion c) {