Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ predicate notDeliberatelyBoxed(LocalBoxedVar v) {
)
}

pragma[nomagic]
int callableGetNumberOfParameters(Callable c) { result = c.getNumberOfParameters() }

/**
* Replacing the type of a boxed variable with the corresponding primitive type may affect
* overload resolution. If this is the case then the boxing is most likely intentional and
Expand All @@ -52,7 +55,7 @@ predicate affectsOverload(LocalBoxedVar v) {
c1.getParameterType(i) instanceof RefType and
c2.getParameterType(i) instanceof PrimitiveType and
c1.getName() = c2.getName() and
c1.getNumberOfParameters() = c2.getNumberOfParameters()
callableGetNumberOfParameters(c1) = callableGetNumberOfParameters(c2)
)
}

Expand Down
1 change: 1 addition & 0 deletions java/ql/src/semmle/code/Location.qll
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Top extends @top {
int getNumberOfCommentLines() { numlines(this, _, _, result) }

/** Gets a textual representation of this element. */
cached
string toString() { hasName(this, result) }
}

Expand Down
2 changes: 1 addition & 1 deletion java/ql/src/semmle/code/java/deadcode/DeadCode.qll
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class RootdefCallable extends Callable {
}
}

pragma[noinline]
pragma[nomagic]
private predicate overrideAccess(Callable c, int i) {
exists(Method m | m.overridesOrInstantiates+(c) | exists(m.getParameter(i).getAnAccess()))
}
Expand Down
26 changes: 18 additions & 8 deletions java/ql/src/semmle/code/java/frameworks/gwt/GWT.qll
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,29 @@ class ClientSideGwtCompilationUnit extends GwtCompilationUnit {
}
}

/** Auxiliary predicate: `jsni` is a JSNI comment associated with method `m`. */
private predicate jsniComment(Javadoc jsni, Method m) {
private predicate jsni(Javadoc jsni, File file, int startline) {
// The comment must start with `-{` ...
jsni.getChild(0).getText().matches("-{%") and
// ... and it must end with `}-`.
jsni.getChild(jsni.getNumChild() - 1).getText().matches("%}-") and
// The associated callable must be marked as `native` ...
file = jsni.getFile() and
startline = jsni.getLocation().getStartLine()
}

private predicate nativeMethodLines(Method m, File file, int line) {
m.isNative() and
// ... and the comment has to be contained in `m`.
jsni.getFile() = m.getFile() and
jsni.getLocation().getStartLine() in [m.getLocation().getStartLine() .. m
.getLocation()
.getEndLine()]
file = m.getFile() and
line in [m.getLocation().getStartLine() .. m.getLocation().getEndLine()]
}

/** Auxiliary predicate: `jsni` is a JSNI comment associated with method `m`. */
private predicate jsniComment(Javadoc jsni, Method m) {
exists(File file, int line |
jsni(jsni, file, line) and
// The associated callable must be marked as `native`
// and the comment has to be contained in `m`.
nativeMethodLines(m, file, line)
)
}

/**
Expand Down