From c785cd9d7bf23f5156ea833b0db05dcefe7df6bd Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Fri, 13 Sep 2024 14:31:16 +0200 Subject: [PATCH] Swift: Revert `Impl` rename for manually added files --- ...ructDeclImpl.qll => ClassOrStructDecl.qll} | 2 +- .../decl/{MethodImpl.qll => Method.qll} | 2 +- ...rationImpl.qll => ArithmeticOperation.qll} | 20 ++++++++-------- ...OperationImpl.qll => BitwiseOperation.qll} | 24 +++++++++---------- ...lementExprImpl.qll => EnumElementExpr.qll} | 2 +- ...llExprImpl.qll => InitializerCallExpr.qll} | 4 ++-- .../elements/expr/InitializerLookupExpr.qll | 13 ++++++++++ .../expr/InitializerLookupExprImpl.qll | 10 -------- ...OperationImpl.qll => LogicalOperation.qll} | 12 +++++----- ...hodCallExprImpl.qll => MethodCallExpr.qll} | 3 ++- ...cingExprImpl.qll => NilCoalescingExpr.qll} | 2 +- .../{SelfRefExprImpl.qll => SelfRefExpr.qll} | 2 +- .../{NumericTypeImpl.qll => NumericType.qll} | 10 ++++---- 13 files changed, 55 insertions(+), 51 deletions(-) rename swift/ql/lib/codeql/swift/elements/decl/{ClassOrStructDeclImpl.qll => ClassOrStructDecl.qll} (89%) rename swift/ql/lib/codeql/swift/elements/decl/{MethodImpl.qll => Method.qll} (97%) rename swift/ql/lib/codeql/swift/elements/expr/{ArithmeticOperationImpl.qll => ArithmeticOperation.qll} (80%) rename swift/ql/lib/codeql/swift/elements/expr/{BitwiseOperationImpl.qll => BitwiseOperation.qll} (78%) rename swift/ql/lib/codeql/swift/elements/expr/{EnumElementExprImpl.qll => EnumElementExpr.qll} (98%) rename swift/ql/lib/codeql/swift/elements/expr/{InitializerCallExprImpl.qll => InitializerCallExpr.qll} (66%) create mode 100644 swift/ql/lib/codeql/swift/elements/expr/InitializerLookupExpr.qll delete mode 100644 swift/ql/lib/codeql/swift/elements/expr/InitializerLookupExprImpl.qll rename swift/ql/lib/codeql/swift/elements/expr/{LogicalOperationImpl.qll => LogicalOperation.qll} (75%) rename swift/ql/lib/codeql/swift/elements/expr/{MethodCallExprImpl.qll => MethodCallExpr.qll} (79%) rename swift/ql/lib/codeql/swift/elements/expr/{NilCoalescingExprImpl.qll => NilCoalescingExpr.qll} (85%) rename swift/ql/lib/codeql/swift/elements/expr/{SelfRefExprImpl.qll => SelfRefExpr.qll} (88%) rename swift/ql/lib/codeql/swift/elements/type/{NumericTypeImpl.qll => NumericType.qll} (80%) diff --git a/swift/ql/lib/codeql/swift/elements/decl/ClassOrStructDeclImpl.qll b/swift/ql/lib/codeql/swift/elements/decl/ClassOrStructDecl.qll similarity index 89% rename from swift/ql/lib/codeql/swift/elements/decl/ClassOrStructDeclImpl.qll rename to swift/ql/lib/codeql/swift/elements/decl/ClassOrStructDecl.qll index 37c3935a17f..e252c70ec8c 100644 --- a/swift/ql/lib/codeql/swift/elements/decl/ClassOrStructDeclImpl.qll +++ b/swift/ql/lib/codeql/swift/elements/decl/ClassOrStructDecl.qll @@ -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 diff --git a/swift/ql/lib/codeql/swift/elements/decl/MethodImpl.qll b/swift/ql/lib/codeql/swift/elements/decl/Method.qll similarity index 97% rename from swift/ql/lib/codeql/swift/elements/decl/MethodImpl.qll rename to swift/ql/lib/codeql/swift/elements/decl/Method.qll index cfaa635f6b6..c271eb6398b 100644 --- a/swift/ql/lib/codeql/swift/elements/decl/MethodImpl.qll +++ b/swift/ql/lib/codeql/swift/elements/decl/Method.qll @@ -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 diff --git a/swift/ql/lib/codeql/swift/elements/expr/ArithmeticOperationImpl.qll b/swift/ql/lib/codeql/swift/elements/expr/ArithmeticOperation.qll similarity index 80% rename from swift/ql/lib/codeql/swift/elements/expr/ArithmeticOperationImpl.qll rename to swift/ql/lib/codeql/swift/elements/expr/ArithmeticOperation.qll index b921e948c34..1639555cd3c 100644 --- a/swift/ql/lib/codeql/swift/elements/expr/ArithmeticOperationImpl.qll +++ b/swift/ql/lib/codeql/swift/elements/expr/ArithmeticOperation.qll @@ -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 @@ -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 @@ -48,7 +48,7 @@ class BinaryArithmeticOperation extends BinaryExpr { * a &+ b * ``` */ -class AddExpr extends BinaryExpr { +final class AddExpr extends BinaryExpr { AddExpr() { this.getStaticTarget().getName() = ["+(_:_:)", "&+(_:_:)"] } } @@ -59,7 +59,7 @@ class AddExpr extends BinaryExpr { * a &- b * ``` */ -class SubExpr extends BinaryExpr { +final class SubExpr extends BinaryExpr { SubExpr() { this.getStaticTarget().getName() = ["-(_:_:)", "&-(_:_:)"] } } @@ -70,7 +70,7 @@ class SubExpr extends BinaryExpr { * a &* b * ``` */ -class MulExpr extends BinaryExpr { +final class MulExpr extends BinaryExpr { MulExpr() { this.getStaticTarget().getName() = ["*(_:_:)", "&*(_:_:)"] } } @@ -80,7 +80,7 @@ class MulExpr extends BinaryExpr { * a / b * ``` */ -class DivExpr extends BinaryExpr { +final class DivExpr extends BinaryExpr { DivExpr() { this.getStaticTarget().getName() = "/(_:_:)" } } @@ -90,7 +90,7 @@ class DivExpr extends BinaryExpr { * a % b * ``` */ -class RemExpr extends BinaryExpr { +final class RemExpr extends BinaryExpr { RemExpr() { this.getStaticTarget().getName() = "%(_:_:)" } } @@ -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 @@ -113,7 +113,7 @@ class UnaryArithmeticOperation extends PrefixUnaryExpr { * -a * ``` */ -class UnaryMinusExpr extends PrefixUnaryExpr { +final class UnaryMinusExpr extends PrefixUnaryExpr { UnaryMinusExpr() { this.getStaticTarget().getName() = "-(_:)" } } @@ -123,6 +123,6 @@ class UnaryMinusExpr extends PrefixUnaryExpr { * +a * ``` */ -class UnaryPlusExpr extends PrefixUnaryExpr { +final class UnaryPlusExpr extends PrefixUnaryExpr { UnaryPlusExpr() { this.getStaticTarget().getName() = "+(_:)" } } diff --git a/swift/ql/lib/codeql/swift/elements/expr/BitwiseOperationImpl.qll b/swift/ql/lib/codeql/swift/elements/expr/BitwiseOperation.qll similarity index 78% rename from swift/ql/lib/codeql/swift/elements/expr/BitwiseOperationImpl.qll rename to swift/ql/lib/codeql/swift/elements/expr/BitwiseOperation.qll index 4e29e6645af..d50ac5dd088 100644 --- a/swift/ql/lib/codeql/swift/elements/expr/BitwiseOperationImpl.qll +++ b/swift/ql/lib/codeql/swift/elements/expr/BitwiseOperation.qll @@ -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 @@ -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 @@ -52,7 +52,7 @@ class BinaryBitwiseOperation extends BinaryExpr { * a & b * ``` */ -class AndBitwiseExpr extends BinaryExpr { +final class AndBitwiseExpr extends BinaryExpr { AndBitwiseExpr() { this.getStaticTarget().getName() = "&(_:_:)" } } @@ -62,7 +62,7 @@ class AndBitwiseExpr extends BinaryExpr { * a | b * ``` */ -class OrBitwiseExpr extends BinaryExpr { +final class OrBitwiseExpr extends BinaryExpr { OrBitwiseExpr() { this.getStaticTarget().getName() = "|(_:_:)" } } @@ -72,7 +72,7 @@ class OrBitwiseExpr extends BinaryExpr { * a ^ b * ``` */ -class XorBitwiseExpr extends BinaryExpr { +final class XorBitwiseExpr extends BinaryExpr { XorBitwiseExpr() { this.getStaticTarget().getName() = "^(_:_:)" } } @@ -82,7 +82,7 @@ class XorBitwiseExpr extends BinaryExpr { * a .& b * ``` */ -class PointwiseAndExpr extends BinaryExpr { +final class PointwiseAndExpr extends BinaryExpr { PointwiseAndExpr() { this.getOperator().getName() = ".&(_:_:)" } } @@ -92,7 +92,7 @@ class PointwiseAndExpr extends BinaryExpr { * a .| b * ``` */ -class PointwiseOrExpr extends BinaryExpr { +final class PointwiseOrExpr extends BinaryExpr { PointwiseOrExpr() { this.getOperator().getName() = ".|(_:_:)" } } @@ -102,7 +102,7 @@ class PointwiseOrExpr extends BinaryExpr { * a .^ b * ``` */ -class PointwiseXorExpr extends BinaryExpr { +final class PointwiseXorExpr extends BinaryExpr { PointwiseXorExpr() { this.getOperator().getName() = ".^(_:_:)" } } @@ -113,7 +113,7 @@ class PointwiseXorExpr extends BinaryExpr { * a &<< * ``` */ -class ShiftLeftBitwiseExpr extends BinaryExpr { +final class ShiftLeftBitwiseExpr extends BinaryExpr { ShiftLeftBitwiseExpr() { this.getStaticTarget().getName() = ["<<(_:_:)", "&<<(_:_:)"] } } @@ -124,7 +124,7 @@ class ShiftLeftBitwiseExpr extends BinaryExpr { * a &>> * ``` */ -class ShiftRightBitwiseExpr extends BinaryExpr { +final class ShiftRightBitwiseExpr extends BinaryExpr { ShiftRightBitwiseExpr() { this.getStaticTarget().getName() = [">>(_:_:)", "&>>(_:_:)"] } } @@ -134,7 +134,7 @@ class ShiftRightBitwiseExpr extends BinaryExpr { * ~a * ``` */ -class UnaryBitwiseOperation extends PrefixUnaryExpr instanceof NotBitwiseExpr { } +final class UnaryBitwiseOperation extends PrefixUnaryExpr instanceof NotBitwiseExpr { } /** * A bitwise NOT expression. @@ -142,6 +142,6 @@ class UnaryBitwiseOperation extends PrefixUnaryExpr instanceof NotBitwiseExpr { * ~a * ``` */ -class NotBitwiseExpr extends PrefixUnaryExpr { +final class NotBitwiseExpr extends PrefixUnaryExpr { NotBitwiseExpr() { this.getStaticTarget().getName() = "~(_:)" } } diff --git a/swift/ql/lib/codeql/swift/elements/expr/EnumElementExprImpl.qll b/swift/ql/lib/codeql/swift/elements/expr/EnumElementExpr.qll similarity index 98% rename from swift/ql/lib/codeql/swift/elements/expr/EnumElementExprImpl.qll rename to swift/ql/lib/codeql/swift/elements/expr/EnumElementExpr.qll index 70432ccae45..3a856af1f92 100644 --- a/swift/ql/lib/codeql/swift/elements/expr/EnumElementExprImpl.qll +++ b/swift/ql/lib/codeql/swift/elements/expr/EnumElementExpr.qll @@ -19,7 +19,7 @@ private import codeql.swift.elements.decl.EnumElementDecl * ... * ``` */ -class EnumElementExpr extends Expr { +final class EnumElementExpr extends Expr { EnumElementDecl decl; EnumElementExpr() { diff --git a/swift/ql/lib/codeql/swift/elements/expr/InitializerCallExprImpl.qll b/swift/ql/lib/codeql/swift/elements/expr/InitializerCallExpr.qll similarity index 66% rename from swift/ql/lib/codeql/swift/elements/expr/InitializerCallExprImpl.qll rename to swift/ql/lib/codeql/swift/elements/expr/InitializerCallExpr.qll index dcb4dff4ba9..795dc8e0beb 100644 --- a/swift/ql/lib/codeql/swift/elements/expr/InitializerCallExprImpl.qll +++ b/swift/ql/lib/codeql/swift/elements/expr/InitializerCallExpr.qll @@ -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() } } diff --git a/swift/ql/lib/codeql/swift/elements/expr/InitializerLookupExpr.qll b/swift/ql/lib/codeql/swift/elements/expr/InitializerLookupExpr.qll new file mode 100644 index 00000000000..4eade2ff5c7 --- /dev/null +++ b/swift/ql/lib/codeql/swift/elements/expr/InitializerLookupExpr.qll @@ -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() } +} diff --git a/swift/ql/lib/codeql/swift/elements/expr/InitializerLookupExprImpl.qll b/swift/ql/lib/codeql/swift/elements/expr/InitializerLookupExprImpl.qll deleted file mode 100644 index 26972894ec6..00000000000 --- a/swift/ql/lib/codeql/swift/elements/expr/InitializerLookupExprImpl.qll +++ /dev/null @@ -1,10 +0,0 @@ -private import codeql.swift.elements.expr.MethodLookupExpr -private import codeql.swift.elements.decl.Initializer - -class InitializerLookupExpr extends MethodLookupExpr { - InitializerLookupExpr() { super.getMethod() instanceof Initializer } - - override Initializer getMethod() { result = super.getMethod() } - - override string toString() { result = this.getMember().toString() } -} diff --git a/swift/ql/lib/codeql/swift/elements/expr/LogicalOperationImpl.qll b/swift/ql/lib/codeql/swift/elements/expr/LogicalOperation.qll similarity index 75% rename from swift/ql/lib/codeql/swift/elements/expr/LogicalOperationImpl.qll rename to swift/ql/lib/codeql/swift/elements/expr/LogicalOperation.qll index 57713551e43..c261a2a378f 100644 --- a/swift/ql/lib/codeql/swift/elements/expr/LogicalOperationImpl.qll +++ b/swift/ql/lib/codeql/swift/elements/expr/LogicalOperation.qll @@ -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 diff --git a/swift/ql/lib/codeql/swift/elements/expr/MethodCallExprImpl.qll b/swift/ql/lib/codeql/swift/elements/expr/MethodCallExpr.qll similarity index 79% rename from swift/ql/lib/codeql/swift/elements/expr/MethodCallExprImpl.qll rename to swift/ql/lib/codeql/swift/elements/expr/MethodCallExpr.qll index 65d7dac7576..9bffe97d129 100644 --- a/swift/ql/lib/codeql/swift/elements/expr/MethodCallExprImpl.qll +++ b/swift/ql/lib/codeql/swift/elements/expr/MethodCallExpr.qll @@ -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 } diff --git a/swift/ql/lib/codeql/swift/elements/expr/NilCoalescingExprImpl.qll b/swift/ql/lib/codeql/swift/elements/expr/NilCoalescingExpr.qll similarity index 85% rename from swift/ql/lib/codeql/swift/elements/expr/NilCoalescingExprImpl.qll rename to swift/ql/lib/codeql/swift/elements/expr/NilCoalescingExpr.qll index 23fe5fc09c5..e527541d7ba 100644 --- a/swift/ql/lib/codeql/swift/elements/expr/NilCoalescingExprImpl.qll +++ b/swift/ql/lib/codeql/swift/elements/expr/NilCoalescingExpr.qll @@ -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() = "??(_:_:)" } } diff --git a/swift/ql/lib/codeql/swift/elements/expr/SelfRefExprImpl.qll b/swift/ql/lib/codeql/swift/elements/expr/SelfRefExpr.qll similarity index 88% rename from swift/ql/lib/codeql/swift/elements/expr/SelfRefExprImpl.qll rename to swift/ql/lib/codeql/swift/elements/expr/SelfRefExpr.qll index 7ffc7a6af20..e5178f9ccab 100644 --- a/swift/ql/lib/codeql/swift/elements/expr/SelfRefExprImpl.qll +++ b/swift/ql/lib/codeql/swift/elements/expr/SelfRefExpr.qll @@ -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() } diff --git a/swift/ql/lib/codeql/swift/elements/type/NumericTypeImpl.qll b/swift/ql/lib/codeql/swift/elements/type/NumericType.qll similarity index 80% rename from swift/ql/lib/codeql/swift/elements/type/NumericTypeImpl.qll rename to swift/ql/lib/codeql/swift/elements/type/NumericType.qll index 1becac4493b..b4c4975d4bd 100644 --- a/swift/ql/lib/codeql/swift/elements/type/NumericTypeImpl.qll +++ b/swift/ql/lib/codeql/swift/elements/type/NumericType.qll @@ -4,7 +4,7 @@ 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 @@ -12,14 +12,14 @@ class FloatingPointType extends Type { } /** 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"] @@ -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