Rust: Add variable consistency query

This commit is contained in:
Tom Hvitved
2025-10-30 21:40:37 +01:00
parent d71f2dee9c
commit 3d7b60a439
3 changed files with 20 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
/**
* @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

@@ -0,0 +1,10 @@
/**
* 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

@@ -0,0 +1,2 @@
| main.rs:367:20:367:20 | x | main.rs:364:9:364:9 | x |
| main.rs:367:20:367:20 | x | main.rs:366:18:366:18 | x |