Swift: codegen

This commit is contained in:
Nora Dimitrijević
2023-05-23 15:43:15 +02:00
parent 387cde5972
commit 026492836c
5 changed files with 44 additions and 7 deletions

View File

@@ -380,10 +380,10 @@ lib/codeql/swift/generated/KeyPathComponent.qll c79c7bc04fc1426992ab472eedc1a20a
lib/codeql/swift/generated/Locatable.qll be20967d48a34cdba126fe298606e0adc11697831f097acba9c52a0b7ce9983e 8aa01bc376614abbc3209e25785c72f86c9b4e94bb5f471a4a0677fedaec4f61
lib/codeql/swift/generated/Location.qll c5793987e77812059a28254dadee29bfe9b38153c0399fbb1bf6a2f5c237fdab 6e6d8802b021e36bbaad81845657769dd48a798ea33080ada05e9818a20b38f7
lib/codeql/swift/generated/OtherAvailabilitySpec.qll 0e26a203b26ff0581b7396b0c6d1606feec5cc32477f676585cdec4911af91c5 0e26a203b26ff0581b7396b0c6d1606feec5cc32477f676585cdec4911af91c5
lib/codeql/swift/generated/ParentChild.qll 5c5ff9812efbed0adf465d1c8b9108c893c77ff946f6feaaec7223ad38664079 94038dcd8a5e98b959ce9f09b7b54b745b0df49b91339b9396017a209abe8bb7
lib/codeql/swift/generated/ParentChild.qll f8647fba02b9acca7bf2870dfaee5709e2d3e3a12d27b012dd1e17f7df2e56e5 75d3501c2a59d931dd537321475687a73ff517e5caaae4ce2e0c2daec0d94df4
lib/codeql/swift/generated/PlatformVersionAvailabilitySpec.qll f82d9ca416fe8bd59b5531b65b1c74c9f317b3297a6101544a11339a1cffce38 7f5c6d3309e66c134107afe55bae76dfc9a72cb7cdd6d4c3706b6b34cee09fa0
lib/codeql/swift/generated/PureSynthConstructors.qll 173c0dd59396a1de26fe870e3bc2766c46de689da2a4d8807cb62023bbce1a98 173c0dd59396a1de26fe870e3bc2766c46de689da2a4d8807cb62023bbce1a98
lib/codeql/swift/generated/Raw.qll 991f95f30bde82ba43237bd9c1a68d3f450038ef828edb89219fbf583dd1956a e3e6c41caac09d532453c28167622fae7057d846f35750873eacd48cd128b957
lib/codeql/swift/generated/Raw.qll e665a9c74c1d2926fdfafb2fda8bf428fc72b0b1afbf472f304b1a925bee9f09 c361be3af00814c13f35666881aed32327662495d1fe4bd5a4b5c1f481986a5b
lib/codeql/swift/generated/Synth.qll 551fdf7e4b53f9ee1314d1bb42c2638cf82f45bfa1f40a635dfa7b6072e4418c 9ab178464700a19951fc5285acacda4913addee81515d8e072b3d7055935a814
lib/codeql/swift/generated/SynthConstructors.qll 2f801bd8b0db829b0253cd459ed3253c1fdfc55dce68ebc53e7fec138ef0aca4 2f801bd8b0db829b0253cd459ed3253c1fdfc55dce68ebc53e7fec138ef0aca4
lib/codeql/swift/generated/UnknownFile.qll 0fcf9beb8de79440bcdfff4bb6ab3dd139bd273e6c32754e05e6a632651e85f6 0fcf9beb8de79440bcdfff4bb6ab3dd139bd273e6c32754e05e6a632651e85f6
@@ -566,7 +566,7 @@ lib/codeql/swift/generated/pattern/ParenPattern.qll 337cb03dcb7384f7ef13e35d843b
lib/codeql/swift/generated/pattern/Pattern.qll 0e96528a8dd87185f4fb23ba33ea418932762127e99739d7e56e5c8988e024d1 ba1e010c9f7f891048fb8c4ff8ea5a6c664c09e43d74b860d559f6459f82554a
lib/codeql/swift/generated/pattern/TuplePattern.qll b3a138b0942f7e3eecb52ad2f095584a6cd5f555e9487c6eaad6a5527ae99f0c d6ff67ecc7395571acef4b82da514cb737c72d97ea557d89da534469feda340c
lib/codeql/swift/generated/pattern/TypedPattern.qll 6a9fd2815755eddc6918d6be8221c7afb90e4fba4fcb8eb54ff42754269bb481 f198c3b09553a5f5f3d97f8088ef82c00552b9635560750c56d801b09dbd9e26
lib/codeql/swift/generated/stmt/BraceStmt.qll eea1a33767c14a3b96aea6bbe10f17c3ecd1d8ac263de07e475e23b46d85a20d a5ee6c19a38e968c245886c28c82513f39ca90a80a9ea11d0e3139a35f682046
lib/codeql/swift/generated/stmt/BraceStmt.qll 9d2b2a2127fb245f10e554c6a9fa31280a30081ebc93d9802a55c334534341d6 e5bfffc41258886dd516ab51cfb7a2c27ef725edff6b29c2f552e9661dab0a35
lib/codeql/swift/generated/stmt/BreakStmt.qll 879cf66911cc7f53e7e8f4ae8244681018fb17d6501b269fb7cf9d8481f0b539 c78fc1b0e3e76321fc1653aa8b0aabaaacf082e01a003b78f693b106cc05faa0
lib/codeql/swift/generated/stmt/CaseLabelItem.qll 9536d2909a274c3a969eec25f8e5966adfaa9b0d6451ea6319d9f7bb2fd6fe07 02e25f036db50e9a6e9a7ceab6002dd605b73afb55fa1dee6f22e7af33a40913
lib/codeql/swift/generated/stmt/CaseStmt.qll c180478c6161439bc76bd39edfab343faba7450900ffedcadd3ccea12dc3a08c b537eb517db76113cfbc91c59e6bdfbf16ff83d639dfe6fd6892171f71a97090

