Skip to content

Commit 4855683

Browse files
committed
Swift: Add a class that's the union of struct and class.
1 parent 0c79c28 commit 4855683

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
private import codeql.swift.elements.decl.ClassDecl
2+
private import codeql.swift.elements.decl.StructDecl
3+
private import codeql.swift.elements.decl.NominalTypeDecl
4+
5+
/**
6+
* A `class` or `struct` declaration. For example `MyStruct` or `MyClass` in the following example:
7+
* ```swift
8+
* struct MyStruct {
9+
* // ...
10+
* }
11+
*
12+
* class MyClass {
13+
* // ...
14+
* }
15+
* ```
16+
*/
17+
class ClassOrStructDecl extends NominalTypeDecl {
18+
ClassOrStructDecl() {
19+
this instanceof ClassDecl
20+
or
21+
this instanceof StructDecl
22+
}
23+
}

swift/ql/lib/swift.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ import codeql.swift.elements
44
import codeql.swift.elements.expr.ArithmeticOperation
55
import codeql.swift.elements.expr.LogicalOperation
66
import codeql.swift.elements.decl.MethodDecl
7+
import codeql.swift.elements.decl.ClassOrStructDecl

0 commit comments

Comments
 (0)