Rust: Add Rust SSA inconsistency infrastructure.

This commit is contained in:
Geoffrey White
2025-04-07 12:07:51 +01:00
parent 810228273b
commit 2c2506c4f8
10 changed files with 44 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
/**
* @name Static single assignment inconsistency counts
* @description Counts the number of static single assignment inconsistencies of each type. This query is intended for internal use.
* @kind diagnostic
* @id rust/diagnostics/ssa-consistency-counts
*/
private import codeql.rust.dataflow.internal.SsaImpl as SsaImpl
// see also `rust/diagnostics/ssa-consistency`, which lists the
// individual inconsistency results.
from string type, int num
where num = SsaImpl::Consistency::getInconsistencyCounts(type)
select type, num

View File

@@ -10,6 +10,7 @@ private import codeql.rust.internal.AstConsistency as AstConsistency
private import codeql.rust.internal.PathResolutionConsistency as PathResolutionConsistency
private import codeql.rust.controlflow.internal.CfgConsistency as CfgConsistency
private import codeql.rust.dataflow.internal.DataFlowConsistency as DataFlowConsistency
private import codeql.rust.dataflow.internal.SsaImpl as SsaImpl
private import codeql.rust.Concepts
private import codeql.rust.Diagnostics
private import codeql.rust.security.SensitiveData
@@ -57,6 +58,13 @@ int getTotalCfgInconsistencies() {
result = sum(string type | | CfgConsistency::getCfgInconsistencyCounts(type))
}
/**
* Gets a count of the total number of SSA inconsistencies in the database.
*/
int getTotalSsaInconsistencies() {
result = sum(string type | | SsaImpl::Consistency::getInconsistencyCounts(type))
}
/**
* Gets a count of the total number of data flow inconsistencies in the database.
*/
@@ -142,6 +150,8 @@ predicate inconsistencyStats(string key, int value) {
or
key = "Inconsistencies - CFG" and value = getTotalCfgInconsistencies()
or
key = "Inconsistencies - SSA" and value = getTotalSsaInconsistencies()
or
key = "Inconsistencies - data flow" and value = getTotalDataFlowInconsistencies()
}