diff --git a/2024-11-25-ts57.md b/2024-11-25-ts57.md new file mode 100644 index 000000000000..3a92872d6d60 --- /dev/null +++ b/2024-11-25-ts57.md @@ -0,0 +1,4 @@ +--- +category: majorAnalysis +--- +* Added support for TypeScript 5.7. diff --git a/cpp/ql/lib/semmle/code/cpp/models/Models.qll b/cpp/ql/lib/semmle/code/cpp/models/Models.qll index 1e0b6cd33ed2..f6776a623ffe 100644 --- a/cpp/ql/lib/semmle/code/cpp/models/Models.qll +++ b/cpp/ql/lib/semmle/code/cpp/models/Models.qll @@ -49,3 +49,4 @@ private import implementations.PostgreSql private import implementations.System private import implementations.StructuredExceptionHandling private import implementations.ZMQ +private import implementations.Win32CommandExecution diff --git a/cpp/ql/lib/semmle/code/cpp/models/implementations/Win32CommandExecution.qll b/cpp/ql/lib/semmle/code/cpp/models/implementations/Win32CommandExecution.qll new file mode 100644 index 000000000000..13d7ffae8075 --- /dev/null +++ b/cpp/ql/lib/semmle/code/cpp/models/implementations/Win32CommandExecution.qll @@ -0,0 +1,56 @@ +private import semmle.code.cpp.models.interfaces.CommandExecution + +/** The `ShellExecute` family of functions from Win32. */ +class ShellExecute extends Function { + ShellExecute() { this.hasGlobalName("ShellExecute" + ["", "A", "W"]) } +} + +private class ShellExecuteModel extends ShellExecute, CommandExecutionFunction { + override predicate hasCommandArgument(FunctionInput input) { input.isParameterDeref(2) } +} + +/** The `WinExec` function from Win32. */ +class WinExec extends Function { + WinExec() { this.hasGlobalName("WinExec") } +} + +private class WinExecModel extends WinExec, CommandExecutionFunction { + override predicate hasCommandArgument(FunctionInput input) { input.isParameterDeref(0) } +} + +/** The `CreateProcess` family of functions from Win32. */ +class CreateProcess extends Function { + CreateProcess() { this.hasGlobalName("CreateProcess" + ["", "A", "W"]) } +} + +private class CreateProcessModel extends CreateProcess, CommandExecutionFunction { + override predicate hasCommandArgument(FunctionInput input) { input.isParameterDeref(0) } +} + +/** The `CreateProcessAsUser` family of functions from Win32. */ +class CreateProcessAsUser extends Function { + CreateProcessAsUser() { this.hasGlobalName("CreateProcessAsUser" + ["", "A", "W"]) } +} + +private class CreateProcessAsUserModel extends CreateProcessAsUser, CommandExecutionFunction { + override predicate hasCommandArgument(FunctionInput input) { input.isParameterDeref(1) } +} + +/** The `CreateProcessWithLogonW` function from Win32. */ +class CreateProcessWithLogonW extends Function { + CreateProcessWithLogonW() { this.hasGlobalName("CreateProcessWithLogonW") } +} + +private class CreateProcessWithLogonModel extends CreateProcessWithLogonW, CommandExecutionFunction { + override predicate hasCommandArgument(FunctionInput input) { input.isParameterDeref(4) } +} + +/** The `CreateProcessWithTokenW` function from Win32. */ +class CreateProcessWithTokenW extends Function { + CreateProcessWithTokenW() { this.hasGlobalName("CreateProcessWithTokenW") } +} + +private class CreateProcessWithTokenWModel extends CreateProcessWithTokenW, CommandExecutionFunction +{ + override predicate hasCommandArgument(FunctionInput input) { input.isParameterDeref(2) } +} diff --git a/java/ql/lib/semmle/code/java/security/Encryption.qll b/java/ql/lib/semmle/code/java/security/Encryption.qll index 1b28f5cbba61..dae80b19be19 100644 --- a/java/ql/lib/semmle/code/java/security/Encryption.qll +++ b/java/ql/lib/semmle/code/java/security/Encryption.qll @@ -247,7 +247,7 @@ string getASecureAlgorithmName() { result = [ "RSA", "SHA-?256", "SHA-?512", "CCM", "GCM", "AES(?![^a-zA-Z](ECB|CBC/PKCS[57]Padding))", - "Blowfish", "ECIES" + "Blowfish", "ECIES", "SHA3-(256|384|512)" ] } diff --git a/java/ql/src/change-notes/2024-11-22-sha3.md b/java/ql/src/change-notes/2024-11-22-sha3.md new file mode 100644 index 000000000000..61dbc35162e1 --- /dev/null +++ b/java/ql/src/change-notes/2024-11-22-sha3.md @@ -0,0 +1,4 @@ +--- +category: minorAnalysis +--- +* Added SHA3 to the list of secure hashing algorithms. As a result the `java/potentially-weak-cryptographic-algorithm` query should no longer flag up uses of SHA3. diff --git a/java/ql/test/query-tests/security/CWE-327/semmle/tests/WeakHashing.java b/java/ql/test/query-tests/security/CWE-327/semmle/tests/WeakHashing.java index 6a3565fc1412..8858576cb904 100644 --- a/java/ql/test/query-tests/security/CWE-327/semmle/tests/WeakHashing.java +++ b/java/ql/test/query-tests/security/CWE-327/semmle/tests/WeakHashing.java @@ -25,5 +25,8 @@ void hashing() throws NoSuchAlgorithmException, IOException { // OK: Property does not exist and default is secure MessageDigest ok2 = MessageDigest.getInstance(props.getProperty("hashAlg3", "SHA-256")); + + // GOOD: Using a strong hashing algorithm + MessageDigest ok3 = MessageDigest.getInstance("SHA3-512"); } -} \ No newline at end of file +} diff --git a/javascript/extractor/lib/typescript/package-lock.json b/javascript/extractor/lib/typescript/package-lock.json index 50a9e0a66caa..1978e3963246 100644 --- a/javascript/extractor/lib/typescript/package-lock.json +++ b/javascript/extractor/lib/typescript/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "typescript-parser-wrapper", "dependencies": { - "typescript": "^5.6.2" + "typescript": "^5.7.2" }, "devDependencies": { "@types/node": "18.15.3" @@ -20,9 +20,9 @@ "license": "MIT" }, "node_modules/typescript": { - "version": "5.6.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", - "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", diff --git a/javascript/extractor/lib/typescript/package.json b/javascript/extractor/lib/typescript/package.json index bf650ec457a4..9d77f4ab740a 100644 --- a/javascript/extractor/lib/typescript/package.json +++ b/javascript/extractor/lib/typescript/package.json @@ -2,7 +2,7 @@ "name": "typescript-parser-wrapper", "private": true, "dependencies": { - "typescript": "5.6.2" + "typescript": "^5.7.2" }, "scripts": { "build": "tsc --project tsconfig.json", diff --git a/javascript/ql/integration-tests/diagnostics/internal-error/src/my_failure.ts b/javascript/ql/integration-tests/diagnostics/internal-error/src/my_failure.ts index 29e78b136e82..f2a1644e18ff 100644 --- a/javascript/ql/integration-tests/diagnostics/internal-error/src/my_failure.ts +++ b/javascript/ql/integration-tests/diagnostics/internal-error/src/my_failure.ts @@ -1,17 +1,3022 @@ -type Output = { - (...args: S): any; -}; - -declare function createThing( - type: K, - fn: (...args: S) => any -): Output; - -const one = createThing("one", () => ({})); - -const two = createThing("two", () => ({})); - -const three = createThing("three", (cursor: string) => null); -const four = createThing("four", (error: number) => null); - -type Events = Array; +console.log( + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 + + 1 +); diff --git a/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected b/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected index 3061a6ba1f04..df304b899bb0 100644 --- a/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected +++ b/javascript/ql/test/library-tests/TypeScript/Types/printAst.expected @@ -1877,8 +1877,35 @@ nodes | tst.ts:508:17:508:38 | [MethodCallExpr] obj[key ... rCase() | semmle.label | [MethodCallExpr] obj[key ... rCase() | | tst.ts:508:21:508:23 | [VarRef] key | semmle.label | [VarRef] key | | tst.ts:508:26:508:36 | [Label] toUpperCase | semmle.label | [Label] toUpperCase | +| tst.ts:513:1:520:1 | [NamespaceDeclaration] namespa ... type. } | semmle.label | [NamespaceDeclaration] namespa ... type. } | +| tst.ts:513:1:520:1 | [NamespaceDeclaration] namespa ... type. } | semmle.order | 92 | +| tst.ts:513:11:513:14 | [VarDecl] TS57 | semmle.label | [VarDecl] TS57 | +| tst.ts:514:3:514:26 | [DeclStmt] const a = ... | semmle.label | [DeclStmt] const a = ... | +| tst.ts:514:17:514:17 | [VarDecl] a | semmle.label | [VarDecl] a | +| tst.ts:514:17:514:25 | [VariableDeclarator] a: symbol | semmle.label | [VariableDeclarator] a: symbol | +| tst.ts:514:20:514:25 | [KeywordTypeExpr] symbol | semmle.label | [KeywordTypeExpr] symbol | +| tst.ts:515:3:517:3 | [ExportDeclaration] export ... }; } | semmle.label | [ExportDeclaration] export ... }; } | +| tst.ts:515:10:517:3 | [ClassDefinition,TypeDefinition] class A ... }; } | semmle.label | [ClassDefinition,TypeDefinition] class A ... }; } | +| tst.ts:515:16:515:16 | [VarDecl] A | semmle.label | [VarDecl] A | +| tst.ts:515:18:515:17 | [BlockStmt] {} | semmle.label | [BlockStmt] {} | +| tst.ts:515:18:515:17 | [ClassInitializedMember,ConstructorDefinition] constructor() {} | semmle.label | [ClassInitializedMember,ConstructorDefinition] constructor() {} | +| tst.ts:515:18:515:17 | [FunctionExpr] () {} | semmle.label | [FunctionExpr] () {} | +| tst.ts:515:18:515:17 | [Label] constructor | semmle.label | [Label] constructor | +| tst.ts:516:7:516:24 | [ClassInitializedMember,MethodDefinition] [a]() { return 1 } | semmle.label | [ClassInitializedMember,MethodDefinition] [a]() { return 1 } | +| tst.ts:516:7:516:24 | [FunctionExpr] [a]() { return 1 } | semmle.label | [FunctionExpr] [a]() { return 1 } | +| tst.ts:516:8:516:8 | [VarRef] a | semmle.label | [VarRef] a | +| tst.ts:516:13:516:24 | [BlockStmt] { return 1 } | semmle.label | [BlockStmt] { return 1 } | +| tst.ts:516:15:516:22 | [ReturnStmt] return 1 | semmle.label | [ReturnStmt] return 1 | +| tst.ts:516:22:516:22 | [Literal] 1 | semmle.label | [Literal] 1 | +| tst.ts:519:3:519:32 | [DeclStmt] const e1 = ... | semmle.label | [DeclStmt] const e1 = ... | +| tst.ts:519:17:519:18 | [VarDecl] e1 | semmle.label | [VarDecl] e1 | +| tst.ts:519:17:519:31 | [VariableDeclarator] e1: A[typeof a] | semmle.label | [VariableDeclarator] e1: A[typeof a] | +| tst.ts:519:21:519:21 | [LocalTypeAccess] A | semmle.label | [LocalTypeAccess] A | +| tst.ts:519:21:519:31 | [IndexedAccessTypeExpr] A[typeof a] | semmle.label | [IndexedAccessTypeExpr] A[typeof a] | +| tst.ts:519:23:519:30 | [TypeofTypeExpr] typeof a | semmle.label | [TypeofTypeExpr] typeof a | +| tst.ts:519:30:519:30 | [LocalVarTypeAccess] a | semmle.label | [LocalVarTypeAccess] a | | tstModuleCJS.cts:1:1:3:1 | [ExportDeclaration] export ... 'b'; } | semmle.label | [ExportDeclaration] export ... 'b'; } | -| tstModuleCJS.cts:1:1:3:1 | [ExportDeclaration] export ... 'b'; } | semmle.order | 92 | +| tstModuleCJS.cts:1:1:3:1 | [ExportDeclaration] export ... 'b'; } | semmle.order | 93 | | tstModuleCJS.cts:1:8:3:1 | [FunctionDeclStmt] functio ... 'b'; } | semmle.label | [FunctionDeclStmt] functio ... 'b'; } | | tstModuleCJS.cts:1:17:1:28 | [VarDecl] tstModuleCJS | semmle.label | [VarDecl] tstModuleCJS | | tstModuleCJS.cts:1:33:1:35 | [LiteralTypeExpr] 'a' | semmle.label | [LiteralTypeExpr] 'a' | @@ -1896,7 +1923,7 @@ nodes | tstModuleCJS.cts:2:34:2:36 | [Literal] 'a' | semmle.label | [Literal] 'a' | | tstModuleCJS.cts:2:40:2:42 | [Literal] 'b' | semmle.label | [Literal] 'b' | | tstModuleES.mts:1:1:3:1 | [ExportDeclaration] export ... 'b'; } | semmle.label | [ExportDeclaration] export ... 'b'; } | -| tstModuleES.mts:1:1:3:1 | [ExportDeclaration] export ... 'b'; } | semmle.order | 93 | +| tstModuleES.mts:1:1:3:1 | [ExportDeclaration] export ... 'b'; } | semmle.order | 94 | | tstModuleES.mts:1:16:3:1 | [FunctionDeclStmt] functio ... 'b'; } | semmle.label | [FunctionDeclStmt] functio ... 'b'; } | | tstModuleES.mts:1:25:1:35 | [VarDecl] tstModuleES | semmle.label | [VarDecl] tstModuleES | | tstModuleES.mts:1:40:1:42 | [LiteralTypeExpr] 'a' | semmle.label | [LiteralTypeExpr] 'a' | @@ -1914,7 +1941,7 @@ nodes | tstModuleES.mts:2:34:2:36 | [Literal] 'a' | semmle.label | [Literal] 'a' | | tstModuleES.mts:2:40:2:42 | [Literal] 'b' | semmle.label | [Literal] 'b' | | tstSuffixA.ts:1:1:3:1 | [ExportDeclaration] export ... .ts'; } | semmle.label | [ExportDeclaration] export ... .ts'; } | -| tstSuffixA.ts:1:1:3:1 | [ExportDeclaration] export ... .ts'; } | semmle.order | 94 | +| tstSuffixA.ts:1:1:3:1 | [ExportDeclaration] export ... .ts'; } | semmle.order | 95 | | tstSuffixA.ts:1:8:3:1 | [FunctionDeclStmt] functio ... .ts'; } | semmle.label | [FunctionDeclStmt] functio ... .ts'; } | | tstSuffixA.ts:1:17:1:28 | [VarDecl] resolvedFile | semmle.label | [VarDecl] resolvedFile | | tstSuffixA.ts:1:33:1:47 | [LiteralTypeExpr] 'tstSuffixA.ts' | semmle.label | [LiteralTypeExpr] 'tstSuffixA.ts' | @@ -1922,7 +1949,7 @@ nodes | tstSuffixA.ts:2:5:2:27 | [ReturnStmt] return ... xA.ts'; | semmle.label | [ReturnStmt] return ... xA.ts'; | | tstSuffixA.ts:2:12:2:26 | [Literal] 'tstSuffixA.ts' | semmle.label | [Literal] 'tstSuffixA.ts' | | tstSuffixB.ios.ts:1:1:3:1 | [ExportDeclaration] export ... .ts'; } | semmle.label | [ExportDeclaration] export ... .ts'; } | -| tstSuffixB.ios.ts:1:1:3:1 | [ExportDeclaration] export ... .ts'; } | semmle.order | 95 | +| tstSuffixB.ios.ts:1:1:3:1 | [ExportDeclaration] export ... .ts'; } | semmle.order | 96 | | tstSuffixB.ios.ts:1:8:3:1 | [FunctionDeclStmt] functio ... .ts'; } | semmle.label | [FunctionDeclStmt] functio ... .ts'; } | | tstSuffixB.ios.ts:1:17:1:28 | [VarDecl] resolvedFile | semmle.label | [VarDecl] resolvedFile | | tstSuffixB.ios.ts:1:33:1:51 | [LiteralTypeExpr] 'tstSuffixB.ios.ts' | semmle.label | [LiteralTypeExpr] 'tstSuffixB.ios.ts' | @@ -1930,7 +1957,7 @@ nodes | tstSuffixB.ios.ts:2:5:2:31 | [ReturnStmt] return ... os.ts'; | semmle.label | [ReturnStmt] return ... os.ts'; | | tstSuffixB.ios.ts:2:12:2:30 | [Literal] 'tstSuffixB.ios.ts' | semmle.label | [Literal] 'tstSuffixB.ios.ts' | | tstSuffixB.ts:1:1:3:1 | [ExportDeclaration] export ... .ts'; } | semmle.label | [ExportDeclaration] export ... .ts'; } | -| tstSuffixB.ts:1:1:3:1 | [ExportDeclaration] export ... .ts'; } | semmle.order | 96 | +| tstSuffixB.ts:1:1:3:1 | [ExportDeclaration] export ... .ts'; } | semmle.order | 97 | | tstSuffixB.ts:1:8:3:1 | [FunctionDeclStmt] functio ... .ts'; } | semmle.label | [FunctionDeclStmt] functio ... .ts'; } | | tstSuffixB.ts:1:17:1:28 | [VarDecl] resolvedFile | semmle.label | [VarDecl] resolvedFile | | tstSuffixB.ts:1:33:1:47 | [LiteralTypeExpr] 'tstSuffixB.ts' | semmle.label | [LiteralTypeExpr] 'tstSuffixB.ts' | @@ -1938,16 +1965,16 @@ nodes | tstSuffixB.ts:2:5:2:27 | [ReturnStmt] return ... xB.ts'; | semmle.label | [ReturnStmt] return ... xB.ts'; | | tstSuffixB.ts:2:12:2:26 | [Literal] 'tstSuffixB.ts' | semmle.label | [Literal] 'tstSuffixB.ts' | | type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | -| type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | semmle.order | 97 | +| type_alias.ts:1:1:1:17 | [TypeAliasDeclaration,TypeDefinition] type B = boolean; | semmle.order | 98 | | type_alias.ts:1:6:1:6 | [Identifier] B | semmle.label | [Identifier] B | | type_alias.ts:1:10:1:16 | [KeywordTypeExpr] boolean | semmle.label | [KeywordTypeExpr] boolean | | type_alias.ts:3:1:3:9 | [DeclStmt] var b = ... | semmle.label | [DeclStmt] var b = ... | -| type_alias.ts:3:1:3:9 | [DeclStmt] var b = ... | semmle.order | 98 | +| type_alias.ts:3:1:3:9 | [DeclStmt] var b = ... | semmle.order | 99 | | type_alias.ts:3:5:3:5 | [VarDecl] b | semmle.label | [VarDecl] b | | type_alias.ts:3:5:3:8 | [VariableDeclarator] b: B | semmle.label | [VariableDeclarator] b: B | | type_alias.ts:3:8:3:8 | [LocalTypeAccess] B | semmle.label | [LocalTypeAccess] B | | type_alias.ts:5:1:5:50 | [TypeAliasDeclaration,TypeDefinition] type Va ... ay>; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type Va ... ay>; | -| type_alias.ts:5:1:5:50 | [TypeAliasDeclaration,TypeDefinition] type Va ... ay>; | semmle.order | 99 | +| type_alias.ts:5:1:5:50 | [TypeAliasDeclaration,TypeDefinition] type Va ... ay>; | semmle.order | 100 | | type_alias.ts:5:6:5:17 | [Identifier] ValueOrArray | semmle.label | [Identifier] ValueOrArray | | type_alias.ts:5:19:5:19 | [Identifier] T | semmle.label | [Identifier] T | | type_alias.ts:5:19:5:19 | [TypeParameter] T | semmle.label | [TypeParameter] T | @@ -1959,14 +1986,14 @@ nodes | type_alias.ts:5:34:5:48 | [GenericTypeExpr] ValueOrArray | semmle.label | [GenericTypeExpr] ValueOrArray | | type_alias.ts:5:47:5:47 | [LocalTypeAccess] T | semmle.label | [LocalTypeAccess] T | | type_alias.ts:7:1:7:28 | [DeclStmt] var c = ... | semmle.label | [DeclStmt] var c = ... | -| type_alias.ts:7:1:7:28 | [DeclStmt] var c = ... | semmle.order | 100 | +| type_alias.ts:7:1:7:28 | [DeclStmt] var c = ... | semmle.order | 101 | | type_alias.ts:7:5:7:5 | [VarDecl] c | semmle.label | [VarDecl] c | | type_alias.ts:7:5:7:27 | [VariableDeclarator] c: Valu ... number> | semmle.label | [VariableDeclarator] c: Valu ... number> | | type_alias.ts:7:8:7:19 | [LocalTypeAccess] ValueOrArray | semmle.label | [LocalTypeAccess] ValueOrArray | | type_alias.ts:7:8:7:27 | [GenericTypeExpr] ValueOrArray | semmle.label | [GenericTypeExpr] ValueOrArray | | type_alias.ts:7:21:7:26 | [KeywordTypeExpr] number | semmle.label | [KeywordTypeExpr] number | | type_alias.ts:9:1:15:13 | [TypeAliasDeclaration,TypeDefinition] type Js ... Json[]; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type Js ... Json[]; | -| type_alias.ts:9:1:15:13 | [TypeAliasDeclaration,TypeDefinition] type Js ... Json[]; | semmle.order | 101 | +| type_alias.ts:9:1:15:13 | [TypeAliasDeclaration,TypeDefinition] type Js ... Json[]; | semmle.order | 102 | | type_alias.ts:9:6:9:9 | [Identifier] Json | semmle.label | [Identifier] Json | | type_alias.ts:10:5:15:12 | [UnionTypeExpr] \| strin ... Json[] | semmle.label | [UnionTypeExpr] \| strin ... Json[] | | type_alias.ts:10:7:10:12 | [KeywordTypeExpr] string | semmle.label | [KeywordTypeExpr] string | @@ -1982,12 +2009,12 @@ nodes | type_alias.ts:15:7:15:10 | [LocalTypeAccess] Json | semmle.label | [LocalTypeAccess] Json | | type_alias.ts:15:7:15:12 | [ArrayTypeExpr] Json[] | semmle.label | [ArrayTypeExpr] Json[] | | type_alias.ts:17:1:17:15 | [DeclStmt] var json = ... | semmle.label | [DeclStmt] var json = ... | -| type_alias.ts:17:1:17:15 | [DeclStmt] var json = ... | semmle.order | 102 | +| type_alias.ts:17:1:17:15 | [DeclStmt] var json = ... | semmle.order | 103 | | type_alias.ts:17:5:17:8 | [VarDecl] json | semmle.label | [VarDecl] json | | type_alias.ts:17:5:17:14 | [VariableDeclarator] json: Json | semmle.label | [VariableDeclarator] json: Json | | type_alias.ts:17:11:17:14 | [LocalTypeAccess] Json | semmle.label | [LocalTypeAccess] Json | | type_alias.ts:19:1:21:57 | [TypeAliasDeclaration,TypeDefinition] type Vi ... ode[]]; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type Vi ... ode[]]; | -| type_alias.ts:19:1:21:57 | [TypeAliasDeclaration,TypeDefinition] type Vi ... ode[]]; | semmle.order | 103 | +| type_alias.ts:19:1:21:57 | [TypeAliasDeclaration,TypeDefinition] type Vi ... ode[]]; | semmle.order | 104 | | type_alias.ts:19:6:19:16 | [Identifier] VirtualNode | semmle.label | [Identifier] VirtualNode | | type_alias.ts:20:5:21:56 | [UnionTypeExpr] \| strin ... Node[]] | semmle.label | [UnionTypeExpr] \| strin ... Node[]] | | type_alias.ts:20:7:20:12 | [KeywordTypeExpr] string | semmle.label | [KeywordTypeExpr] string | @@ -2003,7 +2030,7 @@ nodes | type_alias.ts:21:43:21:53 | [LocalTypeAccess] VirtualNode | semmle.label | [LocalTypeAccess] VirtualNode | | type_alias.ts:21:43:21:55 | [ArrayTypeExpr] VirtualNode[] | semmle.label | [ArrayTypeExpr] VirtualNode[] | | type_alias.ts:23:1:27:6 | [DeclStmt] const myNode = ... | semmle.label | [DeclStmt] const myNode = ... | -| type_alias.ts:23:1:27:6 | [DeclStmt] const myNode = ... | semmle.order | 104 | +| type_alias.ts:23:1:27:6 | [DeclStmt] const myNode = ... | semmle.order | 105 | | type_alias.ts:23:7:23:12 | [VarDecl] myNode | semmle.label | [VarDecl] myNode | | type_alias.ts:23:7:27:5 | [VariableDeclarator] myNode: ... ] ] | semmle.label | [VariableDeclarator] myNode: ... ] ] | | type_alias.ts:23:15:23:25 | [LocalTypeAccess] VirtualNode | semmle.label | [LocalTypeAccess] VirtualNode | @@ -2028,12 +2055,12 @@ nodes | type_alias.ts:26:23:26:36 | [Literal] "second-child" | semmle.label | [Literal] "second-child" | | type_alias.ts:26:41:26:62 | [Literal] "I'm the second child" | semmle.label | [Literal] "I'm the second child" | | type_definition_objects.ts:1:1:1:33 | [ImportDeclaration] import ... dummy"; | semmle.label | [ImportDeclaration] import ... dummy"; | -| type_definition_objects.ts:1:1:1:33 | [ImportDeclaration] import ... dummy"; | semmle.order | 105 | +| type_definition_objects.ts:1:1:1:33 | [ImportDeclaration] import ... dummy"; | semmle.order | 106 | | type_definition_objects.ts:1:8:1:17 | [ImportSpecifier] * as dummy | semmle.label | [ImportSpecifier] * as dummy | | type_definition_objects.ts:1:13:1:17 | [VarDecl] dummy | semmle.label | [VarDecl] dummy | | type_definition_objects.ts:1:24:1:32 | [Literal] "./dummy" | semmle.label | [Literal] "./dummy" | | type_definition_objects.ts:3:1:3:17 | [ExportDeclaration] export class C {} | semmle.label | [ExportDeclaration] export class C {} | -| type_definition_objects.ts:3:1:3:17 | [ExportDeclaration] export class C {} | semmle.order | 106 | +| type_definition_objects.ts:3:1:3:17 | [ExportDeclaration] export class C {} | semmle.order | 107 | | type_definition_objects.ts:3:8:3:17 | [ClassDefinition,TypeDefinition] class C {} | semmle.label | [ClassDefinition,TypeDefinition] class C {} | | type_definition_objects.ts:3:14:3:14 | [VarDecl] C | semmle.label | [VarDecl] C | | type_definition_objects.ts:3:16:3:15 | [BlockStmt] {} | semmle.label | [BlockStmt] {} | @@ -2041,36 +2068,36 @@ nodes | type_definition_objects.ts:3:16:3:15 | [FunctionExpr] () {} | semmle.label | [FunctionExpr] () {} | | type_definition_objects.ts:3:16:3:15 | [Label] constructor | semmle.label | [Label] constructor | | type_definition_objects.ts:4:1:4:17 | [DeclStmt] let classObj = ... | semmle.label | [DeclStmt] let classObj = ... | -| type_definition_objects.ts:4:1:4:17 | [DeclStmt] let classObj = ... | semmle.order | 107 | +| type_definition_objects.ts:4:1:4:17 | [DeclStmt] let classObj = ... | semmle.order | 108 | | type_definition_objects.ts:4:5:4:12 | [VarDecl] classObj | semmle.label | [VarDecl] classObj | | type_definition_objects.ts:4:5:4:16 | [VariableDeclarator] classObj = C | semmle.label | [VariableDeclarator] classObj = C | | type_definition_objects.ts:4:16:4:16 | [VarRef] C | semmle.label | [VarRef] C | | type_definition_objects.ts:6:1:6:16 | [ExportDeclaration] export enum E {} | semmle.label | [ExportDeclaration] export enum E {} | -| type_definition_objects.ts:6:1:6:16 | [ExportDeclaration] export enum E {} | semmle.order | 108 | +| type_definition_objects.ts:6:1:6:16 | [ExportDeclaration] export enum E {} | semmle.order | 109 | | type_definition_objects.ts:6:8:6:16 | [EnumDeclaration,TypeDefinition] enum E {} | semmle.label | [EnumDeclaration,TypeDefinition] enum E {} | | type_definition_objects.ts:6:13:6:13 | [VarDecl] E | semmle.label | [VarDecl] E | | type_definition_objects.ts:7:1:7:16 | [DeclStmt] let enumObj = ... | semmle.label | [DeclStmt] let enumObj = ... | -| type_definition_objects.ts:7:1:7:16 | [DeclStmt] let enumObj = ... | semmle.order | 109 | +| type_definition_objects.ts:7:1:7:16 | [DeclStmt] let enumObj = ... | semmle.order | 110 | | type_definition_objects.ts:7:5:7:11 | [VarDecl] enumObj | semmle.label | [VarDecl] enumObj | | type_definition_objects.ts:7:5:7:15 | [VariableDeclarator] enumObj = E | semmle.label | [VariableDeclarator] enumObj = E | | type_definition_objects.ts:7:15:7:15 | [VarRef] E | semmle.label | [VarRef] E | | type_definition_objects.ts:9:1:9:22 | [ExportDeclaration] export ... e N {;} | semmle.label | [ExportDeclaration] export ... e N {;} | -| type_definition_objects.ts:9:1:9:22 | [ExportDeclaration] export ... e N {;} | semmle.order | 110 | +| type_definition_objects.ts:9:1:9:22 | [ExportDeclaration] export ... e N {;} | semmle.order | 111 | | type_definition_objects.ts:9:8:9:22 | [NamespaceDeclaration] namespace N {;} | semmle.label | [NamespaceDeclaration] namespace N {;} | | type_definition_objects.ts:9:18:9:18 | [VarDecl] N | semmle.label | [VarDecl] N | | type_definition_objects.ts:9:21:9:21 | [EmptyStmt] ; | semmle.label | [EmptyStmt] ; | | type_definition_objects.ts:10:1:10:21 | [DeclStmt] let namespaceObj = ... | semmle.label | [DeclStmt] let namespaceObj = ... | -| type_definition_objects.ts:10:1:10:21 | [DeclStmt] let namespaceObj = ... | semmle.order | 111 | +| type_definition_objects.ts:10:1:10:21 | [DeclStmt] let namespaceObj = ... | semmle.order | 112 | | type_definition_objects.ts:10:5:10:16 | [VarDecl] namespaceObj | semmle.label | [VarDecl] namespaceObj | | type_definition_objects.ts:10:5:10:20 | [VariableDeclarator] namespaceObj = N | semmle.label | [VariableDeclarator] namespaceObj = N | | type_definition_objects.ts:10:20:10:20 | [VarRef] N | semmle.label | [VarRef] N | | type_definitions.ts:1:1:1:33 | [ImportDeclaration] import ... dummy"; | semmle.label | [ImportDeclaration] import ... dummy"; | -| type_definitions.ts:1:1:1:33 | [ImportDeclaration] import ... dummy"; | semmle.order | 112 | +| type_definitions.ts:1:1:1:33 | [ImportDeclaration] import ... dummy"; | semmle.order | 113 | | type_definitions.ts:1:8:1:17 | [ImportSpecifier] * as dummy | semmle.label | [ImportSpecifier] * as dummy | | type_definitions.ts:1:13:1:17 | [VarDecl] dummy | semmle.label | [VarDecl] dummy | | type_definitions.ts:1:24:1:32 | [Literal] "./dummy" | semmle.label | [Literal] "./dummy" | | type_definitions.ts:3:1:5:1 | [InterfaceDeclaration,TypeDefinition] interfa ... x: S; } | semmle.label | [InterfaceDeclaration,TypeDefinition] interfa ... x: S; } | -| type_definitions.ts:3:1:5:1 | [InterfaceDeclaration,TypeDefinition] interfa ... x: S; } | semmle.order | 113 | +| type_definitions.ts:3:1:5:1 | [InterfaceDeclaration,TypeDefinition] interfa ... x: S; } | semmle.order | 114 | | type_definitions.ts:3:11:3:11 | [Identifier] I | semmle.label | [Identifier] I | | type_definitions.ts:3:13:3:13 | [Identifier] S | semmle.label | [Identifier] S | | type_definitions.ts:3:13:3:13 | [TypeParameter] S | semmle.label | [TypeParameter] S | @@ -2078,14 +2105,14 @@ nodes | type_definitions.ts:4:3:4:7 | [FieldDeclaration] x: S; | semmle.label | [FieldDeclaration] x: S; | | type_definitions.ts:4:6:4:6 | [LocalTypeAccess] S | semmle.label | [LocalTypeAccess] S | | type_definitions.ts:6:1:6:16 | [DeclStmt] let i = ... | semmle.label | [DeclStmt] let i = ... | -| type_definitions.ts:6:1:6:16 | [DeclStmt] let i = ... | semmle.order | 114 | +| type_definitions.ts:6:1:6:16 | [DeclStmt] let i = ... | semmle.order | 115 | | type_definitions.ts:6:5:6:5 | [VarDecl] i | semmle.label | [VarDecl] i | | type_definitions.ts:6:5:6:16 | [VariableDeclarator] i: I | semmle.label | [VariableDeclarator] i: I | | type_definitions.ts:6:8:6:8 | [LocalTypeAccess] I | semmle.label | [LocalTypeAccess] I | | type_definitions.ts:6:8:6:16 | [GenericTypeExpr] I | semmle.label | [GenericTypeExpr] I | | type_definitions.ts:6:10:6:15 | [KeywordTypeExpr] number | semmle.label | [KeywordTypeExpr] number | | type_definitions.ts:8:1:10:1 | [ClassDefinition,TypeDefinition] class C ... x: T } | semmle.label | [ClassDefinition,TypeDefinition] class C ... x: T } | -| type_definitions.ts:8:1:10:1 | [ClassDefinition,TypeDefinition] class C ... x: T } | semmle.order | 115 | +| type_definitions.ts:8:1:10:1 | [ClassDefinition,TypeDefinition] class C ... x: T } | semmle.order | 116 | | type_definitions.ts:8:7:8:7 | [VarDecl] C | semmle.label | [VarDecl] C | | type_definitions.ts:8:8:8:7 | [BlockStmt] {} | semmle.label | [BlockStmt] {} | | type_definitions.ts:8:8:8:7 | [ClassInitializedMember,ConstructorDefinition] constructor() {} | semmle.label | [ClassInitializedMember,ConstructorDefinition] constructor() {} | @@ -2097,14 +2124,14 @@ nodes | type_definitions.ts:9:3:9:6 | [FieldDeclaration] x: T | semmle.label | [FieldDeclaration] x: T | | type_definitions.ts:9:6:9:6 | [LocalTypeAccess] T | semmle.label | [LocalTypeAccess] T | | type_definitions.ts:11:1:11:17 | [DeclStmt] let c = ... | semmle.label | [DeclStmt] let c = ... | -| type_definitions.ts:11:1:11:17 | [DeclStmt] let c = ... | semmle.order | 116 | +| type_definitions.ts:11:1:11:17 | [DeclStmt] let c = ... | semmle.order | 117 | | type_definitions.ts:11:5:11:5 | [VarDecl] c | semmle.label | [VarDecl] c | | type_definitions.ts:11:5:11:16 | [VariableDeclarator] c: C | semmle.label | [VariableDeclarator] c: C | | type_definitions.ts:11:8:11:8 | [LocalTypeAccess] C | semmle.label | [LocalTypeAccess] C | | type_definitions.ts:11:8:11:16 | [GenericTypeExpr] C | semmle.label | [GenericTypeExpr] C | | type_definitions.ts:11:10:11:15 | [KeywordTypeExpr] number | semmle.label | [KeywordTypeExpr] number | | type_definitions.ts:13:1:15:1 | [EnumDeclaration,TypeDefinition] enum Co ... blue } | semmle.label | [EnumDeclaration,TypeDefinition] enum Co ... blue } | -| type_definitions.ts:13:1:15:1 | [EnumDeclaration,TypeDefinition] enum Co ... blue } | semmle.order | 117 | +| type_definitions.ts:13:1:15:1 | [EnumDeclaration,TypeDefinition] enum Co ... blue } | semmle.order | 118 | | type_definitions.ts:13:6:13:10 | [VarDecl] Color | semmle.label | [VarDecl] Color | | type_definitions.ts:14:3:14:5 | [EnumMember,TypeDefinition] red | semmle.label | [EnumMember,TypeDefinition] red | | type_definitions.ts:14:3:14:5 | [VarDecl] red | semmle.label | [VarDecl] red | @@ -2113,29 +2140,29 @@ nodes | type_definitions.ts:14:15:14:18 | [EnumMember,TypeDefinition] blue | semmle.label | [EnumMember,TypeDefinition] blue | | type_definitions.ts:14:15:14:18 | [VarDecl] blue | semmle.label | [VarDecl] blue | | type_definitions.ts:16:1:16:17 | [DeclStmt] let color = ... | semmle.label | [DeclStmt] let color = ... | -| type_definitions.ts:16:1:16:17 | [DeclStmt] let color = ... | semmle.order | 118 | +| type_definitions.ts:16:1:16:17 | [DeclStmt] let color = ... | semmle.order | 119 | | type_definitions.ts:16:5:16:9 | [VarDecl] color | semmle.label | [VarDecl] color | | type_definitions.ts:16:5:16:16 | [VariableDeclarator] color: Color | semmle.label | [VariableDeclarator] color: Color | | type_definitions.ts:16:12:16:16 | [LocalTypeAccess] Color | semmle.label | [LocalTypeAccess] Color | | type_definitions.ts:18:1:18:33 | [EnumDeclaration,TypeDefinition] enum En ... ember } | semmle.label | [EnumDeclaration,TypeDefinition] enum En ... ember } | -| type_definitions.ts:18:1:18:33 | [EnumDeclaration,TypeDefinition] enum En ... ember } | semmle.order | 119 | +| type_definitions.ts:18:1:18:33 | [EnumDeclaration,TypeDefinition] enum En ... ember } | semmle.order | 120 | | type_definitions.ts:18:6:18:22 | [VarDecl] EnumWithOneMember | semmle.label | [VarDecl] EnumWithOneMember | | type_definitions.ts:18:26:18:31 | [EnumMember,TypeDefinition] member | semmle.label | [EnumMember,TypeDefinition] member | | type_definitions.ts:18:26:18:31 | [VarDecl] member | semmle.label | [VarDecl] member | | type_definitions.ts:19:1:19:25 | [DeclStmt] let e = ... | semmle.label | [DeclStmt] let e = ... | -| type_definitions.ts:19:1:19:25 | [DeclStmt] let e = ... | semmle.order | 120 | +| type_definitions.ts:19:1:19:25 | [DeclStmt] let e = ... | semmle.order | 121 | | type_definitions.ts:19:5:19:5 | [VarDecl] e | semmle.label | [VarDecl] e | | type_definitions.ts:19:5:19:24 | [VariableDeclarator] e: EnumWithOneMember | semmle.label | [VariableDeclarator] e: EnumWithOneMember | | type_definitions.ts:19:8:19:24 | [LocalTypeAccess] EnumWithOneMember | semmle.label | [LocalTypeAccess] EnumWithOneMember | | type_definitions.ts:21:1:21:20 | [TypeAliasDeclaration,TypeDefinition] type Alias = T[]; | semmle.label | [TypeAliasDeclaration,TypeDefinition] type Alias = T[]; | -| type_definitions.ts:21:1:21:20 | [TypeAliasDeclaration,TypeDefinition] type Alias = T[]; | semmle.order | 121 | +| type_definitions.ts:21:1:21:20 | [TypeAliasDeclaration,TypeDefinition] type Alias = T[]; | semmle.order | 122 | | type_definitions.ts:21:6:21:10 | [Identifier] Alias | semmle.label | [Identifier] Alias | | type_definitions.ts:21:12:21:12 | [Identifier] T | semmle.label | [Identifier] T | | type_definitions.ts:21:12:21:12 | [TypeParameter] T | semmle.label | [TypeParameter] T | | type_definitions.ts:21:17:21:17 | [LocalTypeAccess] T | semmle.label | [LocalTypeAccess] T | | type_definitions.ts:21:17:21:19 | [ArrayTypeExpr] T[] | semmle.label | [ArrayTypeExpr] T[] | | type_definitions.ts:22:1:22:39 | [DeclStmt] let aliasForNumberArray = ... | semmle.label | [DeclStmt] let aliasForNumberArray = ... | -| type_definitions.ts:22:1:22:39 | [DeclStmt] let aliasForNumberArray = ... | semmle.order | 122 | +| type_definitions.ts:22:1:22:39 | [DeclStmt] let aliasForNumberArray = ... | semmle.order | 123 | | type_definitions.ts:22:5:22:23 | [VarDecl] aliasForNumberArray | semmle.label | [VarDecl] aliasForNumberArray | | type_definitions.ts:22:5:22:38 | [VariableDeclarator] aliasFo ... number> | semmle.label | [VariableDeclarator] aliasFo ... number> | | type_definitions.ts:22:26:22:30 | [LocalTypeAccess] Alias | semmle.label | [LocalTypeAccess] Alias | @@ -5534,6 +5561,56 @@ edges | tst.ts:508:17:508:36 | [DotExpr] obj[key].toUpperCase | tst.ts:508:26:508:36 | [Label] toUpperCase | semmle.order | 2 | | tst.ts:508:17:508:38 | [MethodCallExpr] obj[key ... rCase() | tst.ts:508:17:508:36 | [DotExpr] obj[key].toUpperCase | semmle.label | 0 | | tst.ts:508:17:508:38 | [MethodCallExpr] obj[key ... rCase() | tst.ts:508:17:508:36 | [DotExpr] obj[key].toUpperCase | semmle.order | 0 | +| tst.ts:513:1:520:1 | [NamespaceDeclaration] namespa ... type. } | tst.ts:513:11:513:14 | [VarDecl] TS57 | semmle.label | 1 | +| tst.ts:513:1:520:1 | [NamespaceDeclaration] namespa ... type. } | tst.ts:513:11:513:14 | [VarDecl] TS57 | semmle.order | 1 | +| tst.ts:513:1:520:1 | [NamespaceDeclaration] namespa ... type. } | tst.ts:514:3:514:26 | [DeclStmt] const a = ... | semmle.label | 2 | +| tst.ts:513:1:520:1 | [NamespaceDeclaration] namespa ... type. } | tst.ts:514:3:514:26 | [DeclStmt] const a = ... | semmle.order | 2 | +| tst.ts:513:1:520:1 | [NamespaceDeclaration] namespa ... type. } | tst.ts:515:3:517:3 | [ExportDeclaration] export ... }; } | semmle.label | 3 | +| tst.ts:513:1:520:1 | [NamespaceDeclaration] namespa ... type. } | tst.ts:515:3:517:3 | [ExportDeclaration] export ... }; } | semmle.order | 3 | +| tst.ts:513:1:520:1 | [NamespaceDeclaration] namespa ... type. } | tst.ts:519:3:519:32 | [DeclStmt] const e1 = ... | semmle.label | 4 | +| tst.ts:513:1:520:1 | [NamespaceDeclaration] namespa ... type. } | tst.ts:519:3:519:32 | [DeclStmt] const e1 = ... | semmle.order | 4 | +| tst.ts:514:3:514:26 | [DeclStmt] const a = ... | tst.ts:514:17:514:25 | [VariableDeclarator] a: symbol | semmle.label | 1 | +| tst.ts:514:3:514:26 | [DeclStmt] const a = ... | tst.ts:514:17:514:25 | [VariableDeclarator] a: symbol | semmle.order | 1 | +| tst.ts:514:17:514:25 | [VariableDeclarator] a: symbol | tst.ts:514:17:514:17 | [VarDecl] a | semmle.label | 1 | +| tst.ts:514:17:514:25 | [VariableDeclarator] a: symbol | tst.ts:514:17:514:17 | [VarDecl] a | semmle.order | 1 | +| tst.ts:514:17:514:25 | [VariableDeclarator] a: symbol | tst.ts:514:20:514:25 | [KeywordTypeExpr] symbol | semmle.label | 2 | +| tst.ts:514:17:514:25 | [VariableDeclarator] a: symbol | tst.ts:514:20:514:25 | [KeywordTypeExpr] symbol | semmle.order | 2 | +| tst.ts:515:3:517:3 | [ExportDeclaration] export ... }; } | tst.ts:515:10:517:3 | [ClassDefinition,TypeDefinition] class A ... }; } | semmle.label | 1 | +| tst.ts:515:3:517:3 | [ExportDeclaration] export ... }; } | tst.ts:515:10:517:3 | [ClassDefinition,TypeDefinition] class A ... }; } | semmle.order | 1 | +| tst.ts:515:10:517:3 | [ClassDefinition,TypeDefinition] class A ... }; } | tst.ts:515:16:515:16 | [VarDecl] A | semmle.label | 1 | +| tst.ts:515:10:517:3 | [ClassDefinition,TypeDefinition] class A ... }; } | tst.ts:515:16:515:16 | [VarDecl] A | semmle.order | 1 | +| tst.ts:515:10:517:3 | [ClassDefinition,TypeDefinition] class A ... }; } | tst.ts:515:18:515:17 | [ClassInitializedMember,ConstructorDefinition] constructor() {} | semmle.label | 2 | +| tst.ts:515:10:517:3 | [ClassDefinition,TypeDefinition] class A ... }; } | tst.ts:515:18:515:17 | [ClassInitializedMember,ConstructorDefinition] constructor() {} | semmle.order | 2 | +| tst.ts:515:10:517:3 | [ClassDefinition,TypeDefinition] class A ... }; } | tst.ts:516:7:516:24 | [ClassInitializedMember,MethodDefinition] [a]() { return 1 } | semmle.label | 3 | +| tst.ts:515:10:517:3 | [ClassDefinition,TypeDefinition] class A ... }; } | tst.ts:516:7:516:24 | [ClassInitializedMember,MethodDefinition] [a]() { return 1 } | semmle.order | 3 | +| tst.ts:515:18:515:17 | [ClassInitializedMember,ConstructorDefinition] constructor() {} | tst.ts:515:18:515:17 | [FunctionExpr] () {} | semmle.label | 2 | +| tst.ts:515:18:515:17 | [ClassInitializedMember,ConstructorDefinition] constructor() {} | tst.ts:515:18:515:17 | [FunctionExpr] () {} | semmle.order | 2 | +| tst.ts:515:18:515:17 | [ClassInitializedMember,ConstructorDefinition] constructor() {} | tst.ts:515:18:515:17 | [Label] constructor | semmle.label | 1 | +| tst.ts:515:18:515:17 | [ClassInitializedMember,ConstructorDefinition] constructor() {} | tst.ts:515:18:515:17 | [Label] constructor | semmle.order | 1 | +| tst.ts:515:18:515:17 | [FunctionExpr] () {} | tst.ts:515:18:515:17 | [BlockStmt] {} | semmle.label | 5 | +| tst.ts:515:18:515:17 | [FunctionExpr] () {} | tst.ts:515:18:515:17 | [BlockStmt] {} | semmle.order | 5 | +| tst.ts:516:7:516:24 | [ClassInitializedMember,MethodDefinition] [a]() { return 1 } | tst.ts:516:7:516:24 | [FunctionExpr] [a]() { return 1 } | semmle.label | 1 | +| tst.ts:516:7:516:24 | [ClassInitializedMember,MethodDefinition] [a]() { return 1 } | tst.ts:516:7:516:24 | [FunctionExpr] [a]() { return 1 } | semmle.order | 1 | +| tst.ts:516:7:516:24 | [ClassInitializedMember,MethodDefinition] [a]() { return 1 } | tst.ts:516:8:516:8 | [VarRef] a | semmle.label | 2 | +| tst.ts:516:7:516:24 | [ClassInitializedMember,MethodDefinition] [a]() { return 1 } | tst.ts:516:8:516:8 | [VarRef] a | semmle.order | 2 | +| tst.ts:516:7:516:24 | [FunctionExpr] [a]() { return 1 } | tst.ts:516:13:516:24 | [BlockStmt] { return 1 } | semmle.label | 5 | +| tst.ts:516:7:516:24 | [FunctionExpr] [a]() { return 1 } | tst.ts:516:13:516:24 | [BlockStmt] { return 1 } | semmle.order | 5 | +| tst.ts:516:13:516:24 | [BlockStmt] { return 1 } | tst.ts:516:15:516:22 | [ReturnStmt] return 1 | semmle.label | 1 | +| tst.ts:516:13:516:24 | [BlockStmt] { return 1 } | tst.ts:516:15:516:22 | [ReturnStmt] return 1 | semmle.order | 1 | +| tst.ts:516:15:516:22 | [ReturnStmt] return 1 | tst.ts:516:22:516:22 | [Literal] 1 | semmle.label | 1 | +| tst.ts:516:15:516:22 | [ReturnStmt] return 1 | tst.ts:516:22:516:22 | [Literal] 1 | semmle.order | 1 | +| tst.ts:519:3:519:32 | [DeclStmt] const e1 = ... | tst.ts:519:17:519:31 | [VariableDeclarator] e1: A[typeof a] | semmle.label | 1 | +| tst.ts:519:3:519:32 | [DeclStmt] const e1 = ... | tst.ts:519:17:519:31 | [VariableDeclarator] e1: A[typeof a] | semmle.order | 1 | +| tst.ts:519:17:519:31 | [VariableDeclarator] e1: A[typeof a] | tst.ts:519:17:519:18 | [VarDecl] e1 | semmle.label | 1 | +| tst.ts:519:17:519:31 | [VariableDeclarator] e1: A[typeof a] | tst.ts:519:17:519:18 | [VarDecl] e1 | semmle.order | 1 | +| tst.ts:519:17:519:31 | [VariableDeclarator] e1: A[typeof a] | tst.ts:519:21:519:31 | [IndexedAccessTypeExpr] A[typeof a] | semmle.label | 2 | +| tst.ts:519:17:519:31 | [VariableDeclarator] e1: A[typeof a] | tst.ts:519:21:519:31 | [IndexedAccessTypeExpr] A[typeof a] | semmle.order | 2 | +| tst.ts:519:21:519:31 | [IndexedAccessTypeExpr] A[typeof a] | tst.ts:519:21:519:21 | [LocalTypeAccess] A | semmle.label | 1 | +| tst.ts:519:21:519:31 | [IndexedAccessTypeExpr] A[typeof a] | tst.ts:519:21:519:21 | [LocalTypeAccess] A | semmle.order | 1 | +| tst.ts:519:21:519:31 | [IndexedAccessTypeExpr] A[typeof a] | tst.ts:519:23:519:30 | [TypeofTypeExpr] typeof a | semmle.label | 2 | +| tst.ts:519:21:519:31 | [IndexedAccessTypeExpr] A[typeof a] | tst.ts:519:23:519:30 | [TypeofTypeExpr] typeof a | semmle.order | 2 | +| tst.ts:519:23:519:30 | [TypeofTypeExpr] typeof a | tst.ts:519:30:519:30 | [LocalVarTypeAccess] a | semmle.label | 1 | +| tst.ts:519:23:519:30 | [TypeofTypeExpr] typeof a | tst.ts:519:30:519:30 | [LocalVarTypeAccess] a | semmle.order | 1 | | tstModuleCJS.cts:1:1:3:1 | [ExportDeclaration] export ... 'b'; } | tstModuleCJS.cts:1:8:3:1 | [FunctionDeclStmt] functio ... 'b'; } | semmle.label | 1 | | tstModuleCJS.cts:1:1:3:1 | [ExportDeclaration] export ... 'b'; } | tstModuleCJS.cts:1:8:3:1 | [FunctionDeclStmt] functio ... 'b'; } | semmle.order | 1 | | tstModuleCJS.cts:1:8:3:1 | [FunctionDeclStmt] functio ... 'b'; } | tstModuleCJS.cts:1:17:1:28 | [VarDecl] tstModuleCJS | semmle.label | 0 | diff --git a/javascript/ql/test/library-tests/TypeScript/Types/tests.expected b/javascript/ql/test/library-tests/TypeScript/Types/tests.expected index b786fae3713e..150ce1867248 100644 --- a/javascript/ql/test/library-tests/TypeScript/Types/tests.expected +++ b/javascript/ql/test/library-tests/TypeScript/Types/tests.expected @@ -728,6 +728,13 @@ getExprType | tst.ts:508:17:508:38 | obj[key ... rCase() | string | | tst.ts:508:21:508:23 | key | string | | tst.ts:508:26:508:36 | toUpperCase | () => string | +| tst.ts:513:11:513:14 | TS57 | typeof TS57 in tst.ts | +| tst.ts:514:17:514:17 | a | symbol | +| tst.ts:515:16:515:16 | A | A | +| tst.ts:516:7:516:24 | [a]() { return 1 } | () => number | +| tst.ts:516:8:516:8 | a | symbol | +| tst.ts:516:22:516:22 | 1 | 1 | +| tst.ts:519:17:519:18 | e1 | () => number | | tstModuleCJS.cts:1:17:1:28 | tstModuleCJS | () => "a" \| "b" | | tstModuleCJS.cts:2:12:2:15 | Math | Math | | tstModuleCJS.cts:2:12:2:22 | Math.random | () => number | @@ -843,6 +850,7 @@ getTypeDefinitionType | tst.ts:447:5:458:5 | class P ... }\\n } | Person | | tst.ts:473:5:476:5 | class S ... ;\\n } | SomeClass | | tst.ts:481:5:481:34 | type Pa ... T, T]; | Pair3 | +| tst.ts:515:10:517:3 | class A ... };\\n } | A | | type_alias.ts:1:1:1:17 | type B = boolean; | boolean | | type_alias.ts:5:1:5:50 | type Va ... ay>; | ValueOrArray | | type_alias.ts:9:1:15:13 | type Js ... Json[]; | Json | @@ -1219,6 +1227,11 @@ getTypeExprType | tst.ts:506:27:506:32 | string | string | | tst.ts:506:35:506:41 | unknown | unknown | | tst.ts:506:50:506:55 | string | string | +| tst.ts:514:20:514:25 | symbol | symbol | +| tst.ts:519:21:519:21 | A | A | +| tst.ts:519:21:519:31 | A[typeof a] | () => number | +| tst.ts:519:23:519:30 | typeof a | symbol | +| tst.ts:519:30:519:30 | a | symbol | | tstModuleCJS.cts:1:33:1:35 | 'a' | "a" | | tstModuleCJS.cts:1:33:1:41 | 'a' \| 'b' | "a" \| "b" | | tstModuleCJS.cts:1:39:1:41 | 'b' | "b" | @@ -1290,6 +1303,7 @@ getTypeExprType missingToString referenceDefinition | A | badTypes.ts:5:1:5:29 | interfa ... is.B {} | +| A | tst.ts:515:10:517:3 | class A ... };\\n } | | Action | tst.ts:252:3:254:50 | type Ac ... ring }; | | Alias | type_definitions.ts:21:1:21:20 | type Alias = T[]; | | Alias | type_definitions.ts:21:1:21:20 | type Alias = T[]; | diff --git a/javascript/ql/test/library-tests/TypeScript/Types/tst.ts b/javascript/ql/test/library-tests/TypeScript/Types/tst.ts index 4c29465b5645..87f876be9d0f 100644 --- a/javascript/ql/test/library-tests/TypeScript/Types/tst.ts +++ b/javascript/ql/test/library-tests/TypeScript/Types/tst.ts @@ -508,4 +508,13 @@ module TS55 { var str = obj[key].toUpperCase(); // Now okay, previously was error } } -} \ No newline at end of file +} + +namespace TS57{ + declare const a: symbol; + export class A { + [a]() { return 1 }; + } + + declare const e1: A[typeof a]; // Now okay, previously was compilation error TS2538: Type 'symbol' cannot be used as an index type. +} diff --git a/misc/codegen/generators/qlgen.py b/misc/codegen/generators/qlgen.py index f1a68f6bc014..e42c9d015522 100755 --- a/misc/codegen/generators/qlgen.py +++ b/misc/codegen/generators/qlgen.py @@ -118,17 +118,18 @@ def get_ql_property(cls: schema.Class, prop: schema.Property, lookup: typing.Dic type_is_hideable="ql_hideable" in lookup[prop.type].pragmas if prop.type in lookup else False, internal="ql_internal" in prop.pragmas, ) + ql_name = prop.pragmas.get("ql_name", prop.name) if prop.is_single: args.update( - singular=inflection.camelize(prop.name), + singular=inflection.camelize(ql_name), tablename=inflection.tableize(cls.name), tableparams=["this"] + ["result" if p is prop else "_" for p in cls.properties if p.is_single], doc=_get_doc(cls, prop), ) elif prop.is_repeated: args.update( - singular=inflection.singularize(inflection.camelize(prop.name)), - plural=inflection.pluralize(inflection.camelize(prop.name)), + singular=inflection.singularize(inflection.camelize(ql_name)), + plural=inflection.pluralize(inflection.camelize(ql_name)), tablename=inflection.tableize(f"{cls.name}_{prop.name}"), tableparams=["this", "index", "result"] if not prop.is_unordered else ["this", "result"], doc=_get_doc(cls, prop, plural=False), @@ -136,14 +137,14 @@ def get_ql_property(cls: schema.Class, prop: schema.Property, lookup: typing.Dic ) elif prop.is_optional: args.update( - singular=inflection.camelize(prop.name), + singular=inflection.camelize(ql_name), tablename=inflection.tableize(f"{cls.name}_{prop.name}"), tableparams=["this", "result"], doc=_get_doc(cls, prop), ) elif prop.is_predicate: args.update( - singular=inflection.camelize(prop.name, uppercase_first_letter=False), + singular=inflection.camelize(ql_name, uppercase_first_letter=False), tablename=inflection.underscore(f"{cls.name}_{prop.name}"), tableparams=["this"], doc=_get_doc(cls, prop), @@ -154,6 +155,8 @@ def get_ql_property(cls: schema.Class, prop: schema.Property, lookup: typing.Dic def get_ql_class(cls: schema.Class, lookup: typing.Dict[str, schema.Class]) -> ql.Class: + if "ql_name" in cls.pragmas: + raise Error("ql_name is not supported yet for classes, only for properties") prev_child = "" properties = [] for p in cls.properties: diff --git a/misc/codegen/lib/schemadefs.py b/misc/codegen/lib/schemadefs.py index 32d3a6b85aed..8651240c1a3d 100644 --- a/misc/codegen/lib/schemadefs.py +++ b/misc/codegen/lib/schemadefs.py @@ -72,11 +72,11 @@ def include(source: str): @_dataclass class _Namespace: """ simple namespacing mechanism """ - name: str + _name: str def add(self, pragma: "_PragmaBase", key: str | None = None): self.__dict__[pragma.pragma] = pragma - pragma.pragma = key or f"{self.name}_{pragma.pragma}" + pragma.pragma = key or f"{self._name}_{pragma.pragma}" @_dataclass @@ -87,7 +87,7 @@ def modify(self, prop: _schema.Property): prop.synth = self.synth def negate(self) -> _schema.PropertyModifier: - return _SynthModifier(self.name, False) + return _SynthModifier(self._name, False) qltest = _Namespace("qltest") @@ -239,6 +239,7 @@ def __getitem__(self, item): ql.add(_ParametrizedClassPragma("default_doc_name", factory=lambda doc: doc)) ql.add(_ClassPragma("hideable", inherited=True)) ql.add(_Pragma("internal")) +ql.add(_ParametrizedPragma("name", factory=lambda name: name)) cpp.add(_Pragma("skip")) @@ -256,30 +257,24 @@ def __getitem__(self, item): _schema.SynthInfo(on_arguments={k: _schema.get_type_name(t) for k, t in kwargs.items()})), key="synth") +@_dataclass(frozen=True) class _PropertyModifierList(_schema.PropertyModifier): - def __init__(self): - self._mods = [] + _mods: tuple[_schema.PropertyModifier, ...] def __or__(self, other: _schema.PropertyModifier): - self._mods.append(other) - return self + return _PropertyModifierList(self._mods + (other,)) def modify(self, prop: Property): for m in self._mods: m.modify(prop) -class _PropertyAnnotation: - def __or__(self, other: _schema.PropertyModifier): - return _PropertyModifierList() | other - - -_ = _PropertyAnnotation() +_ = _PropertyModifierList(()) drop = object() -def annotate(annotated_cls: type, add_bases: _Iterable[type] | None = None, replace_bases: _Dict[type, type] | None = None, cfg: bool = False) -> _Callable[[type], _PropertyAnnotation]: +def annotate(annotated_cls: type, add_bases: _Iterable[type] | None = None, replace_bases: _Dict[type, type] | None = None, cfg: bool = False) -> _Callable[[type], _PropertyModifierList]: """ Add or modify schema annotations after a class has been defined previously. @@ -287,7 +282,7 @@ def annotate(annotated_cls: type, add_bases: _Iterable[type] | None = None, repl `replace_bases` can be used to replace bases on the annotated class. """ - def decorator(cls: type) -> _PropertyAnnotation: + def decorator(cls: type) -> _PropertyModifierList: if cls.__name__ != "_": raise _schema.Error("Annotation classes must be named _") if cls.__doc__ is not None: @@ -307,7 +302,7 @@ def decorator(cls: type) -> _PropertyAnnotation: del annotated_cls.__annotations__[p] elif p in annotated_cls.__annotations__: annotated_cls.__annotations__[p] |= a - elif isinstance(a, (_PropertyAnnotation, _PropertyModifierList)): + elif isinstance(a, (_PropertyModifierList, _PropertyModifierList)): raise _schema.Error(f"annotated property {p} not present in annotated class " f"{annotated_cls.__name__}") else: diff --git a/rust/extractor/src/generated/.generated.list b/rust/extractor/src/generated/.generated.list index 0f781aae8dab..3ff79b9b0411 100644 --- a/rust/extractor/src/generated/.generated.list +++ b/rust/extractor/src/generated/.generated.list @@ -1,2 +1,2 @@ mod.rs 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 -top.rs 7a5bbe75eae6069f4f255db13787a3575e706742af1f57122c02d46895de9a1b 7a5bbe75eae6069f4f255db13787a3575e706742af1f57122c02d46895de9a1b +top.rs 4504ceb7e13020d5b19a4b938395fa2d5d804a962743985efe8563903448ae0c 4504ceb7e13020d5b19a4b938395fa2d5d804a962743985efe8563903448ae0c diff --git a/rust/extractor/src/generated/top.rs b/rust/extractor/src/generated/top.rs index eb1f16f8cc66..a3e1d7aac803 100644 --- a/rust/extractor/src/generated/top.rs +++ b/rust/extractor/src/generated/top.rs @@ -1501,57 +1501,35 @@ impl From> for trap::Label { } #[derive(Debug)] -pub struct Param { - pub id: trap::TrapId, - pub attrs: Vec>, - pub pat: Option>, - pub ty: Option>, -} - -impl trap::TrapEntry for Param { - fn extract_id(&mut self) -> trap::TrapId { - std::mem::replace(&mut self.id, trap::TrapId::Star) - } - - fn emit(self, id: trap::Label, out: &mut trap::Writer) { - out.add_tuple("params", vec![id.into()]); - for (i, v) in self.attrs.into_iter().enumerate() { - out.add_tuple("param_attrs", vec![id.into(), i.into(), v.into()]); - } - if let Some(v) = self.pat { - out.add_tuple("param_pats", vec![id.into(), v.into()]); - } - if let Some(v) = self.ty { - out.add_tuple("param_ties", vec![id.into(), v.into()]); - } - } +pub struct ParamBase { + _unused: () } -impl trap::TrapClass for Param { - fn class_name() -> &'static str { "Param" } +impl trap::TrapClass for ParamBase { + fn class_name() -> &'static str { "ParamBase" } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme Param is a subclass of AstNode +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme ParamBase is a subclass of AstNode unsafe { Self::from_untyped(value.as_untyped()) } } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme Param is a subclass of Element +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme ParamBase is a subclass of Element unsafe { Self::from_untyped(value.as_untyped()) } } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme Param is a subclass of Locatable +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme ParamBase is a subclass of Locatable unsafe { Self::from_untyped(value.as_untyped()) } @@ -2203,72 +2181,6 @@ impl From> for trap::Label { } } -#[derive(Debug)] -pub struct SelfParam { - pub id: trap::TrapId, - pub attrs: Vec>, - pub is_mut: bool, - pub lifetime: Option>, - pub name: Option>, - pub ty: Option>, -} - -impl trap::TrapEntry for SelfParam { - fn extract_id(&mut self) -> trap::TrapId { - std::mem::replace(&mut self.id, trap::TrapId::Star) - } - - fn emit(self, id: trap::Label, out: &mut trap::Writer) { - out.add_tuple("self_params", vec![id.into()]); - for (i, v) in self.attrs.into_iter().enumerate() { - out.add_tuple("self_param_attrs", vec![id.into(), i.into(), v.into()]); - } - if self.is_mut { - out.add_tuple("self_param_is_mut", vec![id.into()]); - } - if let Some(v) = self.lifetime { - out.add_tuple("self_param_lifetimes", vec![id.into(), v.into()]); - } - if let Some(v) = self.name { - out.add_tuple("self_param_names", vec![id.into(), v.into()]); - } - if let Some(v) = self.ty { - out.add_tuple("self_param_ties", vec![id.into(), v.into()]); - } - } -} - -impl trap::TrapClass for SelfParam { - fn class_name() -> &'static str { "SelfParam" } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme SelfParam is a subclass of AstNode - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme SelfParam is a subclass of Element - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme SelfParam is a subclass of Locatable - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - #[derive(Debug)] pub struct SourceFile { pub id: trap::TrapId, @@ -5862,6 +5774,73 @@ impl From> for trap::Label { } } +#[derive(Debug)] +pub struct Param { + pub id: trap::TrapId, + pub attrs: Vec>, + pub ty: Option>, + pub pat: Option>, +} + +impl trap::TrapEntry for Param { + fn extract_id(&mut self) -> trap::TrapId { + std::mem::replace(&mut self.id, trap::TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("params", vec![id.into()]); + for (i, v) in self.attrs.into_iter().enumerate() { + out.add_tuple("param_base_attrs", vec![id.into(), i.into(), v.into()]); + } + if let Some(v) = self.ty { + out.add_tuple("param_base_ties", vec![id.into(), v.into()]); + } + if let Some(v) = self.pat { + out.add_tuple("param_pats", vec![id.into(), v.into()]); + } + } +} + +impl trap::TrapClass for Param { + fn class_name() -> &'static str { "Param" } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Param is a subclass of AstNode + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Param is a subclass of Element + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Param is a subclass of Locatable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Param is a subclass of ParamBase + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + #[derive(Debug)] pub struct ParenExpr { pub id: trap::TrapId, @@ -7053,6 +7032,81 @@ impl From> for trap::Label { } } +#[derive(Debug)] +pub struct SelfParam { + pub id: trap::TrapId, + pub attrs: Vec>, + pub ty: Option>, + pub is_mut: bool, + pub lifetime: Option>, + pub name: Option>, +} + +impl trap::TrapEntry for SelfParam { + fn extract_id(&mut self) -> trap::TrapId { + std::mem::replace(&mut self.id, trap::TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("self_params", vec![id.into()]); + for (i, v) in self.attrs.into_iter().enumerate() { + out.add_tuple("param_base_attrs", vec![id.into(), i.into(), v.into()]); + } + if let Some(v) = self.ty { + out.add_tuple("param_base_ties", vec![id.into(), v.into()]); + } + if self.is_mut { + out.add_tuple("self_param_is_mut", vec![id.into()]); + } + if let Some(v) = self.lifetime { + out.add_tuple("self_param_lifetimes", vec![id.into(), v.into()]); + } + if let Some(v) = self.name { + out.add_tuple("self_param_names", vec![id.into(), v.into()]); + } + } +} + +impl trap::TrapClass for SelfParam { + fn class_name() -> &'static str { "SelfParam" } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme SelfParam is a subclass of AstNode + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme SelfParam is a subclass of Element + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme SelfParam is a subclass of Locatable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme SelfParam is a subclass of ParamBase + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + #[derive(Debug)] pub struct SlicePat { pub id: trap::TrapId, diff --git a/rust/ql/.generated.list b/rust/ql/.generated.list index 6c3cf6ea6a07..36416013959d 100644 --- a/rust/ql/.generated.list +++ b/rust/ql/.generated.list @@ -1,4 +1,4 @@ -lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll 4005dd5213c45c8f96e12f08d8a6a7532692d68a3cd9e3a0fd55d7f982a92f23 ec753357ac4fc76706acc0cf1d9208e63a0688e480ece52e4314d7dc2a743de5 +lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll 5e6ce2581b312d74ac8ffde44941b77f643025a7ff2c47799b3834596a513fa4 24dc5d28eb4754f968cf850294ac32057a2a97cf5156a3e90e0924c28e50e810 lib/codeql/rust/elements/Abi.qll 4c973d28b6d628f5959d1f1cc793704572fd0acaae9a97dfce82ff9d73f73476 250f68350180af080f904cd34cb2af481c5c688dc93edf7365fd0ae99855e893 lib/codeql/rust/elements/ArgList.qll 661f5100f5d3ef8351452d9058b663a2a5c720eea8cf11bedd628969741486a2 28e424aac01a90fb58cd6f9f83c7e4cf379eea39e636bc0ba07efc818be71c71 lib/codeql/rust/elements/ArrayExpr.qll a3e6e122632f4011644ec31b37f88b32fe3f2b7e388e7e878a6883309937049f 12ccb5873d95c433da5606fd371d182ef2f71b78d0c53c2d6dec10fa45852bdc @@ -93,7 +93,8 @@ lib/codeql/rust/elements/NameRef.qll f11e33cdbefb3efdd8db6cd1eee593948a16ef5dd13 lib/codeql/rust/elements/NeverType.qll 669823dd60bba0cebac614f9dbad9dc9228405d76e62092e265df57fdd2e04e2 8fe32975ef80d86fb8b218f56962f0a89911008a8d6989e245c3e0362f2c747f lib/codeql/rust/elements/OffsetOfExpr.qll 8f6dd1fe0aad1642e58f5e97620306e4b36cdf01324fead1e2a92e8e60951c41 b192f7a5fae3049a6cac3b7a225a0e590f744e6c5ff6346ffdd1699f83bf718f lib/codeql/rust/elements/OrPat.qll 408b71f51edbfc79bf93b86fb058d01fa79caf2ebfeef37b50ae1da886c71b68 4a3f2b00db33fe26ee0859e35261016312cb491e23c46746cdd6d8bb1f6c88ef -lib/codeql/rust/elements/Param.qll 3108a710214977218421b220d1330793173d6b6b91708b641e3d1275f80faedb 4bb2b80d0a9a4d86f980440851d59ca6fffea681e5518f5d605c521191efd7b4 +lib/codeql/rust/elements/Param.qll d0c0a427c003bbbacaeb0c2f4566f35b997ad0bca4d49f97b50c3a4bd1ddbd71 e654a17dfcb7aaeb589e7944c38f591c4cf922ebceb834071bcb9f9165ee48be +lib/codeql/rust/elements/ParamBase.qll ab8cb39ac313a5dce7d1a6dcd490c5033034d88f0e402f315f4236bb76c2c464 414afc1f34c1df28f76220c5d3255ae3d7629f3df8b870d0949f3a6c87e26d71 lib/codeql/rust/elements/ParamList.qll 33a22ba7de565db4009d3f56eecd5ef809c28d9dce9bbac3fb71b528baae4f70 004375e227d87f76f930322ad3eac274f9b691bf58785ae69977fa319f3dba7e lib/codeql/rust/elements/ParenExpr.qll b635f0e5d300cd9cf3651cfcefd58316c21727295bbfd44b1f5672f9e3de67b6 d81c0034d4ea7ca5829f9b00e0a634ba5b557a6296d99f0b5344b11e1ba705a1 lib/codeql/rust/elements/ParenPat.qll 40d033de6c85ad042223e0da80479adebab35494396ab652da85d3497e435c5a 8f2febe5d5cefcb076d201ae9607d403b9cfe8169d2f4b71d13868e0af43dc25 @@ -126,7 +127,7 @@ lib/codeql/rust/elements/RestPat.qll a898a2c396f974a52424efbc8168174416ac6ed30f9 lib/codeql/rust/elements/RetType.qll 36ea39240a56c504d94d5487ea9679563eef3dfe0e23bf42d992d1ab2b883518 2fe5b6f62a634c6aa30a1ecd620f3446c167669cf1285c8ef8dd5e5a6ef5fc71 lib/codeql/rust/elements/ReturnExpr.qll b87187cff55bc33c8c18558c9b88617179183d1341b322c1cab35ba07167bbdb 892f3a9df2187e745c869e67f33c228ee42754bc9e4f8f4c1718472eb8f8c80f lib/codeql/rust/elements/ReturnTypeSyntax.qll 0aa9125f5ea8864ecf1e4ff6e85f060f1b11fdd603448816145fea1b290f0232 3911819548ad1cf493199aac2ed15652c8e48b532a1e92153388b062191c1e6e -lib/codeql/rust/elements/SelfParam.qll 5c9629e1cd837f5d84bdd79a1aef9cca6fb0acb1fb18671d4a4d28c23a74551a 41eb92527cf4379a2df54a0c9fabc368cb6f9b8d1ac73bd2ab3f13214573e764 +lib/codeql/rust/elements/SelfParam.qll 7d720c99097a340bc7bf6cc27ac6fe291a04af53e9bac23bf070b04b36e6e033 736488794a46ea702dcd3f603134052598207f3953acce3c9237bd6c6a038b23 lib/codeql/rust/elements/SlicePat.qll f48f13bb13378cc68f935d5b09175c316f3e81f50ef6a3ac5fdbfbfb473d6fc1 4c8df0b092274f37028e287a949f1a287f7505b7c2c36ee8d5f47fb8365d278a lib/codeql/rust/elements/SliceType.qll 7e49dba57826c7bb72a88f9e802febdb09adfc49804f6205dc88f2a307fd1f30 6c3ee430f812f1d9fbb1fb1fdd2c47130a4bde7fccf17f09404b8cbc8104678a lib/codeql/rust/elements/SourceFile.qll 5916d550385d618bd3b3d4835fbd3040485822220af8ce52ee1adb649b3d8594 0b79766216649e948fa59de467d64fa752de4666c28e0e503e88740ae27a2aef @@ -292,6 +293,7 @@ lib/codeql/rust/elements/internal/NeverTypeConstructor.qll 6a86bff9d885eddf39a15 lib/codeql/rust/elements/internal/OffsetOfExprConstructor.qll 616e146562adb3ac0fba4d6f55dd6ce60518ed377c0856f1f09ba49593e7bfab 80518ce90fc6d08011d6f5fc2a543958067739e1b0a6a5f2ed90fc9b1db078f0 lib/codeql/rust/elements/internal/OffsetOfExprImpl.qll e52d4596068cc54719438121f7d5afcaab04e0c70168ac5e4df1a3a0969817a6 6ab37e659d79e02fb2685d6802ae124157bf14b6f790b31688f437c87f40f52c lib/codeql/rust/elements/internal/OrPatConstructor.qll 4ef583e07298487c0c4c6d7c76ffcc04b1e5fe58aba0c1da3e2c8446a9e0c92b 980a6bd176ae5e5b11c134569910c5468ba91f480982d846e222d031a6a05f1a +lib/codeql/rust/elements/internal/ParamBaseImpl.qll fe11999c728c443c46c992e9bed7a2b3e23afa16ae99592e70054bc57ae371b8 df86fdb23266bdfb9ed8a8f02558a760b67f173943b9d075b081229eb5844f66 lib/codeql/rust/elements/internal/ParamConstructor.qll b98a2d8969f289fdcc8c0fb11cbd19a3b0c71be038c4a74f5988295a2bae52f0 77d81b31064167945b79b19d9697b57ca24462c3a7cc19e462c4693ce87db532 lib/codeql/rust/elements/internal/ParamListConstructor.qll 3123142ab3cab46fb53d7f3eff6ba2d3ff7a45b78839a53dc1979a9c6a54920e 165f3d777ea257cfcf142cc4ba9a0ebcd1902eb99842b8a6657c87087f3df6fe lib/codeql/rust/elements/internal/ParamListImpl.qll 0ed6e9affe1dc0144641502292c2ddd51958fe3d503419caf15198176e3a4174 92d053cc5fdf40a2d98acb665083b5da15403d7da205779a97a4ee66fac0add4 @@ -338,7 +340,7 @@ lib/codeql/rust/elements/internal/ReturnExprConstructor.qll 57be5afbe20aa8db6e63 lib/codeql/rust/elements/internal/ReturnTypeSyntaxConstructor.qll 8994672e504d1674e5773157d0ad8a0dc3aad3d64ef295e7722e647e78e36c11 abe7df754721f4ff7f3e3bb22d275976b2e9a1ef51436a461fe52ebd2d29cff1 lib/codeql/rust/elements/internal/ReturnTypeSyntaxImpl.qll d47a3dcfcc2b02a6a9eaeefe9a7a4be2074ecd2019da129dda0f218bc3fbd94b 87198db7c0620ed49369da160f09287015e0cd1718784e1ba28ec3ec5a0bb4a8 lib/codeql/rust/elements/internal/SelfParamConstructor.qll a63af1d1ccde6013c09e0397f1247f5ab3efd97f3410dd1b6c15e1fb6cd96e54 0d8977653c074d5010c78144327f8b6c4da07f09d21e5cc3342082cd50107a81 -lib/codeql/rust/elements/internal/SelfParamImpl.qll 5408738c40f070e0cea83a6a38d638ac7a134b5a055ecf0cccc035af58ff9b36 604922319ecf9a9405fdd0fe953169162ee2c8cca36349b49163a2895c53ed40 +lib/codeql/rust/elements/internal/SelfParamImpl.qll def23beb8926f498fc81b7b44489001b35d704da1a2058c84c23b329e8bc2f49 c9be1e8fa2c4e23b314a4d0563be6cffcbab6f03d08b77a366f7638b28a09de4 lib/codeql/rust/elements/internal/SlicePatConstructor.qll 19216ec9e87ca98784d78b29b8b06ea9ac428e2faa468f0717d1c0d0a8e7351c 458e5be76aa51aec579566be39486525ec9d4c73d248cb228da74892e2a56c08 lib/codeql/rust/elements/internal/SlicePatImpl.qll c6176095360e3b23382557242d2d3ff0b5e0f01f8b1c438452518e9c36ff3c70 644ab41a59a619947f69f75e2d0807245d4ddefc247efaeab63b99b4f08c1cc1 lib/codeql/rust/elements/internal/SliceTypeConstructor.qll 643e7a2ae261e8f62de8bc2886efddcc096e0c7e8159c0b9e87b24d0509e10d0 719545abb0ccf6e8a203ec9c9f75109c5ab0593c838e2f90e388858680ec62f7 @@ -493,7 +495,7 @@ lib/codeql/rust/elements/internal/generated/MacroStmts.qll cb4f3c2721a4d0c8522e5 lib/codeql/rust/elements/internal/generated/MacroType.qll c462824df4a002956c036966d15cd0bce206e664888f8d0c7834dedb38b3c0bf 947480f07c40128ef3d00ad4c3a29a685472b3e20a661680c22f6bb318205ed1 lib/codeql/rust/elements/internal/generated/MatchArm.qll 8fb740a0f2e308782d9cf390672969cd7cf6e698e5b847fb02ae3fa6c205646f 42bfe8dd94fc24ec925fbd44016df111600f99d1216c9a698631373bb6048830 lib/codeql/rust/elements/internal/generated/MatchArmList.qll 13362680c037fe83fef4653562cc10a4429078316b5ec7c47b076336cf4aca2e 41c674293c13eceaca62134ae0c6778541f6a5201cbc5c146f0ba01b898dc267 -lib/codeql/rust/elements/internal/generated/MatchExpr.qll 689d65f690fe05bc262d0a5bfe69bb4f8a142db387c5765fcc4958a9b49989f8 2979cd2017d0538870d17b2b7592c75cc05b706bd36c9de3e5dc38fa3a957e5b +lib/codeql/rust/elements/internal/generated/MatchExpr.qll b686842e7000fd61e3a0598bf245fb4e18167b99eca9162fdfdff0b0963def22 00f1743b1b0f1a92c5a687f5260fda02d80cc5871694cad0d5e7d94bac7fe977 lib/codeql/rust/elements/internal/generated/MatchGuard.qll 521a507883963106780f1782084c581fbcf1179863c7c15438c4db79e30e78dd 6226feffaaa8d828a42ece0c693e616cd375672eb987c3b7ff1ca15fa23c116a lib/codeql/rust/elements/internal/generated/Meta.qll 38fca2c9958b4179de311546fe0850319010aca9cd17c97d57e12b521c5d0947 740f99c9d41044ceebfcc9d29baaa22f59c11a40f45502a34aa587d423c018f8 lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll 17bffcc826851a8be32a1900b8fdf777f9bab6aed9f8268d566173c4974c1cf9 134a2860bdf16daafdb3e574c52a69d2598210653db89c2fa062ca25e8f8a649 @@ -504,12 +506,13 @@ lib/codeql/rust/elements/internal/generated/NameRef.qll 4292fc7aa9ba22a7fa5bd638 lib/codeql/rust/elements/internal/generated/NeverType.qll 14dd3c08db1db873b365fc7f0d1cf3f5d6229b1f78bc85100c36c22d1bb8ee40 34257df0ac59cfd982ea5f30ab225c8bfece71d9fd3be84ff79cf1b0bff55060 lib/codeql/rust/elements/internal/generated/OffsetOfExpr.qll bb17a1e1d4332225cf4bbbae4a1bab9302c2d81d191fe835f2f973915d40dd2a f9e73210b81992040a5a5a9ac3ad936159fb3475445f130c7b28f83dfb4170f5 lib/codeql/rust/elements/internal/generated/OrPat.qll ee0487b90849c3e2a836c956ae8837f27515a9dc795bf17287cba2cf7a39d839 35117b6a3dcebab09f12665441332b6863200e206679ee97894170dd9ef7795c -lib/codeql/rust/elements/internal/generated/Param.qll c57bf238123e8337adb1556cf788bde2b2e8841d4afa0799649db9d507b02d85 7cb580219ec9b6257735f7c53260cd2bb5533dbe342bef3b793ec7b6a65e7027 +lib/codeql/rust/elements/internal/generated/Param.qll 4f853cece9ca8d41ef41ff7656a7f291568f1218403bebcd8afbf07e93fab6bf 93a1372f1d129b83470aa0dc481f46649771d1f5b72b114f215a51514ddd641a +lib/codeql/rust/elements/internal/generated/ParamBase.qll 9d9a82643019d2a13f28555dbdd60221cf6dc2e890f6541e7f85a91646585f2c 0e4a3e4c0e069a43d449167cb706c6f5d0d097b4cab2a7ade84c2c1b5528eca7 lib/codeql/rust/elements/internal/generated/ParamList.qll c808c9d84dd7800573832b63a2ca5296b5506bffdeea054893a56cde08f91560 d4599c52231f93e1260fbae7de8891fe4287fa68b1423592b7a1d51c80146dc8 lib/codeql/rust/elements/internal/generated/ParenExpr.qll bc0731505bfe88516205ec360582a4222d2681d11342c93e15258590ddee82f2 d4bd6e0c80cf1d63746c88d4bcb3a01d4c75732e5da09e3ebd9437ced227fb60 lib/codeql/rust/elements/internal/generated/ParenPat.qll ce24b8f8ecbf0f204af200317405724063887257460c80cf250c39b2fdf37185 e7c87d37e1a0ca7ea03840017e1aa9ddb7f927f1f3b6396c0305b46aeee33db6 lib/codeql/rust/elements/internal/generated/ParenType.qll 9cc954d73f8330dcac7b475f97748b63af5c8766dee9d2f2872c0a7e4c903537 c07534c8a9c683c4a9b11d490095647e420de0a0bfc23273eaf6f31b00244273 -lib/codeql/rust/elements/internal/generated/ParentChild.qll 52186ab2aead10bbbaab401272afff0b8247b0050064123d0e45d972ec501dee f082318c0da678845763d6070283872b94b59425fbaa305582b5fe72da03e7e6 +lib/codeql/rust/elements/internal/generated/ParentChild.qll 78723cac5f2999f91317f39cf53267043fd2a56e98e838f013eae01b6b39929e 26dd29e5fd868f89982269db6b25aa799be942abdbe41ff1a8ffd4dae4385bdc lib/codeql/rust/elements/internal/generated/Pat.qll 3605ac062be2f294ee73336e9669027b8b655f4ad55660e1eab35266275154ee 7f9400db2884d336dd1d21df2a8093759c2a110be9bf6482ce8e80ae0fd74ed4 lib/codeql/rust/elements/internal/generated/Path.qll 4c1c8e840ed57880e574142b081b11d7a7428a009f10e3aa8f4645e211f6b2e0 989668cf0f1bdee7557e2f97c01e41d2a56848227fed41477833f5fc1e1d35f6 lib/codeql/rust/elements/internal/generated/PathExpr.qll 2096e3c1db22ee488a761690adabfc9cfdea501c99f7c5d96c0019cb113fc506 54245ce0449c4e263173213df01e079d5168a758503a5dbd61b25ad35a311140 @@ -522,7 +525,7 @@ lib/codeql/rust/elements/internal/generated/PtrType.qll 40099c5a4041314b66932dfd lib/codeql/rust/elements/internal/generated/PureSynthConstructors.qll ea294a3ba33fd1bc632046c4fedbcb84dcb961a8e4599969d65893b19d90e590 ea294a3ba33fd1bc632046c4fedbcb84dcb961a8e4599969d65893b19d90e590 lib/codeql/rust/elements/internal/generated/RangeExpr.qll 23cca03bf43535f33b22a38894f70d669787be4e4f5b8fe5c8f7b964d30e9027 18624cef6c6b679eeace2a98737e472432e0ead354cca02192b4d45330f047c9 lib/codeql/rust/elements/internal/generated/RangePat.qll efd93730de217cf50dcba5875595263a5eadf9f7e4e1272401342a094d158614 229b251b3d118932e31e78ac4dfb75f48b766f240f20d436062785606d44467b -lib/codeql/rust/elements/internal/generated/Raw.qll b23d3574920376ca7c52858d6ad2ea6670640812422329f9c44f699075c16d89 13c1a199de3e71f012bdab0fa2b982f1c92f95536b07bbbe816e680a0e64ad71 +lib/codeql/rust/elements/internal/generated/Raw.qll b342060fd7fe2214eea191859f559334a8a64cf6785048f784ed641ea1e616fd 4737f09bbd2e190eee9bb83476a0045887ff2982dd06cd4e6538fc31637ab521 lib/codeql/rust/elements/internal/generated/RecordExpr.qll eb6cb662e463f9260efae1a6ce874fa781172063b916ef1963f861e9942d308d 1a21cbccc8f3799ff13281e822818ebfb21d81591720a427cac3625512cb9d40 lib/codeql/rust/elements/internal/generated/RecordExprField.qll 7e9f8663d3b74ebbc9603b10c9912f082febba6bd73d344b100bbd3edf837802 fbe6b578e7fd5d5a6f21bbb8c388957ab7210a6a249ec71510a50fb35b319ea1 lib/codeql/rust/elements/internal/generated/RecordExprFieldList.qll 179a97211fe7aa6265085d4d54115cdbc0e1cd7c9b2135591e8f36d6432f13d3 dd44bbbc1e83a1ed3a587afb729d7debf7aeb7b63245de181726af13090e50c0 @@ -540,7 +543,7 @@ lib/codeql/rust/elements/internal/generated/RestPat.qll b3a4206e68cf67a0310a4667 lib/codeql/rust/elements/internal/generated/RetType.qll a26860cd526b339b9527c089d126c5486e678dd080e88c60ea2fe641e7d661fd a83c1ce32fd043945ad455b892a60c2a9b6a62d7a5aadf121c4b4056d1dfb094 lib/codeql/rust/elements/internal/generated/ReturnExpr.qll c9c05400d326cd8e0da11c3bfa524daa08b2579ecaee80e468076e5dd7911d56 e7694926727220f46a7617b6ca336767450e359c6fa3782e82b1e21d85d37268 lib/codeql/rust/elements/internal/generated/ReturnTypeSyntax.qll 34e32623d2c0e848c57ce1892c16f4bc81ccca7df22dc21dad5eb48969224465 ccb07c205468bce06392ff4a150136c0d8ebacfb15d1d96dd599ab020b353f47 -lib/codeql/rust/elements/internal/generated/SelfParam.qll cf6837c2731b45632f04092079d295eee3e02d19f73c73b3ccbce1abe12203bf 87eaa9d982506904c42030f7173dd01fd52f3edd9d2c8d19b572f6d5454f769b +lib/codeql/rust/elements/internal/generated/SelfParam.qll e1d994dea58a406dbfca3ea0c724ac48be66ac4380e7270e4037ca2714eef722 90f8ebfac723eef259e13d3c8a7ef6b886c2831d4f436a742144b96db6b6fc92 lib/codeql/rust/elements/internal/generated/SlicePat.qll 8b1463758d7b15a0303384c8136a48a8e71ce27da4ba6e421272b9751a988e64 7562d47308f197bc63ade0f114cd23a17e7f60fa696716f6a30fc7b7411642fe lib/codeql/rust/elements/internal/generated/SliceType.qll 98ee8b566be28f392ab9c9507600e8461ad0b48cbbbd422d22548aca691f8330 528d6eabddf49b9dc474971a2f3a6ddb6f2d77dc7f8449140ef54646c1ceb822 lib/codeql/rust/elements/internal/generated/SourceFile.qll 55d44c9f09c5ff28c4f715f779a0db74083e1180acaf0d410e63ca07b90d1cb5 78c0af48b0b64aa377413ea4799dfe977602a111208e1d25e4bdfa920dbd7238 @@ -548,7 +551,7 @@ lib/codeql/rust/elements/internal/generated/Static.qll 5fbd6879858cf356d4bdaa6da lib/codeql/rust/elements/internal/generated/Stmt.qll 8473ff532dd5cc9d7decaddcd174b94d610f6ca0aec8e473cc051dad9f3db917 6ef7d2b5237c2dbdcacbf7d8b39109d4dc100229f2b28b5c9e3e4fbf673ba72b lib/codeql/rust/elements/internal/generated/StmtList.qll a667193e32341e17400867c6e359878c4e645ef9f5f4d97676afc0283a33a026 a320ed678ee359302e2fc1b70a9476705cd616fcfa44a499d32f0c7715627f73 lib/codeql/rust/elements/internal/generated/Struct.qll 4d57f0db12dc7ad3e31e750a24172ef1505406b4dab16386af0674bd18bf8f4b 1a73c83df926b996f629316f74c61ea775be04532ab61b56af904223354f033e -lib/codeql/rust/elements/internal/generated/Synth.qll 0e5767568fd119df13928adf00950586f5f9f355dae520059b2d6daa7a2bda56 219b40f6458fec2cc436dc2cf80bb1dbfb34dfdbe8576606b5e25f78d36d6210 +lib/codeql/rust/elements/internal/generated/Synth.qll db8ffbd55def03f0b0278cafa60274220eb571257da36e185f380e3c5b2caedf 19074971c3e96a43414738976c9625385c4bbac6b01c7eca2f46432034a279b7 lib/codeql/rust/elements/internal/generated/SynthConstructors.qll e929c49ea60810a2bbc19ad38110b8bbaf21db54dae90393b21a3459a54abf6f e929c49ea60810a2bbc19ad38110b8bbaf21db54dae90393b21a3459a54abf6f lib/codeql/rust/elements/internal/generated/Token.qll 77a91a25ca5669703cf3a4353b591cef4d72caa6b0b9db07bb9e005d69c848d1 2fdffc4882ed3a6ca9ac6d1fb5f1ac5a471ca703e2ffdc642885fa558d6e373b lib/codeql/rust/elements/internal/generated/TokenTree.qll 8577c2b097c1be2f0f7daa5acfcf146f78674a424d99563e08a84dd3e6d91b46 d2f30764e84dbfc0a6a5d3d8a5f935cd432413688cb32da9c94e420fbc10665c @@ -583,7 +586,7 @@ lib/codeql/rust/elements/internal/generated/WhileExpr.qll 7edf1f23fbf953a2baabcd lib/codeql/rust/elements/internal/generated/WildcardPat.qll d74b70b57a0a66bfae017a329352a5b27a6b9e73dd5521d627f680e810c6c59e 4b913b548ba27ff3c82fcd32cf996ff329cb57d176d3bebd0fcef394486ea499 lib/codeql/rust/elements/internal/generated/YeetExpr.qll cac328200872a35337b4bcb15c851afb4743f82c080f9738d295571eb01d7392 94af734eea08129b587fed849b643e7572800e8330c0b57d727d41abda47930b lib/codeql/rust/elements/internal/generated/YieldExpr.qll 37e5f0c1e373a22bbc53d8b7f2c0e1f476e5be5080b8437c5e964f4e83fad79a 4a9a68643401637bf48e5c2b2f74a6bf0ddcb4ff76f6bffb61d436b685621e85 -lib/codeql/rust/elements.qll 76fe494d20d2665777bcb5c5ced016a262789a0e6aa874c1a77ce4cb134422b6 76fe494d20d2665777bcb5c5ced016a262789a0e6aa874c1a77ce4cb134422b6 +lib/codeql/rust/elements.qll 83bda9f3bc481aaecc039db9cecb628495e15e469cc843336ca089f0d707f8d6 83bda9f3bc481aaecc039db9cecb628495e15e469cc843336ca089f0d707f8d6 test/extractor-tests/generated/Abi/Abi.ql 7f6e7dc4af86eca3ebdc79b10373988cd0871bd78b51997d3cffd969105e5fdd 2f936b6ca005c6157c755121584410c03e4a3949c23bee302fbe05ee10ce118f test/extractor-tests/generated/Abi/Abi_getAbiString.ql a496762fcec5a0887b87023bbf93e9b650f02e20113e25c44d6e4281ae8f5335 14109c7ce11ba25e3cd6e7f1b3fcb4cb00622f2a4eac91bfe43145c5f366bc52 test/extractor-tests/generated/ArgList/ArgList.ql e412927756e72165d0e7c5c9bd3fca89d08197bbf760db8fb7683c64bb2229bc 043dba8506946fbb87753e22c387987d7eded6ddb963aa067f9e60ef9024d684 @@ -842,10 +845,10 @@ test/extractor-tests/generated/MatchArm/MatchArm_getPat.ql b346bca229226414b32ac test/extractor-tests/generated/MatchArmList/MatchArmList.ql 14b5e110d48e2b77c85b7a188262e6a98300e0d4d507bb7ed9179c5802251dd6 4d091f06b12fef0fffe1c80a10f74438d8068f2fa09c50d5e240b6d140e60d90 test/extractor-tests/generated/MatchArmList/MatchArmList_getArm.ql 4781d002538a92b7f40fb0ec3d61aeedb6348341ddc354bbdd3ff61b74d59767 ae0da9497a30ce006e03bdb70e0ee24b685df529ac15a7d99a6869b5f7d7b371 test/extractor-tests/generated/MatchArmList/MatchArmList_getAttr.ql 4d7e6d152d2dbeb4c9f594becabea27d3b25fecbde40d791a2907c69cc0c9631 4be9be658bb22e1b764c4ebc8d6b99bf50fd939f35ea44fbb869056c14632bd4 -test/extractor-tests/generated/MatchExpr/MatchExpr.ql ec116bca37079488977a50beeba508c440cf337799947fcb810b6bd7a7605255 42dc7b5f0dd6fd91417d9846a7b4f678cbfcf095791aaf57c8d3b4548ce2dd98 +test/extractor-tests/generated/MatchExpr/MatchExpr.ql 2966bf0507c0d45db1b933442ce8f1c4e0a9d4212c53a768791665cd2e0927f0 8af3b87528b6dd4cd3ff4fc6d2d389b1a743f979d9ccacd0aff134b5a4376118 test/extractor-tests/generated/MatchExpr/MatchExpr_getAttr.ql cb8057372dcf24dfa02896ebf4e60a0b757dc4742b94011edc38f5b898ed4d25 6809695c2d3ac3b92c06049c9b920e8c0e99ee1998a11a7f181f2b0ceb47c197 -test/extractor-tests/generated/MatchExpr/MatchExpr_getExpr.ql 7baaa64071cf2666e3b2bc05630d92a7a3b6cf04a026b1f7053c5e2a735bcaa8 d9ba8d8bbff05cfc0461ab41295f921b48429b4376c29adf54428bd5a9aa5298 test/extractor-tests/generated/MatchExpr/MatchExpr_getMatchArmList.ql d97055bcb0431e8b258b5ecdd98aa07cb24ece06b0cd658b697cd71da4ede8fc 5e9c03b2665ef6b2af98897996abb2e0a9c18d54eb64588340b8efbcee9793bd +test/extractor-tests/generated/MatchExpr/MatchExpr_getScrutinee.ql 0bfeb8f903fb23356d50b7edd80377f4a67045010ffbed04c835191b5bd62820 7dc8e38730ad72b4cea91c1f023cdbe83057053e8dbd077ff925c59e92744498 test/extractor-tests/generated/MatchGuard/MatchGuard.ql 23e47ec1b13e2d80e31b57894a46ec789d6ab5ed1eb66bdb6bba9bd5ae71d3ef 7302f4a93108a83228e0ebd5b4a1bc6bccc1f6f0f3272054866fa90378c0dcc4 test/extractor-tests/generated/MatchGuard/MatchGuard_getCondition.ql 8a79dd46798f111f8d0d5a975380b5cebe5e337267752b77b3718b268ba2773d 6691d8fb483f64fc7e3ad3f46e3129e0a1184d7beb9f83a1000acdbb081c8b5e test/extractor-tests/generated/Meta/Meta.ql 16f163f00ba2bbaa0a8c6f3f6710c860a8f61d02d43321c78e05a10a3606e39b ba982c6bb93ddb4fc2c44d24635bd487128a5b1d1f885214044c989a21f4d05a @@ -878,7 +881,7 @@ test/extractor-tests/generated/OffsetOfExpr/OffsetOfExpr_getField.ql 6d729fb91de test/extractor-tests/generated/OffsetOfExpr/OffsetOfExpr_getTy.ql b8597637cffd7a492148020b306c4ab1d2f17f919f441f462ebc00d229b038ca 2c7de1df4351929c221b30e3cede4cd6981fe8a2c1861e194489981c65e00f33 test/extractor-tests/generated/OrPat/OrPat.ql 49d881b384acaf68fa79de46da997cacab3e75467641f61150908f4112c47fa4 5d721da23be44e79d7b8a0dd475119836828d6a1edaff2c55decea8da83e65b8 test/extractor-tests/generated/OrPat/OrPat_getPat.ql d56b78287cecebacb25249380647500387e0d9e28be20034b8a12406a999a7c4 cba7bb60afaaed4333ea5ff6d3850fb44a8b42edee67d86fd16df85938454269 -test/extractor-tests/generated/Param/Param.ql 060c53b7e93840ae9cbf0c8fdaea17b16d6825f4b7aaa2eab164a660c5a7ea4d 172f6f4b86a98720f710e5d4342b7d52839c6f3c169ce1debb37629961a702ba +test/extractor-tests/generated/Param/Param.ql ab8d0f8cc3c71f5d24be4aebde1ef7d016519490a9715aca6069e58fd11aeb1c 61197a0c2b8d6f0c5a9cddda39585dcd413644cf80e3ea28b037385142100b27 test/extractor-tests/generated/Param/Param_getAttr.ql e1dcf86540fd2971ced34a33b2959f001c3f654914d82e576caa4534b80fbfbf 987a826bf6dcd25c3426edb603a22f6caa030c82c1cb0e9e11062fdbfed23030 test/extractor-tests/generated/Param/Param_getPat.ql 0c448e8ba8bf3432be08b5eb4a052aa19cccf0eb4596a3239481401dae9d2dc2 c943d4da36e1e734c1a012f092b2f597cb389a7ab33d5371ff8ee9c93e115ffc test/extractor-tests/generated/Param/Param_getTy.ql 134dec0c5562a8df68224069f10ee51c7dcc35e0b44a49c0e2078c305487db87 94fa72a213c37f2f63f03789a33e55fc5a22bd83cf0c1d293281bceffb63bd78 @@ -973,7 +976,7 @@ test/extractor-tests/generated/ReturnExpr/ReturnExpr.ql 8e9eba0837a466255e8e249e test/extractor-tests/generated/ReturnExpr/ReturnExpr_getAttr.ql 9fb7e1c79798e4f42e18785f3af17ea75f901a36abf9beb47a1eede69c613ba9 9cdb7cc4a4742865f6c92357973f84cee9229f55ff28081e5d17b6d57d6d275f test/extractor-tests/generated/ReturnExpr/ReturnExpr_getExpr.ql 7d4562efb0d26d92d11f03a0ef80338eb7d5a0c073f1f09cbb8a826f0cef33de 523ebd51b97f957afaf497e5a4d27929eed18e1d276054e3d5a7c5cfe7285c6e test/extractor-tests/generated/ReturnTypeSyntax/ReturnTypeSyntax.ql 976ce33fe3fd34aae2028a11b4accdee122b6d82d07722488c3239f0d2c14609 906bf8c8e7769a1052196bc78947b655158dd3b2903fef2802e2031cffbc1d78 -test/extractor-tests/generated/SelfParam/SelfParam.ql d051c7a2dd88382e37895f1d691f2702aed7f925d3936f51d49949463e4757c8 37f1f429093be7923a55f8b4f46b37bbf71d0dff3843c4d3686383c2863dee1a +test/extractor-tests/generated/SelfParam/SelfParam.ql 12ad3244a2700e13a84603d6992f0c872572bca68d25515a7a9414b3c96a62e0 70028e344bc4ab2937f391f1fd8afd1549935aa621ce2cb9944da6a1dcf4be27 test/extractor-tests/generated/SelfParam/SelfParam_getAttr.ql 00dd5409c07e9a7b5dc51c1444e24b35d2ac3cab11320396ef70f531a3b65dc0 effbed79ad530a835e85b931389a0c8609a10ee035cb694f2e39b8539f8e54ba test/extractor-tests/generated/SelfParam/SelfParam_getLifetime.ql 0b7c243f609e005dd63fd1b3b9f0096fc13cb98fe113e6f3fefb0d5c414e9a5f f6e06de8bcddfc9bd978c058079e53174edbe7b39f18df3c0bd4e80486808eda test/extractor-tests/generated/SelfParam/SelfParam_getName.ql 69207a57b415ba590e50003d506a64fd1780b27b8832b14f9bd3c909bddb5593 56fa28ba1222f45893237052fa5a9421d960e14fbf1396b2d1049b440c2e5abe diff --git a/rust/ql/.gitattributes b/rust/ql/.gitattributes index 6daad6a68c7b..69c1ecbc2c6a 100644 --- a/rust/ql/.gitattributes +++ b/rust/ql/.gitattributes @@ -96,6 +96,7 @@ /lib/codeql/rust/elements/OffsetOfExpr.qll linguist-generated /lib/codeql/rust/elements/OrPat.qll linguist-generated /lib/codeql/rust/elements/Param.qll linguist-generated +/lib/codeql/rust/elements/ParamBase.qll linguist-generated /lib/codeql/rust/elements/ParamList.qll linguist-generated /lib/codeql/rust/elements/ParenExpr.qll linguist-generated /lib/codeql/rust/elements/ParenPat.qll linguist-generated @@ -294,6 +295,7 @@ /lib/codeql/rust/elements/internal/OffsetOfExprConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/OffsetOfExprImpl.qll linguist-generated /lib/codeql/rust/elements/internal/OrPatConstructor.qll linguist-generated +/lib/codeql/rust/elements/internal/ParamBaseImpl.qll linguist-generated /lib/codeql/rust/elements/internal/ParamConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/ParamListConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/ParamListImpl.qll linguist-generated @@ -507,6 +509,7 @@ /lib/codeql/rust/elements/internal/generated/OffsetOfExpr.qll linguist-generated /lib/codeql/rust/elements/internal/generated/OrPat.qll linguist-generated /lib/codeql/rust/elements/internal/generated/Param.qll linguist-generated +/lib/codeql/rust/elements/internal/generated/ParamBase.qll linguist-generated /lib/codeql/rust/elements/internal/generated/ParamList.qll linguist-generated /lib/codeql/rust/elements/internal/generated/ParenExpr.qll linguist-generated /lib/codeql/rust/elements/internal/generated/ParenPat.qll linguist-generated @@ -846,8 +849,8 @@ /test/extractor-tests/generated/MatchArmList/MatchArmList_getAttr.ql linguist-generated /test/extractor-tests/generated/MatchExpr/MatchExpr.ql linguist-generated /test/extractor-tests/generated/MatchExpr/MatchExpr_getAttr.ql linguist-generated -/test/extractor-tests/generated/MatchExpr/MatchExpr_getExpr.ql linguist-generated /test/extractor-tests/generated/MatchExpr/MatchExpr_getMatchArmList.ql linguist-generated +/test/extractor-tests/generated/MatchExpr/MatchExpr_getScrutinee.ql linguist-generated /test/extractor-tests/generated/MatchGuard/MatchGuard.ql linguist-generated /test/extractor-tests/generated/MatchGuard/MatchGuard_getCondition.ql linguist-generated /test/extractor-tests/generated/Meta/Meta.ql linguist-generated diff --git a/rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll b/rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll index df43d450a505..91eeb75fe398 100644 --- a/rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll +++ b/rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll @@ -514,14 +514,14 @@ module ExprTrees { class MatchExprTree extends PostOrderTree instanceof MatchExpr { override predicate propagatesAbnormal(AstNode child) { - child = [super.getExpr(), super.getAnArm().getExpr()] + child = [super.getScrutinee(), super.getAnArm().getExpr()] } - override predicate first(AstNode node) { first(super.getExpr(), node) } + override predicate first(AstNode node) { first(super.getScrutinee(), node) } override predicate succ(AstNode pred, AstNode succ, Completion c) { // Edge from the scrutinee to the first arm or to the match expression if no arms. - last(super.getExpr(), pred, c) and + last(super.getScrutinee(), pred, c) and ( first(super.getArm(0).getPat(), succ) or diff --git a/rust/ql/lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll b/rust/ql/lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll index b550ecf89b75..44024a9d76e7 100644 --- a/rust/ql/lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll +++ b/rust/ql/lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll @@ -1709,7 +1709,7 @@ module MakeCfgNodes Input> { override predicate relevantChild(AstNode child) { none() or - child = this.getExpr() + child = this.getScrutinee() } } @@ -1752,16 +1752,16 @@ module MakeCfgNodes Input> { int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } /** - * Gets the expression of this match expression, if it exists. + * Gets the scrutinee (the expression being matched) of this match expression, if it exists. */ - ExprCfgNode getExpr() { - any(ChildMapping mapping).hasCfgChild(node, node.getExpr(), this, result) + ExprCfgNode getScrutinee() { + any(ChildMapping mapping).hasCfgChild(node, node.getScrutinee(), this, result) } /** - * Holds if `getExpr()` exists. + * Holds if `getScrutinee()` exists. */ - predicate hasExpr() { exists(this.getExpr()) } + predicate hasScrutinee() { exists(this.getScrutinee()) } /** * Gets the match arm list of this match expression, if it exists. @@ -1940,12 +1940,14 @@ module MakeCfgNodes Input> { } /** - * A Param. For example: + * A parameter in a function or method. For example `x` in: * ```rust - * todo!() + * fn new(x: T) -> Foo { + * // ... + * } * ``` */ - final class ParamCfgNode extends CfgNodeFinal { + final class ParamCfgNode extends CfgNodeFinal, ParamBaseCfgNode { private Param node; ParamCfgNode() { node = this.getAstNode() } @@ -1954,34 +1956,50 @@ module MakeCfgNodes Input> { Param getParam() { result = node } /** - * Gets the `index`th attr of this parameter (0-based). + * Gets the pat of this parameter, if it exists. */ - Attr getAttr(int index) { result = node.getAttr(index) } + PatCfgNode getPat() { + any(ChildMapping mapping).hasCfgChild(node, node.getPat(), this, result) + } /** - * Gets any of the attrs of this parameter. + * Holds if `getPat()` exists. */ - Attr getAnAttr() { result = this.getAttr(_) } + predicate hasPat() { exists(this.getPat()) } + } + + final private class ParentParamBase extends ParentAstNode, ParamBase { + override predicate relevantChild(AstNode child) { none() } + } + + /** + * A normal parameter, `Param`, or a self parameter `SelfParam`. + */ + final class ParamBaseCfgNode extends CfgNodeFinal { + private ParamBase node; + + ParamBaseCfgNode() { node = this.getAstNode() } + + /** Gets the underlying `ParamBase`. */ + ParamBase getParamBase() { result = node } /** - * Gets the number of attrs of this parameter. + * Gets the `index`th attr of this parameter base (0-based). */ - int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } + Attr getAttr(int index) { result = node.getAttr(index) } /** - * Gets the pat of this parameter, if it exists. + * Gets any of the attrs of this parameter base. */ - PatCfgNode getPat() { - any(ChildMapping mapping).hasCfgChild(node, node.getPat(), this, result) - } + Attr getAnAttr() { result = this.getAttr(_) } /** - * Holds if `getPat()` exists. + * Gets the number of attrs of this parameter base. */ - predicate hasPat() { exists(this.getPat()) } + int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } /** - * Gets the ty of this parameter, if it exists. + * Gets the ty of this parameter base, if it exists. */ TypeRef getTy() { result = node.getTy() } @@ -2597,12 +2615,14 @@ module MakeCfgNodes Input> { } /** - * A SelfParam. For example: + * A `self` parameter. For example `self` in: * ```rust - * todo!() + * fn push(&mut self, value: T) { + * // ... + * } * ``` */ - final class SelfParamCfgNode extends CfgNodeFinal { + final class SelfParamCfgNode extends CfgNodeFinal, ParamBaseCfgNode { private SelfParam node; SelfParamCfgNode() { node = this.getAstNode() } @@ -2610,21 +2630,6 @@ module MakeCfgNodes Input> { /** Gets the underlying `SelfParam`. */ SelfParam getSelfParam() { result = node } - /** - * Gets the `index`th attr of this self parameter (0-based). - */ - Attr getAttr(int index) { result = node.getAttr(index) } - - /** - * Gets any of the attrs of this self parameter. - */ - Attr getAnAttr() { result = this.getAttr(_) } - - /** - * Gets the number of attrs of this self parameter. - */ - int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } - /** * Holds if this self parameter is mut. */ @@ -2649,16 +2654,6 @@ module MakeCfgNodes Input> { * Holds if `getName()` exists. */ predicate hasName() { exists(this.getName()) } - - /** - * Gets the ty of this self parameter, if it exists. - */ - TypeRef getTy() { result = node.getTy() } - - /** - * Holds if `getTy()` exists. - */ - predicate hasTy() { exists(this.getTy()) } } final private class ParentSlicePat extends ParentAstNode, SlicePat { @@ -3456,14 +3451,14 @@ module MakeCfgNodes Input> { cfgNode ) or - pred = "getExpr" and + pred = "getScrutinee" and parent = any(Nodes::MatchExprCfgNode cfgNode, MatchExpr astNode | astNode = cfgNode.getMatchExpr() and - child = getDesugared(astNode.getExpr()) and + child = getDesugared(astNode.getScrutinee()) and i = -1 and hasCfgNode(child) and - not child = cfgNode.getExpr().getAstNode() + not child = cfgNode.getScrutinee().getAstNode() | cfgNode ) diff --git a/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll b/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll index 1ec8a42ee7e0..91f8065ab5a4 100644 --- a/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll +++ b/rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll @@ -83,7 +83,7 @@ final class ParameterPosition extends TParameterPosition { result = "self" and this.isSelf() } - AstNode getParameterIn(ParamList ps) { + ParamBase getParameterIn(ParamList ps) { result = ps.getParam(this.getPosition()) or result = ps.getSelfParam() and this.isSelf() @@ -181,28 +181,17 @@ module Node { PatCfgNode getPat() { result = n } } - abstract class ParameterNode extends AstCfgFlowNode { } - /** * The value of a parameter at function entry, viewed as a node in a data * flow graph. */ - final class PositionalParameterNode extends ParameterNode, TParameterNode { - override ParamCfgNode n; + final class ParameterNode extends AstCfgFlowNode, TParameterNode { + override ParamBaseCfgNode n; - PositionalParameterNode() { this = TParameterNode(n) } + ParameterNode() { this = TParameterNode(n) } /** Gets the parameter in the CFG that this node corresponds to. */ - ParamCfgNode getParameter() { result = n } - } - - final class SelfParameterNode extends ParameterNode, TSelfParameterNode { - override SelfParamCfgNode n; - - SelfParameterNode() { this = TSelfParameterNode(n) } - - /** Gets the self parameter in the AST that this node corresponds to. */ - SelfParamCfgNode getSelfParameter() { result = n } + ParamBaseCfgNode getParameter() { result = n } } final class ArgumentNode extends ExprNode { @@ -284,7 +273,7 @@ module SsaFlow { private module SsaFlow = SsaImpl::DataFlowIntegration; private Node::ParameterNode toParameterNode(ParamCfgNode p) { - result.(Node::PositionalParameterNode).getParameter() = p + result.(Node::ParameterNode).getParameter() = p } /** Converts a control flow node into an SSA control flow node. */ @@ -333,7 +322,7 @@ module LocalFlow { nodeFrom.(Node::AstCfgFlowNode).getCfgNode() = nodeTo.(Node::SsaNode).getDefinitionExt().(Ssa::WriteDefinition).getControlFlowNode() or - nodeFrom.(Node::PositionalParameterNode).getParameter().getPat() = + nodeFrom.(Node::ParameterNode).getParameter().(ParamCfgNode).getPat() = nodeTo.(Node::PatNode).getPat() or SsaFlow::localFlowStep(_, nodeFrom, nodeTo, _) @@ -399,13 +388,55 @@ module RustDataFlow implements InputSig { final class ReturnKind = ReturnKindAlias; + private import codeql.util.Option + + private class CrateOrigin extends string { + CrateOrigin() { + this = [any(Item i).getCrateOrigin(), any(Resolvable r).getResolvedCrateOrigin()] + } + } + + private class CrateOriginOption = Option::Option; + + pragma[nomagic] + private predicate hasExtendedCanonicalPath( + DataFlowCallable c, CrateOriginOption crate, string path + ) { + exists(Item i | + i = c.asCfgScope() and + path = i.getExtendedCanonicalPath() + | + crate.asSome() = i.getCrateOrigin() + or + crate.isNone() and + not i.hasCrateOrigin() + ) + } + + pragma[nomagic] + private predicate resolvesExtendedCanonicalPath( + DataFlowCall c, CrateOriginOption crate, string path + ) { + exists(Resolvable r | + path = r.getResolvedPath() and + ( + r = c.asMethodCallExprCfgNode().getExpr() + or + r = c.asCallExprCfgNode().getExpr().(PathExprCfgNode).getPath() + ) + | + crate.asSome() = r.getResolvedCrateOrigin() + or + crate.isNone() and + not r.hasResolvedCrateOrigin() + ) + } + /** Gets a viable implementation of the target of the given `Call`. */ - DataFlowCallable viableCallable(DataFlowCall c) { - exists(Function f, string name | result.asCfgScope() = f and name = f.getName().toString() | - if f.getParamList().hasSelfParam() - then name = c.asMethodCallExprCfgNode().getNameRef().getText() - else - name = c.asCallExprCfgNode().getExpr().getExpr().(PathExpr).getPath().getPart().toString() + DataFlowCallable viableCallable(DataFlowCall call) { + exists(string path, CrateOriginOption crate | + hasExtendedCanonicalPath(result, crate, path) and + resolvesExtendedCanonicalPath(call, crate, path) ) } @@ -559,8 +590,7 @@ private module Cached { cached newtype TNode = TExprNode(ExprCfgNode n) or - TParameterNode(ParamCfgNode p) or - TSelfParameterNode(SelfParamCfgNode p) or + TParameterNode(ParamBaseCfgNode p) or TPatNode(PatCfgNode p) or TArgumentPostUpdateNode(ExprCfgNode e) { isArgumentForCall(e, _, _) } or TSsaNode(SsaImpl::DataFlowIntegration::SsaNode node) diff --git a/rust/ql/lib/codeql/rust/elements.qll b/rust/ql/lib/codeql/rust/elements.qll index 6bb59b428824..7d752c1b9be6 100644 --- a/rust/ql/lib/codeql/rust/elements.qll +++ b/rust/ql/lib/codeql/rust/elements.qll @@ -98,6 +98,7 @@ import codeql.rust.elements.NeverType import codeql.rust.elements.OffsetOfExpr import codeql.rust.elements.OrPat import codeql.rust.elements.Param +import codeql.rust.elements.ParamBase import codeql.rust.elements.ParamList import codeql.rust.elements.ParenExpr import codeql.rust.elements.ParenPat diff --git a/rust/ql/lib/codeql/rust/elements/Param.qll b/rust/ql/lib/codeql/rust/elements/Param.qll index eb46d206ba48..74eda683740e 100644 --- a/rust/ql/lib/codeql/rust/elements/Param.qll +++ b/rust/ql/lib/codeql/rust/elements/Param.qll @@ -4,15 +4,15 @@ */ private import internal.ParamImpl -import codeql.rust.elements.AstNode -import codeql.rust.elements.Attr +import codeql.rust.elements.ParamBase import codeql.rust.elements.Pat -import codeql.rust.elements.TypeRef /** - * A Param. For example: + * A parameter in a function or method. For example `x` in: * ```rust - * todo!() + * fn new(x: T) -> Foo { + * // ... + * } * ``` */ final class Param = Impl::Param; diff --git a/rust/ql/lib/codeql/rust/elements/ParamBase.qll b/rust/ql/lib/codeql/rust/elements/ParamBase.qll new file mode 100644 index 000000000000..d3a031f4da5b --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ParamBase.qll @@ -0,0 +1,14 @@ +// generated by codegen, do not edit +/** + * This module provides the public class `ParamBase`. + */ + +private import internal.ParamBaseImpl +import codeql.rust.elements.AstNode +import codeql.rust.elements.Attr +import codeql.rust.elements.TypeRef + +/** + * A normal parameter, `Param`, or a self parameter `SelfParam`. + */ +final class ParamBase = Impl::ParamBase; diff --git a/rust/ql/lib/codeql/rust/elements/SelfParam.qll b/rust/ql/lib/codeql/rust/elements/SelfParam.qll index 74d2fb5e2ebc..88c1a05d8371 100644 --- a/rust/ql/lib/codeql/rust/elements/SelfParam.qll +++ b/rust/ql/lib/codeql/rust/elements/SelfParam.qll @@ -4,16 +4,16 @@ */ private import internal.SelfParamImpl -import codeql.rust.elements.AstNode -import codeql.rust.elements.Attr import codeql.rust.elements.Lifetime import codeql.rust.elements.Name -import codeql.rust.elements.TypeRef +import codeql.rust.elements.ParamBase /** - * A SelfParam. For example: + * A `self` parameter. For example `self` in: * ```rust - * todo!() + * fn push(&mut self, value: T) { + * // ... + * } * ``` */ final class SelfParam = Impl::SelfParam; diff --git a/rust/ql/lib/codeql/rust/elements/internal/MatchExprImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/MatchExprImpl.qll index 3ce9aa773107..15fdcf7e73fb 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/MatchExprImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/MatchExprImpl.qll @@ -29,7 +29,7 @@ module Impl { */ class MatchExpr extends Generated::MatchExpr { override string toString() { - result = "match " + this.getExpr().toAbbreviatedString() + " { ... }" + result = "match " + this.getScrutinee().toAbbreviatedString() + " { ... }" } /** diff --git a/rust/ql/lib/codeql/rust/elements/internal/ParamBaseImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/ParamBaseImpl.qll new file mode 100644 index 000000000000..3b0f82eb6c3d --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/internal/ParamBaseImpl.qll @@ -0,0 +1,19 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `ParamBase`. + * + * INTERNAL: Do not use. + */ + +private import codeql.rust.elements.internal.generated.ParamBase + +/** + * INTERNAL: This module contains the customizable definition of `ParamBase` and should not + * be referenced directly. + */ +module Impl { + /** + * A normal parameter, `Param`, or a self parameter `SelfParam`. + */ + class ParamBase extends Generated::ParamBase { } +} diff --git a/rust/ql/lib/codeql/rust/elements/internal/ParamImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/ParamImpl.qll index 33e4f5fee59b..02d38d32c386 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/ParamImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/ParamImpl.qll @@ -13,9 +13,11 @@ private import codeql.rust.elements.internal.generated.Param module Impl { // the following QLdoc is generated: if you need to edit it, do it in the schema file /** - * A Param. For example: + * A parameter in a function or method. For example `x` in: * ```rust - * todo!() + * fn new(x: T) -> Foo { + * // ... + * } * ``` */ class Param extends Generated::Param { diff --git a/rust/ql/lib/codeql/rust/elements/internal/SelfParamImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/SelfParamImpl.qll index 2be3b75ac47a..0d0d23a1e8c5 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/SelfParamImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/SelfParamImpl.qll @@ -13,9 +13,11 @@ private import codeql.rust.elements.internal.generated.SelfParam */ module Impl { /** - * A SelfParam. For example: + * A `self` parameter. For example `self` in: * ```rust - * todo!() + * fn push(&mut self, value: T) { + * // ... + * } * ``` */ class SelfParam extends Generated::SelfParam { } diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/MatchExpr.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/MatchExpr.qll index 5b48d8e18544..8f49407e5f9e 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/MatchExpr.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/MatchExpr.qll @@ -55,17 +55,17 @@ module Generated { final int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } /** - * Gets the expression of this match expression, if it exists. + * Gets the scrutinee (the expression being matched) of this match expression, if it exists. */ - Expr getExpr() { + Expr getScrutinee() { result = - Synth::convertExprFromRaw(Synth::convertMatchExprToRaw(this).(Raw::MatchExpr).getExpr()) + Synth::convertExprFromRaw(Synth::convertMatchExprToRaw(this).(Raw::MatchExpr).getScrutinee()) } /** - * Holds if `getExpr()` exists. + * Holds if `getScrutinee()` exists. */ - final predicate hasExpr() { exists(this.getExpr()) } + final predicate hasScrutinee() { exists(this.getScrutinee()) } /** * Gets the match arm list of this match expression, if it exists. diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/Param.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/Param.qll index 1ac10da37d35..2bbbc81b2c9f 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/Param.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Param.qll @@ -6,10 +6,8 @@ private import codeql.rust.elements.internal.generated.Synth private import codeql.rust.elements.internal.generated.Raw -import codeql.rust.elements.internal.AstNodeImpl::Impl as AstNodeImpl -import codeql.rust.elements.Attr +import codeql.rust.elements.internal.ParamBaseImpl::Impl as ParamBaseImpl import codeql.rust.elements.Pat -import codeql.rust.elements.TypeRef /** * INTERNAL: This module contains the fully generated definition of `Param` and should not @@ -17,33 +15,18 @@ import codeql.rust.elements.TypeRef */ module Generated { /** - * A Param. For example: + * A parameter in a function or method. For example `x` in: * ```rust - * todo!() + * fn new(x: T) -> Foo { + * // ... + * } * ``` * INTERNAL: Do not reference the `Generated::Param` class directly. * Use the subclass `Param`, where the following predicates are available. */ - class Param extends Synth::TParam, AstNodeImpl::AstNode { + class Param extends Synth::TParam, ParamBaseImpl::ParamBase { override string getAPrimaryQlClass() { result = "Param" } - /** - * Gets the `index`th attr of this parameter (0-based). - */ - Attr getAttr(int index) { - result = Synth::convertAttrFromRaw(Synth::convertParamToRaw(this).(Raw::Param).getAttr(index)) - } - - /** - * Gets any of the attrs of this parameter. - */ - final Attr getAnAttr() { result = this.getAttr(_) } - - /** - * Gets the number of attrs of this parameter. - */ - final int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } - /** * Gets the pat of this parameter, if it exists. */ @@ -55,17 +38,5 @@ module Generated { * Holds if `getPat()` exists. */ final predicate hasPat() { exists(this.getPat()) } - - /** - * Gets the ty of this parameter, if it exists. - */ - TypeRef getTy() { - result = Synth::convertTypeRefFromRaw(Synth::convertParamToRaw(this).(Raw::Param).getTy()) - } - - /** - * Holds if `getTy()` exists. - */ - final predicate hasTy() { exists(this.getTy()) } } } diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/ParamBase.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/ParamBase.qll new file mode 100644 index 000000000000..ea5ef12a64f5 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/ParamBase.qll @@ -0,0 +1,55 @@ +// generated by codegen, do not edit +/** + * This module provides the generated definition of `ParamBase`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.elements.internal.generated.Synth +private import codeql.rust.elements.internal.generated.Raw +import codeql.rust.elements.internal.AstNodeImpl::Impl as AstNodeImpl +import codeql.rust.elements.Attr +import codeql.rust.elements.TypeRef + +/** + * INTERNAL: This module contains the fully generated definition of `ParamBase` and should not + * be referenced directly. + */ +module Generated { + /** + * A normal parameter, `Param`, or a self parameter `SelfParam`. + * INTERNAL: Do not reference the `Generated::ParamBase` class directly. + * Use the subclass `ParamBase`, where the following predicates are available. + */ + class ParamBase extends Synth::TParamBase, AstNodeImpl::AstNode { + /** + * Gets the `index`th attr of this parameter base (0-based). + */ + Attr getAttr(int index) { + result = + Synth::convertAttrFromRaw(Synth::convertParamBaseToRaw(this).(Raw::ParamBase).getAttr(index)) + } + + /** + * Gets any of the attrs of this parameter base. + */ + final Attr getAnAttr() { result = this.getAttr(_) } + + /** + * Gets the number of attrs of this parameter base. + */ + final int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } + + /** + * Gets the ty of this parameter base, if it exists. + */ + TypeRef getTy() { + result = + Synth::convertTypeRefFromRaw(Synth::convertParamBaseToRaw(this).(Raw::ParamBase).getTy()) + } + + /** + * Holds if `getTy()` exists. + */ + final predicate hasTy() { exists(this.getTy()) } + } +} diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll index b03310ce2638..970cfb223640 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll @@ -602,14 +602,13 @@ private module Impl { ) } - private Element getImmediateChildOfParam(Param e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nAttr, int nPat, int nTy | + private Element getImmediateChildOfParamBase(ParamBase e, int index, string partialPredicateCall) { + exists(int b, int bAstNode, int n, int nAttr, int nTy | b = 0 and bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and n = bAstNode and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and - nPat = nAttr + 1 and - nTy = nPat + 1 and + nTy = nAttr + 1 and ( none() or @@ -618,9 +617,7 @@ private module Impl { result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or - index = nAttr and result = e.getPat() and partialPredicateCall = "Pat()" - or - index = nPat and result = e.getTy() and partialPredicateCall = "Ty()" + index = nAttr and result = e.getTy() and partialPredicateCall = "Ty()" ) ) } @@ -885,32 +882,6 @@ private module Impl { ) } - private Element getImmediateChildOfSelfParam(SelfParam e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nAttr, int nLifetime, int nName, int nTy | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and - nLifetime = nAttr + 1 and - nName = nLifetime + 1 and - nTy = nName + 1 and - ( - none() - or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" - or - index = nAttr and result = e.getLifetime() and partialPredicateCall = "Lifetime()" - or - index = nLifetime and result = e.getName() and partialPredicateCall = "Name()" - or - index = nName and result = e.getTy() and partialPredicateCall = "Ty()" - ) - ) - } - private Element getImmediateChildOfSourceFile(SourceFile e, int index, string partialPredicateCall) { exists(int b, int bAstNode, int n, int nAttr, int nItem | b = 0 and @@ -2059,13 +2030,13 @@ private module Impl { } private Element getImmediateChildOfMatchExpr(MatchExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, int nExpr, int nMatchArmList | + exists(int b, int bExpr, int n, int nAttr, int nScrutinee, int nMatchArmList | b = 0 and bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and n = bExpr and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and - nExpr = nAttr + 1 and - nMatchArmList = nExpr + 1 and + nScrutinee = nAttr + 1 and + nMatchArmList = nScrutinee + 1 and ( none() or @@ -2074,9 +2045,11 @@ private module Impl { result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or - index = nAttr and result = e.getExpr() and partialPredicateCall = "Expr()" + index = nAttr and result = e.getScrutinee() and partialPredicateCall = "Scrutinee()" or - index = nExpr and result = e.getMatchArmList() and partialPredicateCall = "MatchArmList()" + index = nScrutinee and + result = e.getMatchArmList() and + partialPredicateCall = "MatchArmList()" ) ) } @@ -2137,6 +2110,22 @@ private module Impl { ) } + private Element getImmediateChildOfParam(Param e, int index, string partialPredicateCall) { + exists(int b, int bParamBase, int n, int nPat | + b = 0 and + bParamBase = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfParamBase(e, i, _)) | i) and + n = bParamBase and + nPat = n + 1 and + ( + none() + or + result = getImmediateChildOfParamBase(e, index - b, partialPredicateCall) + or + index = n and result = e.getPat() and partialPredicateCall = "Pat()" + ) + ) + } + private Element getImmediateChildOfParenExpr(ParenExpr e, int index, string partialPredicateCall) { exists(int b, int bExpr, int n, int nAttr, int nExpr | b = 0 and @@ -2487,6 +2476,25 @@ private module Impl { ) } + private Element getImmediateChildOfSelfParam(SelfParam e, int index, string partialPredicateCall) { + exists(int b, int bParamBase, int n, int nLifetime, int nName | + b = 0 and + bParamBase = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfParamBase(e, i, _)) | i) and + n = bParamBase and + nLifetime = n + 1 and + nName = nLifetime + 1 and + ( + none() + or + result = getImmediateChildOfParamBase(e, index - b, partialPredicateCall) + or + index = n and result = e.getLifetime() and partialPredicateCall = "Lifetime()" + or + index = nLifetime and result = e.getName() and partialPredicateCall = "Name()" + ) + ) + } + private Element getImmediateChildOfSlicePat(SlicePat e, int index, string partialPredicateCall) { exists(int b, int bPat, int n, int nPat | b = 0 and @@ -3621,8 +3629,6 @@ private module Impl { or result = getImmediateChildOfNameRef(e, index, partialAccessor) or - result = getImmediateChildOfParam(e, index, partialAccessor) - or result = getImmediateChildOfParamList(e, index, partialAccessor) or result = getImmediateChildOfPathSegment(e, index, partialAccessor) @@ -3643,8 +3649,6 @@ private module Impl { or result = getImmediateChildOfReturnTypeSyntax(e, index, partialAccessor) or - result = getImmediateChildOfSelfParam(e, index, partialAccessor) - or result = getImmediateChildOfSourceFile(e, index, partialAccessor) or result = getImmediateChildOfStmtList(e, index, partialAccessor) @@ -3751,6 +3755,8 @@ private module Impl { or result = getImmediateChildOfOrPat(e, index, partialAccessor) or + result = getImmediateChildOfParam(e, index, partialAccessor) + or result = getImmediateChildOfParenExpr(e, index, partialAccessor) or result = getImmediateChildOfParenPat(e, index, partialAccessor) @@ -3787,6 +3793,8 @@ private module Impl { or result = getImmediateChildOfReturnExpr(e, index, partialAccessor) or + result = getImmediateChildOfSelfParam(e, index, partialAccessor) + or result = getImmediateChildOfSlicePat(e, index, partialAccessor) or result = getImmediateChildOfSliceType(e, index, partialAccessor) diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll index 64de46c55bb1..69aa32d4ad8c 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll @@ -525,28 +525,18 @@ module Raw { /** * INTERNAL: Do not use. - * A Param. For example: - * ```rust - * todo!() - * ``` + * A normal parameter, `Param`, or a self parameter `SelfParam`. */ - class Param extends @param, AstNode { - override string toString() { result = "Param" } - + class ParamBase extends @param_base, AstNode { /** - * Gets the `index`th attr of this parameter (0-based). + * Gets the `index`th attr of this parameter base (0-based). */ - Attr getAttr(int index) { param_attrs(this, index, result) } - - /** - * Gets the pat of this parameter, if it exists. - */ - Pat getPat() { param_pats(this, result) } + Attr getAttr(int index) { param_base_attrs(this, index, result) } /** - * Gets the ty of this parameter, if it exists. + * Gets the ty of this parameter base, if it exists. */ - TypeRef getTy() { param_ties(this, result) } + TypeRef getTy() { param_base_ties(this, result) } } /** @@ -808,42 +798,6 @@ module Raw { override string toString() { result = "ReturnTypeSyntax" } } - /** - * INTERNAL: Do not use. - * A SelfParam. For example: - * ```rust - * todo!() - * ``` - */ - class SelfParam extends @self_param, AstNode { - override string toString() { result = "SelfParam" } - - /** - * Gets the `index`th attr of this self parameter (0-based). - */ - Attr getAttr(int index) { self_param_attrs(this, index, result) } - - /** - * Holds if this self parameter is mut. - */ - predicate isMut() { self_param_is_mut(this) } - - /** - * Gets the lifetime of this self parameter, if it exists. - */ - Lifetime getLifetime() { self_param_lifetimes(this, result) } - - /** - * Gets the name of this self parameter, if it exists. - */ - Name getName() { self_param_names(this, result) } - - /** - * Gets the ty of this self parameter, if it exists. - */ - TypeRef getTy() { self_param_ties(this, result) } - } - /** * INTERNAL: Do not use. * A SourceFile. For example: @@ -2216,9 +2170,9 @@ module Raw { Attr getAttr(int index) { match_expr_attrs(this, index, result) } /** - * Gets the expression of this match expression, if it exists. + * Gets the scrutinee (the expression being matched) of this match expression, if it exists. */ - Expr getExpr() { match_expr_exprs(this, result) } + Expr getScrutinee() { match_expr_exprs(this, result) } /** * Gets the match arm list of this match expression, if it exists. @@ -2281,6 +2235,24 @@ module Raw { Pat getPat(int index) { or_pat_pats(this, index, result) } } + /** + * INTERNAL: Do not use. + * A parameter in a function or method. For example `x` in: + * ```rust + * fn new(x: T) -> Foo { + * // ... + * } + * ``` + */ + class Param extends @param, ParamBase { + override string toString() { result = "Param" } + + /** + * Gets the pat of this parameter, if it exists. + */ + Pat getPat() { param_pats(this, result) } + } + /** * INTERNAL: Do not use. * A ParenExpr. For example: @@ -2717,6 +2689,34 @@ module Raw { Expr getExpr() { return_expr_exprs(this, result) } } + /** + * INTERNAL: Do not use. + * A `self` parameter. For example `self` in: + * ```rust + * fn push(&mut self, value: T) { + * // ... + * } + * ``` + */ + class SelfParam extends @self_param, ParamBase { + override string toString() { result = "SelfParam" } + + /** + * Holds if this self parameter is mut. + */ + predicate isMut() { self_param_is_mut(this) } + + /** + * Gets the lifetime of this self parameter, if it exists. + */ + Lifetime getLifetime() { self_param_lifetimes(this, result) } + + /** + * Gets the name of this self parameter, if it exists. + */ + Name getName() { self_param_names(this, result) } + } + /** * INTERNAL: Do not use. * A slice pattern. For example: diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/SelfParam.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/SelfParam.qll index 243d04e9bb77..b2cc6e4b0c4a 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/SelfParam.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/SelfParam.qll @@ -6,11 +6,9 @@ private import codeql.rust.elements.internal.generated.Synth private import codeql.rust.elements.internal.generated.Raw -import codeql.rust.elements.internal.AstNodeImpl::Impl as AstNodeImpl -import codeql.rust.elements.Attr import codeql.rust.elements.Lifetime import codeql.rust.elements.Name -import codeql.rust.elements.TypeRef +import codeql.rust.elements.internal.ParamBaseImpl::Impl as ParamBaseImpl /** * INTERNAL: This module contains the fully generated definition of `SelfParam` and should not @@ -18,34 +16,18 @@ import codeql.rust.elements.TypeRef */ module Generated { /** - * A SelfParam. For example: + * A `self` parameter. For example `self` in: * ```rust - * todo!() + * fn push(&mut self, value: T) { + * // ... + * } * ``` * INTERNAL: Do not reference the `Generated::SelfParam` class directly. * Use the subclass `SelfParam`, where the following predicates are available. */ - class SelfParam extends Synth::TSelfParam, AstNodeImpl::AstNode { + class SelfParam extends Synth::TSelfParam, ParamBaseImpl::ParamBase { override string getAPrimaryQlClass() { result = "SelfParam" } - /** - * Gets the `index`th attr of this self parameter (0-based). - */ - Attr getAttr(int index) { - result = - Synth::convertAttrFromRaw(Synth::convertSelfParamToRaw(this).(Raw::SelfParam).getAttr(index)) - } - - /** - * Gets any of the attrs of this self parameter. - */ - final Attr getAnAttr() { result = this.getAttr(_) } - - /** - * Gets the number of attrs of this self parameter. - */ - final int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } - /** * Holds if this self parameter is mut. */ @@ -78,18 +60,5 @@ module Generated { * Holds if `getName()` exists. */ final predicate hasName() { exists(this.getName()) } - - /** - * Gets the ty of this self parameter, if it exists. - */ - TypeRef getTy() { - result = - Synth::convertTypeRefFromRaw(Synth::convertSelfParamToRaw(this).(Raw::SelfParam).getTy()) - } - - /** - * Holds if `getTy()` exists. - */ - final predicate hasTy() { exists(this.getTy()) } } } diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll index dda242ffdf93..b6b1a92a01f7 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll @@ -624,12 +624,12 @@ module Synth { TExpr or TExternItem or TExternItemList or TFieldList or TFormatArgsArg or TGenericArg or TGenericArgList or TGenericParam or TGenericParamList or TItemList or TLabel or TLetElse or TLifetime or TMacroItems or TMacroStmts or TMatchArm or TMatchArmList or TMatchGuard or - TMeta or TName or TNameRef or TParam or TParamList or TPat or TPathSegment or + TMeta or TName or TNameRef or TParamBase or TParamList or TPat or TPathSegment or TRecordExprField or TRecordExprFieldList or TRecordField or TRecordPatField or TRecordPatFieldList or TRename or TResolvable or TRetType or TReturnTypeSyntax or - TSelfParam or TSourceFile or TStmt or TStmtList or TToken or TTokenTree or TTupleField or - TTypeBound or TTypeBoundList or TTypeRef or TUseTree or TUseTreeList or TVariant or - TVariantList or TVisibility or TWhereClause or TWherePred; + TSourceFile or TStmt or TStmtList or TToken or TTokenTree or TTupleField or TTypeBound or + TTypeBoundList or TTypeRef or TUseTree or TUseTreeList or TVariant or TVariantList or + TVisibility or TWhereClause or TWherePred; /** * INTERNAL: Do not use. @@ -695,6 +695,11 @@ module Synth { */ class TLoopingExpr = TForExpr or TLoopExpr or TWhileExpr; + /** + * INTERNAL: Do not use. + */ + class TParamBase = TParam or TSelfParam; + /** * INTERNAL: Do not use. */ @@ -1699,7 +1704,7 @@ module Synth { or result = convertNameRefFromRaw(e) or - result = convertParamFromRaw(e) + result = convertParamBaseFromRaw(e) or result = convertParamListFromRaw(e) or @@ -1725,8 +1730,6 @@ module Synth { or result = convertReturnTypeSyntaxFromRaw(e) or - result = convertSelfParamFromRaw(e) - or result = convertSourceFileFromRaw(e) or result = convertStmtFromRaw(e) @@ -1984,6 +1987,16 @@ module Synth { result = convertWhileExprFromRaw(e) } + /** + * INTERNAL: Do not use. + * Converts a raw DB element to a synthesized `TParamBase`, if possible. + */ + TParamBase convertParamBaseFromRaw(Raw::Element e) { + result = convertParamFromRaw(e) + or + result = convertSelfParamFromRaw(e) + } + /** * INTERNAL: Do not use. * Converts a raw DB element to a synthesized `TPat`, if possible. @@ -3065,7 +3078,7 @@ module Synth { or result = convertNameRefToRaw(e) or - result = convertParamToRaw(e) + result = convertParamBaseToRaw(e) or result = convertParamListToRaw(e) or @@ -3091,8 +3104,6 @@ module Synth { or result = convertReturnTypeSyntaxToRaw(e) or - result = convertSelfParamToRaw(e) - or result = convertSourceFileToRaw(e) or result = convertStmtToRaw(e) @@ -3350,6 +3361,16 @@ module Synth { result = convertWhileExprToRaw(e) } + /** + * INTERNAL: Do not use. + * Converts a synthesized `TParamBase` to a raw DB element, if possible. + */ + Raw::Element convertParamBaseToRaw(TParamBase e) { + result = convertParamToRaw(e) + or + result = convertSelfParamToRaw(e) + } + /** * INTERNAL: Do not use. * Converts a synthesized `TPat` to a raw DB element, if possible. diff --git a/rust/ql/lib/rust.dbscheme b/rust/ql/lib/rust.dbscheme index c9933b5b5e33..7c2ba7da58c8 100644 --- a/rust/ql/lib/rust.dbscheme +++ b/rust/ql/lib/rust.dbscheme @@ -162,7 +162,7 @@ locatable_locations( | @meta | @name | @name_ref -| @param +| @param_base | @param_list | @pat | @path_segment @@ -175,7 +175,6 @@ locatable_locations( | @resolvable | @ret_type | @return_type_syntax -| @self_param | @source_file | @stmt | @stmt_list @@ -582,26 +581,21 @@ name_ref_texts( string text: string ref ); -params( - unique int id: @param -); +@param_base = + @param +| @self_param +; #keyset[id, index] -param_attrs( - int id: @param ref, +param_base_attrs( + int id: @param_base ref, int index: int ref, int attr: @attr ref ); #keyset[id] -param_pats( - int id: @param ref, - int pat: @pat ref -); - -#keyset[id] -param_ties( - int id: @param ref, +param_base_ties( + int id: @param_base ref, int ty: @type_ref ref ); @@ -844,40 +838,6 @@ return_type_syntaxes( unique int id: @return_type_syntax ); -self_params( - unique int id: @self_param -); - -#keyset[id, index] -self_param_attrs( - int id: @self_param ref, - int index: int ref, - int attr: @attr ref -); - -#keyset[id] -self_param_is_mut( - int id: @self_param ref -); - -#keyset[id] -self_param_lifetimes( - int id: @self_param ref, - int lifetime: @lifetime ref -); - -#keyset[id] -self_param_names( - int id: @self_param ref, - int name: @name ref -); - -#keyset[id] -self_param_ties( - int id: @self_param ref, - int ty: @type_ref ref -); - source_files( unique int id: @source_file ); @@ -1986,6 +1946,16 @@ or_pat_pats( int pat: @pat ref ); +params( + unique int id: @param +); + +#keyset[id] +param_pats( + int id: @param ref, + int pat: @pat ref +); + paren_exprs( unique int id: @paren_expr ); @@ -2296,6 +2266,27 @@ return_expr_exprs( int expr: @expr ref ); +self_params( + unique int id: @self_param +); + +#keyset[id] +self_param_is_mut( + int id: @self_param ref +); + +#keyset[id] +self_param_lifetimes( + int id: @self_param ref, + int lifetime: @lifetime ref +); + +#keyset[id] +self_param_names( + int id: @self_param ref, + int name: @name ref +); + slice_pats( unique int id: @slice_pat ); diff --git a/rust/ql/src/queries/diagnostics/UnextractedElements.ql b/rust/ql/src/queries/diagnostics/UnextractedElements.ql index dccf7d2ab09f..1a819e3f7847 100644 --- a/rust/ql/src/queries/diagnostics/UnextractedElements.ql +++ b/rust/ql/src/queries/diagnostics/UnextractedElements.ql @@ -1,6 +1,7 @@ /** * @name Unextracted Elements * @description List all elements that weren't extracted due to unimplemented features or parse errors. + * @kind diagnostic * @id rust/diagnostics/unextracted-elements */ diff --git a/rust/ql/src/queries/diagnostics/UnresolvedMacroCalls.ql b/rust/ql/src/queries/diagnostics/UnresolvedMacroCalls.ql new file mode 100644 index 000000000000..a20c5035b6ab --- /dev/null +++ b/rust/ql/src/queries/diagnostics/UnresolvedMacroCalls.ql @@ -0,0 +1,12 @@ +/** + * @name Unresolved Macro Calls + * @description List all macro calls that were not resolved to a target. + * @kind diagnostic + * @id rust/diagnostics/unresolved-macro-calls + */ + +import rust + +from MacroCall mc +where not mc.hasExpanded() +select mc, "Macro call was not resolved to a target." diff --git a/rust/ql/src/queries/summary/SummaryStats.ql b/rust/ql/src/queries/summary/SummaryStats.ql index b453d80e5e00..09ee83fc5e64 100644 --- a/rust/ql/src/queries/summary/SummaryStats.ql +++ b/rust/ql/src/queries/summary/SummaryStats.ql @@ -39,7 +39,13 @@ where or key = "Inconsistencies - data flow" and value = getTotalDataFlowInconsistencies() or + key = "Macro calls - total" and value = count(MacroCall mc) + or + key = "Macro calls - resolved" and value = count(MacroCall mc | mc.hasExpanded()) + or + key = "Macro calls - unresolved" and value = count(MacroCall mc | not mc.hasExpanded()) + or key = "Taint sources - total" and value = count(ThreatModelSource s) or key = "Taint sources - active" and value = count(ActiveThreatModelSource s) -select key, value +select key, value order by key diff --git a/rust/ql/test/extractor-tests/generated/.generated_tests.list b/rust/ql/test/extractor-tests/generated/.generated_tests.list index 83affdc7e649..1fe8e805b268 100644 --- a/rust/ql/test/extractor-tests/generated/.generated_tests.list +++ b/rust/ql/test/extractor-tests/generated/.generated_tests.list @@ -75,7 +75,7 @@ NameRef/gen_name_ref.rs 41307c2f7ca82d28217129639e556bd4c91221cf3a4170250b313fd5 NeverType/gen_never_type.rs a5413fab6a45dcfc2ff0ec5c8308b6c515963212ec4aa9edb9a96ec9a7e96830 a5413fab6a45dcfc2ff0ec5c8308b6c515963212ec4aa9edb9a96ec9a7e96830 OffsetOfExpr/gen_offset_of_expr.rs 8e2077b4d7b85c91c17c3630511bc4f929950e9007261cbf0471c4a064c4b934 8e2077b4d7b85c91c17c3630511bc4f929950e9007261cbf0471c4a064c4b934 OrPat/gen_or_pat.rs 71feef6e056bfe4cc8c22c9eb54fa3fecef613606769061d0efd059adbbd6f56 71feef6e056bfe4cc8c22c9eb54fa3fecef613606769061d0efd059adbbd6f56 -Param/gen_param.rs 6c9e4a972b2dc0702dc29ebcbdcbe2c6a433b3cd372ad6924feedcea4698faba 6c9e4a972b2dc0702dc29ebcbdcbe2c6a433b3cd372ad6924feedcea4698faba +Param/gen_param.rs 39f3979d6cb10e4c43e0b5601af2a92b7520a75a104211955bbbb5e6f13e9db9 39f3979d6cb10e4c43e0b5601af2a92b7520a75a104211955bbbb5e6f13e9db9 ParamList/gen_param_list.rs ef2e83d0aed45b969fe78dd717e87ef3c1f848e6179cfb4dc3cb136f1836b998 ef2e83d0aed45b969fe78dd717e87ef3c1f848e6179cfb4dc3cb136f1836b998 ParenExpr/gen_paren_expr.rs dd0c4a21a92e54e8a6151145e013cbec9c9e1cad093d572e293b4f51d6c44aea dd0c4a21a92e54e8a6151145e013cbec9c9e1cad093d572e293b4f51d6c44aea ParenPat/gen_paren_pat.rs c8d18521b9a0b7d39841eb72e3895914aa652b7235dea42ed12a4eb280e3bf0e c8d18521b9a0b7d39841eb72e3895914aa652b7235dea42ed12a4eb280e3bf0e @@ -104,7 +104,7 @@ RestPat/gen_rest_pat.rs e762bf7537225f97da751c5dca6a2cd3836ad7579b68c748b8c6cba6 RetType/gen_ret_type.rs 0947aed0974461b7a5b56bbc5fe36131663bde715c37302345d4eee23b71c825 0947aed0974461b7a5b56bbc5fe36131663bde715c37302345d4eee23b71c825 ReturnExpr/gen_return_expr.rs 4f6ef29d7b3c60d6d71d1a6034a0721671f517428ba21897361a92b01009d38f 4f6ef29d7b3c60d6d71d1a6034a0721671f517428ba21897361a92b01009d38f ReturnTypeSyntax/gen_return_type_syntax.rs 0b11a4cc400f9a2001996f99d61391bdb636e8aea036f587cf18ad6a957fe496 0b11a4cc400f9a2001996f99d61391bdb636e8aea036f587cf18ad6a957fe496 -SelfParam/gen_self_param.rs b7bf9f23fedad6f1a15f02e5fac33fc2c68ec3409b44f24142c2fdec1e5e6f1f b7bf9f23fedad6f1a15f02e5fac33fc2c68ec3409b44f24142c2fdec1e5e6f1f +SelfParam/gen_self_param.rs 9be528c454e2734292d54550f8850ae8e48e1558da46dcf7f06fc7a7a8c3e569 9be528c454e2734292d54550f8850ae8e48e1558da46dcf7f06fc7a7a8c3e569 SlicePat/gen_slice_pat.rs df4a6692f5100aa11dd777561400ce71e37b85f2363b0638c21975a1771b15d5 df4a6692f5100aa11dd777561400ce71e37b85f2363b0638c21975a1771b15d5 SliceType/gen_slice_type.rs 073282f4755994473933db7e4f1e4d34a80363d7e331299ec4ac1a2d6a235b86 073282f4755994473933db7e4f1e4d34a80363d7e331299ec4ac1a2d6a235b86 SourceFile/gen_source_file.rs a7a1d4fa77b53adb6fbc031bf7ab49cf7c8787728ba0a687c348b5eefbb5b9df a7a1d4fa77b53adb6fbc031bf7ab49cf7c8787728ba0a687c348b5eefbb5b9df diff --git a/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr.expected b/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr.expected index b98c3de696b6..8c5b0a32a8fa 100644 --- a/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr.expected +++ b/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr.expected @@ -1,2 +1,2 @@ -| gen_match_expr.rs:5:5:8:5 | match x { ... } | getNumberOfAttrs: | 0 | hasExpr: | yes | hasMatchArmList: | yes | -| gen_match_expr.rs:9:5:12:5 | match x { ... } | getNumberOfAttrs: | 0 | hasExpr: | yes | hasMatchArmList: | yes | +| gen_match_expr.rs:5:5:8:5 | match x { ... } | getNumberOfAttrs: | 0 | hasScrutinee: | yes | hasMatchArmList: | yes | +| gen_match_expr.rs:9:5:12:5 | match x { ... } | getNumberOfAttrs: | 0 | hasScrutinee: | yes | hasMatchArmList: | yes | diff --git a/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr.ql b/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr.ql index b29e333d3304..0847933e937c 100644 --- a/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr.ql +++ b/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr.ql @@ -2,12 +2,12 @@ import codeql.rust.elements import TestUtils -from MatchExpr x, int getNumberOfAttrs, string hasExpr, string hasMatchArmList +from MatchExpr x, int getNumberOfAttrs, string hasScrutinee, string hasMatchArmList where toBeTested(x) and not x.isUnknown() and getNumberOfAttrs = x.getNumberOfAttrs() and - (if x.hasExpr() then hasExpr = "yes" else hasExpr = "no") and + (if x.hasScrutinee() then hasScrutinee = "yes" else hasScrutinee = "no") and if x.hasMatchArmList() then hasMatchArmList = "yes" else hasMatchArmList = "no" -select x, "getNumberOfAttrs:", getNumberOfAttrs, "hasExpr:", hasExpr, "hasMatchArmList:", +select x, "getNumberOfAttrs:", getNumberOfAttrs, "hasScrutinee:", hasScrutinee, "hasMatchArmList:", hasMatchArmList diff --git a/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getScrutinee.expected b/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getScrutinee.expected new file mode 100644 index 000000000000..427af7c6ed0c --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getScrutinee.expected @@ -0,0 +1,2 @@ +| gen_match_expr.rs:5:5:8:5 | match x { ... } | gen_match_expr.rs:5:11:5:11 | x | +| gen_match_expr.rs:9:5:12:5 | match x { ... } | gen_match_expr.rs:9:11:9:11 | x | diff --git a/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getExpr.ql b/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getScrutinee.ql similarity index 84% rename from rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getExpr.ql rename to rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getScrutinee.ql index 40dd65afcbcd..4d29f21fbfba 100644 --- a/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getExpr.ql +++ b/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getScrutinee.ql @@ -4,4 +4,4 @@ import TestUtils from MatchExpr x where toBeTested(x) and not x.isUnknown() -select x, x.getExpr() +select x, x.getScrutinee() diff --git a/rust/ql/test/extractor-tests/generated/Param/Param.expected b/rust/ql/test/extractor-tests/generated/Param/Param.expected index e69de29bb2d1..e0f54f135831 100644 --- a/rust/ql/test/extractor-tests/generated/Param/Param.expected +++ b/rust/ql/test/extractor-tests/generated/Param/Param.expected @@ -0,0 +1 @@ +| gen_param.rs:5:12:5:15 | ...: T | getNumberOfAttrs: | 0 | hasTy: | yes | hasPat: | yes | diff --git a/rust/ql/test/extractor-tests/generated/Param/Param.ql b/rust/ql/test/extractor-tests/generated/Param/Param.ql index 6e022c29db92..1e744bae58b6 100644 --- a/rust/ql/test/extractor-tests/generated/Param/Param.ql +++ b/rust/ql/test/extractor-tests/generated/Param/Param.ql @@ -2,11 +2,11 @@ import codeql.rust.elements import TestUtils -from Param x, int getNumberOfAttrs, string hasPat, string hasTy +from Param x, int getNumberOfAttrs, string hasTy, string hasPat where toBeTested(x) and not x.isUnknown() and getNumberOfAttrs = x.getNumberOfAttrs() and - (if x.hasPat() then hasPat = "yes" else hasPat = "no") and - if x.hasTy() then hasTy = "yes" else hasTy = "no" -select x, "getNumberOfAttrs:", getNumberOfAttrs, "hasPat:", hasPat, "hasTy:", hasTy + (if x.hasTy() then hasTy = "yes" else hasTy = "no") and + if x.hasPat() then hasPat = "yes" else hasPat = "no" +select x, "getNumberOfAttrs:", getNumberOfAttrs, "hasTy:", hasTy, "hasPat:", hasPat diff --git a/rust/ql/test/extractor-tests/generated/Param/Param_getPat.expected b/rust/ql/test/extractor-tests/generated/Param/Param_getPat.expected index e69de29bb2d1..c42d7ce0b9f2 100644 --- a/rust/ql/test/extractor-tests/generated/Param/Param_getPat.expected +++ b/rust/ql/test/extractor-tests/generated/Param/Param_getPat.expected @@ -0,0 +1 @@ +| gen_param.rs:5:12:5:15 | ...: T | gen_param.rs:5:12:5:12 | x | diff --git a/rust/ql/test/extractor-tests/generated/Param/Param_getTy.expected b/rust/ql/test/extractor-tests/generated/Param/Param_getTy.expected index e69de29bb2d1..10bf906af5da 100644 --- a/rust/ql/test/extractor-tests/generated/Param/Param_getTy.expected +++ b/rust/ql/test/extractor-tests/generated/Param/Param_getTy.expected @@ -0,0 +1 @@ +| gen_param.rs:5:12:5:15 | ...: T | gen_param.rs:5:15:5:15 | T | diff --git a/rust/ql/test/extractor-tests/generated/Param/gen_param.rs b/rust/ql/test/extractor-tests/generated/Param/gen_param.rs index 5bc96d632198..679943f8aa7f 100644 --- a/rust/ql/test/extractor-tests/generated/Param/gen_param.rs +++ b/rust/ql/test/extractor-tests/generated/Param/gen_param.rs @@ -1,6 +1,8 @@ // generated by codegen, do not edit fn test_param() -> () { - // A Param. For example: - todo!() + // A parameter in a function or method. For example `x` in: + fn new(x: T) -> Foo { + // ... + } } diff --git a/rust/ql/test/extractor-tests/generated/SelfParam/SelfParam.expected b/rust/ql/test/extractor-tests/generated/SelfParam/SelfParam.expected index e69de29bb2d1..41c5e89e83d0 100644 --- a/rust/ql/test/extractor-tests/generated/SelfParam/SelfParam.expected +++ b/rust/ql/test/extractor-tests/generated/SelfParam/SelfParam.expected @@ -0,0 +1 @@ +| gen_self_param.rs:5:13:5:21 | SelfParam | getNumberOfAttrs: | 0 | hasTy: | no | isMut: | yes | hasLifetime: | no | hasName: | yes | diff --git a/rust/ql/test/extractor-tests/generated/SelfParam/SelfParam.ql b/rust/ql/test/extractor-tests/generated/SelfParam/SelfParam.ql index af2fa064a724..579ec7ffa2ad 100644 --- a/rust/ql/test/extractor-tests/generated/SelfParam/SelfParam.ql +++ b/rust/ql/test/extractor-tests/generated/SelfParam/SelfParam.ql @@ -3,14 +3,14 @@ import codeql.rust.elements import TestUtils from - SelfParam x, int getNumberOfAttrs, string isMut, string hasLifetime, string hasName, string hasTy + SelfParam x, int getNumberOfAttrs, string hasTy, string isMut, string hasLifetime, string hasName where toBeTested(x) and not x.isUnknown() and getNumberOfAttrs = x.getNumberOfAttrs() and + (if x.hasTy() then hasTy = "yes" else hasTy = "no") and (if x.isMut() then isMut = "yes" else isMut = "no") and (if x.hasLifetime() then hasLifetime = "yes" else hasLifetime = "no") and - (if x.hasName() then hasName = "yes" else hasName = "no") and - if x.hasTy() then hasTy = "yes" else hasTy = "no" -select x, "getNumberOfAttrs:", getNumberOfAttrs, "isMut:", isMut, "hasLifetime:", hasLifetime, - "hasName:", hasName, "hasTy:", hasTy + if x.hasName() then hasName = "yes" else hasName = "no" +select x, "getNumberOfAttrs:", getNumberOfAttrs, "hasTy:", hasTy, "isMut:", isMut, "hasLifetime:", + hasLifetime, "hasName:", hasName diff --git a/rust/ql/test/extractor-tests/generated/SelfParam/SelfParam_getName.expected b/rust/ql/test/extractor-tests/generated/SelfParam/SelfParam_getName.expected index e69de29bb2d1..70a9a4a06596 100644 --- a/rust/ql/test/extractor-tests/generated/SelfParam/SelfParam_getName.expected +++ b/rust/ql/test/extractor-tests/generated/SelfParam/SelfParam_getName.expected @@ -0,0 +1 @@ +| gen_self_param.rs:5:13:5:21 | SelfParam | gen_self_param.rs:5:18:5:21 | self | diff --git a/rust/ql/test/extractor-tests/generated/SelfParam/gen_self_param.rs b/rust/ql/test/extractor-tests/generated/SelfParam/gen_self_param.rs index 36f8ffd8baf5..6278147a8783 100644 --- a/rust/ql/test/extractor-tests/generated/SelfParam/gen_self_param.rs +++ b/rust/ql/test/extractor-tests/generated/SelfParam/gen_self_param.rs @@ -1,6 +1,8 @@ // generated by codegen, do not edit fn test_self_param() -> () { - // A SelfParam. For example: - todo!() + // A `self` parameter. For example `self` in: + fn push(&mut self, value: T) { + // ... + } } diff --git a/rust/ql/test/query-tests/diagnostics/CONSISTENCY/ExtractionConsistency.expected b/rust/ql/test/query-tests/diagnostics/CONSISTENCY/ExtractionConsistency.expected index 5b4796faa8c5..f1c469a407da 100644 --- a/rust/ql/test/query-tests/diagnostics/CONSISTENCY/ExtractionConsistency.expected +++ b/rust/ql/test/query-tests/diagnostics/CONSISTENCY/ExtractionConsistency.expected @@ -5,3 +5,4 @@ extractionWarning | does_not_compile.rs:2:21:2:20 | expected SEMICOLON | | does_not_compile.rs:2:26:2:25 | expected SEMICOLON | | error.rs:2:5:2:17 | An error! | +| my_macro.rs:17:9:17:27 | macro expansion failed: could not resolve macro 'myUndefinedMacro' | diff --git a/rust/ql/test/query-tests/diagnostics/ExtractionWarnings.expected b/rust/ql/test/query-tests/diagnostics/ExtractionWarnings.expected index 5ea7e808176e..7f14093f20e5 100644 --- a/rust/ql/test/query-tests/diagnostics/ExtractionWarnings.expected +++ b/rust/ql/test/query-tests/diagnostics/ExtractionWarnings.expected @@ -4,3 +4,4 @@ | does_not_compile.rs:2:21:2:20 | expected SEMICOLON | Extraction warning in does_not_compile.rs with message expected SEMICOLON | 1 | | does_not_compile.rs:2:26:2:25 | expected SEMICOLON | Extraction warning in does_not_compile.rs with message expected SEMICOLON | 1 | | error.rs:2:5:2:17 | An error! | Extraction warning in error.rs with message An error! | 1 | +| my_macro.rs:17:9:17:27 | macro expansion failed: could not resolve macro 'myUndefinedMacro' | Extraction warning in my_macro.rs with message macro expansion failed: could not resolve macro 'myUndefinedMacro' | 1 | diff --git a/rust/ql/test/query-tests/diagnostics/LinesOfCode.expected b/rust/ql/test/query-tests/diagnostics/LinesOfCode.expected index 6facd293859d..5fa7b20e01bb 100644 --- a/rust/ql/test/query-tests/diagnostics/LinesOfCode.expected +++ b/rust/ql/test/query-tests/diagnostics/LinesOfCode.expected @@ -1 +1 @@ -| 59 | +| 60 | diff --git a/rust/ql/test/query-tests/diagnostics/LinesOfUserCode.expected b/rust/ql/test/query-tests/diagnostics/LinesOfUserCode.expected index 6facd293859d..5fa7b20e01bb 100644 --- a/rust/ql/test/query-tests/diagnostics/LinesOfUserCode.expected +++ b/rust/ql/test/query-tests/diagnostics/LinesOfUserCode.expected @@ -1 +1 @@ -| 59 | +| 60 | diff --git a/rust/ql/test/query-tests/diagnostics/LinesOfUserCodeInFiles.expected b/rust/ql/test/query-tests/diagnostics/LinesOfUserCodeInFiles.expected index b34654710961..0a58a05feed2 100644 --- a/rust/ql/test/query-tests/diagnostics/LinesOfUserCodeInFiles.expected +++ b/rust/ql/test/query-tests/diagnostics/LinesOfUserCodeInFiles.expected @@ -1,7 +1,7 @@ | my_struct.rs:0:0:0:0 | my_struct.rs | 20 | | comments.rs:0:0:0:0 | comments.rs | 13 | | main.rs:0:0:0:0 | main.rs | 8 | -| my_macro.rs:0:0:0:0 | my_macro.rs | 7 | +| my_macro.rs:0:0:0:0 | my_macro.rs | 8 | | lib.rs:0:0:0:0 | lib.rs | 5 | | does_not_compile.rs:0:0:0:0 | does_not_compile.rs | 3 | | error.rs:0:0:0:0 | error.rs | 3 | diff --git a/rust/ql/test/query-tests/diagnostics/SummaryStats.expected b/rust/ql/test/query-tests/diagnostics/SummaryStats.expected index b7bbd277be44..74e1e461c6fe 100644 --- a/rust/ql/test/query-tests/diagnostics/SummaryStats.expected +++ b/rust/ql/test/query-tests/diagnostics/SummaryStats.expected @@ -1,14 +1,17 @@ -| Elements extracted | 375 | +| Elements extracted | 382 | | Elements unextracted | 0 | | Extraction errors | 0 | -| Extraction warnings | 6 | +| Extraction warnings | 7 | | Files extracted - total | 8 | -| Files extracted - with errors | 2 | -| Files extracted - without errors | 6 | +| Files extracted - with errors | 3 | +| Files extracted - without errors | 5 | | Inconsistencies - AST | 0 | | Inconsistencies - CFG | 0 | | Inconsistencies - data flow | 0 | -| Lines of code extracted | 59 | -| Lines of user code extracted | 59 | +| Lines of code extracted | 60 | +| Lines of user code extracted | 60 | +| Macro calls - resolved | 8 | +| Macro calls - total | 9 | +| Macro calls - unresolved | 1 | | Taint sources - active | 0 | | Taint sources - total | 0 | diff --git a/rust/ql/test/query-tests/diagnostics/UnresolvedMacroCalls.expected b/rust/ql/test/query-tests/diagnostics/UnresolvedMacroCalls.expected new file mode 100644 index 000000000000..72f78794ab29 --- /dev/null +++ b/rust/ql/test/query-tests/diagnostics/UnresolvedMacroCalls.expected @@ -0,0 +1 @@ +| my_macro.rs:17:9:17:27 | myUndefinedMacro!... | Macro call was not resolved to a target. | diff --git a/rust/ql/test/query-tests/diagnostics/UnresolvedMacroCalls.qlref b/rust/ql/test/query-tests/diagnostics/UnresolvedMacroCalls.qlref new file mode 100644 index 000000000000..77f337e27032 --- /dev/null +++ b/rust/ql/test/query-tests/diagnostics/UnresolvedMacroCalls.qlref @@ -0,0 +1 @@ +queries/diagnostics/UnresolvedMacroCalls.ql diff --git a/rust/ql/test/query-tests/diagnostics/my_macro.rs b/rust/ql/test/query-tests/diagnostics/my_macro.rs index d8a0cc2812bd..3b24857aa6c8 100644 --- a/rust/ql/test/query-tests/diagnostics/my_macro.rs +++ b/rust/ql/test/query-tests/diagnostics/my_macro.rs @@ -1,6 +1,6 @@ /** - * total lines in this file: 18 - * of which code: 10 + * total lines in this file: 19 + * of which code: 11 * of which only comments: 6 * of which blank: 2 */ @@ -14,5 +14,6 @@ macro_rules! myMacro { pub fn my_func() { if true { myMacro!(); + myUndefinedMacro!(); } } diff --git a/rust/schema/annotations.py b/rust/schema/annotations.py index 91a6d6add281..9e857ad7b0f2 100644 --- a/rust/schema/annotations.py +++ b/rust/schema/annotations.py @@ -289,6 +289,7 @@ class _: } ``` """ + expr: _ | ql.name("scrutinee") | doc("scrutinee (the expression being matched) of this match expression") @annotate(ContinueExpr, cfg = True) @@ -1324,14 +1325,29 @@ class _: """ -@annotate(Param, cfg = True) +class ParamBase(AstNode): + """ + A normal parameter, `Param`, or a self parameter `SelfParam`. + """ + attrs: list["Attr"] | child + ty: optional["TypeRef"] | child + +@annotate(ParamBase, cfg = True) +class _: + pass + +@annotate(Param, replace_bases={AstNode: ParamBase}, cfg = True) class _: """ - A Param. For example: + A parameter in a function or method. For example `x` in: ```rust - todo!() + fn new(x: T) -> Foo { + // ... + } ``` """ + attrs: drop + ty: drop @annotate(ParamList) @@ -1494,14 +1510,18 @@ class _: """ -@annotate(SelfParam, cfg = True) +@annotate(SelfParam, replace_bases={AstNode: ParamBase}, cfg = True) class _: """ - A SelfParam. For example: + A `self` parameter. For example `self` in: ```rust - todo!() + fn push(&mut self, value: T) { + // ... + } ``` """ + attrs: drop + ty: drop @annotate(SliceType) diff --git a/shared/util/codeql/util/Option.qll b/shared/util/codeql/util/Option.qll index 31df747afe87..8ba4d8e840bc 100644 --- a/shared/util/codeql/util/Option.qll +++ b/shared/util/codeql/util/Option.qll @@ -2,6 +2,7 @@ /** A type with `toString`. */ private signature class TypeWithToString { + bindingset[this] string toString(); }