Skip to content

Commit f3f0e06

Browse files
authored
Merge branch 'main' into fix-history
2 parents 4eddb62 + f2bc73b commit f3f0e06

File tree

134 files changed

+3138
-313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+3138
-313
lines changed

java/kotlin-extractor/build.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ def is_windows():
3535
return True
3636
return False
3737

38+
# kotlinc might be kotlinc.bat or kotlinc.cmd on Windows, so we use `which` to find out what it is
39+
kotlinc = shutil.which('kotlinc')
40+
if kotlinc is None:
41+
print("Cannot build the Kotlin extractor: no kotlinc found on your PATH", file = sys.stderr)
42+
sys.exit(1)
3843

39-
kotlinc = 'kotlinc.bat' if is_windows() else 'kotlinc'
4044
javac = 'javac'
4145
kotlin_dependency_folder = args.dependencies
4246

@@ -201,10 +205,6 @@ def compile_standalone(version):
201205
'build/temp_src',
202206
version)
203207

204-
if shutil.which(kotlinc) == None:
205-
print("Cannot build the Kotlin extractor: no '%s' found on your PATH" % kotlinc, file = sys.stderr)
206-
sys.exit(1)
207-
208208
if args.many:
209209
for version in kotlin_plugin_versions.many_versions:
210210
compile_standalone(version)

java/kotlin-extractor/kotlin_plugin_versions.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import platform
22
import re
3+
import shutil
34
import subprocess
45
import sys
56

@@ -26,11 +27,11 @@ class KotlincNotFoundException(Exception):
2627
pass
2728

2829
def get_single_version(fakeVersionOutput = None):
29-
# TODO: `shell=True` is a workaround to get CI working on Windows. It breaks the build on Linux.
30-
try:
31-
versionOutput = subprocess.run(['kotlinc', '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, shell=is_windows()).stderr if fakeVersionOutput is None else fakeVersionOutput
32-
except FileNotFoundError as e:
33-
raise KotlincNotFoundException(e)
30+
# kotlinc might be kotlinc.bat or kotlinc.cmd on Windows, so we use `which` to find out what it is
31+
kotlinc = shutil.which('kotlinc')
32+
if kotlinc is None:
33+
raise KotlincNotFoundException()
34+
versionOutput = subprocess.run([kotlinc, '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).stderr if fakeVersionOutput is None else fakeVersionOutput
3435
m = re.match(r'.* kotlinc-jvm ([0-9]+\.[0-9]+\.[0-9]+) .*', versionOutput)
3536
if m is None:
3637
raise Exception('Cannot detect version of kotlinc (got ' + str(versionOutput) + ')')

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ExternalDeclExtractor(val logger: FileLogger, val invocationTrapFile: Stri
2121

2222
fun extractLater(d: IrDeclaration, signature: String): Boolean {
2323
if (d !is IrClass && !isExternalFileClassMember(d)) {
24-
logger.warnElement("External declaration is neither a class, nor a top-level declaration", d)
24+
logger.errorElement("External declaration is neither a class, nor a top-level declaration", d)
2525
return false
2626
}
2727
val ret = externalDeclsDone.add(d)
@@ -64,7 +64,7 @@ class ExternalDeclExtractor(val logger: FileLogger, val invocationTrapFile: Stri
6464

6565
val containingClass = getContainingClassOrSelf(irDecl)
6666
if (containingClass == null) {
67-
logger.warnElement("Unable to get containing class", irDecl)
67+
logger.errorElement("Unable to get containing class", irDecl)
6868
return
6969
}
7070
val binaryPath = getIrClassBinaryPath(containingClass)

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ open class KotlinFileExtractor(
270270
if (kind == ClassKind.ENUM_CLASS) {
271271
tw.writeIsEnumType(classId)
272272
} else if (kind != ClassKind.CLASS && kind != ClassKind.OBJECT) {
273-
logger.warnElement("Unrecognised class kind $kind", c)
273+
logger.errorElement("Unrecognised class kind $kind", c)
274274
}
275275
}
276276

@@ -549,7 +549,7 @@ open class KotlinFileExtractor(
549549
val constructorId = useFunction<DbConstructor>(enclosingConstructor)
550550
val enclosingClass = enclosingConstructor.parentClassOrNull
551551
if (enclosingClass == null) {
552-
logger.warnElement("Constructor's parent is not a class", enclosingConstructor)
552+
logger.errorElement("Constructor's parent is not a class", enclosingConstructor)
553553
return
554554
}
555555

@@ -807,21 +807,21 @@ open class KotlinFileExtractor(
807807
}
808808
} else {
809809
if (p.modality != Modality.FINAL || !isExternalDeclaration(p)) {
810-
logger.errorElement("IrProperty without a getter", p)
810+
logger.warnElement("IrProperty without a getter", p)
811811
}
812812
}
813813

814814
if (setter != null) {
815815
if (!p.isVar) {
816-
logger.errorElement("!isVar property with a setter", p)
816+
logger.warnElement("!isVar property with a setter", p)
817817
}
818818
val setterId = extractFunction(setter, parentId, extractBody = extractFunctionBodies, extractMethodAndParameterTypeAccesses = extractFunctionBodies, typeSubstitution, classTypeArgsIncludingOuterClasses)?.cast<DbMethod>()
819819
if (setterId != null) {
820820
tw.writeKtPropertySetters(id, setterId)
821821
}
822822
} else {
823823
if (p.isVar && !isExternalDeclaration(p)) {
824-
logger.errorElement("isVar property without a setter", p)
824+
logger.warnElement("isVar property without a setter", p)
825825
}
826826
}
827827

@@ -1657,7 +1657,7 @@ open class KotlinFileExtractor(
16571657
// as they can't be extracted as external dependencies.
16581658
isBuiltinCallInternal(c, "less") -> {
16591659
if(c.origin != IrStatementOrigin.LT) {
1660-
logger.errorElement("Unexpected origin for LT: ${c.origin}", c)
1660+
logger.warnElement("Unexpected origin for LT: ${c.origin}", c)
16611661
}
16621662
val id = tw.getFreshIdLabel<DbLtexpr>()
16631663
val type = useType(c.type)
@@ -1667,7 +1667,7 @@ open class KotlinFileExtractor(
16671667
}
16681668
isBuiltinCallInternal(c, "lessOrEqual") -> {
16691669
if(c.origin != IrStatementOrigin.LTEQ) {
1670-
logger.errorElement("Unexpected origin for LTEQ: ${c.origin}", c)
1670+
logger.warnElement("Unexpected origin for LTEQ: ${c.origin}", c)
16711671
}
16721672
val id = tw.getFreshIdLabel<DbLeexpr>()
16731673
val type = useType(c.type)
@@ -1677,7 +1677,7 @@ open class KotlinFileExtractor(
16771677
}
16781678
isBuiltinCallInternal(c, "greater") -> {
16791679
if(c.origin != IrStatementOrigin.GT) {
1680-
logger.errorElement("Unexpected origin for GT: ${c.origin}", c)
1680+
logger.warnElement("Unexpected origin for GT: ${c.origin}", c)
16811681
}
16821682
val id = tw.getFreshIdLabel<DbGtexpr>()
16831683
val type = useType(c.type)
@@ -1687,7 +1687,7 @@ open class KotlinFileExtractor(
16871687
}
16881688
isBuiltinCallInternal(c, "greaterOrEqual") -> {
16891689
if(c.origin != IrStatementOrigin.GTEQ) {
1690-
logger.errorElement("Unexpected origin for GTEQ: ${c.origin}", c)
1690+
logger.warnElement("Unexpected origin for GTEQ: ${c.origin}", c)
16911691
}
16921692
val id = tw.getFreshIdLabel<DbGeexpr>()
16931693
val type = useType(c.type)
@@ -1697,7 +1697,7 @@ open class KotlinFileExtractor(
16971697
}
16981698
isBuiltinCallInternal(c, "EQEQ") -> {
16991699
if(c.origin != IrStatementOrigin.EQEQ) {
1700-
logger.errorElement("Unexpected origin for EQEQ: ${c.origin}", c)
1700+
logger.warnElement("Unexpected origin for EQEQ: ${c.origin}", c)
17011701
}
17021702
val id = tw.getFreshIdLabel<DbValueeqexpr>()
17031703
val type = useType(c.type)
@@ -1707,7 +1707,7 @@ open class KotlinFileExtractor(
17071707
}
17081708
isBuiltinCallInternal(c, "EQEQEQ") -> {
17091709
if(c.origin != IrStatementOrigin.EQEQEQ) {
1710-
logger.errorElement("Unexpected origin for EQEQEQ: ${c.origin}", c)
1710+
logger.warnElement("Unexpected origin for EQEQEQ: ${c.origin}", c)
17111711
}
17121712
val id = tw.getFreshIdLabel<DbEqexpr>()
17131713
val type = useType(c.type)
@@ -1717,7 +1717,7 @@ open class KotlinFileExtractor(
17171717
}
17181718
isBuiltinCallInternal(c, "ieee754equals") -> {
17191719
if(c.origin != IrStatementOrigin.EQEQ) {
1720-
logger.errorElement("Unexpected origin for ieee754equals: ${c.origin}", c)
1720+
logger.warnElement("Unexpected origin for ieee754equals: ${c.origin}", c)
17211721
}
17221722
val id = tw.getFreshIdLabel<DbEqexpr>()
17231723
val type = useType(c.type)
@@ -1727,7 +1727,7 @@ open class KotlinFileExtractor(
17271727
}
17281728
isBuiltinCallInternal(c, "CHECK_NOT_NULL") -> {
17291729
if(c.origin != IrStatementOrigin.EXCLEXCL) {
1730-
logger.errorElement("Unexpected origin for CHECK_NOT_NULL: ${c.origin}", c)
1730+
logger.warnElement("Unexpected origin for CHECK_NOT_NULL: ${c.origin}", c)
17311731
}
17321732

17331733
val id = tw.getFreshIdLabel<DbNotnullexpr>()
@@ -2394,7 +2394,7 @@ open class KotlinFileExtractor(
23942394
val stmtParent = parent.stmt(e, callable)
23952395
val irConstructor = declarationStack.peek() as? IrConstructor
23962396
if (irConstructor == null) {
2397-
logger.warnElement("IrInstanceInitializerCall outside constructor", e)
2397+
logger.errorElement("IrInstanceInitializerCall outside constructor", e)
23982398
return
23992399
}
24002400
extractInstanceInitializerBlock(stmtParent, irConstructor)
@@ -3368,7 +3368,7 @@ open class KotlinFileExtractor(
33683368
) {
33693369
with("function reference", functionReferenceExpr) {
33703370
val target = functionReferenceExpr.reflectionTarget ?: run {
3371-
logger.errorElement("Expected to find reflection target for function reference. Using underlying symbol instead.", functionReferenceExpr)
3371+
logger.warnElement("Expected to find reflection target for function reference. Using underlying symbol instead.", functionReferenceExpr)
33723372
functionReferenceExpr.symbol
33733373
}
33743374

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
isFinalField
22
| test.kt:3:3:3:18 | x |
3-
#select
4-
| test.kt:3:3:3:18 | this.x | test.kt:6:10:6:10 | getX(...) |
3+
#select

java/ql/test/kotlin/library-tests/field-initializer-flow/test.ql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import semmle.code.java.dataflow.DataFlow
44
class Config extends DataFlow::Configuration {
55
Config() { this = "Config" }
66

7-
override predicate isSource(DataFlow::Node n) {
8-
n.asExpr().(CompileTimeConstantExpr).getStringValue() = "Source"
9-
}
7+
override predicate isSource(DataFlow::Node n) { n.asExpr().(StringLiteral).getValue() = "Source" }
108

119
override predicate isSink(DataFlow::Node n) {
1210
n.asExpr().(Argument).getCall().getCallee().getName() = "sink"

swift/codegen/BUILD.bazel

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ py_binary(
2727
py_binary(
2828
name = "trapgen",
2929
srcs = ["trapgen.py"],
30-
data = ["//swift/codegen/templates:trap"],
30+
data = [
31+
"//swift:dbscheme",
32+
"//swift/codegen/templates:trap",
33+
],
3134
visibility = ["//swift:__subpackages__"],
3235
deps = [
3336
"//swift/codegen/lib",
@@ -38,7 +41,11 @@ py_binary(
3841
py_binary(
3942
name = "cppgen",
4043
srcs = ["cppgen.py"],
41-
data = ["//swift/codegen/templates:cpp"],
44+
data = [
45+
":schema",
46+
":schema_includes",
47+
"//swift/codegen/templates:cpp",
48+
],
4249
visibility = ["//swift:__subpackages__"],
4350
deps = [
4451
"//swift/codegen/lib",

0 commit comments

Comments
 (0)