Skip to content

Commit 40197fc

Browse files
authored
Merge branch 'main' into feature/cpp-mmio-unsanitized-memcpy
2 parents c15c416 + 53db3bd commit 40197fc

23 files changed

Lines changed: 711 additions & 568 deletions

File tree

MODULE.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ use_repo(
278278
"kotlin-compiler-2.3.0",
279279
"kotlin-compiler-2.3.20",
280280
"kotlin-compiler-2.4.0",
281+
"kotlin-compiler-2.4.20",
281282
"kotlin-compiler-embeddable-1.8.0",
282283
"kotlin-compiler-embeddable-1.9.0-Beta",
283284
"kotlin-compiler-embeddable-1.9.20-Beta",
@@ -290,6 +291,7 @@ use_repo(
290291
"kotlin-compiler-embeddable-2.3.0",
291292
"kotlin-compiler-embeddable-2.3.20",
292293
"kotlin-compiler-embeddable-2.4.0",
294+
"kotlin-compiler-embeddable-2.4.20",
293295
"kotlin-stdlib-1.8.0",
294296
"kotlin-stdlib-1.9.0-Beta",
295297
"kotlin-stdlib-1.9.20-Beta",
@@ -302,6 +304,7 @@ use_repo(
302304
"kotlin-stdlib-2.3.0",
303305
"kotlin-stdlib-2.3.20",
304306
"kotlin-stdlib-2.4.0",
307+
"kotlin-stdlib-2.4.20",
305308
)
306309

307310
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")

docs/codeql/reusables/supported-versions-compilers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
Java,"Java 7 to 26 [5]_","javac (OpenJDK and Oracle JDK),
2222

2323
Eclipse compiler for Java (ECJ) [6]_",``.java``
24-
Kotlin,"Kotlin 1.8.0 to 2.4.1\ *x*","kotlinc",``.kt``
24+
Kotlin,"Kotlin 1.8.0 to 2.4.20","kotlinc",``.kt``
2525
JavaScript,ECMAScript 2022 or lower,Not applicable,"``.js``, ``.jsx``, ``.mjs``, ``.es``, ``.es6``, ``.htm``, ``.html``, ``.xhtm``, ``.xhtml``, ``.vue``, ``.hbs``, ``.ejs``, ``.njk``, ``.json``, ``.yaml``, ``.yml``, ``.raml``, ``.xml`` [7]_"
2626
Python [8]_,"2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, 3.14",Not applicable,``.py``
2727
Ruby,"up to 3.3",Not applicable,"``.rb``, ``.erb``, ``.gemspec``, ``Gemfile``"

java/kotlin-extractor/BUILD.bazel

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ _compiler_plugin_registrar_service_source = "src/main/resources/META-INF/service
5757

5858
_compiler_plugin_registrar_service_target = "META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar"
5959

60+
_component_registrar_service_source = "src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar"
61+
62+
_component_registrar_service_target = "META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar"
63+
6064
py_binary(
6165
name = "generate_dbscheme",
6266
srcs = ["generate_dbscheme.py"],
@@ -68,14 +72,22 @@ _resources = [
6872
r[len("src/main/resources/"):],
6973
)
7074
for r in glob(["src/main/resources/**"])
71-
if r != _compiler_plugin_registrar_service_source
75+
if r not in (
76+
_compiler_plugin_registrar_service_source,
77+
_component_registrar_service_source,
78+
)
7279
]
7380

7481
_compiler_plugin_registrar_service = (
7582
_compiler_plugin_registrar_service_source,
7683
_compiler_plugin_registrar_service_target,
7784
)
7885

86+
_component_registrar_service = (
87+
_component_registrar_service_source,
88+
_component_registrar_service_target,
89+
)
90+
7991
kt_javac_options(
8092
name = "javac-options",
8193
release = "8",
@@ -93,7 +105,11 @@ kt_javac_options(
93105
"kotlin.RequiresOptIn",
94106
"org.jetbrains.kotlin.ir.symbols.%s" %
95107
("IrSymbolInternals" if version_less(v, "2.0.0") else "UnsafeDuringIrConstructionAPI"),
96-
] + ([] if version_less(v, "2.2.20") else ["org.jetbrains.kotlin.DeprecatedForRemovalCompilerApi"]),
108+
] + (
109+
[] if version_less(v, "2.2.20") else ["org.jetbrains.kotlin.DeprecatedForRemovalCompilerApi"]
110+
) + (
111+
[] if version_less(v, "2.4.20") else ["org.jetbrains.kotlin.K1Deprecation"]
112+
),
97113
x_suppress_version_warnings = True,
98114
),
99115
# * extractor.name is different for each version, so we need to put it in different output dirs
@@ -103,6 +119,8 @@ kt_javac_options(
103119
name = "resources-%s" % v,
104120
srcs = [src for src, _ in _resources] + (
105121
[_compiler_plugin_registrar_service[0]] if not version_less(v, "2.4.0") else []
122+
) + (
123+
[_component_registrar_service[0]] if version_less(v, "2.4.20") else []
106124
),
107125
outs = [
108126
"%s/com/github/codeql/extractor.name" % v,
@@ -114,6 +132,11 @@ kt_javac_options(
114132
v,
115133
_compiler_plugin_registrar_service[1],
116134
)] if not version_less(v, "2.4.0") else []
135+
) + (
136+
["%s/%s" % (
137+
v,
138+
_component_registrar_service[1],
139+
)] if version_less(v, "2.4.20") else []
117140
),
118141
cmd = "\n".join([
119142
"echo %s-%s > $(RULEDIR)/%s/com/github/codeql/extractor.name" % (_extractor_name_prefix, v, v),
@@ -126,6 +149,12 @@ kt_javac_options(
126149
v,
127150
_compiler_plugin_registrar_service[1],
128151
)] if not version_less(v, "2.4.0") else []
152+
) + (
153+
["cp $(execpath %s) $(RULEDIR)/%s/%s" % (
154+
_component_registrar_service[0],
155+
v,
156+
_component_registrar_service[1],
157+
)] if version_less(v, "2.4.20") else []
129158
)),
130159
),
131160
kt_jvm_library(
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:038d406cc51d5fe3f6b5a16366a3f083b783bceb9e576e3103e695c3ce04e0fa
3+
size 60184475
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:cf97161430683fb9af96dc6a7017ffae1fe8737b80d12eee11f2fe3e76f8ded8
3+
size 58593245
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:2226de463d309d4a5500a481320b3dea515a6981dcae1def531fbc158884e25f
3+
size 1853314

java/kotlin-extractor/dev/wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import io
2828
import os
2929

30-
DEFAULT_VERSION = "2.4.10"
30+
DEFAULT_VERSION = "2.4.20"
3131

3232

3333
def options():

java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,8 +1645,9 @@ open class KotlinFileExtractor(
16451645
extractMethodAndParameterTypeAccesses: Boolean,
16461646
typeSubstitution: TypeSubstitution?,
16471647
classTypeArgsIncludingOuterClasses: List<IrTypeArgument>?
1648-
) : Label<out DbCallable> =
1649-
forceExtractFunction(
1648+
) : Label<out DbCallable> {
1649+
val sourceLoc = tw.getLocation(f.parentClassOrNull ?: f)
1650+
return forceExtractFunction(
16501651
f,
16511652
parentId,
16521653
extractBody = false,
@@ -1656,6 +1657,7 @@ open class KotlinFileExtractor(
16561657
classTypeArgsIncludingOuterClasses,
16571658
overriddenAttributes =
16581659
OverriddenFunctionAttributes(
1660+
sourceLoc = sourceLoc,
16591661
visibility = DescriptorVisibilities.PUBLIC,
16601662
modality = Modality.OPEN
16611663
)
@@ -1666,7 +1668,6 @@ open class KotlinFileExtractor(
16661668
CompilerGeneratedKinds.INTERFACE_FORWARDER.kind
16671669
)
16681670
if (extractBody) {
1669-
val realFunctionLocId = tw.getLocation(f)
16701671
val inheritedDefaultFunction = f.realOverrideTarget
16711672
val directlyInheritedSymbol =
16721673
when (f) {
@@ -1686,10 +1687,10 @@ open class KotlinFileExtractor(
16861687
(directlyInheritedSymbol.owner.parentClassOrNull ?: return functionId)
16871688
.typeWith()
16881689

1689-
extractExpressionBody(functionId, realFunctionLocId).also { returnId ->
1690+
extractExpressionBody(functionId, sourceLoc).also { returnId ->
16901691
extractRawMethodAccess(
16911692
f,
1692-
realFunctionLocId,
1693+
sourceLoc,
16931694
f.returnType,
16941695
functionId,
16951696
returnId,
@@ -1702,7 +1703,7 @@ open class KotlinFileExtractor(
17021703
extractVariableAccess(
17031704
syntheticParamId,
17041705
param.type,
1705-
realFunctionLocId,
1706+
sourceLoc,
17061707
argParentId,
17071708
idxOffset + idx,
17081709
functionId,
@@ -1718,14 +1719,15 @@ open class KotlinFileExtractor(
17181719
callId,
17191720
-1,
17201721
returnId,
1721-
realFunctionLocId
1722+
sourceLoc
17221723
)
17231724
},
17241725
null
17251726
)
17261727
}
17271728
}
17281729
}
1730+
}
17291731

17301732
private fun extractFunction(
17311733
f: IrFunction,

java/kotlin-extractor/src/main/kotlin/MetaAnnotationSupport.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ class MetaAnnotationSupport(
9696
val metaAnnotations = annotationClass.annotations
9797
val jvmRepeatable =
9898
metaAnnotations.find {
99-
it.symbol.owner.parentAsClass.fqNameWhenAvailable ==
100-
JvmAnnotationNames.REPEATABLE_ANNOTATION
99+
it.annotationClass.fqNameWhenAvailable == JvmAnnotationNames.REPEATABLE_ANNOTATION
101100
}
102101
return if (jvmRepeatable != null) {
103102
((jvmRepeatable.codeQlGetValueArgument(0) as? IrClassReference)?.symbol as? IrClassSymbol)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.github.codeql
2+
3+
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
4+
import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar
5+
import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi
6+
import org.jetbrains.kotlin.config.CompilerConfiguration
7+
8+
@OptIn(ExperimentalCompilerApi::class)
9+
abstract class Kotlin2ComponentRegistrar : CompilerPluginRegistrar() {
10+
override val supportsK2: Boolean
11+
get() = true
12+
13+
override val pluginId: String
14+
get() = "kotlin-extractor"
15+
16+
private var extensionStorage: CompilerPluginRegistrar.ExtensionStorage? = null
17+
18+
override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) {
19+
this@Kotlin2ComponentRegistrar.extensionStorage = this
20+
doRegisterExtensions(configuration)
21+
}
22+
23+
abstract fun doRegisterExtensions(configuration: CompilerConfiguration)
24+
25+
protected fun registerExtractorExtension(extension: IrGenerationExtension) {
26+
val storage = extensionStorage
27+
?: throw IllegalStateException("registerExtractorExtension called before registerExtensions")
28+
with(storage) {
29+
IrGenerationExtension.registerExtension(extension)
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)