mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Swift: Manual changes after running code generator
This commit is contained in:
@@ -5,7 +5,8 @@ private import codeql.swift.elements.expr.ClosureExpr
|
||||
private import codeql.swift.elements.Callable
|
||||
private import codeql.swift.generated.ParentChild
|
||||
|
||||
private module Cached {
|
||||
module Impl {
|
||||
private module Cached {
|
||||
private Element getEnclosingDeclStep(Element e) {
|
||||
not e instanceof Decl and
|
||||
result = getImmediateParent(e)
|
||||
@@ -33,12 +34,12 @@ private module Cached {
|
||||
ClosureExpr getEnclosingClosure(AstNode ast) {
|
||||
result = getEnclosingClosureStep*(getImmediateParent(ast))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* A node in the abstract syntax tree.
|
||||
*/
|
||||
class AstNode extends Generated::AstNode {
|
||||
class AstNode extends Generated::AstNode {
|
||||
/**
|
||||
* Gets the nearest function definition that contains this AST node, if any.
|
||||
* This includes functions, methods, (de)initializers, and accessors, but not closures.
|
||||
@@ -81,4 +82,5 @@ class AstNode extends Generated::AstNode {
|
||||
then result = Cached::getEnclosingClosure(this)
|
||||
else result = Cached::getEnclosingFunction(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
private import codeql.swift.generated.AvailabilityInfo
|
||||
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
module Impl {
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
* An availability condition of an `if`, `while`, or `guard` statements.
|
||||
*
|
||||
* Examples:
|
||||
@@ -16,10 +17,11 @@ private import codeql.swift.generated.AvailabilityInfo
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
class AvailabilityInfo extends Generated::AvailabilityInfo {
|
||||
class AvailabilityInfo extends Generated::AvailabilityInfo {
|
||||
override string toString() {
|
||||
result = "#available" and not this.isUnavailable()
|
||||
or
|
||||
result = "#unavailable" and this.isUnavailable()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ private import codeql.swift.generated.Callable
|
||||
private import codeql.swift.elements.AstNode
|
||||
private import codeql.swift.elements.decl.Decl
|
||||
|
||||
class Callable extends Generated::Callable {
|
||||
module Impl {
|
||||
class Callable extends Generated::Callable {
|
||||
/**
|
||||
* Holds if this Callable is a function named `funcName`.
|
||||
*/
|
||||
@@ -16,4 +17,5 @@ class Callable extends Generated::Callable {
|
||||
this.hasName(funcName) and
|
||||
this.(Decl).getModule().getFullName() = moduleName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,8 @@
|
||||
private import codeql.swift.generated.Comment
|
||||
|
||||
class Comment extends Generated::Comment {
|
||||
module Impl {
|
||||
class Comment extends Generated::Comment {
|
||||
/** toString */
|
||||
override string toString() { result = this.getText() }
|
||||
}
|
||||
|
||||
class SingleLineComment extends Comment {
|
||||
SingleLineComment() {
|
||||
this.getText().matches("//%") and
|
||||
not this instanceof SingleLineDocComment
|
||||
}
|
||||
}
|
||||
|
||||
class MultiLineComment extends Comment {
|
||||
MultiLineComment() {
|
||||
this.getText().matches("/*%") and
|
||||
not this instanceof MultiLineDocComment
|
||||
}
|
||||
}
|
||||
|
||||
class DocComment extends Comment {
|
||||
DocComment() {
|
||||
this instanceof SingleLineDocComment or
|
||||
this instanceof MultiLineDocComment
|
||||
}
|
||||
}
|
||||
|
||||
class SingleLineDocComment extends Comment {
|
||||
SingleLineDocComment() { this.getText().matches("///%") }
|
||||
}
|
||||
|
||||
class MultiLineDocComment extends Comment {
|
||||
MultiLineDocComment() { this.getText().matches("/**%") }
|
||||
}
|
||||
|
||||
27
swift/ql/lib/codeql/swift/elements/Comments.qll
Normal file
27
swift/ql/lib/codeql/swift/elements/Comments.qll
Normal file
@@ -0,0 +1,27 @@
|
||||
import Comment
|
||||
|
||||
final class SingleLineComment extends Comment {
|
||||
SingleLineComment() {
|
||||
this.getText().matches("//%") and
|
||||
not this instanceof SingleLineDocComment
|
||||
}
|
||||
}
|
||||
|
||||
final class MultiLineComment extends Comment {
|
||||
MultiLineComment() {
|
||||
this.getText().matches("/*%") and
|
||||
not this instanceof MultiLineDocComment
|
||||
}
|
||||
}
|
||||
|
||||
abstract private class DocCommentImpl extends Comment { }
|
||||
|
||||
final class DocComment = DocCommentImpl;
|
||||
|
||||
final class SingleLineDocComment extends DocCommentImpl {
|
||||
SingleLineDocComment() { this.getText().matches("///%") }
|
||||
}
|
||||
|
||||
final class MultiLineDocComment extends DocCommentImpl {
|
||||
MultiLineDocComment() { this.getText().matches("/**%") }
|
||||
}
|
||||
29
swift/ql/lib/codeql/swift/elements/CompilerDiagnostics.qll
Normal file
29
swift/ql/lib/codeql/swift/elements/CompilerDiagnostics.qll
Normal file
@@ -0,0 +1,29 @@
|
||||
import Diagnostics
|
||||
|
||||
/**
|
||||
* A compiler error message.
|
||||
*/
|
||||
final class CompilerError extends Diagnostics {
|
||||
CompilerError() { this.getSeverity() = "error" }
|
||||
}
|
||||
|
||||
/**
|
||||
* A compiler-generated warning.
|
||||
*/
|
||||
final class CompilerWarning extends Diagnostics {
|
||||
CompilerWarning() { this.getSeverity() = "warning" }
|
||||
}
|
||||
|
||||
/**
|
||||
* A compiler-generated note (typically attached to an error or warning).
|
||||
*/
|
||||
final class CompilerNote extends Diagnostics {
|
||||
CompilerNote() { this.getSeverity() = "note" }
|
||||
}
|
||||
|
||||
/**
|
||||
* A compiler-generated remark (milder than a warning, this does not indicate an issue).
|
||||
*/
|
||||
final class CompilerRemark extends Diagnostics {
|
||||
CompilerRemark() { this.getSeverity() = "remark" }
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
private import codeql.swift.generated.Diagnostics
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* A compiler-generated error, warning, note or remark.
|
||||
*/
|
||||
class Diagnostics extends Generated::Diagnostics {
|
||||
class Diagnostics extends Generated::Diagnostics {
|
||||
override string toString() { result = this.getSeverity() + ": " + this.getText() }
|
||||
|
||||
/**
|
||||
@@ -18,32 +19,5 @@ class Diagnostics extends Generated::Diagnostics {
|
||||
or
|
||||
this.getKind() = 4 and result = "remark"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A compiler error message.
|
||||
*/
|
||||
class CompilerError extends Diagnostics {
|
||||
CompilerError() { this.getSeverity() = "error" }
|
||||
}
|
||||
|
||||
/**
|
||||
* A compiler-generated warning.
|
||||
*/
|
||||
class CompilerWarning extends Diagnostics {
|
||||
CompilerWarning() { this.getSeverity() = "warning" }
|
||||
}
|
||||
|
||||
/**
|
||||
* A compiler-generated note (typically attached to an error or warning).
|
||||
*/
|
||||
class CompilerNote extends Diagnostics {
|
||||
CompilerNote() { this.getSeverity() = "note" }
|
||||
}
|
||||
|
||||
/**
|
||||
* A compiler-generated remark (milder than a warning, this does not indicate an issue).
|
||||
*/
|
||||
class CompilerRemark extends Diagnostics {
|
||||
CompilerRemark() { this.getSeverity() = "remark" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
private import codeql.swift.generated.Element
|
||||
|
||||
class Element extends Generated::Element {
|
||||
module Impl {
|
||||
class Element extends Generated::Element {
|
||||
private predicate resolvesFrom(Element e) { e.getResolveStep() = this }
|
||||
|
||||
override string toString() { result = this.getPrimaryQlClasses() }
|
||||
@@ -13,8 +14,9 @@ class Element extends Generated::Element {
|
||||
result = e.getFullyUnresolved()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class UnknownElement extends Element {
|
||||
class UnknownElement extends Element {
|
||||
UnknownElement() { this.isUnknown() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ private import codeql.swift.generated.File
|
||||
private import codeql.swift.elements.Location
|
||||
private import codeql.swift.elements.UnknownLocation
|
||||
|
||||
class File extends Generated::File {
|
||||
module Impl {
|
||||
class File extends Generated::File {
|
||||
/** toString */
|
||||
override string toString() { result = this.getAbsolutePath() }
|
||||
|
||||
@@ -81,7 +82,9 @@ class File extends Generated::File {
|
||||
result =
|
||||
count(int line |
|
||||
exists(Location loc |
|
||||
not loc instanceof UnknownLocation and loc.getFile() = this and loc.getStartLine() = line
|
||||
not loc instanceof UnknownLocation and
|
||||
loc.getFile() = this and
|
||||
loc.getStartLine() = line
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -104,4 +107,5 @@ class File extends Generated::File {
|
||||
not result.matches("/%")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
private import codeql.swift.generated.KeyPathComponent
|
||||
private import swift
|
||||
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
module Impl {
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
* A component of a `KeyPathExpr`.
|
||||
*/
|
||||
class KeyPathComponent extends Generated::KeyPathComponent {
|
||||
class KeyPathComponent extends Generated::KeyPathComponent {
|
||||
/**
|
||||
* Property access like `.bar` in `\Foo.bar`.
|
||||
*/
|
||||
@@ -54,9 +55,10 @@ class KeyPathComponent extends Generated::KeyPathComponent {
|
||||
hasKeyPathExprAndIndex(e, i + 1, result)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
private predicate hasKeyPathExprAndIndex(KeyPathExpr e, int i, KeyPathComponent c) {
|
||||
pragma[nomagic]
|
||||
private predicate hasKeyPathExprAndIndex(KeyPathExpr e, int i, KeyPathComponent c) {
|
||||
e.getComponent(i) = c
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ private import codeql.swift.generated.Locatable
|
||||
private import codeql.swift.elements.File
|
||||
private import codeql.swift.elements.UnknownLocation
|
||||
|
||||
class Locatable extends Generated::Locatable {
|
||||
module Impl {
|
||||
class Locatable extends Generated::Locatable {
|
||||
pragma[nomagic]
|
||||
override Location getLocation() {
|
||||
result = Generated::Locatable.super.getLocation()
|
||||
@@ -15,4 +16,5 @@ class Locatable extends Generated::Locatable {
|
||||
* Gets the primary file where this element occurs.
|
||||
*/
|
||||
File getFile() { result = this.getLocation().getFile() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
private import codeql.swift.generated.Location
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* A location of a program element.
|
||||
*/
|
||||
class Location extends Generated::Location {
|
||||
class Location extends Generated::Location {
|
||||
/**
|
||||
* Holds if this location is described by `path`, `startLine`, `startColumn`, `endLine` and `endColumn`.
|
||||
*/
|
||||
predicate hasLocationInfo(string path, int startLine, int startColumn, int endLine, int endColumn) {
|
||||
predicate hasLocationInfo(
|
||||
string path, int startLine, int startColumn, int endLine, int endColumn
|
||||
) {
|
||||
path = this.getFile().getFullName() and
|
||||
startLine = this.getStartLine() and
|
||||
startColumn = this.getStartColumn() and
|
||||
@@ -25,4 +28,5 @@ class Location extends Generated::Location {
|
||||
toUrl(filePath, startLine, startColumn, endLine, endColumn, result)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
|
||||
private import codeql.swift.generated.MacroRole
|
||||
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
module Impl {
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
* The role of a macro, for example #freestanding(declaration) or @attached(member).
|
||||
*/
|
||||
class MacroRole extends Generated::MacroRole {
|
||||
class MacroRole extends Generated::MacroRole {
|
||||
/**
|
||||
* String representation of the role kind.
|
||||
*/
|
||||
@@ -96,5 +97,8 @@ class MacroRole extends Generated::MacroRole {
|
||||
*/
|
||||
predicate isAttachedMacroSyntax() { this.getMacroSyntax() = 1 }
|
||||
|
||||
override string toString() { result = this.getMacroSyntaxName() + "(" + this.getKindName() + ")" }
|
||||
override string toString() {
|
||||
result = this.getMacroSyntaxName() + "(" + this.getKindName() + ")"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
private import codeql.swift.generated.OtherAvailabilitySpec
|
||||
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
module Impl {
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
* A wildcard availability spec `*`
|
||||
*/
|
||||
class OtherAvailabilitySpec extends Generated::OtherAvailabilitySpec {
|
||||
class OtherAvailabilitySpec extends Generated::OtherAvailabilitySpec {
|
||||
override string toString() { result = "*" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
private import codeql.swift.generated.PlatformVersionAvailabilitySpec
|
||||
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
module Impl {
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
* An availability spec based on platform and version, for example `macOS 12` or `watchOS 14`
|
||||
*/
|
||||
class PlatformVersionAvailabilitySpec extends Generated::PlatformVersionAvailabilitySpec {
|
||||
class PlatformVersionAvailabilitySpec extends Generated::PlatformVersionAvailabilitySpec {
|
||||
override string toString() { result = this.getPlatform() + " " + this.getVersion() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.UnknownFile
|
||||
|
||||
class UnknownFile extends Generated::UnknownFile {
|
||||
module Impl {
|
||||
class UnknownFile extends Generated::UnknownFile {
|
||||
override string getName() { result = "" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,11 @@ private import codeql.swift.generated.UnknownLocation
|
||||
private import codeql.swift.elements.UnknownFile
|
||||
private import codeql.swift.elements.File
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* A `Location` that is given to something that is not associated with any position in the source code.
|
||||
*/
|
||||
class UnknownLocation extends Generated::UnknownLocation {
|
||||
class UnknownLocation extends Generated::UnknownLocation {
|
||||
override File getFile() { result instanceof UnknownFile }
|
||||
|
||||
override int getStartLine() { result = 0 }
|
||||
@@ -17,4 +18,5 @@ class UnknownLocation extends Generated::UnknownLocation {
|
||||
override int getEndColumn() { result = 0 }
|
||||
|
||||
override string toString() { result = "UnknownLocation" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ private import codeql.swift.generated.UnspecifiedElement
|
||||
import codeql.swift.elements.Location
|
||||
import codeql.swift.elements.Locatable
|
||||
|
||||
class UnspecifiedElement extends Generated::UnspecifiedElement {
|
||||
module Impl {
|
||||
class UnspecifiedElement extends Generated::UnspecifiedElement {
|
||||
override string toString() {
|
||||
exists(string source, string index |
|
||||
(
|
||||
@@ -20,4 +21,5 @@ class UnspecifiedElement extends Generated::UnspecifiedElement {
|
||||
}
|
||||
|
||||
override Location getLocation() { result = this.getParent().(Locatable).getLocation() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
private import codeql.swift.generated.decl.Accessor
|
||||
private import SetObserver
|
||||
|
||||
private predicate isKnownAccessorKind(Accessor decl, string kind) {
|
||||
module Impl {
|
||||
private predicate isKnownAccessorKind(Accessor decl, string kind) {
|
||||
decl.isGetter() and kind = "get"
|
||||
or
|
||||
decl.isSetter() and kind = "set"
|
||||
@@ -16,9 +18,9 @@ private predicate isKnownAccessorKind(Accessor decl, string kind) {
|
||||
decl.isUnsafeAddress() and kind = "unsafeAddress"
|
||||
or
|
||||
decl.isUnsafeMutableAddress() and kind = "unsafeMutableAddress"
|
||||
}
|
||||
}
|
||||
|
||||
class Accessor extends Generated::Accessor {
|
||||
class Accessor extends Generated::Accessor {
|
||||
predicate isPropertyObserver() {
|
||||
this instanceof WillSetObserver or this instanceof DidSetObserver
|
||||
}
|
||||
@@ -29,12 +31,5 @@ class Accessor extends Generated::Accessor {
|
||||
not isKnownAccessorKind(this, _) and
|
||||
result = super.toString()
|
||||
}
|
||||
}
|
||||
|
||||
class WillSetObserver extends Accessor {
|
||||
WillSetObserver() { this.isWillSet() }
|
||||
}
|
||||
|
||||
class DidSetObserver extends Accessor {
|
||||
DidSetObserver() { this.isDidSet() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,11 @@ private import codeql.swift.generated.decl.CapturedDecl
|
||||
private import codeql.swift.elements.Callable
|
||||
private import codeql.swift.elements.expr.DeclRefExpr
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* A captured variable or function parameter in the scope of a closure.
|
||||
*/
|
||||
class CapturedDecl extends Generated::CapturedDecl {
|
||||
class CapturedDecl extends Generated::CapturedDecl {
|
||||
override string toString() { result = this.getDecl().toString() }
|
||||
|
||||
/**
|
||||
@@ -20,4 +21,5 @@ class CapturedDecl extends Generated::CapturedDecl {
|
||||
result.getEnclosingCallable() = this.getScope() and
|
||||
result.getDecl() = this.getDecl()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ private import codeql.swift.generated.decl.Decl
|
||||
private import codeql.swift.elements.decl.NominalTypeDecl
|
||||
private import codeql.swift.elements.decl.ExtensionDecl
|
||||
|
||||
class Decl extends Generated::Decl {
|
||||
module Impl {
|
||||
class Decl extends Generated::Decl {
|
||||
override string toString() { result = super.toString() }
|
||||
|
||||
/**
|
||||
@@ -19,4 +20,5 @@ class Decl extends Generated::Decl {
|
||||
* Gets the declaration that declares this declaration as a member, if any.
|
||||
*/
|
||||
Decl getDeclaringDecl() { this = result.getAMember() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
private import codeql.swift.generated.decl.Deinitializer
|
||||
private import codeql.swift.elements.decl.Method
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* A deinitializer of a class.
|
||||
*/
|
||||
class Deinitializer extends Generated::Deinitializer, Method {
|
||||
class Deinitializer extends Generated::Deinitializer {
|
||||
override string toString() { result = this.getSelfParam().getType() + "." + super.toString() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.decl.EnumCaseDecl
|
||||
|
||||
class EnumCaseDecl extends Generated::EnumCaseDecl {
|
||||
module Impl {
|
||||
class EnumCaseDecl extends Generated::EnumCaseDecl {
|
||||
override string toString() { result = "case ..." }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@ private import codeql.swift.elements.decl.EnumCaseDecl
|
||||
private import codeql.swift.elements.decl.EnumElementDecl
|
||||
private import codeql.swift.elements.decl.Decl
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* An enumeration declaration, for example:
|
||||
* ```
|
||||
* enum MyColours {
|
||||
@@ -13,7 +14,7 @@ private import codeql.swift.elements.decl.Decl
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
class EnumDecl extends Generated::EnumDecl {
|
||||
class EnumDecl extends Generated::EnumDecl {
|
||||
/**
|
||||
* Gets the `index`th enumeration element of this enumeration (0-based).
|
||||
*/
|
||||
@@ -33,4 +34,5 @@ class EnumDecl extends Generated::EnumDecl {
|
||||
final EnumElementDecl getAnEnumElement() {
|
||||
result = this.getMember(_).(EnumCaseDecl).getElement(_)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
private import codeql.swift.generated.decl.EnumElementDecl
|
||||
private import codeql.swift.elements.decl.EnumDecl
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* An enum element declaration, for example `enumElement` and `anotherEnumElement` in:
|
||||
* ```
|
||||
* enum MyEnum {
|
||||
@@ -10,7 +11,7 @@ private import codeql.swift.elements.decl.EnumDecl
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
class EnumElementDecl extends Generated::EnumElementDecl {
|
||||
class EnumElementDecl extends Generated::EnumElementDecl {
|
||||
override string toString() { result = this.getName() }
|
||||
|
||||
/**
|
||||
@@ -34,4 +35,5 @@ class EnumElementDecl extends Generated::EnumElementDecl {
|
||||
this.hasQualifiedName(enumName, enumElementName) and
|
||||
this.getModule().getFullName() = moduleName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
private import codeql.swift.generated.decl.ExtensionDecl
|
||||
|
||||
class ExtensionDecl extends Generated::ExtensionDecl {
|
||||
module Impl {
|
||||
class ExtensionDecl extends Generated::ExtensionDecl {
|
||||
override string toString() {
|
||||
result =
|
||||
"extension of " + unique(NominalTypeDecl td | td = this.getExtendedTypeDecl()).toString()
|
||||
@@ -8,4 +9,5 @@ class ExtensionDecl extends Generated::ExtensionDecl {
|
||||
count(this.getExtendedTypeDecl()) != 1 and
|
||||
result = "extension"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
32
swift/ql/lib/codeql/swift/elements/decl/FieldDecl.qll
Normal file
32
swift/ql/lib/codeql/swift/elements/decl/FieldDecl.qll
Normal file
@@ -0,0 +1,32 @@
|
||||
private import VarDecl
|
||||
|
||||
/**
|
||||
* A field declaration. That is, a variable declaration that is a member of a
|
||||
* class, struct, enum or protocol.
|
||||
*/
|
||||
final class FieldDecl extends VarDecl {
|
||||
FieldDecl() { this = any(Decl ctx).getAMember() }
|
||||
|
||||
/**
|
||||
* Holds if this field is called `fieldName` and is a member of a
|
||||
* class, struct, extension, enum or protocol called `typeName`.
|
||||
*/
|
||||
cached
|
||||
predicate hasQualifiedName(string typeName, string fieldName) {
|
||||
this.getName() = fieldName and
|
||||
exists(Decl d |
|
||||
d.asNominalTypeDecl().getFullName() = typeName and
|
||||
d.getAMember() = this
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this field is called `fieldName` and is a member of a
|
||||
* class, struct, extension, enum or protocol called `typeName` in a module
|
||||
* called `moduleName`.
|
||||
*/
|
||||
predicate hasQualifiedName(string moduleName, string typeName, string fieldName) {
|
||||
this.hasQualifiedName(typeName, fieldName) and
|
||||
this.getModule().getFullName() = moduleName
|
||||
}
|
||||
}
|
||||
9
swift/ql/lib/codeql/swift/elements/decl/FreeFunction.qll
Normal file
9
swift/ql/lib/codeql/swift/elements/decl/FreeFunction.qll
Normal file
@@ -0,0 +1,9 @@
|
||||
private import Function
|
||||
private import Method
|
||||
|
||||
/**
|
||||
* A free (non-member) function.
|
||||
*/
|
||||
final class FreeFunction extends Function {
|
||||
FreeFunction() { not this instanceof Method }
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
private import codeql.swift.generated.decl.Function
|
||||
private import codeql.swift.elements.decl.Method
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* A function.
|
||||
*/
|
||||
class Function extends Generated::Function, Callable {
|
||||
class Function extends Generated::Function {
|
||||
override string toString() { result = this.getName() }
|
||||
|
||||
/**
|
||||
@@ -16,11 +17,12 @@ class Function extends Generated::Function, Callable {
|
||||
// (`*+` is possessive matching)
|
||||
result = this.getName().regexpCapture("([^(]*+).*", 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* A free (non-member) function.
|
||||
*/
|
||||
class FreeFunction extends Function {
|
||||
class FreeFunction extends Function {
|
||||
FreeFunction() { not this instanceof Method }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.decl.IfConfigDecl
|
||||
|
||||
class IfConfigDecl extends Generated::IfConfigDecl {
|
||||
module Impl {
|
||||
class IfConfigDecl extends Generated::IfConfigDecl {
|
||||
override string toString() { result = "#if ..." }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.decl.ImportDecl
|
||||
|
||||
class ImportDecl extends Generated::ImportDecl {
|
||||
module Impl {
|
||||
class ImportDecl extends Generated::ImportDecl {
|
||||
override string toString() { result = "import ..." }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
private import codeql.swift.generated.decl.Initializer
|
||||
private import codeql.swift.elements.decl.Method
|
||||
private import codeql.swift.elements.decl.MethodImpl::Impl as MethodImpl
|
||||
private import codeql.swift.elements.type.FunctionType
|
||||
private import codeql.swift.elements.type.OptionalType
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* An initializer of a class, struct, enum or protocol.
|
||||
*/
|
||||
class Initializer extends Generated::Initializer, Method {
|
||||
class Initializer extends Generated::Initializer, MethodImpl::Method {
|
||||
override string toString() { result = this.getSelfParam().getType() + "." + super.toString() }
|
||||
|
||||
/** Holds if this initializer returns an optional type. Failable initializers are written as `init?`. */
|
||||
@@ -14,4 +16,5 @@ class Initializer extends Generated::Initializer, Method {
|
||||
this.getInterfaceType().(FunctionType).getResult().(FunctionType).getResult() instanceof
|
||||
OptionalType
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +1,3 @@
|
||||
private import swift
|
||||
private import MethodImpl
|
||||
|
||||
private Decl getAMember(Decl ctx) {
|
||||
ctx.getAMember() = result
|
||||
or
|
||||
exists(VarDecl var |
|
||||
ctx.getAMember() = var and
|
||||
var.getAnAccessor() = result
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that is a member of a class, struct, enum or protocol.
|
||||
*/
|
||||
final class Method extends Function {
|
||||
Method() {
|
||||
this = getAMember(any(ClassDecl c))
|
||||
or
|
||||
this = getAMember(any(StructDecl c))
|
||||
or
|
||||
this = getAMember(any(ExtensionDecl c))
|
||||
or
|
||||
this = getAMember(any(EnumDecl c))
|
||||
or
|
||||
this = getAMember(any(ProtocolDecl c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this function is called `funcName` and is a member of a
|
||||
* class, struct, extension, enum or protocol called `typeName`.
|
||||
*/
|
||||
cached
|
||||
predicate hasQualifiedName(string typeName, string funcName) {
|
||||
this.getName() = funcName and
|
||||
exists(Decl d |
|
||||
d.asNominalTypeDecl().getFullName() = typeName and
|
||||
d.getAMember() = this
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this function is called `funcName` and is a member of a
|
||||
* class, struct, extension, enum or protocol called `typeName` in a module
|
||||
* called `moduleName`.
|
||||
*/
|
||||
predicate hasQualifiedName(string moduleName, string typeName, string funcName) {
|
||||
this.hasQualifiedName(typeName, funcName) and
|
||||
this.getModule().getFullName() = moduleName
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this function is a `static` or `class` method, as opposed to an instance method.
|
||||
*/
|
||||
predicate isStaticOrClassMethod() { this.getSelfParam().getType() instanceof MetatypeType }
|
||||
|
||||
/**
|
||||
* Holds if this function is an instance method, as opposed to a `static` or `class` method.
|
||||
*/
|
||||
predicate isInstanceMethod() { not this.isStaticOrClassMethod() }
|
||||
}
|
||||
final class Method = Impl::Method;
|
||||
|
||||
63
swift/ql/lib/codeql/swift/elements/decl/MethodImpl.qll
Normal file
63
swift/ql/lib/codeql/swift/elements/decl/MethodImpl.qll
Normal file
@@ -0,0 +1,63 @@
|
||||
private import swift
|
||||
private import codeql.swift.elements.decl.FunctionImpl::Impl as FunctionImpl
|
||||
|
||||
module Impl {
|
||||
private Decl getAMember(Decl ctx) {
|
||||
ctx.getAMember() = result
|
||||
or
|
||||
exists(VarDecl var |
|
||||
ctx.getAMember() = var and
|
||||
var.getAnAccessor() = result
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that is a member of a class, struct, enum or protocol.
|
||||
*/
|
||||
class Method extends FunctionImpl::Function {
|
||||
Method() {
|
||||
this = getAMember(any(ClassDecl c))
|
||||
or
|
||||
this = getAMember(any(StructDecl c))
|
||||
or
|
||||
this = getAMember(any(ExtensionDecl c))
|
||||
or
|
||||
this = getAMember(any(EnumDecl c))
|
||||
or
|
||||
this = getAMember(any(ProtocolDecl c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this function is called `funcName` and is a member of a
|
||||
* class, struct, extension, enum or protocol called `typeName`.
|
||||
*/
|
||||
cached
|
||||
predicate hasQualifiedName(string typeName, string funcName) {
|
||||
this.getName() = funcName and
|
||||
exists(Decl d |
|
||||
d.asNominalTypeDecl().getFullName() = typeName and
|
||||
d.getAMember() = this
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this function is called `funcName` and is a member of a
|
||||
* class, struct, extension, enum or protocol called `typeName` in a module
|
||||
* called `moduleName`.
|
||||
*/
|
||||
predicate hasQualifiedName(string moduleName, string typeName, string funcName) {
|
||||
this.hasQualifiedName(typeName, funcName) and
|
||||
this.getModule().getFullName() = moduleName
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this function is a `static` or `class` method, as opposed to an instance method.
|
||||
*/
|
||||
predicate isStaticOrClassMethod() { this.getSelfParam().getType() instanceof MetatypeType }
|
||||
|
||||
/**
|
||||
* Holds if this function is an instance method, as opposed to a `static` or `class` method.
|
||||
*/
|
||||
predicate isInstanceMethod() { not this.isStaticOrClassMethod() }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
private import codeql.swift.generated.decl.MissingMemberDecl
|
||||
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
module Impl {
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
* A placeholder for missing declarations that can arise on object deserialization.
|
||||
*/
|
||||
class MissingMemberDecl extends Generated::MissingMemberDecl {
|
||||
class MissingMemberDecl extends Generated::MissingMemberDecl {
|
||||
override string toString() { result = this.getName() + " (missing)" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
private import codeql.swift.generated.decl.NominalTypeDecl
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* A class, struct, enum or protocol.
|
||||
*/
|
||||
class NominalTypeDecl extends Generated::NominalTypeDecl { }
|
||||
class NominalTypeDecl extends Generated::NominalTypeDecl { }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.decl.OperatorDecl
|
||||
|
||||
class OperatorDecl extends Generated::OperatorDecl {
|
||||
module Impl {
|
||||
class OperatorDecl extends Generated::OperatorDecl {
|
||||
override string toString() { result = this.getName() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
private import codeql.swift.generated.decl.ParamDecl
|
||||
private import codeql.swift.elements.Callable
|
||||
|
||||
class ParamDecl extends Generated::ParamDecl {
|
||||
module Impl {
|
||||
class ParamDecl extends Generated::ParamDecl {
|
||||
/** Gets the function which declares this parameter. */
|
||||
Callable getDeclaringFunction() { result.getAParam() = this }
|
||||
|
||||
@@ -10,10 +11,10 @@ class ParamDecl extends Generated::ParamDecl {
|
||||
* or -1 if this is `self`.
|
||||
*/
|
||||
int getIndex() { exists(Callable func | func.getParam(result) = this) }
|
||||
}
|
||||
}
|
||||
|
||||
/** A `self` parameter. */
|
||||
class SelfParamDecl extends ParamDecl {
|
||||
/** A `self` parameter. */
|
||||
class SelfParamDecl extends ParamDecl {
|
||||
Callable call;
|
||||
|
||||
SelfParamDecl() { call.getSelfParam() = this }
|
||||
@@ -21,4 +22,5 @@ class SelfParamDecl extends ParamDecl {
|
||||
override Callable getDeclaringFunction() { result = call }
|
||||
|
||||
override int getIndex() { result = -1 }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.decl.PatternBindingDecl
|
||||
|
||||
class PatternBindingDecl extends Generated::PatternBindingDecl {
|
||||
module Impl {
|
||||
class PatternBindingDecl extends Generated::PatternBindingDecl {
|
||||
override string toString() { result = "var ... = ..." }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
private import codeql.swift.generated.decl.PoundDiagnosticDecl
|
||||
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
module Impl {
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
* A diagnostic directive, which is either `#error` or `#warning`.
|
||||
*/
|
||||
class PoundDiagnosticDecl extends Generated::PoundDiagnosticDecl {
|
||||
class PoundDiagnosticDecl extends Generated::PoundDiagnosticDecl {
|
||||
override string toString() {
|
||||
this.isError() and result = "#error(...)"
|
||||
or
|
||||
@@ -14,4 +15,5 @@ class PoundDiagnosticDecl extends Generated::PoundDiagnosticDecl {
|
||||
predicate isError() { this.getKind() = 1 }
|
||||
|
||||
predicate isWarning() { this.getKind() = 2 }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.decl.PrecedenceGroupDecl
|
||||
|
||||
class PrecedenceGroupDecl extends Generated::PrecedenceGroupDecl {
|
||||
module Impl {
|
||||
class PrecedenceGroupDecl extends Generated::PrecedenceGroupDecl {
|
||||
override string toString() { result = "precedencegroup ..." }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
private import ParamDeclImpl
|
||||
|
||||
final class SelfParamDecl = Impl::SelfParamDecl;
|
||||
9
swift/ql/lib/codeql/swift/elements/decl/SetObserver.qll
Normal file
9
swift/ql/lib/codeql/swift/elements/decl/SetObserver.qll
Normal file
@@ -0,0 +1,9 @@
|
||||
private import Accessor
|
||||
|
||||
final class WillSetObserver extends Accessor {
|
||||
WillSetObserver() { this.isWillSet() }
|
||||
}
|
||||
|
||||
class DidSetObserver extends Accessor {
|
||||
DidSetObserver() { this.isDidSet() }
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.decl.SubscriptDecl
|
||||
|
||||
class SubscriptDecl extends Generated::SubscriptDecl {
|
||||
module Impl {
|
||||
class SubscriptDecl extends Generated::SubscriptDecl {
|
||||
override string toString() { result = "subscript ..." }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.decl.TopLevelCodeDecl
|
||||
|
||||
class TopLevelCodeDecl extends Generated::TopLevelCodeDecl {
|
||||
module Impl {
|
||||
class TopLevelCodeDecl extends Generated::TopLevelCodeDecl {
|
||||
override string toString() { result = this.getBody().toString() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
private import codeql.swift.generated.decl.TypeAliasDecl
|
||||
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
module Impl {
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
* A declaration of a type alias to another type. For example:
|
||||
* ```
|
||||
* typealias MyInt = Int
|
||||
* ```
|
||||
*/
|
||||
class TypeAliasDecl extends Generated::TypeAliasDecl { }
|
||||
class TypeAliasDecl extends Generated::TypeAliasDecl { }
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ private import codeql.swift.generated.decl.TypeDecl
|
||||
private import codeql.swift.elements.type.AnyGenericType
|
||||
private import swift
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* A Swift type declaration, for example a class, struct, enum or protocol
|
||||
* declaration.
|
||||
*
|
||||
@@ -16,7 +17,7 @@ private import swift
|
||||
* Not all types have type declarations, for example built-in types do not
|
||||
* have type declarations.
|
||||
*/
|
||||
class TypeDecl extends Generated::TypeDecl {
|
||||
class TypeDecl extends Generated::TypeDecl {
|
||||
override string toString() { result = this.getName() }
|
||||
|
||||
/**
|
||||
@@ -25,7 +26,9 @@ class TypeDecl extends Generated::TypeDecl {
|
||||
* This is the same as `getImmediateInheritedType`.
|
||||
* DEPRECATED: either use `getImmediateInheritedType` or unindexed `getABaseType`.
|
||||
*/
|
||||
deprecated Type getImmediateBaseType(int index) { result = this.getImmediateInheritedType(index) }
|
||||
deprecated Type getImmediateBaseType(int index) {
|
||||
result = this.getImmediateInheritedType(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the `index`th base type of this type declaration (0-based).
|
||||
@@ -108,7 +111,9 @@ class TypeDecl extends Generated::TypeDecl {
|
||||
result = this.getEnclosingDecl().(TypeDecl).getFullName() + "." + this.getName()
|
||||
or
|
||||
result =
|
||||
unique(NominalTypeDecl td | td = this.getEnclosingDecl().(ExtensionDecl).getExtendedTypeDecl())
|
||||
.getFullName() + "." + this.getName()
|
||||
unique(NominalTypeDecl td |
|
||||
td = this.getEnclosingDecl().(ExtensionDecl).getExtendedTypeDecl()
|
||||
).getFullName() + "." + this.getName()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,11 @@ private import codeql.swift.generated.decl.ValueDecl
|
||||
private import codeql.swift.elements.decl.CapturedDecl
|
||||
private import codeql.swift.elements.expr.DeclRefExpr
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* A declaration that introduces a value with a type.
|
||||
*/
|
||||
class ValueDecl extends Generated::ValueDecl {
|
||||
class ValueDecl extends Generated::ValueDecl {
|
||||
/**
|
||||
* Gets a capture of this declaration in the scope of a closure.
|
||||
*/
|
||||
@@ -20,4 +21,5 @@ class ValueDecl extends Generated::ValueDecl {
|
||||
* Gets an expression that references this declaration.
|
||||
*/
|
||||
DeclRefExpr getAnAccess() { result.getDecl() = this }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
private import codeql.swift.generated.decl.VarDecl
|
||||
private import codeql.swift.elements.decl.Decl
|
||||
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
module Impl {
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
* A declaration of a variable such as
|
||||
* * a local variable in a function:
|
||||
* ```
|
||||
@@ -20,15 +21,15 @@ private import codeql.swift.elements.decl.Decl
|
||||
* ```
|
||||
* * ...
|
||||
*/
|
||||
class VarDecl extends Generated::VarDecl {
|
||||
class VarDecl extends Generated::VarDecl {
|
||||
override string toString() { result = this.getName() }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* A field declaration. That is, a variable declaration that is a member of a
|
||||
* class, struct, enum or protocol.
|
||||
*/
|
||||
class FieldDecl extends VarDecl {
|
||||
class FieldDecl extends VarDecl {
|
||||
FieldDecl() { this = any(Decl ctx).getAMember() }
|
||||
|
||||
/**
|
||||
@@ -53,4 +54,5 @@ class FieldDecl extends VarDecl {
|
||||
this.hasQualifiedName(typeName, fieldName) and
|
||||
this.getModule().getFullName() = moduleName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ private import codeql.swift.elements.expr.DotSyntaxBaseIgnoredExpr
|
||||
private import codeql.swift.elements.expr.AutoClosureExpr
|
||||
private import codeql.swift.elements.decl.Method
|
||||
|
||||
class ApplyExpr extends Generated::ApplyExpr {
|
||||
module Impl {
|
||||
class ApplyExpr extends Generated::ApplyExpr {
|
||||
Callable getStaticTarget() { result = this.getFunction().(DeclRefExpr).getDecl() }
|
||||
|
||||
/** Gets the method qualifier, if this is applying a method */
|
||||
@@ -26,9 +27,9 @@ class ApplyExpr extends Generated::ApplyExpr {
|
||||
not exists(this.getStaticTarget()) and
|
||||
result = "call to ..."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MethodApplyExpr extends ApplyExpr {
|
||||
class MethodApplyExpr extends ApplyExpr {
|
||||
private MethodLookupExpr method;
|
||||
|
||||
MethodApplyExpr() { method = this.getFunction() }
|
||||
@@ -36,9 +37,9 @@ class MethodApplyExpr extends ApplyExpr {
|
||||
override Method getStaticTarget() { result = method.getMethod() }
|
||||
|
||||
override Expr getQualifier() { result = method.getBase() }
|
||||
}
|
||||
}
|
||||
|
||||
private class PartialDotSyntaxBaseIgnoredApplyExpr extends ApplyExpr {
|
||||
private class PartialDotSyntaxBaseIgnoredApplyExpr extends ApplyExpr {
|
||||
private DotSyntaxBaseIgnoredExpr expr;
|
||||
|
||||
PartialDotSyntaxBaseIgnoredApplyExpr() { expr = this.getFunction() }
|
||||
@@ -48,12 +49,13 @@ private class PartialDotSyntaxBaseIgnoredApplyExpr extends ApplyExpr {
|
||||
override Expr getQualifier() { result = expr.getQualifier() }
|
||||
|
||||
override string toString() { result = "call to " + expr }
|
||||
}
|
||||
}
|
||||
|
||||
private class FullDotSyntaxBaseIgnoredApplyExpr extends ApplyExpr {
|
||||
private class FullDotSyntaxBaseIgnoredApplyExpr extends ApplyExpr {
|
||||
private PartialDotSyntaxBaseIgnoredApplyExpr expr;
|
||||
|
||||
FullDotSyntaxBaseIgnoredApplyExpr() { expr = this.getFunction() }
|
||||
|
||||
override AutoClosureExpr getStaticTarget() { result = expr.getStaticTarget().getExpr() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
private import codeql.swift.generated.expr.Argument
|
||||
private import codeql.swift.elements.expr.ApplyExpr
|
||||
|
||||
class Argument extends Generated::Argument {
|
||||
module Impl {
|
||||
class Argument extends Generated::Argument {
|
||||
override string toString() { result = this.getLabel() + ": " + this.getExpr().toString() }
|
||||
|
||||
int getIndex() { any(ApplyExpr apply).getArgument(result) = this }
|
||||
|
||||
ApplyExpr getApplyExpr() { result.getAnArgument() = this }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.ArrayExpr
|
||||
|
||||
class ArrayExpr extends Generated::ArrayExpr {
|
||||
module Impl {
|
||||
class ArrayExpr extends Generated::ArrayExpr {
|
||||
override string toString() { result = "[...]" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
private import codeql.swift.generated.expr.AssignExpr
|
||||
private import codeql.swift.elements.expr.BinaryExpr
|
||||
private import codeql.swift.elements.expr.BinaryExprImpl::Impl
|
||||
private import codeql.swift.elements.expr.ExprImpl::Impl as ExprImpl
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* An assignment expression. For example:
|
||||
* ```
|
||||
* x = 0
|
||||
@@ -9,24 +11,14 @@ private import codeql.swift.elements.expr.BinaryExpr
|
||||
* z <<= 1
|
||||
* ```
|
||||
*/
|
||||
class Assignment extends Expr {
|
||||
Assignment() {
|
||||
this instanceof AssignExpr or
|
||||
this instanceof AssignArithmeticOperationEx or
|
||||
this instanceof AssignBitwiseOperationEx or
|
||||
this instanceof AssignPointwiseOperationEx
|
||||
}
|
||||
|
||||
abstract class Assignment extends ExprImpl::Expr {
|
||||
/**
|
||||
* Gets the destination of this assignment. For example `x` in:
|
||||
* ```
|
||||
* x = y
|
||||
* ```
|
||||
*/
|
||||
Expr getDest() {
|
||||
result = this.(AssignExpr).getDest() or
|
||||
result = this.(AssignOperation).getLeftOperand()
|
||||
}
|
||||
abstract Expr getDest();
|
||||
|
||||
/**
|
||||
* Gets the source of this assignment. For example `y` in:
|
||||
@@ -34,10 +26,7 @@ class Assignment extends Expr {
|
||||
* x = y
|
||||
* ```
|
||||
*/
|
||||
Expr getSource() {
|
||||
result = this.(AssignExpr).getSource() or
|
||||
result = this.(AssignOperation).getRightOperand()
|
||||
}
|
||||
abstract Expr getSource();
|
||||
|
||||
/**
|
||||
* Holds if this assignment expression uses an overflow operator, that is,
|
||||
@@ -50,205 +39,195 @@ class Assignment extends Expr {
|
||||
this.(AssignOperation).getOperator().getName() =
|
||||
["&*=(_:_:)", "&+=(_:_:)", "&-=(_:_:)", "&<<=(_:_:)", "&>>=(_:_:)"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* A simple assignment expression using the `=` operator:
|
||||
* ```
|
||||
* x = 0
|
||||
* ```
|
||||
*/
|
||||
class AssignExpr extends Generated::AssignExpr {
|
||||
class AssignExpr extends Generated::AssignExpr {
|
||||
override string toString() { result = " ... = ..." }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
private class AssignExprAssignment extends Assignment instanceof AssignExpr {
|
||||
override Expr getDest() { result = AssignExpr.super.getDest() }
|
||||
|
||||
override Expr getSource() { result = AssignExpr.super.getSource() }
|
||||
}
|
||||
|
||||
/**
|
||||
* An assignment expression apart from `=`. For example:
|
||||
* ```
|
||||
* x += 1
|
||||
* y &= z
|
||||
* ```
|
||||
*/
|
||||
class AssignOperation extends Assignment, BinaryExpr {
|
||||
AssignOperation() {
|
||||
this instanceof AssignArithmeticOperationEx or
|
||||
this instanceof AssignBitwiseOperationEx or
|
||||
this instanceof AssignPointwiseOperationEx
|
||||
}
|
||||
}
|
||||
abstract class AssignOperation extends Assignment, BinaryExpr {
|
||||
override Expr getDest() { result = this.getLeftOperand() }
|
||||
|
||||
/**
|
||||
override Expr getSource() { result = this.getRightOperand() }
|
||||
}
|
||||
|
||||
/**
|
||||
* An arithmetic assignment expression. For example:
|
||||
* ```
|
||||
* x += 1
|
||||
* y *= z
|
||||
* ```
|
||||
*/
|
||||
class AssignArithmeticOperation extends AssignOperation instanceof AssignArithmeticOperationEx { }
|
||||
abstract class AssignArithmeticOperation extends AssignOperation { }
|
||||
|
||||
/**
|
||||
* Private abstract class, extended to define the scope of `AssignArithmeticOperation`.
|
||||
*/
|
||||
abstract private class AssignArithmeticOperationEx extends BinaryExpr { }
|
||||
|
||||
/**
|
||||
/**
|
||||
* A bitwise assignment expression. For example:
|
||||
* ```
|
||||
* x &= y
|
||||
* z <<= 1
|
||||
* ```
|
||||
*/
|
||||
class AssignBitwiseOperation extends AssignOperation instanceof AssignBitwiseOperationEx { }
|
||||
abstract class AssignBitwiseOperation extends AssignOperation { }
|
||||
|
||||
/**
|
||||
* Private abstract class, extended to define the scope of `AssignBitwiseOperation`.
|
||||
*/
|
||||
abstract private class AssignBitwiseOperationEx extends BinaryExpr { }
|
||||
|
||||
/**
|
||||
/**
|
||||
* A pointwise assignment expression. For example:
|
||||
* ```
|
||||
* x .&= y
|
||||
* ```
|
||||
*/
|
||||
class AssignPointwiseOperation extends AssignOperation instanceof AssignPointwiseOperationEx { }
|
||||
abstract class AssignPointwiseOperation extends AssignOperation { }
|
||||
|
||||
/**
|
||||
* Private abstract class, extended to define the scope of `AssignPointwiseOperation`.
|
||||
*/
|
||||
abstract private class AssignPointwiseOperationEx extends BinaryExpr { }
|
||||
|
||||
/**
|
||||
/**
|
||||
* An addition assignment expression:
|
||||
* ```
|
||||
* a += b
|
||||
* a &+= b
|
||||
* ```
|
||||
*/
|
||||
class AssignAddExpr extends AssignArithmeticOperationEx {
|
||||
class AssignAddExpr extends AssignArithmeticOperation {
|
||||
AssignAddExpr() { this.getOperator().getName() = ["+=(_:_:)", "&+=(_:_:)"] }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* A subtraction assignment expression:
|
||||
* ```
|
||||
* a -= b
|
||||
* a &-= b
|
||||
* ```
|
||||
*/
|
||||
class AssignSubExpr extends AssignArithmeticOperationEx {
|
||||
class AssignSubExpr extends AssignArithmeticOperation {
|
||||
AssignSubExpr() { this.getOperator().getName() = ["-=(_:_:)", "&-=(_:_:)"] }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* A multiplication assignment expression:
|
||||
* ```
|
||||
* a *= b
|
||||
* a &*= b
|
||||
* ```
|
||||
*/
|
||||
class AssignMulExpr extends AssignArithmeticOperationEx {
|
||||
class AssignMulExpr extends AssignArithmeticOperation {
|
||||
AssignMulExpr() { this.getOperator().getName() = ["*=(_:_:)", "&*=(_:_:)"] }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* A division assignment expression:
|
||||
* ```
|
||||
* a /= b
|
||||
* ```
|
||||
*/
|
||||
class AssignDivExpr extends AssignArithmeticOperationEx {
|
||||
class AssignDivExpr extends AssignArithmeticOperation {
|
||||
AssignDivExpr() { this.getOperator().getName() = "/=(_:_:)" }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* A remainder assignment expression:
|
||||
* ```
|
||||
* a %= b
|
||||
* ```
|
||||
*/
|
||||
class AssignRemExpr extends AssignArithmeticOperationEx {
|
||||
class AssignRemExpr extends AssignArithmeticOperation {
|
||||
AssignRemExpr() { this.getOperator().getName() = "%=(_:_:)" }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* A left-shift assignment expression:
|
||||
* ```
|
||||
* a <<= b
|
||||
* a &<<= b
|
||||
* ```
|
||||
*/
|
||||
class AssignLShiftExpr extends AssignBitwiseOperationEx {
|
||||
class AssignLShiftExpr extends AssignBitwiseOperation {
|
||||
AssignLShiftExpr() { this.getOperator().getName() = ["<<=(_:_:)", "&<<=(_:_:)"] }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* A right-shift assignment expression:
|
||||
* ```
|
||||
* a >>= b
|
||||
* a &>>= b
|
||||
* ```
|
||||
*/
|
||||
class AssignRShiftExpr extends AssignBitwiseOperationEx {
|
||||
class AssignRShiftExpr extends AssignBitwiseOperation {
|
||||
AssignRShiftExpr() { this.getOperator().getName() = [">>=(_:_:)", "&>>=(_:_:)"] }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* A bitwise-and assignment expression:
|
||||
* ```
|
||||
* a &= b
|
||||
* ```
|
||||
*/
|
||||
class AssignAndExpr extends AssignBitwiseOperationEx {
|
||||
class AssignAndExpr extends AssignBitwiseOperation {
|
||||
AssignAndExpr() { this.getOperator().getName() = "&=(_:_:)" }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* A bitwise-or assignment expression:
|
||||
* ```
|
||||
* a |= b
|
||||
* ```
|
||||
*/
|
||||
class AssignOrExpr extends AssignBitwiseOperationEx {
|
||||
class AssignOrExpr extends AssignBitwiseOperation {
|
||||
AssignOrExpr() { this.getOperator().getName() = "|=(_:_:)" }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* A bitwise exclusive-or assignment expression:
|
||||
* ```
|
||||
* a ^= b
|
||||
* ```
|
||||
*/
|
||||
class AssignXorExpr extends AssignBitwiseOperationEx {
|
||||
class AssignXorExpr extends AssignBitwiseOperation {
|
||||
AssignXorExpr() { this.getOperator().getName() = "^=(_:_:)" }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* A pointwise bitwise-and assignment expression:
|
||||
* ```
|
||||
* a .&= b
|
||||
* ```
|
||||
*/
|
||||
class AssignPointwiseAndExpr extends AssignPointwiseOperationEx {
|
||||
class AssignPointwiseAndExpr extends AssignPointwiseOperation {
|
||||
AssignPointwiseAndExpr() { this.getOperator().getName() = ".&=(_:_:)" }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* A pointwise bitwise-or assignment expression:
|
||||
* ```
|
||||
* a .|= b
|
||||
* ```
|
||||
*/
|
||||
class AssignPointwiseOrExpr extends AssignPointwiseOperationEx {
|
||||
class AssignPointwiseOrExpr extends AssignPointwiseOperation {
|
||||
AssignPointwiseOrExpr() { this.getOperator().getName() = ".|=(_:_:)" }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* A pointwise bitwise exclusive-or assignment expression:
|
||||
* ```
|
||||
* a .^= b
|
||||
* ```
|
||||
*/
|
||||
class AssignPointwiseXorExpr extends AssignPointwiseOperationEx {
|
||||
class AssignPointwiseXorExpr extends AssignPointwiseOperation {
|
||||
AssignPointwiseXorExpr() { this.getOperator().getName() = ".^=(_:_:)" }
|
||||
}
|
||||
}
|
||||
|
||||
37
swift/ql/lib/codeql/swift/elements/expr/Assignment.qll
Normal file
37
swift/ql/lib/codeql/swift/elements/expr/Assignment.qll
Normal file
@@ -0,0 +1,37 @@
|
||||
private import AssignExprImpl
|
||||
|
||||
final class Assignment = Impl::Assignment;
|
||||
|
||||
final class AssignOperation = Impl::AssignOperation;
|
||||
|
||||
final class AssignArithmeticOperation = Impl::AssignArithmeticOperation;
|
||||
|
||||
final class AssignBitwiseOperation = Impl::AssignBitwiseOperation;
|
||||
|
||||
final class AssignPointwiseOperation = Impl::AssignPointwiseOperation;
|
||||
|
||||
final class AssignAddExpr = Impl::AssignAddExpr;
|
||||
|
||||
final class AssignSubExpr = Impl::AssignSubExpr;
|
||||
|
||||
final class AssignMulExpr = Impl::AssignMulExpr;
|
||||
|
||||
final class AssignDivExpr = Impl::AssignDivExpr;
|
||||
|
||||
final class AssignRemExpr = Impl::AssignRemExpr;
|
||||
|
||||
final class AssignLShiftExpr = Impl::AssignLShiftExpr;
|
||||
|
||||
final class AssignRShiftExpr = Impl::AssignRShiftExpr;
|
||||
|
||||
final class AssignAndExpr = Impl::AssignAndExpr;
|
||||
|
||||
final class AssignOrExpr = Impl::AssignOrExpr;
|
||||
|
||||
final class AssignXorExpr = Impl::AssignXorExpr;
|
||||
|
||||
final class AssignPointwiseAndExpr = Impl::AssignPointwiseAndExpr;
|
||||
|
||||
final class AssignPointwiseOrExpr = Impl::AssignPointwiseOrExpr;
|
||||
|
||||
final class AssignPointwiseXorExpr = Impl::AssignPointwiseXorExpr;
|
||||
@@ -2,7 +2,8 @@ private import codeql.swift.generated.expr.AutoClosureExpr
|
||||
private import codeql.swift.elements.stmt.ReturnStmt
|
||||
private import codeql.swift.elements.expr.Expr
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* A Swift autoclosure expression, that is, a closure automatically generated
|
||||
* around an argument when the parameter has the `@autoclosure` attribute or
|
||||
* for the right-hand operand of short-circuiting logical operations. For
|
||||
@@ -15,7 +16,7 @@ private import codeql.swift.elements.expr.Expr
|
||||
* myFunction(0)
|
||||
* ```
|
||||
*/
|
||||
class AutoClosureExpr extends Generated::AutoClosureExpr {
|
||||
class AutoClosureExpr extends Generated::AutoClosureExpr {
|
||||
/**
|
||||
* Gets the implicit return statement generated by this autoclosure expression.
|
||||
*/
|
||||
@@ -27,4 +28,5 @@ class AutoClosureExpr extends Generated::AutoClosureExpr {
|
||||
Expr getExpr() { result = this.getReturn().getResult() }
|
||||
|
||||
override string toString() { result = this.getBody().toString() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.AwaitExpr
|
||||
|
||||
class AwaitExpr extends Generated::AwaitExpr {
|
||||
module Impl {
|
||||
class AwaitExpr extends Generated::AwaitExpr {
|
||||
override string toString() { result = "await ..." }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,15 @@ private import codeql.swift.generated.expr.BinaryExpr
|
||||
private import codeql.swift.elements.expr.Expr
|
||||
private import codeql.swift.elements.decl.Function
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* A Swift binary expression, that is, an expression that appears between its
|
||||
* two operands. For example:
|
||||
* ```
|
||||
* x + y
|
||||
* ```
|
||||
*/
|
||||
class BinaryExpr extends Generated::BinaryExpr {
|
||||
class BinaryExpr extends Generated::BinaryExpr {
|
||||
/**
|
||||
* Gets the left operand (left expression) of this binary expression.
|
||||
*/
|
||||
@@ -33,4 +34,5 @@ class BinaryExpr extends Generated::BinaryExpr {
|
||||
override string toString() { result = "... " + this.getFunction().toString() + " ..." }
|
||||
|
||||
override Function getStaticTarget() { result = super.getStaticTarget() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.BindOptionalExpr
|
||||
|
||||
class BindOptionalExpr extends Generated::BindOptionalExpr {
|
||||
module Impl {
|
||||
class BindOptionalExpr extends Generated::BindOptionalExpr {
|
||||
override string toString() { result = "...?" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
private import codeql.swift.generated.expr.BooleanLiteralExpr
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* A boolean literal. For example `true` in:
|
||||
* ```
|
||||
* let x = true
|
||||
* ```
|
||||
*/
|
||||
class BooleanLiteralExpr extends Generated::BooleanLiteralExpr {
|
||||
class BooleanLiteralExpr extends Generated::BooleanLiteralExpr {
|
||||
override string toString() { result = this.getValue().toString() }
|
||||
|
||||
override string getValueString() { result = this.getValue().toString() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
|
||||
private import codeql.swift.generated.expr.BuiltinLiteralExpr
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* A Swift literal of a kind that is built in to the Swift language.
|
||||
*/
|
||||
class BuiltinLiteralExpr extends Generated::BuiltinLiteralExpr {
|
||||
class BuiltinLiteralExpr extends Generated::BuiltinLiteralExpr {
|
||||
/**
|
||||
* Gets the value of this literal expression (as a string).
|
||||
*/
|
||||
string getValueString() { none() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
private import codeql.swift.generated.expr.CaptureListExpr
|
||||
private import codeql.swift.elements.pattern.NamedPattern
|
||||
|
||||
class CaptureListExpr extends Generated::CaptureListExpr {
|
||||
module Impl {
|
||||
class CaptureListExpr extends Generated::CaptureListExpr {
|
||||
override string toString() { result = this.getClosureBody().toString() }
|
||||
|
||||
override VarDecl getVariable(int index) {
|
||||
// all capture binding declarations consist of a single named pattern
|
||||
result = this.getBindingDecl(index).getPattern(0).(NamedPattern).getVarDecl()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.ClosureExpr
|
||||
|
||||
class ClosureExpr extends Generated::ClosureExpr {
|
||||
module Impl {
|
||||
class ClosureExpr extends Generated::ClosureExpr {
|
||||
override string toString() { result = "{ ... }" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
private import codeql.swift.generated.expr.DeclRefExpr
|
||||
private import codeql.swift.elements.decl.CapturedDecl
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* An expression that references or accesses a declaration.
|
||||
*/
|
||||
class DeclRefExpr extends Generated::DeclRefExpr {
|
||||
class DeclRefExpr extends Generated::DeclRefExpr {
|
||||
override string toString() {
|
||||
if exists(this.getDecl().toString())
|
||||
then result = this.getDecl().toString()
|
||||
@@ -20,4 +21,5 @@ class DeclRefExpr extends Generated::DeclRefExpr {
|
||||
* Holds if this expression references a closure capture.
|
||||
*/
|
||||
predicate hasCapturedDecl() { exists(this.getCapturedDecl()) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.DefaultArgumentExpr
|
||||
|
||||
class DefaultArgumentExpr extends Generated::DefaultArgumentExpr {
|
||||
module Impl {
|
||||
class DefaultArgumentExpr extends Generated::DefaultArgumentExpr {
|
||||
override string toString() { result = "default " + this.getParamDecl().getName() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.DictionaryExpr
|
||||
|
||||
class DictionaryExpr extends Generated::DictionaryExpr {
|
||||
module Impl {
|
||||
class DictionaryExpr extends Generated::DictionaryExpr {
|
||||
override string toString() { result = "[...]" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
private import codeql.swift.generated.expr.DifferentiableFunctionExtractOriginalExpr
|
||||
|
||||
class DifferentiableFunctionExtractOriginalExpr extends Generated::DifferentiableFunctionExtractOriginalExpr
|
||||
{ }
|
||||
module Impl {
|
||||
class DifferentiableFunctionExtractOriginalExpr extends Generated::DifferentiableFunctionExtractOriginalExpr
|
||||
{ }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.DiscardAssignmentExpr
|
||||
|
||||
class DiscardAssignmentExpr extends Generated::DiscardAssignmentExpr {
|
||||
module Impl {
|
||||
class DiscardAssignmentExpr extends Generated::DiscardAssignmentExpr {
|
||||
override string toString() { result = "_" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.DotSelfExpr
|
||||
|
||||
class DotSelfExpr extends Generated::DotSelfExpr {
|
||||
module Impl {
|
||||
class DotSelfExpr extends Generated::DotSelfExpr {
|
||||
override string toString() { result = ".self" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@ private import codeql.swift.elements.expr.CallExpr
|
||||
private import codeql.swift.elements.expr.TypeExpr
|
||||
private import codeql.swift.elements.decl.Method
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* An expression representing a partially applied lookup of an instance property via the receiver's type object.
|
||||
*
|
||||
* An example is the sub-expression `SomeClass.instanceMethod` of
|
||||
@@ -14,7 +15,7 @@ private import codeql.swift.elements.decl.Method
|
||||
* `{ (someInstance: SomeClass) in { (arg, ...) in someInstance.instanceMethod(arg, ...) } }`,
|
||||
* which in turn can be accessed using the `getSubExpr/0` predicate.
|
||||
*/
|
||||
class DotSyntaxBaseIgnoredExpr extends Generated::DotSyntaxBaseIgnoredExpr {
|
||||
class DotSyntaxBaseIgnoredExpr extends Generated::DotSyntaxBaseIgnoredExpr {
|
||||
override string toString() {
|
||||
result =
|
||||
any(string base |
|
||||
@@ -38,4 +39,5 @@ class DotSyntaxBaseIgnoredExpr extends Generated::DotSyntaxBaseIgnoredExpr {
|
||||
.(CallExpr)
|
||||
.getStaticTarget()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.DynamicMemberRefExpr
|
||||
|
||||
class DynamicMemberRefExpr extends Generated::DynamicMemberRefExpr {
|
||||
module Impl {
|
||||
class DynamicMemberRefExpr extends Generated::DynamicMemberRefExpr {
|
||||
override string toString() { result = "." + this.getMember().toString() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.DynamicSubscriptExpr
|
||||
|
||||
class DynamicSubscriptExpr extends Generated::DynamicSubscriptExpr {
|
||||
module Impl {
|
||||
class DynamicSubscriptExpr extends Generated::DynamicSubscriptExpr {
|
||||
override string toString() { result = this.getMember().toString() + "[...]" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.DynamicTypeExpr
|
||||
|
||||
class DynamicTypeExpr extends Generated::DynamicTypeExpr {
|
||||
module Impl {
|
||||
class DynamicTypeExpr extends Generated::DynamicTypeExpr {
|
||||
override string toString() { result = "type(of: ...)" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.EnumIsCaseExpr
|
||||
|
||||
class EnumIsCaseExpr extends Generated::EnumIsCaseExpr {
|
||||
module Impl {
|
||||
class EnumIsCaseExpr extends Generated::EnumIsCaseExpr {
|
||||
override string toString() { result = "... is " + this.getElement().toString() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
private import codeql.swift.generated.expr.ExplicitCastExpr
|
||||
|
||||
class ExplicitCastExpr extends Generated::ExplicitCastExpr {
|
||||
module Impl {
|
||||
class ExplicitCastExpr extends Generated::ExplicitCastExpr {
|
||||
override predicate convertsFrom(Expr e) { e = this.getImmediateSubExpr() }
|
||||
|
||||
override string toString() { result = "(" + this.getType() + ") ..." }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
private import codeql.swift.generated.expr.ExplicitClosureExpr
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* A Swift explicit closure expr, that is, a closure written using
|
||||
* `{ ... -> ... in ... }` syntax rather than automatically generated by the
|
||||
* compiler.
|
||||
*/
|
||||
class ExplicitClosureExpr extends Generated::ExplicitClosureExpr { }
|
||||
class ExplicitClosureExpr extends Generated::ExplicitClosureExpr { }
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
private import codeql.swift.generated.expr.Expr
|
||||
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
module Impl {
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
* The base class for all expressions in Swift.
|
||||
*/
|
||||
class Expr extends Generated::Expr {
|
||||
class Expr extends Generated::Expr {
|
||||
final override Expr getResolveStep() { this.convertsFrom(result) }
|
||||
|
||||
predicate convertsFrom(Expr e) { none() } // overridden by subclasses
|
||||
@@ -24,4 +25,5 @@ class Expr extends Generated::Expr {
|
||||
Expr getFullyConverted() { result = this.getFullyUnresolved() }
|
||||
|
||||
Expr getUnconverted() { result = this.resolve() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
private import codeql.swift.generated.expr.FloatLiteralExpr
|
||||
|
||||
class FloatLiteralExpr extends Generated::FloatLiteralExpr {
|
||||
module Impl {
|
||||
class FloatLiteralExpr extends Generated::FloatLiteralExpr {
|
||||
override string toString() { result = this.getStringValue() }
|
||||
|
||||
override string getValueString() { result = this.getStringValue() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.ForceTryExpr
|
||||
|
||||
class ForceTryExpr extends Generated::ForceTryExpr {
|
||||
module Impl {
|
||||
class ForceTryExpr extends Generated::ForceTryExpr {
|
||||
override string toString() { result = "try! ..." }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.ForceValueExpr
|
||||
|
||||
class ForceValueExpr extends Generated::ForceValueExpr {
|
||||
module Impl {
|
||||
class ForceValueExpr extends Generated::ForceValueExpr {
|
||||
override string toString() { result = "...!" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.IdentityExpr
|
||||
|
||||
class IdentityExpr extends Generated::IdentityExpr {
|
||||
module Impl {
|
||||
class IdentityExpr extends Generated::IdentityExpr {
|
||||
override predicate convertsFrom(Expr e) { e = this.getImmediateSubExpr() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
private import codeql.swift.generated.expr.IfExpr
|
||||
|
||||
class IfExpr extends Generated::IfExpr {
|
||||
module Impl {
|
||||
class IfExpr extends Generated::IfExpr {
|
||||
Expr getBranch(boolean b) {
|
||||
b = true and
|
||||
result = this.getThenExpr()
|
||||
@@ -10,4 +11,5 @@ class IfExpr extends Generated::IfExpr {
|
||||
}
|
||||
|
||||
override string toString() { result = "... ? ... : ..." }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
private import codeql.swift.generated.expr.ImplicitConversionExpr
|
||||
|
||||
class ImplicitConversionExpr extends Generated::ImplicitConversionExpr {
|
||||
module Impl {
|
||||
class ImplicitConversionExpr extends Generated::ImplicitConversionExpr {
|
||||
override predicate convertsFrom(Expr e) { e = this.getImmediateSubExpr() }
|
||||
|
||||
override string toString() { result = "(" + this.getType().toString() + ") ..." }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
private import codeql.swift.generated.expr.InOutExpr
|
||||
|
||||
class InOutExpr extends Generated::InOutExpr {
|
||||
module Impl {
|
||||
class InOutExpr extends Generated::InOutExpr {
|
||||
override string toString() { result = "&..." }
|
||||
|
||||
override predicate convertsFrom(Expr e) { e = this.getImmediateSubExpr() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
private import codeql.swift.generated.expr.IntegerLiteralExpr
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* An integer literal. For example `1` in:
|
||||
* ```
|
||||
* let x = 1
|
||||
* ```
|
||||
*/
|
||||
class IntegerLiteralExpr extends Generated::IntegerLiteralExpr {
|
||||
class IntegerLiteralExpr extends Generated::IntegerLiteralExpr {
|
||||
override string toString() { result = this.getStringValue() }
|
||||
|
||||
override string getValueString() { result = this.getStringValue() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.InterpolatedStringLiteralExpr
|
||||
|
||||
class InterpolatedStringLiteralExpr extends Generated::InterpolatedStringLiteralExpr {
|
||||
module Impl {
|
||||
class InterpolatedStringLiteralExpr extends Generated::InterpolatedStringLiteralExpr {
|
||||
override string toString() { result = "\"...\"" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.IsExpr
|
||||
|
||||
class IsExpr extends Generated::IsExpr {
|
||||
module Impl {
|
||||
class IsExpr extends Generated::IsExpr {
|
||||
override string toString() { result = "... is ..." }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.KeyPathApplicationExpr
|
||||
|
||||
class KeyPathApplicationExpr extends Generated::KeyPathApplicationExpr {
|
||||
module Impl {
|
||||
class KeyPathApplicationExpr extends Generated::KeyPathApplicationExpr {
|
||||
override string toString() { result = "\\...[...]" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.KeyPathDotExpr
|
||||
|
||||
class KeyPathDotExpr extends Generated::KeyPathDotExpr {
|
||||
module Impl {
|
||||
class KeyPathDotExpr extends Generated::KeyPathDotExpr {
|
||||
override string toString() { result = "\\...." }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
private import codeql.swift.generated.expr.KeyPathExpr
|
||||
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
module Impl {
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
* A key-path expression.
|
||||
*/
|
||||
class KeyPathExpr extends Generated::KeyPathExpr {
|
||||
class KeyPathExpr extends Generated::KeyPathExpr {
|
||||
override string toString() { result = "#keyPath(...)" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.LazyInitializationExpr
|
||||
|
||||
class LazyInitializationExpr extends Generated::LazyInitializationExpr {
|
||||
module Impl {
|
||||
class LazyInitializationExpr extends Generated::LazyInitializationExpr {
|
||||
override string toString() { result = this.getSubExpr().toString() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
|
||||
private import codeql.swift.generated.expr.LiteralExpr
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* A Swift literal.
|
||||
*
|
||||
* This is the root class for all literals.
|
||||
*/
|
||||
class LiteralExpr extends Generated::LiteralExpr { }
|
||||
class LiteralExpr extends Generated::LiteralExpr { }
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
private import codeql.swift.generated.expr.MagicIdentifierLiteralExpr
|
||||
|
||||
/**
|
||||
module Impl {
|
||||
/**
|
||||
* An identifier literal that is expanded at compile time. For example `#file` in:
|
||||
* ```
|
||||
* let x = #file
|
||||
* ```
|
||||
*/
|
||||
class MagicIdentifierLiteralExpr extends Generated::MagicIdentifierLiteralExpr {
|
||||
class MagicIdentifierLiteralExpr extends Generated::MagicIdentifierLiteralExpr {
|
||||
override string toString() { result = "#..." }
|
||||
|
||||
override string getValueString() { none() } // TODO: value not yet extracted
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.MakeTemporarilyEscapableExpr
|
||||
|
||||
class MakeTemporarilyEscapableExpr extends Generated::MakeTemporarilyEscapableExpr {
|
||||
module Impl {
|
||||
class MakeTemporarilyEscapableExpr extends Generated::MakeTemporarilyEscapableExpr {
|
||||
override string toString() { result = this.getSubExpr().toString() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.MemberRefExpr
|
||||
|
||||
class MemberRefExpr extends Generated::MemberRefExpr {
|
||||
module Impl {
|
||||
class MemberRefExpr extends Generated::MemberRefExpr {
|
||||
override string toString() { result = "." + this.getMember().toString() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
private import ApplyExprImpl
|
||||
|
||||
final class MethodApplyExpr = Impl::MethodApplyExpr;
|
||||
@@ -1,4 +1,4 @@
|
||||
private import ApplyExprExt
|
||||
private import MethodApplyExpr
|
||||
private import codeql.swift.elements.expr.CallExpr
|
||||
private import codeql.swift.elements.expr.ApplyExpr
|
||||
private import codeql.swift.elements.expr.SuperRefExpr
|
||||
|
||||
@@ -7,7 +7,8 @@ private import codeql.swift.elements.decl.Method
|
||||
private import codeql.swift.generated.Raw
|
||||
private import codeql.swift.generated.Synth
|
||||
|
||||
class MethodLookupExpr extends Generated::MethodLookupExpr {
|
||||
module Impl {
|
||||
class MethodLookupExpr extends Generated::MethodLookupExpr {
|
||||
override string toString() { result = "." + this.getMember().toString() }
|
||||
|
||||
override Expr getImmediateBase() {
|
||||
@@ -28,4 +29,5 @@ class MethodLookupExpr extends Generated::MethodLookupExpr {
|
||||
|
||||
cached
|
||||
private Raw::SelfApplyExpr getUnderlying() { this = Synth::TMethodLookupExpr(result) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.NilLiteralExpr
|
||||
|
||||
class NilLiteralExpr extends Generated::NilLiteralExpr {
|
||||
module Impl {
|
||||
class NilLiteralExpr extends Generated::NilLiteralExpr {
|
||||
override string toString() { result = "nil" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
private import codeql.swift.generated.expr.ObjCSelectorExpr
|
||||
|
||||
class ObjCSelectorExpr extends Generated::ObjCSelectorExpr {
|
||||
module Impl {
|
||||
class ObjCSelectorExpr extends Generated::ObjCSelectorExpr {
|
||||
override string toString() { result = "#selector(...)" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
private import codeql.swift.generated.expr.ObjectLiteralExpr
|
||||
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
module Impl {
|
||||
// the following QLdoc is generated: if you need to edit it, do it in the schema file
|
||||
/**
|
||||
* An instance of `#fileLiteral`, `#imageLiteral` or `#colorLiteral` expressions, which are used in playgrounds.
|
||||
*/
|
||||
class ObjectLiteralExpr extends Generated::ObjectLiteralExpr { }
|
||||
class ObjectLiteralExpr extends Generated::ObjectLiteralExpr { }
|
||||
|
||||
class FileLiteralExpr extends ObjectLiteralExpr {
|
||||
class FileLiteralExpr extends ObjectLiteralExpr {
|
||||
FileLiteralExpr() { this.getKind() = 0 }
|
||||
|
||||
override string toString() { result = "#fileLiteral(...)" }
|
||||
}
|
||||
}
|
||||
|
||||
class ImageLiteralExpr extends ObjectLiteralExpr {
|
||||
class ImageLiteralExpr extends ObjectLiteralExpr {
|
||||
ImageLiteralExpr() { this.getKind() = 1 }
|
||||
|
||||
override string toString() { result = "#imageLiteral(...)" }
|
||||
}
|
||||
}
|
||||
|
||||
class ColorLiteralExpr extends ObjectLiteralExpr {
|
||||
class ColorLiteralExpr extends ObjectLiteralExpr {
|
||||
ColorLiteralExpr() { this.getKind() = 2 }
|
||||
|
||||
override string toString() { result = "#colorLiteral(...)" }
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user