Skip to content

Java: Improve more join-orders #20092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions java/ql/src/Likely Bugs/Collections/ArrayIndexOutOfBounds.ql
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ import semmle.code.java.dataflow.SSA
import semmle.code.java.dataflow.RangeUtils
import semmle.code.java.dataflow.RangeAnalysis

pragma[nomagic]
predicate ssaArrayLengthBound(SsaVariable arr, Bound b) {
exists(FieldAccess len |
len.getField() instanceof ArrayLengthField and
len.getQualifier() = arr.getAUse() and
b.getExpr() = len
)
}

/**
* Holds if the index expression of `aa` is less than or equal to the array length plus `k`.
*/
Expand All @@ -27,12 +36,8 @@ predicate boundedArrayAccess(ArrayAccess aa, int k) {
aa.getArray() = arr.getAUse() and
bounded(index, b, delta, true, _)
|
exists(FieldAccess len |
len.getField() instanceof ArrayLengthField and
len.getQualifier() = arr.getAUse() and
b.getExpr() = len and
k = delta
)
ssaArrayLengthBound(arr, b) and
k = delta
or
exists(ArrayCreationExpr arraycreation | arraycreation = getArrayDef(arr) |
k = delta and
Expand Down
26 changes: 23 additions & 3 deletions java/ql/src/Likely Bugs/Statements/PartiallyMaskedCatch.ql
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,34 @@

import java

pragma[nomagic]
predicate mayThrow(Stmt s, RefType rt) {
s.(ThrowStmt).getExpr().getType() = rt
or
exists(Call call |
call.getEnclosingStmt() = s and
call.getCallee().getAnException().getType() = rt
)
}

pragma[nomagic]
predicate caughtBy(TryStmt try, Stmt s, RefType rt) {
mayThrow(s, rt) and
s.getEnclosingStmt+() = try.getBlock() and
caughtType(try, _).hasSubtype*(rt)
}

pragma[nomagic]
predicate nestedTry(TryStmt outer, TryStmt inner) { inner.getEnclosingStmt+() = outer.getBlock() }

/**
* Exceptions of type `rt` thrown from within statement `s` are caught by an inner try block
* and are therefore not propagated to the outer try block `t`.
*/
private predicate caughtInside(TryStmt t, Stmt s, RefType rt) {
exists(TryStmt innerTry | innerTry.getEnclosingStmt+() = t.getBlock() |
s.getEnclosingStmt+() = innerTry.getBlock() and
caughtType(innerTry, _).hasSubtype*(rt)
exists(TryStmt innerTry |
nestedTry(t, innerTry) and
caughtBy(innerTry, s, rt)
)
}

Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy