mirror of
https://github.com/github/codeql.git
synced 2025-12-22 03:36:30 +01:00
By explicitly marking children in the `schema.yml` file, an internal `getAChild` predicate is implemented, that is in turn used in `AstNode` to implement `getParent`. This is yet to be used in the control flow library to replace the hand-rolled implementation. A further, more complex step is to use the same information to fully generate the core implementation of `PrintAst` (including the accessor string). This will be done later. The `parent` tests use the same swift code as the extractor tests, and this is currently enforced by `sync-files.py`. Notice that `qltest.sh` had to be modified to deal with multiple files, which was not working yet.
85 lines
1.0 KiB
Swift
85 lines
1.0 KiB
Swift
func loop() {
|
|
label1: for i in 1...5 {
|
|
if i == 3 {
|
|
break
|
|
} else {
|
|
continue
|
|
}
|
|
}
|
|
var i = 0
|
|
label2: while (i < 12) {
|
|
i = i + 1
|
|
}
|
|
|
|
i = 0
|
|
label3: repeat {
|
|
i = i + 1
|
|
} while (i < 12)
|
|
|
|
do {
|
|
try failure(11)
|
|
} catch {
|
|
print("error")
|
|
}
|
|
|
|
do {
|
|
try failure(11)
|
|
} catch AnError.failed {
|
|
print("AnError.failed")
|
|
} catch {
|
|
print("error")
|
|
}
|
|
}
|
|
|
|
enum AnError: Error {
|
|
case failed
|
|
}
|
|
|
|
func failure(_ x: Int) throws {
|
|
guard x != 0 else {
|
|
throw AnError.failed
|
|
}
|
|
}
|
|
|
|
defer {
|
|
print("done")
|
|
}
|
|
|
|
do {
|
|
print("doing")
|
|
}
|
|
|
|
let index = 42
|
|
switch index {
|
|
case 1:
|
|
print("1")
|
|
fallthrough
|
|
case 5, 10:
|
|
print("5, 10")
|
|
break
|
|
default:
|
|
print("default")
|
|
}
|
|
|
|
let x: Int? = 4
|
|
if case let xx? = x {
|
|
}
|
|
if case .some(_) = x {
|
|
}
|
|
|
|
let numbers = [1, 2, 3]
|
|
for number in numbers where number % 2 == 0 {
|
|
}
|
|
|
|
struct HasModifyAccessorDecl {
|
|
var x : Int
|
|
var hasModify : Int {
|
|
_modify {
|
|
yield &x
|
|
}
|
|
|
|
get {
|
|
return 0
|
|
}
|
|
}
|
|
} |