mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
Swift: Add the same code to the AST test as well.
This commit is contained in:
@@ -7148,3 +7148,95 @@ statements.swift:
|
||||
# 92| getExpr(): [DefaultArgumentExpr] default separator
|
||||
# 92| getArgument(2): [Argument] terminator: default terminator
|
||||
# 92| getExpr(): [DefaultArgumentExpr] default terminator
|
||||
# 95| [Comment] // ---
|
||||
# 95|
|
||||
# 97| [ProtocolDecl] MyProtocol
|
||||
#-----| getGenericTypeParam(0): [GenericTypeParamDecl] Self
|
||||
# 98| getMember(0): [NamedFunction] source()
|
||||
# 98| InterfaceType = <Self where Self : MyProtocol> (Self) -> () -> Int
|
||||
# 98| getSelfParam(): [ParamDecl] self
|
||||
# 98| Type = Self
|
||||
# 101| [ClassDecl] MyProcotolImpl
|
||||
# 102| getMember(0): [NamedFunction] source()
|
||||
# 102| InterfaceType = (MyProcotolImpl) -> () -> Int
|
||||
# 102| getSelfParam(): [ParamDecl] self
|
||||
# 102| Type = MyProcotolImpl
|
||||
# 102| getBody(): [BraceStmt] { ... }
|
||||
# 102| getElement(0): [ReturnStmt] return ...
|
||||
# 102| getResult(): [IntegerLiteralExpr] 0
|
||||
# 101| getMember(1): [Deinitializer] MyProcotolImpl.deinit()
|
||||
# 101| InterfaceType = (MyProcotolImpl) -> () -> ()
|
||||
# 101| getSelfParam(): [ParamDecl] self
|
||||
# 101| Type = MyProcotolImpl
|
||||
# 101| getBody(): [BraceStmt] { ... }
|
||||
# 101| getMember(2): [Initializer] MyProcotolImpl.init()
|
||||
# 101| InterfaceType = (MyProcotolImpl.Type) -> () -> MyProcotolImpl
|
||||
# 101| getSelfParam(): [ParamDecl] self
|
||||
# 101| Type = MyProcotolImpl
|
||||
# 101| getBody(): [BraceStmt] { ... }
|
||||
# 101| getElement(0): [ReturnStmt] return
|
||||
# 105| [NamedFunction] getMyProtocol()
|
||||
# 105| InterfaceType = () -> MyProtocol
|
||||
# 105| getBody(): [BraceStmt] { ... }
|
||||
# 105| getElement(0): [ReturnStmt] return ...
|
||||
# 105| getResult(): [CallExpr] call to MyProcotolImpl.init()
|
||||
# 105| getFunction(): [MethodLookupExpr] MyProcotolImpl.init()
|
||||
# 105| getBase(): [TypeExpr] MyProcotolImpl.Type
|
||||
# 105| getTypeRepr(): [TypeRepr] MyProcotolImpl
|
||||
# 105| getMethodRef(): [DeclRefExpr] MyProcotolImpl.init()
|
||||
# 105| getResult().getFullyConverted(): [ErasureExpr] (MyProtocol) ...
|
||||
# 106| [NamedFunction] getMyProtocolImpl()
|
||||
# 106| InterfaceType = () -> MyProcotolImpl
|
||||
# 106| getBody(): [BraceStmt] { ... }
|
||||
# 106| getElement(0): [ReturnStmt] return ...
|
||||
# 106| getResult(): [CallExpr] call to MyProcotolImpl.init()
|
||||
# 106| getFunction(): [MethodLookupExpr] MyProcotolImpl.init()
|
||||
# 106| getBase(): [TypeExpr] MyProcotolImpl.Type
|
||||
# 106| getTypeRepr(): [TypeRepr] MyProcotolImpl
|
||||
# 106| getMethodRef(): [DeclRefExpr] MyProcotolImpl.init()
|
||||
# 108| [NamedFunction] sink(arg:)
|
||||
# 108| InterfaceType = (Int) -> ()
|
||||
# 108| getParam(0): [ParamDecl] arg
|
||||
# 108| Type = Int
|
||||
# 108| getBody(): [BraceStmt] { ... }
|
||||
# 110| [NamedFunction] testOpenExistentialExpr(x:y:)
|
||||
# 110| InterfaceType = (MyProtocol, MyProcotolImpl) -> ()
|
||||
# 110| getParam(0): [ParamDecl] x
|
||||
# 110| Type = MyProtocol
|
||||
# 110| getParam(1): [ParamDecl] y
|
||||
# 110| Type = MyProcotolImpl
|
||||
# 110| getBody(): [BraceStmt] { ... }
|
||||
# 111| getElement(0): [CallExpr] call to sink(arg:)
|
||||
# 111| getFunction(): [DeclRefExpr] sink(arg:)
|
||||
# 111| getArgument(0): [Argument] arg: OpenExistentialExpr
|
||||
# 111| getExpr(): [OpenExistentialExpr] OpenExistentialExpr
|
||||
# 111| getSubExpr(): [CallExpr] call to source()
|
||||
# 111| getFunction(): [MethodLookupExpr] .source()
|
||||
# 111| getBase(): [OpaqueValueExpr] OpaqueValueExpr
|
||||
# 111| getMethodRef(): [DeclRefExpr] source()
|
||||
# 111| getExistential(): [DeclRefExpr] x
|
||||
# 112| getElement(1): [CallExpr] call to sink(arg:)
|
||||
# 112| getFunction(): [DeclRefExpr] sink(arg:)
|
||||
# 112| getArgument(0): [Argument] arg: call to source()
|
||||
# 112| getExpr(): [CallExpr] call to source()
|
||||
# 112| getFunction(): [MethodLookupExpr] .source()
|
||||
# 112| getBase(): [DeclRefExpr] y
|
||||
# 112| getMethodRef(): [DeclRefExpr] source()
|
||||
# 113| getElement(2): [CallExpr] call to sink(arg:)
|
||||
# 113| getFunction(): [DeclRefExpr] sink(arg:)
|
||||
# 113| getArgument(0): [Argument] arg: OpenExistentialExpr
|
||||
# 113| getExpr(): [OpenExistentialExpr] OpenExistentialExpr
|
||||
# 113| getSubExpr(): [CallExpr] call to source()
|
||||
# 113| getFunction(): [MethodLookupExpr] .source()
|
||||
# 113| getBase(): [OpaqueValueExpr] OpaqueValueExpr
|
||||
# 113| getMethodRef(): [DeclRefExpr] source()
|
||||
# 113| getExistential(): [CallExpr] call to getMyProtocol()
|
||||
# 113| getFunction(): [DeclRefExpr] getMyProtocol()
|
||||
# 114| getElement(3): [CallExpr] call to sink(arg:)
|
||||
# 114| getFunction(): [DeclRefExpr] sink(arg:)
|
||||
# 114| getArgument(0): [Argument] arg: call to source()
|
||||
# 114| getExpr(): [CallExpr] call to source()
|
||||
# 114| getFunction(): [MethodLookupExpr] .source()
|
||||
# 114| getBase(): [CallExpr] call to getMyProtocolImpl()
|
||||
# 114| getFunction(): [DeclRefExpr] getMyProtocolImpl()
|
||||
# 114| getMethodRef(): [DeclRefExpr] source()
|
||||
|
||||
@@ -92,4 +92,24 @@ if #unavailable(macOS 42) {
|
||||
print(42)
|
||||
}
|
||||
|
||||
// ---
|
||||
|
||||
protocol MyProtocol {
|
||||
func source() -> Int
|
||||
}
|
||||
|
||||
class MyProcotolImpl : MyProtocol {
|
||||
func source() -> Int { return 0 }
|
||||
}
|
||||
|
||||
func getMyProtocol() -> MyProtocol { return MyProcotolImpl() }
|
||||
func getMyProtocolImpl() -> MyProcotolImpl { return MyProcotolImpl() }
|
||||
|
||||
func sink(arg: Int) { }
|
||||
|
||||
func testOpenExistentialExpr(x: MyProtocol, y: MyProcotolImpl) {
|
||||
sink(arg: x.source())
|
||||
sink(arg: y.source())
|
||||
sink(arg: getMyProtocol().source())
|
||||
sink(arg: getMyProtocolImpl().source())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user