@@ -45,3 +45,50 @@ query predicate deadEnd(CfgImpl::Node node) {
4545 Consistency:: deadEnd ( node ) and
4646 not letElsePanic ( node .getAstNode ( ) )
4747}
48+
49+ /**
50+ * Gets counts of control flow graph inconsistencies of each type.
51+ */
52+ int getCfgInconsistencyCounts ( string type ) {
53+ // total results from all the CFG consistency query predicates in:
54+ // - `codeql.rust.controlflow.internal.CfgConsistency` (this file)
55+ // - `shared.controlflow.codeql.controlflow.Cfg`
56+ type = "Non-unique set representation" and
57+ result = count ( CfgImpl:: Splits ss | Consistency:: nonUniqueSetRepresentation ( ss , _) | ss )
58+ or
59+ type = "Splitting invariant 2" and
60+ result = count ( AstNode n | Consistency:: breakInvariant2 ( n , _, _, _, _, _) | n )
61+ or
62+ type = "Splitting invariant 3" and
63+ result = count ( AstNode n | Consistency:: breakInvariant3 ( n , _, _, _, _, _) | n )
64+ or
65+ type = "Splitting invariant 4" and
66+ result = count ( AstNode n | Consistency:: breakInvariant4 ( n , _, _, _, _, _) | n )
67+ or
68+ type = "Splitting invariant 5" and
69+ result = count ( AstNode n | Consistency:: breakInvariant5 ( n , _, _, _, _, _) | n )
70+ or
71+ type = "Multiple successors of the same type" and
72+ result = count ( CfgNode n | Consistency:: multipleSuccessors ( n , _, _) | n )
73+ or
74+ type = "Simple and normal successors" and
75+ result = count ( CfgNode n | Consistency:: simpleAndNormalSuccessors ( n , _, _, _, _) | n )
76+ or
77+ type = "Dead end" and
78+ result = count ( CfgNode n | Consistency:: deadEnd ( n ) | n )
79+ or
80+ type = "Non-unique split kind" and
81+ result = count ( CfgImpl:: SplitImpl si | Consistency:: nonUniqueSplitKind ( si , _) | si )
82+ or
83+ type = "Non-unique list order" and
84+ result = count ( CfgImpl:: SplitKind sk | Consistency:: nonUniqueListOrder ( sk , _) | sk )
85+ or
86+ type = "Multiple toStrings" and
87+ result = count ( CfgNode n | Consistency:: multipleToString ( n , _) | n )
88+ or
89+ type = "CFG scope lacks initial AST node" and
90+ result = count ( CfgScope s | Consistency:: scopeNoFirst ( s ) | s )
91+ or
92+ type = "Non-PostOrderTree Expr node" and
93+ result = count ( Expr e | nonPostOrderExpr ( e , _) | e )
94+ }
0 commit comments