View File

@@ -3434,18 +3434,22 @@ private module Impl {
}
private Element getImmediateChildOfBraceStmt(BraceStmt e, int index, string partialPredicateCall) {
exists(int b, int bStmt, int n, int nElement |
exists(int b, int bStmt, int n, int nVariable, int nElement |
b = 0 and
bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and
n = bStmt and
nElement = n + 1 + max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) and
nVariable = n + 1 + max(int i | i = -1 or exists(e.getVariable(i)) | i) and
nElement = nVariable + 1 + max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) and
(
none()
or
result = getImmediateChildOfStmt(e, index - b, partialPredicateCall)
or
result = e.getImmediateElement(index - n) and
partialPredicateCall = "Element(" + (index - n).toString() + ")"
result = e.getVariable(index - n) and
partialPredicateCall = "Variable(" + (index - n).toString() + ")"
or
result = e.getImmediateElement(index - nVariable) and
partialPredicateCall = "Element(" + (index - nVariable).toString() + ")"
)
)
}

View File

@@ -2569,6 +2569,11 @@ module Raw {
class BraceStmt extends @brace_stmt, Stmt {
override string toString() { result = "BraceStmt" }
/**
* Gets the `index`th variable declared in the scope of this brace statement (0-based).
*/
VarDecl getVariable(int index) { brace_stmt_variables(this, index, result) }
/**
* Gets the `index`th element of this brace statement (0-based).
*/

View File

@@ -3,11 +3,32 @@ private import codeql.swift.generated.Synth
private import codeql.swift.generated.Raw
import codeql.swift.elements.AstNode
import codeql.swift.elements.stmt.Stmt
import codeql.swift.elements.decl.VarDecl
module Generated {
class BraceStmt extends Synth::TBraceStmt, Stmt {
override string getAPrimaryQlClass() { result = "BraceStmt" }
/**
* Gets the `index`th variable declared in the scope of this brace statement (0-based).
*/
VarDecl getVariable(int index) {
result =
Synth::convertVarDeclFromRaw(Synth::convertBraceStmtToRaw(this)
.(Raw::BraceStmt)
.getVariable(index))
}
/**
* Gets any of the variables declared in the scope of this brace statement.
*/
final VarDecl getAVariable() { result = this.getVariable(_) }
/**
* Gets the number of variables declared in the scope of this brace statement.
*/
final int getNumberOfVariables() { result = count(int i | exists(this.getVariable(i))) }
/**
* Gets the `index`th element of this brace statement (0-based).
*

View File

@@ -1768,6 +1768,13 @@ brace_stmts( //dir=stmt
unique int id: @brace_stmt
);
#keyset[id, index]
brace_stmt_variables( //dir=stmt
int id: @brace_stmt ref,
int index: int ref,
int variable: @var_decl_or_none ref
);
#keyset[id, index]
brace_stmt_elements( //dir=stmt
int id: @brace_stmt ref,