mirror of
https://github.com/github/codeql.git
synced 2026-03-31 12:48:17 +02:00
C++: Add expressions with type data to cpp/extraction-information
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
import cpp
|
||||
import codeql.util.ReportStats
|
||||
|
||||
/** A file that is included in the quality statistics. */
|
||||
private class RelevantFile extends File {
|
||||
RelevantFile() { this.fromSource() and exists(this.getRelativePath()) }
|
||||
}
|
||||
|
||||
module CallTargetStats implements StatsSig {
|
||||
private class RelevantCall extends Call {
|
||||
RelevantCall() { this.getFile() = any(File f | f.fromSource() and exists(f.getRelativePath())) }
|
||||
RelevantCall() { this.getFile() instanceof RelevantFile }
|
||||
}
|
||||
|
||||
// We assume that calls with an implicit target are calls that could not be
|
||||
@@ -22,4 +27,24 @@ module CallTargetStats implements StatsSig {
|
||||
string getNotOkText() { result = "calls with missing call target" }
|
||||
}
|
||||
|
||||
private class SourceExpr extends Expr {
|
||||
SourceExpr() { this.getFile() instanceof RelevantFile }
|
||||
}
|
||||
|
||||
predicate find(SourceExpr e) { not hasGoodType(e) }
|
||||
|
||||
private predicate hasGoodType(Expr e) { not e.getType() instanceof ErroneousType }
|
||||
|
||||
module ExprTypeStats implements StatsSig {
|
||||
int getNumberOfOk() { result = count(SourceExpr e | hasGoodType(e)) }
|
||||
|
||||
int getNumberOfNotOk() { result = count(SourceExpr e | not hasGoodType(e)) }
|
||||
|
||||
string getOkText() { result = "expressions with known type" }
|
||||
|
||||
string getNotOkText() { result = "expressions with unknown type" }
|
||||
}
|
||||
|
||||
module CallTargetStatsReport = ReportStats<CallTargetStats>;
|
||||
|
||||
module ExprTypeStatsReport = ReportStats<ExprTypeStats>;
|
||||
|
||||
@@ -14,7 +14,10 @@ where
|
||||
(
|
||||
CallTargetStatsReport::numberOfOk(key, value) or
|
||||
CallTargetStatsReport::numberOfNotOk(key, value) or
|
||||
CallTargetStatsReport::percentageOfOk(key, value)
|
||||
CallTargetStatsReport::percentageOfOk(key, value) or
|
||||
ExprTypeStatsReport::numberOfOk(key, value) or
|
||||
ExprTypeStatsReport::numberOfNotOk(key, value) or
|
||||
ExprTypeStatsReport::percentageOfOk(key, value)
|
||||
) and
|
||||
/* Infinity */
|
||||
value != 1.0 / 0.0 and
|
||||
|
||||
Reference in New Issue
Block a user