Skip to content

Commit 75c549b

Browse files
committed
Java: Deprecate ParExpr.
1 parent c4d2163 commit 75c549b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+87
-172
lines changed

java/ql/src/Language Abuse/UselessUpcast.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import java
1515
predicate usefulUpcast(CastExpr e) {
1616
// Upcasts that may be performed to affect resolution of methods or constructors.
1717
exists(Call c, int i, Callable target |
18-
c.getArgument(i).getProperExpr() = e and
18+
c.getArgument(i) = e and
1919
target = c.getCallee() and
2020
// An upcast to the type of the corresponding parameter.
2121
e.getType() = target.getParameterType(i)
@@ -31,13 +31,13 @@ predicate usefulUpcast(CastExpr e) {
3131
)
3232
or
3333
// Upcasts of a varargs argument.
34-
exists(Call c, int iArg, int iParam | c.getArgument(iArg).getProperExpr() = e |
34+
exists(Call c, int iArg, int iParam | c.getArgument(iArg) = e |
3535
c.getCallee().getParameter(iParam).isVarargs() and iArg >= iParam
3636
)
3737
or
3838
// Upcasts that are performed on an operand of a ternary expression.
3939
exists(ConditionalExpr ce |
40-
e = ce.getTrueExpr().getProperExpr() or e = ce.getFalseExpr().getProperExpr()
40+
e = ce.getTrueExpr() or e = ce.getFalseExpr()
4141
)
4242
or
4343
// Upcasts to raw types.
@@ -46,12 +46,12 @@ predicate usefulUpcast(CastExpr e) {
4646
e.getType().(Array).getElementType() instanceof RawType
4747
or
4848
// Upcasts that are performed to affect field, private method, or static method resolution.
49-
exists(FieldAccess fa | e = fa.getQualifier().getProperExpr() |
49+
exists(FieldAccess fa | e = fa.getQualifier() |
5050
not e.getExpr().getType().(RefType).inherits(fa.getField())
5151
)
5252
or
5353
exists(MethodAccess ma, Method m |
54-
e = ma.getQualifier().getProperExpr() and
54+
e = ma.getQualifier() and
5555
m = ma.getMethod() and
5656
(m.isStatic() or m.isPrivate())
5757
|

java/ql/src/Likely Bugs/Arithmetic/BadCheckOdd.ql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import java
1515
import semmle.code.java.Collections
1616

1717
predicate isDefinitelyPositive(Expr e) {
18-
isDefinitelyPositive(e.getProperExpr()) or
18+
isDefinitelyPositive(e) or
1919
e.(IntegerLiteral).getIntValue() >= 0 or
2020
e.(MethodAccess).getMethod() instanceof CollectionSizeMethod or
2121
e.(MethodAccess).getMethod() instanceof StringLengthMethod or
@@ -24,10 +24,10 @@ predicate isDefinitelyPositive(Expr e) {
2424

2525
from BinaryExpr t, RemExpr lhs, IntegerLiteral rhs, string parity
2626
where
27-
t.getLeftOperand().getProperExpr() = lhs and
28-
t.getRightOperand().getProperExpr() = rhs and
27+
t.getLeftOperand() = lhs and
28+
t.getRightOperand() = rhs and
2929
not isDefinitelyPositive(lhs.getLeftOperand()) and
30-
lhs.getRightOperand().getProperExpr().(IntegerLiteral).getIntValue() = 2 and
30+
lhs.getRightOperand().(IntegerLiteral).getIntValue() = 2 and
3131
(
3232
t instanceof EQExpr and rhs.getIntValue() = 1 and parity = "oddness"
3333
or

java/ql/src/Likely Bugs/Arithmetic/ConstantExpAppearsNonConstant.ql

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ predicate isConstantExp(Expr e) {
1717
// A literal is constant.
1818
e instanceof Literal
1919
or
20-
// A parenthesized expression is constant if its proper expression is.
21-
isConstantExp(e.(ParExpr).getProperExpr())
22-
or
2320
e instanceof TypeAccess
2421
or
2522
e instanceof ArrayTypeAccess
@@ -33,25 +30,25 @@ predicate isConstantExp(Expr e) {
3330
)
3431
or
3532
// A cast expression is constant if its expression is.
36-
exists(CastExpr c | c = e | isConstantExp(c.getExpr().getProperExpr()))
33+
exists(CastExpr c | c = e | isConstantExp(c.getExpr()))
3734
or
3835
// Multiplication by 0 is constant.
39-
exists(MulExpr m | m = e | eval(m.getAnOperand().getProperExpr()) = 0)
36+
exists(MulExpr m | m = e | eval(m.getAnOperand()) = 0)
4037
or
4138
// Integer remainder by 1 is constant.
4239
exists(RemExpr r | r = e |
4340
r.getLeftOperand().getType() instanceof IntegralType and
44-
eval(r.getRightOperand().getProperExpr()) = 1
41+
eval(r.getRightOperand()) = 1
4542
)
4643
or
47-
exists(AndBitwiseExpr a | a = e | eval(a.getAnOperand().getProperExpr()) = 0)
44+
exists(AndBitwiseExpr a | a = e | eval(a.getAnOperand()) = 0)
4845
or
4946
exists(AndLogicalExpr a | a = e |
50-
a.getAnOperand().getProperExpr().(BooleanLiteral).getBooleanValue() = false
47+
a.getAnOperand().(BooleanLiteral).getBooleanValue() = false
5148
)
5249
or
5350
exists(OrLogicalExpr o | o = e |
54-
o.getAnOperand().getProperExpr().(BooleanLiteral).getBooleanValue() = true
51+
o.getAnOperand().(BooleanLiteral).getBooleanValue() = true
5552
)
5653
}
5754

java/ql/src/Likely Bugs/Arithmetic/IntMultToLong.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ float exprBound(Expr e) {
3535
/** A multiplication that does not overflow. */
3636
predicate small(MulExpr e) {
3737
exists(NumType t, float lhs, float rhs, float res | t = e.getType() |
38-
lhs = exprBound(e.getLeftOperand().getProperExpr()) and
39-
rhs = exprBound(e.getRightOperand().getProperExpr()) and
38+
lhs = exprBound(e.getLeftOperand()) and
39+
rhs = exprBound(e.getRightOperand()) and
4040
lhs * rhs = res and
4141
res <= t.getOrdPrimitiveType().getMaxValue()
4242
)
@@ -47,7 +47,7 @@ predicate small(MulExpr e) {
4747
*/
4848
Expr getRestrictedParent(Expr e) {
4949
result = e.getParent() and
50-
(result instanceof ArithExpr or result instanceof ConditionalExpr or result instanceof ParExpr)
50+
(result instanceof ArithExpr or result instanceof ConditionalExpr)
5151
}
5252

5353
from ConversionSite c, MulExpr e, NumType sourceType, NumType destType

java/ql/src/Likely Bugs/Comparison/DefineEqualsWhenAddingFields.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ predicate checksReferenceEquality(EqualsMethod em) {
3232
eq.getAnOperand().(VarAccess).getVariable() = em.getParameter(0) and
3333
(
3434
// `{ return (ojb==this); }`
35-
eq = blk.getStmt().(ReturnStmt).getResult().getProperExpr()
35+
eq = blk.getStmt().(ReturnStmt).getResult()
3636
or
3737
// `{ if (ojb==this) return true; else return false; }`
3838
exists(IfStmt ifStmt | ifStmt = blk.getStmt() |
39-
eq = ifStmt.getCondition().getProperExpr() and
39+
eq = ifStmt.getCondition() and
4040
ifStmt.getThen().(ReturnStmt).getResult().(BooleanLiteral).getBooleanValue() = true and
4141
ifStmt.getElse().(ReturnStmt).getResult().(BooleanLiteral).getBooleanValue() = false
4242
)

java/ql/src/Likely Bugs/Comparison/MissingInstanceofInEquals.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ReferenceEquals extends EqualsMethod {
4545
exists(Block b, ReturnStmt ret, EQExpr eq |
4646
this.getBody() = b and
4747
b.getStmt(0) = ret and
48-
ret.getResult().getProperExpr() = eq and
48+
ret.getResult() = eq and
4949
eq.getAnOperand() = this.getAParameter().getAnAccess() and
5050
(eq.getAnOperand() instanceof ThisAccess or eq.getAnOperand() instanceof FieldAccess)
5151
)

java/ql/src/Likely Bugs/Comparison/NoAssignInBooleanExprs.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class BooleanExpr extends Expr {
2626
}
2727

2828
private predicate assignAndCheck(AssignExpr e) {
29-
exists(BinaryExpr c | e = c.getAChildExpr().getProperExpr() |
29+
exists(BinaryExpr c | e = c.getAChildExpr() |
3030
c instanceof ComparisonExpr or
3131
c instanceof EqualityTest
3232
)

java/ql/src/Likely Bugs/Comparison/StringComparison.ql

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ class StringValue extends Expr {
2424
this.(MethodAccess).getMethod() = intern
2525
)
2626
or
27-
// Parenthesized expressions.
28-
this.(ParExpr).getExpr().(StringValue).isInterned()
29-
or
3027
// Ternary conditional operator.
3128
this.(ConditionalExpr).getTrueExpr().(StringValue).isInterned() and
3229
this.(ConditionalExpr).getFalseExpr().(StringValue).isInterned()
@@ -52,7 +49,7 @@ predicate variableValuesInterned(Variable v) {
5249
not v instanceof Parameter and
5350
// If the string is modified with `+=`, then the new string is not interned
5451
// even if the components are.
55-
not exists(AssignOp append | append.getDest().getProperExpr() = v.getAnAccess())
52+
not exists(AssignOp append | append.getDest() = v.getAnAccess())
5653
}
5754

5855
from EqualityTest e, StringValue lhs, StringValue rhs

java/ql/src/Likely Bugs/Comparison/UselessComparisonTest.ql

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ Expr overFlowCand() {
127127
or
128128
exists(SsaExplicitUpdate x | result = x.getAUse() and x.getDefiningExpr() = overFlowCand())
129129
or
130-
result.(ParExpr).getExpr() = overFlowCand()
131-
or
132130
result.(AssignExpr).getRhs() = overFlowCand()
133131
or
134132
result.(LocalVariableDeclExpr).getInit() = overFlowCand()
@@ -165,8 +163,6 @@ Expr increaseOrDecreaseOfVar(SsaVariable v) {
165163
result = x.getAUse() and x.getDefiningExpr() = increaseOrDecreaseOfVar(v)
166164
)
167165
or
168-
result.(ParExpr).getExpr() = increaseOrDecreaseOfVar(v)
169-
or
170166
result.(AssignExpr).getRhs() = increaseOrDecreaseOfVar(v)
171167
or
172168
result.(LocalVariableDeclExpr).getInit() = increaseOrDecreaseOfVar(v)

java/ql/src/Likely Bugs/Concurrency/DoubleCheckedLocking.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ private Expr getAFieldRead(Field f) {
1313
v.getDefiningExpr().(VariableAssign).getSource() = getAFieldRead(f)
1414
)
1515
or
16-
result.(ParExpr).getExpr() = getAFieldRead(f)
17-
or
1816
result.(AssignExpr).getSource() = getAFieldRead(f)
1917
}
2018

0 commit comments

Comments
 (0)