Skip to content

Commit

Permalink
Swift: Revert Impl rename for manually added files
Browse files Browse the repository at this point in the history
  • Loading branch information
hvitved committed Sep 13, 2024
1 parent 62d3f85 commit 288cdc5
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private import codeql.swift.elements.decl.NominalTypeDecl
* }
* ```
*/
class ClassOrStructDecl extends NominalTypeDecl {
final class ClassOrStructDecl extends NominalTypeDecl {
ClassOrStructDecl() {
this instanceof ClassDecl
or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ private Decl getAMember(Decl ctx) {
/**
* A function that is a member of a class, struct, enum or protocol.
*/
class Method extends Function {
final class Method extends Function {
Method() {
this = getAMember(any(ClassDecl c))
or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ private import codeql.swift.elements.expr.DotSyntaxCallExpr
* a + b
* ```
*/
class ArithmeticOperation extends Expr {
final class ArithmeticOperation extends Expr {
ArithmeticOperation() {
this instanceof BinaryArithmeticOperation or
this instanceof UnaryArithmeticOperation
Expand All @@ -31,7 +31,7 @@ class ArithmeticOperation extends Expr {
* a + b
* ```
*/
class BinaryArithmeticOperation extends BinaryExpr {
final class BinaryArithmeticOperation extends BinaryExpr {
BinaryArithmeticOperation() {
this instanceof AddExpr or
this instanceof SubExpr or
Expand All @@ -48,7 +48,7 @@ class BinaryArithmeticOperation extends BinaryExpr {
* a &+ b
* ```
*/
class AddExpr extends BinaryExpr {
final class AddExpr extends BinaryExpr {
AddExpr() { this.getStaticTarget().getName() = ["+(_:_:)", "&+(_:_:)"] }
}

Expand All @@ -59,7 +59,7 @@ class AddExpr extends BinaryExpr {
* a &- b
* ```
*/
class SubExpr extends BinaryExpr {
final class SubExpr extends BinaryExpr {
SubExpr() { this.getStaticTarget().getName() = ["-(_:_:)", "&-(_:_:)"] }
}

Expand All @@ -70,7 +70,7 @@ class SubExpr extends BinaryExpr {
* a &* b
* ```
*/
class MulExpr extends BinaryExpr {
final class MulExpr extends BinaryExpr {
MulExpr() { this.getStaticTarget().getName() = ["*(_:_:)", "&*(_:_:)"] }
}

Expand All @@ -80,7 +80,7 @@ class MulExpr extends BinaryExpr {
* a / b
* ```
*/
class DivExpr extends BinaryExpr {
final class DivExpr extends BinaryExpr {
DivExpr() { this.getStaticTarget().getName() = "/(_:_:)" }
}

Expand All @@ -90,7 +90,7 @@ class DivExpr extends BinaryExpr {
* a % b
* ```
*/
class RemExpr extends BinaryExpr {
final class RemExpr extends BinaryExpr {
RemExpr() { this.getStaticTarget().getName() = "%(_:_:)" }
}

Expand All @@ -100,7 +100,7 @@ class RemExpr extends BinaryExpr {
* -a
* ```
*/
class UnaryArithmeticOperation extends PrefixUnaryExpr {
final class UnaryArithmeticOperation extends PrefixUnaryExpr {
UnaryArithmeticOperation() {
this instanceof UnaryMinusExpr or
this instanceof UnaryPlusExpr
Expand All @@ -113,7 +113,7 @@ class UnaryArithmeticOperation extends PrefixUnaryExpr {
* -a
* ```
*/
class UnaryMinusExpr extends PrefixUnaryExpr {
final class UnaryMinusExpr extends PrefixUnaryExpr {
UnaryMinusExpr() { this.getStaticTarget().getName() = "-(_:)" }
}

Expand All @@ -123,6 +123,6 @@ class UnaryMinusExpr extends PrefixUnaryExpr {
* +a
* ```
*/
class UnaryPlusExpr extends PrefixUnaryExpr {
final class UnaryPlusExpr extends PrefixUnaryExpr {
UnaryPlusExpr() { this.getStaticTarget().getName() = "+(_:)" }
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ private import codeql.swift.elements.expr.PrefixUnaryExpr
* ~a
* ```
*/
class BitwiseOperation extends Expr {
final class BitwiseOperation extends Expr {
BitwiseOperation() {
this instanceof BinaryBitwiseOperation or
this instanceof UnaryBitwiseOperation
Expand All @@ -33,7 +33,7 @@ class BitwiseOperation extends Expr {
* a .^ b
* ```
*/
class BinaryBitwiseOperation extends BinaryExpr {
final class BinaryBitwiseOperation extends BinaryExpr {
BinaryBitwiseOperation() {
this instanceof AndBitwiseExpr or
this instanceof OrBitwiseExpr or
Expand All @@ -52,7 +52,7 @@ class BinaryBitwiseOperation extends BinaryExpr {
* a & b
* ```
*/
class AndBitwiseExpr extends BinaryExpr {
final class AndBitwiseExpr extends BinaryExpr {
AndBitwiseExpr() { this.getStaticTarget().getName() = "&(_:_:)" }
}

Expand All @@ -62,7 +62,7 @@ class AndBitwiseExpr extends BinaryExpr {
* a | b
* ```
*/
class OrBitwiseExpr extends BinaryExpr {
final class OrBitwiseExpr extends BinaryExpr {
OrBitwiseExpr() { this.getStaticTarget().getName() = "|(_:_:)" }
}

Expand All @@ -72,7 +72,7 @@ class OrBitwiseExpr extends BinaryExpr {
* a ^ b
* ```
*/
class XorBitwiseExpr extends BinaryExpr {
final class XorBitwiseExpr extends BinaryExpr {
XorBitwiseExpr() { this.getStaticTarget().getName() = "^(_:_:)" }
}

Expand All @@ -82,7 +82,7 @@ class XorBitwiseExpr extends BinaryExpr {
* a .& b
* ```
*/
class PointwiseAndExpr extends BinaryExpr {
final class PointwiseAndExpr extends BinaryExpr {
PointwiseAndExpr() { this.getOperator().getName() = ".&(_:_:)" }
}

Expand All @@ -92,7 +92,7 @@ class PointwiseAndExpr extends BinaryExpr {
* a .| b
* ```
*/
class PointwiseOrExpr extends BinaryExpr {
final class PointwiseOrExpr extends BinaryExpr {
PointwiseOrExpr() { this.getOperator().getName() = ".|(_:_:)" }
}

Expand All @@ -102,7 +102,7 @@ class PointwiseOrExpr extends BinaryExpr {
* a .^ b
* ```
*/
class PointwiseXorExpr extends BinaryExpr {
final class PointwiseXorExpr extends BinaryExpr {
PointwiseXorExpr() { this.getOperator().getName() = ".^(_:_:)" }
}

Expand All @@ -113,7 +113,7 @@ class PointwiseXorExpr extends BinaryExpr {
* a &<<
* ```
*/
class ShiftLeftBitwiseExpr extends BinaryExpr {
final class ShiftLeftBitwiseExpr extends BinaryExpr {
ShiftLeftBitwiseExpr() { this.getStaticTarget().getName() = ["<<(_:_:)", "&<<(_:_:)"] }
}

Expand All @@ -124,7 +124,7 @@ class ShiftLeftBitwiseExpr extends BinaryExpr {
* a &>>
* ```
*/
class ShiftRightBitwiseExpr extends BinaryExpr {
final class ShiftRightBitwiseExpr extends BinaryExpr {
ShiftRightBitwiseExpr() { this.getStaticTarget().getName() = [">>(_:_:)", "&>>(_:_:)"] }
}

Expand All @@ -134,14 +134,14 @@ class ShiftRightBitwiseExpr extends BinaryExpr {
* ~a
* ```
*/
class UnaryBitwiseOperation extends PrefixUnaryExpr instanceof NotBitwiseExpr { }
final class UnaryBitwiseOperation extends PrefixUnaryExpr instanceof NotBitwiseExpr { }

/**
* A bitwise NOT expression.
* ```
* ~a
* ```
*/
class NotBitwiseExpr extends PrefixUnaryExpr {
final class NotBitwiseExpr extends PrefixUnaryExpr {
NotBitwiseExpr() { this.getStaticTarget().getName() = "~(_:)" }
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private import codeql.swift.elements.decl.EnumElementDecl
* ...
* ```
*/
class EnumElementExpr extends Expr {
final class EnumElementExpr extends Expr {
EnumElementDecl decl;

EnumElementExpr() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ private import codeql.swift.elements.expr.MethodCallExpr
private import codeql.swift.elements.expr.InitializerLookupExpr
private import codeql.swift.elements.decl.Initializer

class InitializerCallExpr extends MethodCallExpr {
final class InitializerCallExpr extends MethodCallExpr {
InitializerCallExpr() { this.getFunction() instanceof InitializerLookupExpr }

override Initializer getStaticTarget() { result = super.getStaticTarget() }
Initializer getStaticTarget() { result = super.getStaticTarget() }
}
13 changes: 13 additions & 0 deletions swift/ql/lib/codeql/swift/elements/expr/InitializerLookupExpr.qll
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
private import codeql.swift.elements.expr.MethodLookupExpr
private import codeql.swift.elements.expr.MethodLookupExprImpl::Impl as Impl
private import codeql.swift.elements.decl.Initializer

final private class InitializerLookupExprImpl extends Impl::MethodLookupExpr {
InitializerLookupExprImpl() { super.getMethod() instanceof Initializer }

override string toString() { result = this.getMember().toString() }
}

final class InitializerLookupExpr extends MethodLookupExpr, InitializerLookupExprImpl {
Initializer getMethod() { result = super.getMethod() }
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@ private predicate unaryHasName(PrefixUnaryExpr e, string name) {

private predicate binaryHasName(BinaryExpr e, string name) { e.getStaticTarget().getName() = name }

class LogicalAndExpr extends BinaryExpr {
final class LogicalAndExpr extends BinaryExpr {
LogicalAndExpr() { binaryHasName(this, "&&(_:_:)") }
}

class LogicalOrExpr extends BinaryExpr {
final class LogicalOrExpr extends BinaryExpr {
LogicalOrExpr() { binaryHasName(this, "||(_:_:)") }
}

class BinaryLogicalOperation extends BinaryExpr {
final class BinaryLogicalOperation extends BinaryExpr {
BinaryLogicalOperation() {
this instanceof LogicalAndExpr or
this instanceof LogicalOrExpr
}
}

class NotExpr extends PrefixUnaryExpr {
final class NotExpr extends PrefixUnaryExpr {
NotExpr() { unaryHasName(this, "!(_:)") }
}

class UnaryLogicalOperation extends PrefixUnaryExpr instanceof NotExpr { }
final class UnaryLogicalOperation extends PrefixUnaryExpr instanceof NotExpr { }

class LogicalOperation extends Expr {
final class LogicalOperation extends Expr {
LogicalOperation() {
this instanceof BinaryLogicalOperation or
this instanceof UnaryLogicalOperation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
private import ApplyExprExt
private import codeql.swift.elements.expr.CallExpr
private import codeql.swift.elements.expr.ApplyExpr
private import codeql.swift.elements.expr.SuperRefExpr
private import codeql.swift.elements.expr.SelfRefExpr

class MethodCallExpr extends CallExpr, MethodApplyExpr {
final class MethodCallExpr extends CallExpr, MethodApplyExpr {
predicate isSelfCall() { this.getQualifier() instanceof SelfRefExpr }

predicate isSuperCall() { this.getQualifier() instanceof SuperRefExpr }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ private import codeql.swift.elements.expr.BinaryExpr
/**
* A Swift nil-coalesing expr (`??`).
*/
class NilCoalescingExpr extends BinaryExpr {
final class NilCoalescingExpr extends BinaryExpr {
NilCoalescingExpr() { this.getStaticTarget().getName() = "??(_:_:)" }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ private import codeql.swift.elements.decl.Method
private import codeql.swift.elements.decl.VarDecl

/** A reference to `self`. */
class SelfRefExpr extends DeclRefExpr {
final class SelfRefExpr extends DeclRefExpr {
Method method;

SelfRefExpr() { this.getDecl() = method.getSelfParam() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ private import swift
* A floating-point type. This includes the `Float` type, the `Double`, and
* builtin floating-point types.
*/
class FloatingPointType extends Type {
final class FloatingPointType extends Type {
FloatingPointType() {
this.getName() = ["Float", "Double"] or
this instanceof BuiltinFloatType
}
}

/** The `Character` type. */
class CharacterType extends StructType {
final class CharacterType extends StructType {
CharacterType() { this.getName() = "Character" }
}

/**
* An integer-like type. For example, `Int`, `Int16`, `Uint16`, etc.
*/
class IntegralType extends Type {
final class IntegralType extends Type {
IntegralType() {
this.getName() =
["Int", "Int8", "Int16", "Int32", "Int64", "UInt", "UInt8", "UInt16", "UInt32", "UInt64"]
Expand All @@ -29,14 +29,14 @@ class IntegralType extends Type {
}

/** The `Bool` type. */
class BoolType extends Type {
final class BoolType extends Type {
BoolType() { this.getName() = "Bool" }
}

/**
* A numeric type. This includes the integer and floating point types.
*/
class NumericType extends Type {
final class NumericType extends Type {
NumericType() {
this instanceof IntegralType or
this instanceof FloatingPointType
Expand Down

0 comments on commit 288cdc5

Please sign in to comment.