Skip to content

Commit 1f92267

Browse files
committed
Swift: Sort out identical files situation.
1 parent 890b9d5 commit 1f92267

File tree

4 files changed

+118
-120
lines changed

4 files changed

+118
-120
lines changed

swift/ql/test/extractor-tests/statements/statements.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,3 @@ if #available(macOS 155, *) {
9191
if #unavailable(macOS 42) {
9292
print(42)
9393
}
94-
95-

swift/ql/test/library-tests/ast/PrintAst.expected

Lines changed: 94 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -3366,6 +3366,100 @@ cfg.swift:
33663366
# 545| getElse(): [BraceStmt] { ... }
33673367
# 546| getElement(0): [ReturnStmt] return ...
33683368
# 546| getResult(): [IntegerLiteralExpr] 0
3369+
# 550| [Comment] // ---
3370+
# 550|
3371+
# 552| [ProtocolDecl] MyProtocol
3372+
#-----| getGenericTypeParam(0): [GenericTypeParamDecl] Self
3373+
# 553| getMember(0): [NamedFunction] source()
3374+
# 553| InterfaceType = <Self where Self : MyProtocol> (Self) -> () -> Int
3375+
# 553| getSelfParam(): [ParamDecl] self
3376+
# 553| Type = Self
3377+
# 556| [ClassDecl] MyProcotolImpl
3378+
# 557| getMember(0): [NamedFunction] source()
3379+
# 557| InterfaceType = (MyProcotolImpl) -> () -> Int
3380+
# 557| getSelfParam(): [ParamDecl] self
3381+
# 557| Type = MyProcotolImpl
3382+
# 557| getBody(): [BraceStmt] { ... }
3383+
# 557| getElement(0): [ReturnStmt] return ...
3384+
# 557| getResult(): [IntegerLiteralExpr] 0
3385+
# 556| getMember(1): [Deinitializer] MyProcotolImpl.deinit()
3386+
# 556| InterfaceType = (MyProcotolImpl) -> () -> ()
3387+
# 556| getSelfParam(): [ParamDecl] self
3388+
# 556| Type = MyProcotolImpl
3389+
# 556| getBody(): [BraceStmt] { ... }
3390+
# 556| getMember(2): [Initializer] MyProcotolImpl.init()
3391+
# 556| InterfaceType = (MyProcotolImpl.Type) -> () -> MyProcotolImpl
3392+
# 556| getSelfParam(): [ParamDecl] self
3393+
# 556| Type = MyProcotolImpl
3394+
# 556| getBody(): [BraceStmt] { ... }
3395+
# 556| getElement(0): [ReturnStmt] return
3396+
# 560| [NamedFunction] getMyProtocol()
3397+
# 560| InterfaceType = () -> MyProtocol
3398+
# 560| getBody(): [BraceStmt] { ... }
3399+
# 560| getElement(0): [ReturnStmt] return ...
3400+
# 560| getResult(): [CallExpr] call to MyProcotolImpl.init()
3401+
# 560| getFunction(): [MethodLookupExpr] MyProcotolImpl.init()
3402+
# 560| getBase(): [TypeExpr] MyProcotolImpl.Type
3403+
# 560| getTypeRepr(): [TypeRepr] MyProcotolImpl
3404+
# 560| getMethodRef(): [DeclRefExpr] MyProcotolImpl.init()
3405+
# 560| getResult().getFullyConverted(): [ErasureExpr] (MyProtocol) ...
3406+
# 561| [NamedFunction] getMyProtocolImpl()
3407+
# 561| InterfaceType = () -> MyProcotolImpl
3408+
# 561| getBody(): [BraceStmt] { ... }
3409+
# 561| getElement(0): [ReturnStmt] return ...
3410+
# 561| getResult(): [CallExpr] call to MyProcotolImpl.init()
3411+
# 561| getFunction(): [MethodLookupExpr] MyProcotolImpl.init()
3412+
# 561| getBase(): [TypeExpr] MyProcotolImpl.Type
3413+
# 561| getTypeRepr(): [TypeRepr] MyProcotolImpl
3414+
# 561| getMethodRef(): [DeclRefExpr] MyProcotolImpl.init()
3415+
# 563| [NamedFunction] sink(arg:)
3416+
# 563| InterfaceType = (Int) -> ()
3417+
# 563| getParam(0): [ParamDecl] arg
3418+
# 563| Type = Int
3419+
# 563| getBody(): [BraceStmt] { ... }
3420+
# 565| [NamedFunction] testOpenExistentialExpr(x:y:)
3421+
# 565| InterfaceType = (MyProtocol, MyProcotolImpl) -> ()
3422+
# 565| getParam(0): [ParamDecl] x
3423+
# 565| Type = MyProtocol
3424+
# 565| getParam(1): [ParamDecl] y
3425+
# 565| Type = MyProcotolImpl
3426+
# 565| getBody(): [BraceStmt] { ... }
3427+
# 566| getElement(0): [CallExpr] call to sink(arg:)
3428+
# 566| getFunction(): [DeclRefExpr] sink(arg:)
3429+
# 566| getArgument(0): [Argument] arg: OpenExistentialExpr
3430+
# 566| getExpr(): [OpenExistentialExpr] OpenExistentialExpr
3431+
# 566| getSubExpr(): [CallExpr] call to source()
3432+
# 566| getFunction(): [MethodLookupExpr] .source()
3433+
# 566| getBase(): [OpaqueValueExpr] OpaqueValueExpr
3434+
# 566| getMethodRef(): [DeclRefExpr] source()
3435+
# 566| getExistential(): [DeclRefExpr] x
3436+
# 567| getElement(1): [CallExpr] call to sink(arg:)
3437+
# 567| getFunction(): [DeclRefExpr] sink(arg:)
3438+
# 567| getArgument(0): [Argument] arg: call to source()
3439+
# 567| getExpr(): [CallExpr] call to source()
3440+
# 567| getFunction(): [MethodLookupExpr] .source()
3441+
# 567| getBase(): [DeclRefExpr] y
3442+
# 567| getMethodRef(): [DeclRefExpr] source()
3443+
# 568| getElement(2): [CallExpr] call to sink(arg:)
3444+
# 568| getFunction(): [DeclRefExpr] sink(arg:)
3445+
# 568| getArgument(0): [Argument] arg: OpenExistentialExpr
3446+
# 568| getExpr(): [OpenExistentialExpr] OpenExistentialExpr
3447+
# 568| getSubExpr(): [CallExpr] call to source()
3448+
# 568| getFunction(): [MethodLookupExpr] .source()
3449+
# 568| getBase(): [OpaqueValueExpr] OpaqueValueExpr
3450+
# 568| getMethodRef(): [DeclRefExpr] source()
3451+
# 568| getExistential(): [CallExpr] call to getMyProtocol()
3452+
# 568| getFunction(): [DeclRefExpr] getMyProtocol()
3453+
# 569| getElement(3): [CallExpr] call to sink(arg:)
3454+
# 569| getFunction(): [DeclRefExpr] sink(arg:)
3455+
# 569| getArgument(0): [Argument] arg: call to source()
3456+
# 569| getExpr(): [CallExpr] call to source()
3457+
# 569| getFunction(): [MethodLookupExpr] .source()
3458+
# 569| getBase(): [CallExpr] call to getMyProtocolImpl()
3459+
# 569| getFunction(): [DeclRefExpr] getMyProtocolImpl()
3460+
# 569| getMethodRef(): [DeclRefExpr] source()
3461+
# 572| [Comment] // ---
3462+
# 572|
33693463
declarations.swift:
33703464
# 1| [StructDecl] Foo
33713465
# 2| getMember(0): [PatternBindingDecl] var ... = ...
@@ -7232,97 +7326,3 @@ statements.swift:
72327326
# 92| getExpr(): [DefaultArgumentExpr] default separator
72337327
# 92| getArgument(2): [Argument] terminator: default terminator
72347328
# 92| getExpr(): [DefaultArgumentExpr] default terminator
7235-
# 95| [Comment] // ---
7236-
# 95|
7237-
# 97| [ProtocolDecl] MyProtocol
7238-
#-----| getGenericTypeParam(0): [GenericTypeParamDecl] Self
7239-
# 98| getMember(0): [NamedFunction] source()
7240-
# 98| InterfaceType = <Self where Self : MyProtocol> (Self) -> () -> Int
7241-
# 98| getSelfParam(): [ParamDecl] self
7242-
# 98| Type = Self
7243-
# 101| [ClassDecl] MyProcotolImpl
7244-
# 102| getMember(0): [NamedFunction] source()
7245-
# 102| InterfaceType = (MyProcotolImpl) -> () -> Int
7246-
# 102| getSelfParam(): [ParamDecl] self
7247-
# 102| Type = MyProcotolImpl
7248-
# 102| getBody(): [BraceStmt] { ... }
7249-
# 102| getElement(0): [ReturnStmt] return ...
7250-
# 102| getResult(): [IntegerLiteralExpr] 0
7251-
# 101| getMember(1): [Deinitializer] MyProcotolImpl.deinit()
7252-
# 101| InterfaceType = (MyProcotolImpl) -> () -> ()
7253-
# 101| getSelfParam(): [ParamDecl] self
7254-
# 101| Type = MyProcotolImpl
7255-
# 101| getBody(): [BraceStmt] { ... }
7256-
# 101| getMember(2): [Initializer] MyProcotolImpl.init()
7257-
# 101| InterfaceType = (MyProcotolImpl.Type) -> () -> MyProcotolImpl
7258-
# 101| getSelfParam(): [ParamDecl] self
7259-
# 101| Type = MyProcotolImpl
7260-
# 101| getBody(): [BraceStmt] { ... }
7261-
# 101| getElement(0): [ReturnStmt] return
7262-
# 105| [NamedFunction] getMyProtocol()
7263-
# 105| InterfaceType = () -> MyProtocol
7264-
# 105| getBody(): [BraceStmt] { ... }
7265-
# 105| getElement(0): [ReturnStmt] return ...
7266-
# 105| getResult(): [CallExpr] call to MyProcotolImpl.init()
7267-
# 105| getFunction(): [MethodLookupExpr] MyProcotolImpl.init()
7268-
# 105| getBase(): [TypeExpr] MyProcotolImpl.Type
7269-
# 105| getTypeRepr(): [TypeRepr] MyProcotolImpl
7270-
# 105| getMethodRef(): [DeclRefExpr] MyProcotolImpl.init()
7271-
# 105| getResult().getFullyConverted(): [ErasureExpr] (MyProtocol) ...
7272-
# 106| [NamedFunction] getMyProtocolImpl()
7273-
# 106| InterfaceType = () -> MyProcotolImpl
7274-
# 106| getBody(): [BraceStmt] { ... }
7275-
# 106| getElement(0): [ReturnStmt] return ...
7276-
# 106| getResult(): [CallExpr] call to MyProcotolImpl.init()
7277-
# 106| getFunction(): [MethodLookupExpr] MyProcotolImpl.init()
7278-
# 106| getBase(): [TypeExpr] MyProcotolImpl.Type
7279-
# 106| getTypeRepr(): [TypeRepr] MyProcotolImpl
7280-
# 106| getMethodRef(): [DeclRefExpr] MyProcotolImpl.init()
7281-
# 108| [NamedFunction] sink(arg:)
7282-
# 108| InterfaceType = (Int) -> ()
7283-
# 108| getParam(0): [ParamDecl] arg
7284-
# 108| Type = Int
7285-
# 108| getBody(): [BraceStmt] { ... }
7286-
# 110| [NamedFunction] testOpenExistentialExpr(x:y:)
7287-
# 110| InterfaceType = (MyProtocol, MyProcotolImpl) -> ()
7288-
# 110| getParam(0): [ParamDecl] x
7289-
# 110| Type = MyProtocol
7290-
# 110| getParam(1): [ParamDecl] y
7291-
# 110| Type = MyProcotolImpl
7292-
# 110| getBody(): [BraceStmt] { ... }
7293-
# 111| getElement(0): [CallExpr] call to sink(arg:)
7294-
# 111| getFunction(): [DeclRefExpr] sink(arg:)
7295-
# 111| getArgument(0): [Argument] arg: OpenExistentialExpr
7296-
# 111| getExpr(): [OpenExistentialExpr] OpenExistentialExpr
7297-
# 111| getSubExpr(): [CallExpr] call to source()
7298-
# 111| getFunction(): [MethodLookupExpr] .source()
7299-
# 111| getBase(): [OpaqueValueExpr] OpaqueValueExpr
7300-
# 111| getMethodRef(): [DeclRefExpr] source()
7301-
# 111| getExistential(): [DeclRefExpr] x
7302-
# 112| getElement(1): [CallExpr] call to sink(arg:)
7303-
# 112| getFunction(): [DeclRefExpr] sink(arg:)
7304-
# 112| getArgument(0): [Argument] arg: call to source()
7305-
# 112| getExpr(): [CallExpr] call to source()
7306-
# 112| getFunction(): [MethodLookupExpr] .source()
7307-
# 112| getBase(): [DeclRefExpr] y
7308-
# 112| getMethodRef(): [DeclRefExpr] source()
7309-
# 113| getElement(2): [CallExpr] call to sink(arg:)
7310-
# 113| getFunction(): [DeclRefExpr] sink(arg:)
7311-
# 113| getArgument(0): [Argument] arg: OpenExistentialExpr
7312-
# 113| getExpr(): [OpenExistentialExpr] OpenExistentialExpr
7313-
# 113| getSubExpr(): [CallExpr] call to source()
7314-
# 113| getFunction(): [MethodLookupExpr] .source()
7315-
# 113| getBase(): [OpaqueValueExpr] OpaqueValueExpr
7316-
# 113| getMethodRef(): [DeclRefExpr] source()
7317-
# 113| getExistential(): [CallExpr] call to getMyProtocol()
7318-
# 113| getFunction(): [DeclRefExpr] getMyProtocol()
7319-
# 114| getElement(3): [CallExpr] call to sink(arg:)
7320-
# 114| getFunction(): [DeclRefExpr] sink(arg:)
7321-
# 114| getArgument(0): [Argument] arg: call to source()
7322-
# 114| getExpr(): [CallExpr] call to source()
7323-
# 114| getFunction(): [MethodLookupExpr] .source()
7324-
# 114| getBase(): [CallExpr] call to getMyProtocolImpl()
7325-
# 114| getFunction(): [DeclRefExpr] getMyProtocolImpl()
7326-
# 114| getMethodRef(): [DeclRefExpr] source()
7327-
# 117| [Comment] // ---
7328-
# 117|

