C++: Add expressions with type data to cpp/extraction-information#21544
C++: Add expressions with type data to cpp/extraction-information#21544paldepind merged 2 commits intogithub:mainfrom
cpp/extraction-information#21544Conversation
There was a problem hiding this comment.
Pull request overview
Extends the C/C++ cpp/telemetry/extraction-information metric query to also report statistics about expression type availability for expressions originating from source files, complementing the existing “resolved call target” quality metrics.
Changes:
- Added expression type quality metrics (known vs unknown/erroneous type) to the extraction-information telemetry output.
- Introduced shared “relevant source file” filtering to ensure metrics are restricted to source files with a relative path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| cpp/ql/src/Telemetry/ExtractorInformation.ql | Adds expression-type stats keys/values to the emitted telemetry metrics alongside call-target stats. |
| cpp/ql/src/Telemetry/DatabaseQuality.qll | Defines the expression-type stats computation and refactors source-file scoping via a RelevantFile helper. |
| import cpp | ||
| import codeql.util.ReportStats | ||
|
|
||
| /** A file that is included in the quality statistics. */ |
There was a problem hiding this comment.
The doc comment for RelevantFile is a bit vague given the actual predicate (source file + has relative path). Consider clarifying that this is specifically a source file included in the database-quality metrics (and why exists(getRelativePath()) is part of the criteria).
| /** A file that is included in the quality statistics. */ | |
| /** A source file that is included in the database-quality statistics, that is, | |
| * a file coming from the source code (`fromSource()`) and having a relative | |
| * path in the database (`exists(getRelativePath())`), so that only files | |
| * properly mapped into the database file tree are counted. */ |
| SourceExpr() { this.getFile() instanceof RelevantFile } | ||
| } | ||
|
|
||
| predicate find(SourceExpr e) { not hasGoodType(e) } |
There was a problem hiding this comment.
The purpose of this predicate isn't clear to me, and it's unused.
There was a problem hiding this comment.
Thanks, I used it during testing and forgot to remove it. Fixed in 8cb5380.
Follow up from #21512. Extends the query to also include data for expressions in the source with types. Like before the QL is more or less copy pasted from the similar queries for Rust/Java/C#.
Here's a comparison table for
nmapsimilar to the one in the previous PR. The first row is the existing data, and the three below are fromcpp/telemetry/extraction-information.Again, the new numbers show more clearly the actual changes from BMN and dependency installation. Though at least for this project the call target data seemed more revealing. Two observations:
Perhaps others have some additional insight, but to me it seems that the resolved calls metric is more significant.
Here's the data shown in DCA.