Rust: Move variable consistency check into AstConsistency.qll

This commit is contained in:
Tom Hvitved
2025-10-31 10:16:22 +01:00
parent 5a2467414c
commit 6d64800e85
4 changed files with 12 additions and 18 deletions

View File

@@ -1,8 +0,0 @@
/**
* @name Variable inconsistencies
* @description Lists the variable inconsistencies in the database. This query is intended for internal use.
* @kind table
* @id rust/diagnostics/variable-consistency
*/
import codeql.rust.internal.VariableConsistency

View File

@@ -73,6 +73,14 @@ query predicate multiplePositions(Element parent, int pos1, int pos2, string acc
pos1 != pos2
}
/**
* Holds if `va` is a variable access that refers to multiple variables.
*/
query predicate multipleVariableTargets(VariableAccess va, Variable v1) {
va = v1.getAnAccess() and
strictcount(va.getVariable()) > 1
}
/**
* Gets counts of abstract syntax tree inconsistencies of each type.
*/
@@ -98,4 +106,7 @@ int getAstInconsistencyCounts(string type) {
or
type = "Multiple positions" and
result = count(Element e | multiplePositions(_, _, _, _, e) | e)
or
type = "Multiple variable targets" and
result = count(VariableAccess va | multipleVariableTargets(va, _) | va)
}

View File

@@ -1,10 +0,0 @@
/**
* Provides logic for recognizing variable inconsistencies.
*/
private import rust
query predicate multipleVariableTargets(VariableAccess va, Variable v1) {
va = v1.getAnAccess() and
strictcount(va.getVariable()) > 1
}

View File

@@ -4,4 +4,5 @@
| Multiple positions | 0 |
| Multiple primary QL classes | 0 |
| Multiple toStrings | 0 |
| Multiple variable targets | 0 |
| No location | 0 |