swift/ql/test/library-tests/ast/cfg.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,3 +546,27 @@ func testNilCoalescing2(x: Bool?) -> Int {
546546
return 0
547547
}
548548
}
549+
550+
// ---
551+
552+
protocol MyProtocol {
553+
func source() -> Int
554+
}
555+
556+
class MyProcotolImpl : MyProtocol {
557+
func source() -> Int { return 0 }
558+
}
559+
560+
func getMyProtocol() -> MyProtocol { return MyProcotolImpl() }
561+
func getMyProtocolImpl() -> MyProcotolImpl { return MyProcotolImpl() }
562+
563+
func sink(arg: Int) { }
564+
565+
func testOpenExistentialExpr(x: MyProtocol, y: MyProcotolImpl) {
566+
sink(arg: x.source())
567+
sink(arg: y.source())
568+
sink(arg: getMyProtocol().source())
569+
sink(arg: getMyProtocolImpl().source())
570+
}
571+
572+
// ---

swift/ql/test/library-tests/ast/statements.swift

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -91,27 +91,3 @@ if #available(macOS 155, *) {
9191
if #unavailable(macOS 42) {
9292
print(42)
9393
}
94-
95-
// ---
96-
97-
protocol MyProtocol {
98-
func source() -> Int
99-
}
100-
101-
class MyProcotolImpl : MyProtocol {
102-
func source() -> Int { return 0 }
103-
}
104-
105-
func getMyProtocol() -> MyProtocol { return MyProcotolImpl() }
106-
func getMyProtocolImpl() -> MyProcotolImpl { return MyProcotolImpl() }
107-
108-
func sink(arg: Int) { }
109-
110-
func testOpenExistentialExpr(x: MyProtocol, y: MyProcotolImpl) {
111-
sink(arg: x.source())
112-
sink(arg: y.source())
113-
sink(arg: getMyProtocol().source())
114-
sink(arg: getMyProtocolImpl().source())
115-
}
116-
117-
// ---

0 commit comments

Comments
 (0)