Skip to content

Commit

Permalink
Rust: CFG classes are in expression module iff they correspond to exp…
Browse files Browse the repository at this point in the history
…ressions
  • Loading branch information
paldepind committed Nov 4, 2024
1 parent bde517f commit 633bac6
Showing 1 changed file with 33 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,8 @@ class ParamTree extends StandardPostOrderTree, Param {
override AstNode getChildNode(int i) { i = 0 and result = this.getPat() }
}

class FormatArgsExprTree extends StandardPostOrderTree, FormatArgsExpr {
override AstNode getChildNode(int i) {
i = -1 and result = this.getTemplate()
or
result = this.getArg(i).getExpr()
or
result =
any(FormatTemplateVariableAccess v, Format f, int index, int kind |
f = this.getFormat(index) and
(
v.getArgument() = f.getArgumentRef() and kind = 0
or
v.getArgument() = f.getWidthArgument() and kind = 1
or
v.getArgument() = f.getPrecisionArgument() and kind = 2
) and
i = this.getNumberOfArgs() + index * 3 + kind
|
v
)
}
class ExprStmtTree extends StandardPreOrderTree instanceof ExprStmt {
override AstNode getChildNode(int i) { i = 0 and result = super.getExpr() }
}

class FormatTemplateVariableAccessTree extends LeafTree, FormatTemplateVariableAccess { }
Expand Down Expand Up @@ -219,22 +200,6 @@ class NameTree extends LeafTree, Name { }

class NameRefTree extends LeafTree, NameRef { }

class OffsetOfExprTree extends LeafTree instanceof OffsetOfExpr { }

class ParenExprTree extends ControlFlowTree, ParenExpr {
private ControlFlowTree expr;

ParenExprTree() { expr = super.getExpr() }

override predicate propagatesAbnormal(AstNode child) { expr.propagatesAbnormal(child) }

override predicate first(AstNode first) { expr.first(first) }

override predicate last(AstNode last, Completion c) { expr.last(last, c) }

override predicate succ(AstNode pred, AstNode succ, Completion c) { none() }
}

class TypeRefTree extends LeafTree instanceof TypeRef { }

/**
Expand Down Expand Up @@ -360,10 +325,6 @@ module ExprTrees {
}
}

class ExprStmtTree extends StandardPreOrderTree instanceof ExprStmt {
override AstNode getChildNode(int i) { i = 0 and result = super.getExpr() }
}

class FieldExprTree extends StandardPostOrderTree instanceof FieldExpr {
override AstNode getChildNode(int i) { i = 0 and result = super.getExpr() }
}
Expand Down Expand Up @@ -409,6 +370,21 @@ module ExprTrees {
i = -1 and result = this.getTemplate()
or
result = this.getArg(i).getExpr()
or
result =
any(FormatTemplateVariableAccess v, Format f, int index, int kind |
f = this.getFormat(index) and
(
v.getArgument() = f.getArgumentRef() and kind = 0
or
v.getArgument() = f.getWidthArgument() and kind = 1
or
v.getArgument() = f.getPrecisionArgument() and kind = 2
) and
i = this.getNumberOfArgs() + index * 3 + kind
|
v
)
}
}

Expand Down Expand Up @@ -566,6 +542,22 @@ module ExprTrees {
}
}

class OffsetOfExprTree extends LeafTree instanceof OffsetOfExpr { }

class ParenExprTree extends ControlFlowTree, ParenExpr {
private ControlFlowTree expr;

ParenExprTree() { expr = super.getExpr() }

override predicate propagatesAbnormal(AstNode child) { expr.propagatesAbnormal(child) }

override predicate first(AstNode first) { expr.first(first) }

override predicate last(AstNode last, Completion c) { expr.last(last, c) }

override predicate succ(AstNode pred, AstNode succ, Completion c) { none() }
}

class PathExprTree extends LeafTree instanceof PathExpr { }

class PrefixExprTree extends StandardPostOrderTree instanceof PrefixExpr {
Expand Down

0 comments on commit 633bac6

Please sign in to comment.