mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Extract container of adapter function as compiler generated
This commit is contained in:
@@ -943,6 +943,10 @@ open class KotlinFileExtractor(
|
|||||||
extractLocalTypeDeclStmt(classId, s, callable, parent, idx)
|
extractLocalTypeDeclStmt(classId, s, callable, parent, idx)
|
||||||
val ids = getLocallyVisibleFunctionLabels(s)
|
val ids = getLocallyVisibleFunctionLabels(s)
|
||||||
tw.writeKtLocalFunction(ids.function)
|
tw.writeKtLocalFunction(ids.function)
|
||||||
|
|
||||||
|
if (s.origin == IrDeclarationOrigin.ADAPTER_FOR_CALLABLE_REFERENCE) {
|
||||||
|
tw.writeCompiler_generated(classId, 1)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.errorElement("Expected to find local function", s)
|
logger.errorElement("Expected to find local function", s)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1222,3 +1222,9 @@ ktPropertyDelegates(
|
|||||||
unique int id: @kt_property ref,
|
unique int id: @kt_property ref,
|
||||||
unique int variableId: @variable ref
|
unique int variableId: @variable ref
|
||||||
)
|
)
|
||||||
|
|
||||||
|
compiler_generated(
|
||||||
|
unique int id: @top ref,
|
||||||
|
int kind: int ref
|
||||||
|
// 1: Kotlin declaring classes of adapter functions
|
||||||
|
);
|
||||||
|
|||||||
@@ -50,7 +50,9 @@ predicate dead(RefType dead) {
|
|||||||
// Exclude classes that look like they may be reflectively constructed.
|
// Exclude classes that look like they may be reflectively constructed.
|
||||||
not dead.getAnAnnotation() instanceof ReflectiveAccessAnnotation and
|
not dead.getAnAnnotation() instanceof ReflectiveAccessAnnotation and
|
||||||
// Insist all source ancestors are dead as well.
|
// Insist all source ancestors are dead as well.
|
||||||
forall(RefType t | t.fromSource() and t = getASuperTypePlus(dead) | dead(t))
|
forall(RefType t | t.fromSource() and t = getASuperTypePlus(dead) | dead(t)) and
|
||||||
|
// Exclude compiler generated classes (e.g. declaring type of adapter functions in Kotlin)
|
||||||
|
not compiler_generated(dead, _)
|
||||||
}
|
}
|
||||||
|
|
||||||
from RefType t, string kind
|
from RefType t, string kind
|
||||||
|
|||||||
@@ -228,3 +228,5 @@ modifiers
|
|||||||
| reflection.kt:116:40:116:44 | ...::... | reflection.kt:116:40:116:44 | invoke | override |
|
| reflection.kt:116:40:116:44 | ...::... | reflection.kt:116:40:116:44 | invoke | override |
|
||||||
| reflection.kt:116:40:116:44 | ...::... | reflection.kt:116:40:116:44 | invoke | public |
|
| reflection.kt:116:40:116:44 | ...::... | reflection.kt:116:40:116:44 | invoke | public |
|
||||||
| reflection.kt:126:9:126:13 | ...::... | reflection.kt:126:9:126:13 | invoke | public |
|
| reflection.kt:126:9:126:13 | ...::... | reflection.kt:126:9:126:13 | invoke | public |
|
||||||
|
compGenerated
|
||||||
|
| reflection.kt:126:9:126:13 | | 1 |
|
||||||
|
|||||||
@@ -86,3 +86,5 @@ query predicate modifiers(ClassInstanceExpr e, Method m, string modifier) {
|
|||||||
e.getAnonymousClass().getAMethod() = m and
|
e.getAnonymousClass().getAMethod() = m and
|
||||||
m.hasModifier(modifier)
|
m.hasModifier(modifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query predicate compGenerated(Top t, int i) { compiler_generated(t, i) }
|
||||||
|
|||||||
Reference in New Issue
Block a user