mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
Kotlin: Pull Kotlin type for localvars out into its own table
This commit is contained in:
@@ -2,6 +2,7 @@ import java
|
||||
|
||||
predicate badKotlinType(Element e, int i) {
|
||||
e = any(Expr expr | count(expr.getKotlinType()) = i) or
|
||||
e = any(LocalVariableDecl lvd | count(lvd.getKotlinType()) = i) or
|
||||
e = any(Parameter p | count(p.getKotlinType()) = i) or
|
||||
e = any(Constructor c | count(c.getReturnKotlinType()) = i) or
|
||||
e = any(Method m | count(m.getReturnKotlinType()) = i) or
|
||||
|
||||
@@ -406,7 +406,7 @@ fields(
|
||||
fieldsKotlinType(
|
||||
unique int id: @field ref,
|
||||
int kttypeid: @kt_type ref
|
||||
)
|
||||
);
|
||||
|
||||
constrs(
|
||||
unique int id: @constructor,
|
||||
@@ -420,7 +420,7 @@ constrs(
|
||||
constrsKotlinType(
|
||||
unique int id: @constructor ref,
|
||||
int kttypeid: @kt_type ref
|
||||
)
|
||||
);
|
||||
|
||||
methods(
|
||||
unique int id: @method,
|
||||
@@ -434,7 +434,7 @@ methods(
|
||||
methodsKotlinType(
|
||||
unique int id: @method ref,
|
||||
int kttypeid: @kt_type ref
|
||||
)
|
||||
);
|
||||
|
||||
#keyset[parentid,pos]
|
||||
params(
|
||||
@@ -448,7 +448,7 @@ params(
|
||||
paramsKotlinType(
|
||||
unique int id: @param ref,
|
||||
int kttypeid: @kt_type ref
|
||||
)
|
||||
);
|
||||
|
||||
paramName(
|
||||
unique int id: @param ref,
|
||||
@@ -644,7 +644,7 @@ exprs(
|
||||
exprsKotlinType(
|
||||
unique int id: @expr ref,
|
||||
int kttypeid: @kt_type ref
|
||||
)
|
||||
);
|
||||
|
||||
callableEnclosingExpr(
|
||||
unique int id: @expr ref,
|
||||
@@ -856,10 +856,14 @@ localvars(
|
||||
unique int id: @localvar,
|
||||
string nodeName: string ref,
|
||||
int typeid: @type ref,
|
||||
int kttypeid: @kt_type ref,
|
||||
int parentid: @localvariabledeclexpr ref
|
||||
);
|
||||
|
||||
localvarsKotlinType(
|
||||
unique int id: @localvar ref,
|
||||
int kttypeid: @kt_type ref
|
||||
);
|
||||
|
||||
@namedexprorstmt = @breakstmt
|
||||
| @continuestmt
|
||||
| @labeledstmt
|
||||
|
||||
@@ -34,7 +34,7 @@ predicate hasName(Element e, string name) {
|
||||
name = "p" + pos
|
||||
)
|
||||
or
|
||||
localvars(e, name, _, _, _)
|
||||
localvars(e, name, _, _)
|
||||
or
|
||||
typeVars(e, name, _, _, _)
|
||||
or
|
||||
|
||||
@@ -1529,7 +1529,7 @@ class LocalVariableDeclExpr extends Expr, @localvariabledeclexpr {
|
||||
VarAccess getAnAccess() { variableBinding(result, this.getVariable()) }
|
||||
|
||||
/** Gets the local variable declared by this local variable declaration expression. */
|
||||
LocalVariableDecl getVariable() { localvars(result, _, _, _, this) }
|
||||
LocalVariableDecl getVariable() { localvars(result, _, _, this) }
|
||||
|
||||
/** Gets the type access of this local variable declaration expression. */
|
||||
Expr getTypeAccess() {
|
||||
|
||||
@@ -38,16 +38,16 @@ class LocalScopeVariable extends Variable, @localscopevariable {
|
||||
/** A local variable declaration */
|
||||
class LocalVariableDecl extends @localvar, LocalScopeVariable {
|
||||
/** Gets the type of this local variable. */
|
||||
override Type getType() { localvars(this, _, result, _, _) }
|
||||
override Type getType() { localvars(this, _, result, _) }
|
||||
|
||||
/** Gets the Kotlin type of this local variable. */
|
||||
override KotlinType getKotlinType() { localvars(this, _, _, result, _) }
|
||||
override KotlinType getKotlinType() { localvarsKotlinType(this, result) }
|
||||
|
||||
/** Gets the expression declaring this variable. */
|
||||
LocalVariableDeclExpr getDeclExpr() { localvars(this, _, _, _, result) }
|
||||
LocalVariableDeclExpr getDeclExpr() { localvars(this, _, _, result) }
|
||||
|
||||
/** Gets the parent of this declaration. */
|
||||
Expr getParent() { localvars(this, _, _, _, result) }
|
||||
Expr getParent() { localvars(this, _, _, result) }
|
||||
|
||||
/** Gets the callable in which this declaration occurs. */
|
||||
override Callable getCallable() { result = this.getParent().getEnclosingCallable() }
|
||||
|
||||
Reference in New Issue
Block a user