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() {