Merge pull request #6637 from github/alexet/imporve-query

Java: Fix performance issues with future versions of codeql.
This commit is contained in:
Anders Schack-Mulligen
2021-09-08 11:16:19 +02:00
committed by GitHub
3 changed files with 20 additions and 12 deletions

View File

@@ -110,6 +110,7 @@ class Annotatable extends Element {
}
/** Gets an annotation that applies to this element. */
cached
Annotation getAnAnnotation() { result.getAnnotatedElement() = this }
/**

View File

@@ -616,16 +616,21 @@ private predicate elementSpec(
summaryModel(namespace, type, subtypes, name, signature, ext, _, _, _)
}
private predicate relevantCallable(Callable c) { elementSpec(_, _, _, c.getName(), _, _) }
private string paramsStringPart(Callable c, int i) {
i = -1 and result = "("
or
exists(int n, string p | c.getParameterType(n).getErasure().toString() = p |
i = 2 * n and result = p
relevantCallable(c) and
(
i = -1 and result = "("
or
i = 2 * n - 1 and result = "," and n != 0
exists(int n, string p | c.getParameterType(n).getErasure().toString() = p |
i = 2 * n and result = p
or
i = 2 * n - 1 and result = "," and n != 0
)
or
i = 2 * c.getNumberOfParameters() and result = ")"
)
or
i = 2 * c.getNumberOfParameters() and result = ")"
}
private string paramsString(Callable c) {

View File

@@ -11,11 +11,13 @@ import semmle.code.xml.AndroidManifest
*/
class AndroidComponent extends Class {
AndroidComponent() {
this.getASupertype*().hasQualifiedName("android.app", "Activity") or
this.getASupertype*().hasQualifiedName("android.app", "Service") or
this.getASupertype*().hasQualifiedName("android.content", "BroadcastReceiver") or
this.getASupertype*().hasQualifiedName("android.content", "ContentProvider") or
this.getASupertype*().hasQualifiedName("android.content", "ContentResolver")
// The casts here are due to misoptimisation if they are missing
// but are not needed semantically.
this.(Class).getASupertype*().hasQualifiedName("android.app", "Activity") or
this.(Class).getASupertype*().hasQualifiedName("android.app", "Service") or
this.(Class).getASupertype*().hasQualifiedName("android.content", "BroadcastReceiver") or
this.(Class).getASupertype*().hasQualifiedName("android.content", "ContentProvider") or
this.(Class).getASupertype*().hasQualifiedName("android.content", "ContentResolver")
}
/** The XML element corresponding to this Android component. */