Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions unified/ql/lib/codeql/unified/internal/AnalysisQuality.qll
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ private import codeql.unified.internal.NameBinding
private import codeql.unified.internal.dataflow.DataFlowCall
private import codeql.unified.internal.dataflow.DataFlowCallable
private import codeql.unified.internal.dataflow.CallGraph
private import codeql.unified.internal.typeinference.Type as Type
private import codeql.unified.internal.typeinference.TypeMention

/** Stats about name nodes that static name binding could resolve. */
module StaticNameResolutionStats implements EntityStatsSig {
Expand Down Expand Up @@ -109,6 +111,18 @@ module CallGraphStats implements EntityStatsSig {

module CallGraphStatsReport = EntityReportStats<CallGraphStats>;

module TypeMentionStats implements EntityStatsSig {
class Candidate extends ExprTypeMention {
predicate isOk() { this.getType() = any(Type::Type t | not t instanceof Type::UnknownType) }
}

string getOkText() { result = "resolvable type mentions" }

string getNotOkText() { result = "unresolvable type mentions" }
}

module TypeMentionStatsReport = EntityReportStats<TypeMentionStats>;

/**
* Gets summary statistics about taint.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ private import TypeInferencePlugin as Plugin
private import codeql.unified.internal.StaticNameBinding
private import codeql.unified.internal.ExprPositions

final class TypeMention = TypeMentionImpl;

/** An AST node that mentions a type. */
abstract class TypeMention extends AstNode {
abstract private class TypeMentionImpl extends AstNode {
/**
* Gets the type mentioned at `path`.
*/
Expand All @@ -27,8 +29,10 @@ private Type resolveType(Identifier access) {
)
}

abstract private class ExprTypeMention extends TypeMention, Expr {
ExprTypeMention() { isInTypeContext(this) }
final class ExprTypeMention = ExprTypeMentionImpl;

abstract private class ExprTypeMentionImpl extends TypeMentionImpl, Expr {
ExprTypeMentionImpl() { isInTypeContext(this) }

pragma[nomagic]
abstract TypePath getTypeArgumentPath(int i);
Expand All @@ -37,7 +41,7 @@ abstract private class ExprTypeMention extends TypeMention, Expr {
/**
* A type mention that resolves via an alias (aliases are expanded).
*/
private class AliasExprTypeMention extends ExprTypeMention {
private class AliasExprTypeMention extends ExprTypeMentionImpl {
private TypeAliasDeclaration alias;

AliasExprTypeMention() { alias.getNameNode() = getStaticBindingTargetFromRef(this) }
Expand All @@ -62,7 +66,7 @@ private class AliasExprTypeMention extends ExprTypeMention {
/**
* A type mention that does not resolve via an alias.
*/
private class NonAliasExprTypeMention extends ExprTypeMention {
private class NonAliasExprTypeMention extends ExprTypeMentionImpl {
NonAliasExprTypeMention() { not this instanceof AliasExprTypeMention }

private Type getRootType0() {
Expand Down Expand Up @@ -141,7 +145,7 @@ private class NonAliasExprTypeMention extends ExprTypeMention {
}
}

private class GenericTypeExprTypeMention extends TypeMention, GenericTypeExpr {
private class GenericTypeExprTypeMention extends TypeMentionImpl, GenericTypeExpr {
private ExprTypeMention base;

GenericTypeExprTypeMention() { base = this.getBase() }
Expand All @@ -163,7 +167,7 @@ private class GenericTypeExprTypeMention extends TypeMention, GenericTypeExpr {
}

/** A class declaration mentions itself. */
private class ClassLikeDeclarationTypeMention extends TypeMention, Identifier {
private class ClassLikeDeclarationTypeMention extends TypeMentionImpl, Identifier {
private ClassLikeDeclaration c;

ClassLikeDeclarationTypeMention() { this = c.getNameNode() }
Expand Down
3 changes: 2 additions & 1 deletion unified/ql/src/diagnostic/ExtractorInformation.ql
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ where
numberOfLinesOfCodeByExtension(key, value) or
StaticNameResolutionStatsReport::keyValuePair(key, value) or
FilesCoveredByModuleManifestStatsReport::keyValuePair(key, value) or
CallGraphStatsReport::keyValuePair(key, value)
CallGraphStatsReport::keyValuePair(key, value) or
TypeMentionStatsReport::keyValuePair(key, value)
) and
/* Infinity */
value != 1.0 / 0.0 and
Expand Down
Loading