mirror of
https://github.com/github/codeql.git
synced 2026-03-30 12:18:18 +02:00
Merge pull request #21465 from owen-mc/go/small-tweaks
Go: improve detection of type expressions when database is missing some type information
This commit is contained in:
@@ -829,7 +829,7 @@ class ConversionExpr extends CallOrConversionExpr {
|
||||
/**
|
||||
* A function call expression.
|
||||
*
|
||||
* On snapshots with incomplete type information, type conversions may be misclassified
|
||||
* On databases with incomplete type information, type conversions may be misclassified
|
||||
* as function call expressions.
|
||||
*
|
||||
* Examples:
|
||||
@@ -2096,7 +2096,7 @@ class LabelName extends Name {
|
||||
* Holds if `e` is a type expression, as determined by a bottom-up syntactic
|
||||
* analysis starting with `TypeName`s.
|
||||
*
|
||||
* On a snapshot with full type information, this predicate covers all type
|
||||
* On a database with full type information, this predicate covers all type
|
||||
* expressions. However, if type information is missing then not all type names
|
||||
* may be identified as such, so not all type expressions can be determined by
|
||||
* a bottom-up analysis. In such cases, `isTypeExprTopDown` below is useful.
|
||||
@@ -2134,11 +2134,12 @@ private predicate isTypeExprBottomUp(Expr e) {
|
||||
* Holds if `e` must be a type expression because it either occurs in a syntactic
|
||||
* position where a type is expected, or it is part of a larger type expression.
|
||||
*
|
||||
* This predicate is only needed on snapshots for which type information is
|
||||
* incomplete. It is an underapproximation; in cases where it is syntactically ambiguous
|
||||
* whether an expression refers to a type or a value, we conservatively assume that
|
||||
* it may be the latter and so this predicate does not consider the expression to be
|
||||
* a type expression.
|
||||
* This predicate is only needed on databases for which type information is
|
||||
* incomplete - for example, when some dependencies could not be reached during
|
||||
* extraction. It is an underapproximation; in cases where it is syntactically
|
||||
* ambiguous whether an expression refers to a type or a value, we conservatively
|
||||
* assume that it may be the latter and so this predicate does not consider the
|
||||
* expression to be a type expression.
|
||||
*/
|
||||
pragma[nomagic]
|
||||
private predicate isTypeExprTopDown(Expr e) {
|
||||
@@ -2148,20 +2149,12 @@ private predicate isTypeExprTopDown(Expr e) {
|
||||
or
|
||||
e = any(ArrayTypeExpr ae).getElement()
|
||||
or
|
||||
e = any(FieldDecl f).getTypeExpr()
|
||||
or
|
||||
e = any(ParameterDecl pd).getTypeExpr()
|
||||
e = any(FieldBase fb).getTypeExpr()
|
||||
or
|
||||
e = any(TypeParamDecl tpd).getTypeConstraintExpr()
|
||||
or
|
||||
e = any(TypeParamDecl tpd).getNameExpr(_)
|
||||
or
|
||||
e = any(ReceiverDecl rd).getTypeExpr()
|
||||
or
|
||||
e = any(ResultVariableDecl rvd).getTypeExpr()
|
||||
or
|
||||
e = any(MethodSpec md).getTypeExpr()
|
||||
or
|
||||
e = any(MapTypeExpr mt).getKeyTypeExpr()
|
||||
or
|
||||
e = any(MapTypeExpr mt).getValueTypeExpr()
|
||||
|
||||
@@ -294,7 +294,7 @@ module IR {
|
||||
/**
|
||||
* An IR instruction that reads the value of a field.
|
||||
*
|
||||
* On snapshots with incomplete type information, method expressions may sometimes be
|
||||
* On databases with incomplete type information, method expressions may sometimes be
|
||||
* misclassified as field reads.
|
||||
*/
|
||||
class FieldReadInstruction extends ComponentReadInstruction {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @name Classify files
|
||||
* @description This query produces a list of all files in a snapshot that are classified as
|
||||
* @description This query produces a list of all files in a database that are classified as
|
||||
* generated code, test code or vendored-in library code.
|
||||
* @kind file-classifier
|
||||
* @id go/file-classifier
|
||||
|
||||
Reference in New Issue
Block a user