Skip to content

Commit bbd0aa9

Browse files
committed
Rust: Add more missing CFG trees
1 parent 17770af commit bbd0aa9

File tree

98 files changed

+35
-204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+35
-204
lines changed

rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ import CfgImpl
6161
/** Holds if `p` is a trivial pattern that is always guaranteed to match. */
6262
predicate trivialPat(Pat p) { p instanceof WildcardPat or p instanceof IdentPat }
6363

64+
class ArrayExprTree extends StandardPostOrderTree, ArrayExpr {
65+
override AstNode getChildNode(int i) { result = this.getExpr(i) }
66+
}
67+
6468
class AsmExprTree extends LeafTree instanceof AsmExpr { }
6569

6670
class AwaitExprTree extends StandardPostOrderTree instanceof AwaitExpr {
@@ -392,6 +396,9 @@ class ForExprTree extends LoopingExprTree instanceof ForExpr {
392396
}
393397
}
394398

399+
// TODO: replace with expanded macro once the extractor supports it
400+
class MacroExprTree extends LeafTree, MacroExpr { }
401+
395402
class MatchArmTree extends ControlFlowTree instanceof MatchArm {
396403
override predicate propagatesAbnormal(AstNode child) { child = super.getExpr() }
397404

@@ -452,6 +459,10 @@ class MethodCallExprTree extends StandardPostOrderTree instanceof MethodCallExpr
452459
}
453460
}
454461

462+
class NameTree extends LeafTree, Name { }
463+
464+
class NameRefTree extends LeafTree, NameRef { }
465+
455466
class OffsetOfExprTree extends LeafTree instanceof OffsetOfExpr { }
456467

457468
class ParenExprTree extends StandardPostOrderTree, ParenExpr {
@@ -461,6 +472,18 @@ class ParenExprTree extends StandardPostOrderTree, ParenExpr {
461472
// This covers all patterns as they all extend `Pat`
462473
class PatExprTree extends LeafTree instanceof Pat { }
463474

475+
class PathTree extends StandardPostOrderTree, Path {
476+
override AstNode getChildNode(int i) {
477+
i = 0 and result = this.getQualifier()
478+
or
479+
i = 1 and result = this.getPart()
480+
}
481+
}
482+
483+
class PathSegmentTree extends StandardPostOrderTree, PathSegment {
484+
override AstNode getChildNode(int i) { i = 0 and result = this.getNameRef() }
485+
}
486+
464487
class PathExprTree extends LeafTree instanceof PathExpr { }
465488

466489
class PrefixExprTree extends StandardPostOrderTree instanceof PrefixExpr {
@@ -499,6 +522,14 @@ class ReturnExprTree extends PostOrderTree instanceof ReturnExpr {
499522
}
500523
}
501524

525+
class StaticTree extends StandardPostOrderTree, Static {
526+
override AstNode getChildNode(int i) {
527+
i = 0 and result = this.getName()
528+
or
529+
i = 1 and result = this.getBody()
530+
}
531+
}
532+
502533
class TupleExprTree extends StandardPostOrderTree instanceof TupleExpr {
503534
override AstNode getChildNode(int i) { result = super.getField(i) }
504535
}
@@ -507,6 +538,10 @@ class TypeRefTree extends LeafTree instanceof TypeRef { }
507538

508539
class UnderscoreExprTree extends LeafTree instanceof UnderscoreExpr { }
509540

541+
class UseTree_ extends StandardPreOrderTree, Use {
542+
override AstNode getChildNode(int i) { i = 0 and result = this.getUseTree().getPath() }
543+
}
544+
510545
// NOTE: `yield` is a reserved but unused keyword.
511546
class YieldExprTree extends StandardPostOrderTree instanceof YieldExpr {
512547
override AstNode getChildNode(int i) { i = 0 and result = super.getExpr() }

rust/ql/test/extractor-tests/generated/Abi/CONSISTENCY/CfgConsistency.expected

Lines changed: 0 additions & 2 deletions
This file was deleted.

rust/ql/test/extractor-tests/generated/ArgList/CONSISTENCY/CfgConsistency.expected

Lines changed: 0 additions & 2 deletions
This file was deleted.

rust/ql/test/extractor-tests/generated/ArrayExpr/CONSISTENCY/CfgConsistency.expected

Lines changed: 0 additions & 2 deletions
This file was deleted.

rust/ql/test/extractor-tests/generated/ArrayType/CONSISTENCY/CfgConsistency.expected

Lines changed: 0 additions & 2 deletions
This file was deleted.

rust/ql/test/extractor-tests/generated/AssocItemList/CONSISTENCY/CfgConsistency.expected

Lines changed: 0 additions & 2 deletions
This file was deleted.

rust/ql/test/extractor-tests/generated/AssocTypeArg/CONSISTENCY/CfgConsistency.expected

Lines changed: 0 additions & 2 deletions
This file was deleted.

rust/ql/test/extractor-tests/generated/Attr/CONSISTENCY/CfgConsistency.expected

Lines changed: 0 additions & 2 deletions
This file was deleted.

rust/ql/test/extractor-tests/generated/ClosureBinder/CONSISTENCY/CfgConsistency.expected

Lines changed: 0 additions & 2 deletions
This file was deleted.

rust/ql/test/extractor-tests/generated/Const/CONSISTENCY/CfgConsistency.expected

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)