Java: Sync files and update other relavant files related to the new naming of shift.

This commit is contained in:
Michael Nebel
2023-01-10 09:42:20 +01:00
parent 49a87e152a
commit 5c466f3319
14 changed files with 91 additions and 73 deletions

View File

@@ -366,11 +366,11 @@ class CompileTimeConstantExpr extends Expr {
or
b instanceof SubExpr and result = v1 - v2
or
b instanceof LShiftExpr and result = v1.bitShiftLeft(v2)
b instanceof LeftShiftExpr and result = v1.bitShiftLeft(v2)
or
b instanceof RShiftExpr and result = v1.bitShiftRightSigned(v2)
b instanceof RightShiftExpr and result = v1.bitShiftRightSigned(v2)
or
b instanceof URShiftExpr and result = v1.bitShiftRight(v2)
b instanceof UnsignedRightShiftExpr and result = v1.bitShiftRight(v2)
or
b instanceof AndBitwiseExpr and result = v1.bitAnd(v2)
or
@@ -623,26 +623,35 @@ class AssignXorExpr extends AssignOp, @assignxorexpr {
}
/** A compound assignment expression using the `<<=` operator. */
class AssignLShiftExpr extends AssignOp, @assignlshiftexpr {
class AssignLeftShiftExpr extends AssignOp, @assignlshiftexpr {
override string getOp() { result = "<<=" }
override string getAPrimaryQlClass() { result = "AssignLShiftExpr" }
override string getAPrimaryQlClass() { result = "AssignLeftShiftExpr" }
}
/** DEPRECATED: Alias for AssignLeftShiftExpr. */
deprecated class AssignLShiftExpr = AssignLeftShiftExpr;
/** A compound assignment expression using the `>>=` operator. */
class AssignRShiftExpr extends AssignOp, @assignrshiftexpr {
class AssignRightShiftExpr extends AssignOp, @assignrshiftexpr {
override string getOp() { result = ">>=" }
override string getAPrimaryQlClass() { result = "AssignRShiftExpr" }
override string getAPrimaryQlClass() { result = "AssignRightShiftExpr" }
}
/** DEPRECATED: Alias for AssignRightShiftExpr. */
deprecated class AssignRShiftExpr = AssignRightShiftExpr;
/** A compound assignment expression using the `>>>=` operator. */
class AssignURShiftExpr extends AssignOp, @assignurshiftexpr {
class AssignUnsignedRightShiftExpr extends AssignOp, @assignurshiftexpr {
override string getOp() { result = ">>>=" }
override string getAPrimaryQlClass() { result = "AssignURShiftExpr" }
override string getAPrimaryQlClass() { result = "AssignUnsignedRightShiftExpr" }
}
/** DEPRECATED: Alias for AssignUnsignedRightShiftExpr. */
deprecated class AssignURShiftExpr = AssignUnsignedRightShiftExpr;
/** A common super-class to represent constant literals. */
class Literal extends Expr, @literal {
/**
@@ -904,26 +913,35 @@ class SubExpr extends BinaryExpr, @subexpr {
}
/** A binary expression using the `<<` operator. */
class LShiftExpr extends BinaryExpr, @lshiftexpr {
class LeftShiftExpr extends BinaryExpr, @lshiftexpr {
override string getOp() { result = " << " }
override string getAPrimaryQlClass() { result = "LShiftExpr" }
override string getAPrimaryQlClass() { result = "LeftShiftExpr" }
}
/** DEPRECATED: Alias for LeftShiftExpr. */
deprecated class LShiftExpr = LeftShiftExpr;
/** A binary expression using the `>>` operator. */
class RShiftExpr extends BinaryExpr, @rshiftexpr {
class RightShiftExpr extends BinaryExpr, @rshiftexpr {
override string getOp() { result = " >> " }
override string getAPrimaryQlClass() { result = "RShiftExpr" }
override string getAPrimaryQlClass() { result = "RightShiftExpr" }
}
/** DEPRECATED: Alias for RightShiftExpr. */
deprecated class RShiftExpr = RightShiftExpr;
/** A binary expression using the `>>>` operator. */
class URShiftExpr extends BinaryExpr, @urshiftexpr {
class UnsignedRightShiftExpr extends BinaryExpr, @urshiftexpr {
override string getOp() { result = " >>> " }
override string getAPrimaryQlClass() { result = "URShiftExpr" }
override string getAPrimaryQlClass() { result = "UnsignedRightShiftExpr" }
}
/** DEPRECATED: Alias for UnsignedRightShiftExpr. */
deprecated class URShiftExpr = UnsignedRightShiftExpr;
/** A binary expression using the `&` operator. */
class AndBitwiseExpr extends BinaryExpr, @andbitexpr {
override string getOp() { result = " & " }

View File

@@ -105,7 +105,7 @@ private predicate evenlyDivisibleExpr(Expr e, int factor) {
exists(ConstantIntegerExpr c, int k | k = c.getIntValue() |
e.(MulExpr).getAnOperand() = c and factor = k.abs() and factor >= 2
or
e.(LShiftExpr).getRhs() = c and factor = 2.pow(k) and k > 0
e.(LeftShiftExpr).getRhs() = c and factor = 2.pow(k) and k > 0
or
e.(BitwiseAndExpr).getAnOperand() = c and factor = max(int f | andmaskFactor(k, f))
)

View File

@@ -528,11 +528,11 @@ private predicate boundFlowStepMul(Expr e2, Expr e1, int factor) {
or
exists(AssignMulExpr e | e = e2 and e.getDest() = c and e.getRhs() = e1 and factor = k)
or
exists(LShiftExpr e |
exists(LeftShiftExpr e |
e = e2 and e.getLeftOperand() = e1 and e.getRightOperand() = c and factor = 2.pow(k)
)
or
exists(AssignLShiftExpr e |
exists(AssignLeftShiftExpr e |
e = e2 and e.getDest() = e1 and e.getRhs() = c and factor = 2.pow(k)
)
)
@@ -552,19 +552,19 @@ private predicate boundFlowStepDiv(Expr e2, Expr e1, int factor) {
or
exists(AssignDivExpr e | e = e2 and e.getDest() = e1 and e.getRhs() = c and factor = k)
or
exists(RShiftExpr e |
exists(RightShiftExpr e |
e = e2 and e.getLeftOperand() = e1 and e.getRightOperand() = c and factor = 2.pow(k)
)
or
exists(AssignRShiftExpr e |
exists(AssignRightShiftExpr e |
e = e2 and e.getDest() = e1 and e.getRhs() = c and factor = 2.pow(k)
)
or
exists(URShiftExpr e |
exists(UnsignedRightShiftExpr e |
e = e2 and e.getLeftOperand() = e1 and e.getRightOperand() = c and factor = 2.pow(k)
)
or
exists(AssignURShiftExpr e |
exists(AssignUnsignedRightShiftExpr e |
e = e2 and e.getDest() = e1 and e.getRhs() = c and factor = 2.pow(k)
)
)

View File

@@ -72,13 +72,13 @@ module Private {
}
/** A left shift or an assign-lshift expression. */
class LShiftExpr extends J::Expr {
LShiftExpr() { this instanceof J::LShiftExpr or this instanceof J::AssignLShiftExpr }
class LeftShiftExpr extends J::Expr {
LeftShiftExpr() { this instanceof J::LeftShiftExpr or this instanceof J::AssignLeftShiftExpr }
/** Gets the RHS operand of this shift. */
Expr getRhs() {
result = this.(J::LShiftExpr).getRightOperand() or
result = this.(J::AssignLShiftExpr).getRhs()
result = this.(J::LeftShiftExpr).getRightOperand() or
result = this.(J::AssignLeftShiftExpr).getRhs()
}
}

View File

@@ -18,9 +18,9 @@ newtype TBinarySignOperation =
TBitAndOp() or
TBitOrOp() or
TBitXorOp() or
TLShiftOp() or
TRShiftOp() or
TURShiftOp()
TLeftShiftOp() or
TRightShiftOp() or
TUnsignedRightShiftOp()
/** Class representing expression signs (+, -, 0). */
class Sign extends TSign {
@@ -271,10 +271,10 @@ class Sign extends TSign {
or
op = TBitXorOp() and result = bitxor(s)
or
op = TLShiftOp() and result = lshift(s)
op = TLeftShiftOp() and result = lshift(s)
or
op = TRShiftOp() and result = rshift(s)
op = TRightShiftOp() and result = rshift(s)
or
op = TURShiftOp() and result = urshift(s)
op = TUnsignedRightShiftOp() and result = urshift(s)
}
}

View File

@@ -102,12 +102,12 @@ module Private {
this instanceof J::AssignOrExpr or
this instanceof J::XorBitwiseExpr or
this instanceof J::AssignXorExpr or
this instanceof J::LShiftExpr or
this instanceof J::AssignLShiftExpr or
this instanceof J::RShiftExpr or
this instanceof J::AssignRShiftExpr or
this instanceof J::URShiftExpr or
this instanceof J::AssignURShiftExpr
this instanceof J::LeftShiftExpr or
this instanceof J::AssignLeftShiftExpr or
this instanceof J::RightShiftExpr or
this instanceof J::AssignRightShiftExpr or
this instanceof J::UnsignedRightShiftExpr or
this instanceof J::AssignUnsignedRightShiftExpr
}
/** Returns the operation representing this expression. */
@@ -144,17 +144,17 @@ module Private {
or
this instanceof J::AssignXorExpr and result = TBitXorOp()
or
this instanceof J::LShiftExpr and result = TLShiftOp()
this instanceof J::LeftShiftExpr and result = TLeftShiftOp()
or
this instanceof J::AssignLShiftExpr and result = TLShiftOp()
this instanceof J::AssignLeftShiftExpr and result = TLeftShiftOp()
or
this instanceof J::RShiftExpr and result = TRShiftOp()
this instanceof J::RightShiftExpr and result = TRightShiftOp()
or
this instanceof J::AssignRShiftExpr and result = TRShiftOp()
this instanceof J::AssignRightShiftExpr and result = TRightShiftOp()
or
this instanceof J::URShiftExpr and result = TURShiftOp()
this instanceof J::UnsignedRightShiftExpr and result = TUnsignedRightShiftOp()
or
this instanceof J::AssignURShiftExpr and result = TURShiftOp()
this instanceof J::AssignUnsignedRightShiftExpr and result = TUnsignedRightShiftOp()
}
Expr getLeftOperand() {

View File

@@ -14,7 +14,7 @@ int integralTypeWidth(IntegralType t) {
if t.hasName("long") or t.hasName("Long") then result = 64 else result = 32
}
from LShiftExpr shift, IntegralType t, int v, string typname, int width
from LeftShiftExpr shift, IntegralType t, int v, string typname, int width
where
shift.getLeftOperand().getType() = t and
shift.getRightOperand().(CompileTimeConstantExpr).getIntValue() = v and

View File

@@ -33,9 +33,9 @@ class ArithmeticExpr extends BinaryExpr {
*/
class ShiftExpr extends BinaryExpr {
ShiftExpr() {
this instanceof LShiftExpr or
this instanceof RShiftExpr or
this instanceof URShiftExpr
this instanceof LeftShiftExpr or
this instanceof RightShiftExpr or
this instanceof UnsignedRightShiftExpr
}
}

View File

@@ -99,7 +99,7 @@ Expr overFlowCand() {
|
bin instanceof AddExpr or
bin instanceof MulExpr or
bin instanceof LShiftExpr
bin instanceof LeftShiftExpr
)
or
exists(AssignOp op |
@@ -109,7 +109,7 @@ Expr overFlowCand() {
|
op instanceof AssignAddExpr or
op instanceof AssignMulExpr or
op instanceof AssignLShiftExpr
op instanceof AssignLeftShiftExpr
)
or
exists(AddExpr add, CompileTimeConstantExpr c |

View File

@@ -153,9 +153,9 @@ predicate upcastToWiderType(Expr e) {
/** Holds if the result of `exp` has certain bits filtered by a bitwise and. */
private predicate inBitwiseAnd(Expr exp) {
exists(AndBitwiseExpr a | a.getAnOperand() = exp) or
inBitwiseAnd(exp.(LShiftExpr).getAnOperand()) or
inBitwiseAnd(exp.(RShiftExpr).getAnOperand()) or
inBitwiseAnd(exp.(URShiftExpr).getAnOperand())
inBitwiseAnd(exp.(LeftShiftExpr).getAnOperand()) or
inBitwiseAnd(exp.(RightShiftExpr).getAnOperand()) or
inBitwiseAnd(exp.(UnsignedRightShiftExpr).getAnOperand())
}
/** Holds if overflow/underflow is irrelevant for this expression. */

View File

@@ -16,10 +16,10 @@ class NumericNarrowingCastExpr extends CastExpr {
class RightShiftOp extends Expr {
RightShiftOp() {
this instanceof RShiftExpr or
this instanceof URShiftExpr or
this instanceof AssignRShiftExpr or
this instanceof AssignURShiftExpr
this instanceof RightShiftExpr or
this instanceof UnsignedRightShiftExpr or
this instanceof AssignRightShiftExpr or
this instanceof AssignUnsignedRightShiftExpr
}
private Expr getLhs() {

View File

@@ -1944,17 +1944,17 @@ exprs.kt:
# 15| 1: [VarAccess] y
# 16| 5: [LocalVariableDeclStmt] var ...;
# 16| 1: [LocalVariableDeclExpr] i6
# 16| 0: [LShiftExpr] ... << ...
# 16| 0: [LeftShiftExpr] ... << ...
# 16| 0: [VarAccess] x
# 16| 1: [VarAccess] y
# 17| 6: [LocalVariableDeclStmt] var ...;
# 17| 1: [LocalVariableDeclExpr] i7
# 17| 0: [RShiftExpr] ... >> ...
# 17| 0: [RightShiftExpr] ... >> ...
# 17| 0: [VarAccess] x
# 17| 1: [VarAccess] y
# 18| 7: [LocalVariableDeclStmt] var ...;
# 18| 1: [LocalVariableDeclExpr] i8
# 18| 0: [URShiftExpr] ... >>> ...
# 18| 0: [UnsignedRightShiftExpr] ... >>> ...
# 18| 0: [VarAccess] x
# 18| 1: [VarAccess] y
# 19| 8: [LocalVariableDeclStmt] var ...;
@@ -2236,17 +2236,17 @@ exprs.kt:
# 72| 1: [VarAccess] ly
# 73| 59: [LocalVariableDeclStmt] var ...;
# 73| 1: [LocalVariableDeclExpr] l6
# 73| 0: [LShiftExpr] ... << ...
# 73| 0: [LeftShiftExpr] ... << ...
# 73| 0: [VarAccess] lx
# 73| 1: [VarAccess] y
# 74| 60: [LocalVariableDeclStmt] var ...;
# 74| 1: [LocalVariableDeclExpr] l7
# 74| 0: [RShiftExpr] ... >> ...
# 74| 0: [RightShiftExpr] ... >> ...
# 74| 0: [VarAccess] lx
# 74| 1: [VarAccess] y
# 75| 61: [LocalVariableDeclStmt] var ...;
# 75| 1: [LocalVariableDeclExpr] l8
# 75| 0: [URShiftExpr] ... >>> ...
# 75| 0: [UnsignedRightShiftExpr] ... >>> ...
# 75| 0: [VarAccess] lx
# 75| 1: [VarAccess] y
# 76| 62: [LocalVariableDeclStmt] var ...;

View File

@@ -924,15 +924,15 @@
| exprs.kt:15:18:15:18 | y | exprs.kt:4:1:142:1 | topLevelMethod | VarAccess |
| exprs.kt:16:9:16:10 | i6 | exprs.kt:4:1:142:1 | topLevelMethod | LocalVariableDeclExpr |
| exprs.kt:16:14:16:14 | x | exprs.kt:4:1:142:1 | topLevelMethod | VarAccess |
| exprs.kt:16:14:16:20 | ... << ... | exprs.kt:4:1:142:1 | topLevelMethod | LShiftExpr |
| exprs.kt:16:14:16:20 | ... << ... | exprs.kt:4:1:142:1 | topLevelMethod | LeftShiftExpr |
| exprs.kt:16:20:16:20 | y | exprs.kt:4:1:142:1 | topLevelMethod | VarAccess |
| exprs.kt:17:9:17:10 | i7 | exprs.kt:4:1:142:1 | topLevelMethod | LocalVariableDeclExpr |
| exprs.kt:17:14:17:14 | x | exprs.kt:4:1:142:1 | topLevelMethod | VarAccess |
| exprs.kt:17:14:17:20 | ... >> ... | exprs.kt:4:1:142:1 | topLevelMethod | RShiftExpr |
| exprs.kt:17:14:17:20 | ... >> ... | exprs.kt:4:1:142:1 | topLevelMethod | RightShiftExpr |
| exprs.kt:17:20:17:20 | y | exprs.kt:4:1:142:1 | topLevelMethod | VarAccess |
| exprs.kt:18:9:18:10 | i8 | exprs.kt:4:1:142:1 | topLevelMethod | LocalVariableDeclExpr |
| exprs.kt:18:14:18:14 | x | exprs.kt:4:1:142:1 | topLevelMethod | VarAccess |
| exprs.kt:18:14:18:21 | ... >>> ... | exprs.kt:4:1:142:1 | topLevelMethod | URShiftExpr |
| exprs.kt:18:14:18:21 | ... >>> ... | exprs.kt:4:1:142:1 | topLevelMethod | UnsignedRightShiftExpr |
| exprs.kt:18:21:18:21 | y | exprs.kt:4:1:142:1 | topLevelMethod | VarAccess |
| exprs.kt:19:9:19:10 | i9 | exprs.kt:4:1:142:1 | topLevelMethod | LocalVariableDeclExpr |
| exprs.kt:19:14:19:14 | x | exprs.kt:4:1:142:1 | topLevelMethod | VarAccess |
@@ -1162,15 +1162,15 @@
| exprs.kt:72:19:72:20 | ly | exprs.kt:4:1:142:1 | topLevelMethod | VarAccess |
| exprs.kt:73:9:73:10 | l6 | exprs.kt:4:1:142:1 | topLevelMethod | LocalVariableDeclExpr |
| exprs.kt:73:14:73:15 | lx | exprs.kt:4:1:142:1 | topLevelMethod | VarAccess |
| exprs.kt:73:14:73:21 | ... << ... | exprs.kt:4:1:142:1 | topLevelMethod | LShiftExpr |
| exprs.kt:73:14:73:21 | ... << ... | exprs.kt:4:1:142:1 | topLevelMethod | LeftShiftExpr |
| exprs.kt:73:21:73:21 | y | exprs.kt:4:1:142:1 | topLevelMethod | VarAccess |
| exprs.kt:74:9:74:10 | l7 | exprs.kt:4:1:142:1 | topLevelMethod | LocalVariableDeclExpr |
| exprs.kt:74:14:74:15 | lx | exprs.kt:4:1:142:1 | topLevelMethod | VarAccess |
| exprs.kt:74:14:74:21 | ... >> ... | exprs.kt:4:1:142:1 | topLevelMethod | RShiftExpr |
| exprs.kt:74:14:74:21 | ... >> ... | exprs.kt:4:1:142:1 | topLevelMethod | RightShiftExpr |
| exprs.kt:74:21:74:21 | y | exprs.kt:4:1:142:1 | topLevelMethod | VarAccess |
| exprs.kt:75:9:75:10 | l8 | exprs.kt:4:1:142:1 | topLevelMethod | LocalVariableDeclExpr |
| exprs.kt:75:14:75:15 | lx | exprs.kt:4:1:142:1 | topLevelMethod | VarAccess |
| exprs.kt:75:14:75:22 | ... >>> ... | exprs.kt:4:1:142:1 | topLevelMethod | URShiftExpr |
| exprs.kt:75:14:75:22 | ... >>> ... | exprs.kt:4:1:142:1 | topLevelMethod | UnsignedRightShiftExpr |
| exprs.kt:75:22:75:22 | y | exprs.kt:4:1:142:1 | topLevelMethod | VarAccess |
| exprs.kt:76:9:76:10 | l9 | exprs.kt:4:1:142:1 | topLevelMethod | LocalVariableDeclExpr |
| exprs.kt:76:14:76:15 | lx | exprs.kt:4:1:142:1 | topLevelMethod | VarAccess |

View File

@@ -376,26 +376,26 @@ constants/Values.java:
# 62| 43: [LocalVariableDeclStmt] var ...;
# 62| 0: [TypeAccess] int
# 62| 1: [LocalVariableDeclExpr] lshift
# 62| 0: [LShiftExpr] ... << ...
# 62| 0: [LeftShiftExpr] ... << ...
# 62| 0: [IntegerLiteral] 21
# 62| 1: [IntegerLiteral] 2
# 63| 44: [LocalVariableDeclStmt] var ...;
# 63| 0: [TypeAccess] int
# 63| 1: [LocalVariableDeclExpr] lshift_parameter
# 63| 0: [LShiftExpr] ... << ...
# 63| 0: [LeftShiftExpr] ... << ...
# 63| 0: [VarAccess] notConstant
# 63| 1: [VarAccess] notConstant
# 65| 45: [LocalVariableDeclStmt] var ...;
# 65| 0: [TypeAccess] int
# 65| 1: [LocalVariableDeclExpr] rshift
# 65| 0: [RShiftExpr] ... >> ...
# 65| 0: [RightShiftExpr] ... >> ...
# 65| 0: [MinusExpr] -...
# 65| 0: [IntegerLiteral] 1
# 65| 1: [IntegerLiteral] 2
# 66| 46: [LocalVariableDeclStmt] var ...;
# 66| 0: [TypeAccess] int
# 66| 1: [LocalVariableDeclExpr] urshift
# 66| 0: [URShiftExpr] ... >>> ...
# 66| 0: [UnsignedRightShiftExpr] ... >>> ...
# 66| 0: [MinusExpr] -...
# 66| 0: [IntegerLiteral] 1
# 66| 1: [IntegerLiteral] 1