mirror of
https://github.com/github/codeql.git
synced 2026-04-25 00:35:20 +02:00
Add upgrade and downgrade scripts for latest dbscheme
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
class Expr extends @expr { string toString() { result = "expr" } }
|
||||
class LocalVariableDeclExpr extends @localvariabledeclexpr, Expr { }
|
||||
class InstanceOfExpr extends @instanceofexpr, Expr { }
|
||||
class Type extends @type { string toString() { result = "type" } }
|
||||
class ExprParent extends @exprparent { string toString() { result = "exprparent" } }
|
||||
|
||||
// Initialisers of local variable declarations that occur as the 0th child of an instanceof expression should be reparented to be the 0th child of the instanceof itself,
|
||||
// while the LocalVariableDeclExpr, now without an initialiser, should become its 2nd child.
|
||||
// This implements a reorganisation of the representation of "o instanceof String s", which used to be InstanceOfExpr -0-> LocalVariableDeclExpr --init-> o
|
||||
// \-name-> s
|
||||
// It is now InstanceOfExpr --0-> o
|
||||
// \-2-> LocalVariableDeclExpr -name-> s
|
||||
//
|
||||
// Other children are unaffected.
|
||||
|
||||
ExprParent getParent(Expr e) { exprs(e, _, _, result, _) }
|
||||
|
||||
predicate hasNewParent(Expr e, ExprParent newParent, int newIndex) {
|
||||
if (getParent(e) instanceof LocalVariableDeclExpr and getParent(getParent(e)) instanceof InstanceOfExpr)
|
||||
then (newParent = getParent(getParent(e)) and newIndex = 0) // Initialiser moves to hang directly off the instanceof expression
|
||||
else (
|
||||
if (e instanceof LocalVariableDeclExpr and getParent(e) instanceof InstanceOfExpr)
|
||||
then (newParent = getParent(e) and newIndex = 2) // Variable declaration moves to be the instanceof expression's 2nd child
|
||||
else exprs(e, _, _, newParent, newIndex) // Other expressions unchanged
|
||||
)
|
||||
}
|
||||
|
||||
from Expr e, int kind, Type typeid, ExprParent parent, int index
|
||||
where exprs(e, kind, typeid, _, _) and
|
||||
hasNewParent(e, parent, index)
|
||||
select e, kind, typeid, parent, index
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
description: Add tables for canonical constructors and `case null, default`, plus an expression kind for record patterns. Also alter the representation for instanceof with a binding pattern.
|
||||
compatibility: backwards
|
||||
exprs.rel: run exprs.qlo
|
||||
Reference in New Issue
Block a user