Skip to content

Commit b0c7964

Browse files
committed
Swift: Add the same code to the CFG test as well.
1 parent b3185e9 commit b0c7964

File tree

2 files changed

+237
-0
lines changed

2 files changed

+237
-0
lines changed

swift/ql/test/library-tests/controlflow/graph/Cfg.expected

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6180,3 +6180,218 @@ cfg.swift:
61806180

61816181
# 534| i
61826182
#-----| -> (Any) ...
6183+
6184+
# 544| MyProcotolImpl.deinit()
6185+
#-----| -> self
6186+
6187+
# 544| MyProcotolImpl.init()
6188+
#-----| -> self
6189+
6190+
# 544| enter MyProcotolImpl.deinit()
6191+
#-----| -> MyProcotolImpl.deinit()
6192+
6193+
# 544| enter MyProcotolImpl.init()
6194+
#-----| -> MyProcotolImpl.init()
6195+
6196+
# 544| exit MyProcotolImpl.deinit()
6197+
6198+
# 544| exit MyProcotolImpl.deinit() (normal)
6199+
#-----| -> exit MyProcotolImpl.deinit()
6200+
6201+
# 544| exit MyProcotolImpl.init()
6202+
6203+
# 544| exit MyProcotolImpl.init() (normal)
6204+
#-----| -> exit MyProcotolImpl.init()
6205+
6206+
# 544| return
6207+
#-----| return -> exit MyProcotolImpl.init() (normal)
6208+
6209+
# 544| self
6210+
#-----| -> { ... }
6211+
6212+
# 544| self
6213+
#-----| -> return
6214+
6215+
# 544| { ... }
6216+
#-----| -> exit MyProcotolImpl.deinit() (normal)
6217+
6218+
# 545| enter source()
6219+
#-----| -> source()
6220+
6221+
# 545| exit source()
6222+
6223+
# 545| exit source() (normal)
6224+
#-----| -> exit source()
6225+
6226+
# 545| source()
6227+
#-----| -> self
6228+
6229+
# 545| self
6230+
#-----| -> 0
6231+
6232+
# 545| return ...
6233+
#-----| return -> exit source() (normal)
6234+
6235+
# 545| 0
6236+
#-----| -> return ...
6237+
6238+
# 548| enter getMyProtocol()
6239+
#-----| -> getMyProtocol()
6240+
6241+
# 548| exit getMyProtocol()
6242+
6243+
# 548| exit getMyProtocol() (normal)
6244+
#-----| -> exit getMyProtocol()
6245+
6246+
# 548| getMyProtocol()
6247+
#-----| -> MyProcotolImpl.init()
6248+
6249+
# 548| return ...
6250+
#-----| return -> exit getMyProtocol() (normal)
6251+
6252+
# 548| MyProcotolImpl.Type
6253+
#-----| -> call to MyProcotolImpl.init()
6254+
6255+
# 548| MyProcotolImpl.init()
6256+
#-----| -> MyProcotolImpl.Type
6257+
6258+
# 548| (MyProtocol) ...
6259+
#-----| -> return ...
6260+
6261+
# 548| call to MyProcotolImpl.init()
6262+
#-----| -> (MyProtocol) ...
6263+
6264+
# 549| enter getMyProtocolImpl()
6265+
#-----| -> getMyProtocolImpl()
6266+
6267+
# 549| exit getMyProtocolImpl()
6268+
6269+
# 549| exit getMyProtocolImpl() (normal)
6270+
#-----| -> exit getMyProtocolImpl()
6271+
6272+
# 549| getMyProtocolImpl()
6273+
#-----| -> MyProcotolImpl.init()
6274+
6275+
# 549| return ...
6276+
#-----| return -> exit getMyProtocolImpl() (normal)
6277+
6278+
# 549| MyProcotolImpl.Type
6279+
#-----| -> call to MyProcotolImpl.init()
6280+
6281+
# 549| MyProcotolImpl.init()
6282+
#-----| -> MyProcotolImpl.Type
6283+
6284+
# 549| call to MyProcotolImpl.init()
6285+
#-----| -> return ...
6286+
6287+
# 551| enter sink(arg:)
6288+
#-----| -> sink(arg:)
6289+
6290+
# 551| exit sink(arg:)
6291+
6292+
# 551| exit sink(arg:) (normal)
6293+
#-----| -> exit sink(arg:)
6294+
6295+
# 551| sink(arg:)
6296+
#-----| -> arg
6297+
6298+
# 551| arg
6299+
#-----| -> { ... }
6300+
6301+
# 551| { ... }
6302+
#-----| -> exit sink(arg:) (normal)
6303+
6304+
# 553| enter testOpenExistentialExpr(x:y:)
6305+
#-----| -> testOpenExistentialExpr(x:y:)
6306+
6307+
# 553| exit testOpenExistentialExpr(x:y:)
6308+
6309+
# 553| exit testOpenExistentialExpr(x:y:) (normal)
6310+
#-----| -> exit testOpenExistentialExpr(x:y:)
6311+
6312+
# 553| testOpenExistentialExpr(x:y:)
6313+
#-----| -> x
6314+
6315+
# 553| x
6316+
#-----| -> y
6317+
6318+
# 553| y
6319+
#-----| -> sink(arg:)
6320+
6321+
# 554| sink(arg:)
6322+
#-----| -> x
6323+
6324+
# 554| call to sink(arg:)
6325+
#-----| -> sink(arg:)
6326+
6327+
# 554| OpaqueValueExpr
6328+
#-----| -> call to source()
6329+
6330+
# 554| x
6331+
#-----| -> .source()
6332+
6333+
# 554| .source()
6334+
#-----| -> OpaqueValueExpr
6335+
6336+
# 554| OpenExistentialExpr
6337+
#-----| -> call to sink(arg:)
6338+
6339+
# 554| call to source()
6340+
#-----| -> OpenExistentialExpr
6341+
6342+
# 555| sink(arg:)
6343+
#-----| -> .source()
6344+
6345+
# 555| call to sink(arg:)
6346+
#-----| -> sink(arg:)
6347+
6348+
# 555| y
6349+
#-----| -> call to source()
6350+
6351+
# 555| .source()
6352+
#-----| -> y
6353+
6354+
# 555| call to source()
6355+
#-----| -> call to sink(arg:)
6356+
6357+
# 556| sink(arg:)
6358+
#-----| -> getMyProtocol()
6359+
6360+
# 556| call to sink(arg:)
6361+
#-----| -> sink(arg:)
6362+
6363+
# 556| getMyProtocol()
6364+
#-----| -> call to getMyProtocol()
6365+
6366+
# 556| OpaqueValueExpr
6367+
#-----| -> call to source()
6368+
6369+
# 556| call to getMyProtocol()
6370+
#-----| -> .source()
6371+
6372+
# 556| .source()
6373+
#-----| -> OpaqueValueExpr
6374+
6375+
# 556| OpenExistentialExpr
6376+
#-----| -> call to sink(arg:)
6377+
6378+
# 556| call to source()
6379+
#-----| -> OpenExistentialExpr
6380+
6381+
# 557| sink(arg:)
6382+
#-----| -> .source()
6383+
6384+
# 557| call to sink(arg:)
6385+
#-----| -> exit testOpenExistentialExpr(x:y:) (normal)
6386+
6387+
# 557| getMyProtocolImpl()
6388+
#-----| -> call to getMyProtocolImpl()
6389+
6390+
# 557| call to getMyProtocolImpl()
6391+
#-----| -> call to source()
6392+
6393+
# 557| .source()
6394+
#-----| -> getMyProtocolImpl()
6395+
6396+
# 557| call to source()
6397+
#-----| -> call to sink(arg:)

swift/ql/test/library-tests/controlflow/graph/cfg.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,3 +534,25 @@ func testAsyncFor () async {
534534
print(i)
535535
}
536536
}
537+
538+
// ---
539+
540+
protocol MyProtocol {
541+
func source() -> Int
542+
}
543+
544+
class MyProcotolImpl : MyProtocol {
545+
func source() -> Int { return 0 }
546+
}
547+
548+
func getMyProtocol() -> MyProtocol { return MyProcotolImpl() }
549+
func getMyProtocolImpl() -> MyProcotolImpl { return MyProcotolImpl() }
550+
551+
func sink(arg: Int) { }
552+
553+
func testOpenExistentialExpr(x: MyProtocol, y: MyProcotolImpl) {
554+
sink(arg: x.source())
555+
sink(arg: y.source())
556+
sink(arg: getMyProtocol().source())
557+
sink(arg: getMyProtocolImpl().source())
558+
}

0 commit comments

Comments
 (0)