Swift: remove unneeded properties from `InterpolatedStringLiteralExpr`

These properties were unused in the QL library (hence the full
upgrade/downgrade compatibility).
This commit is contained in:
Paolo Tranquilli 2023-05-22 15:10:51 +02:00
Родитель f56ffbc25e
Коммит 9a0f87434e
15 изменённых файлов: 10521 добавлений и 113 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,2 @@
description: Revert removing `getInterpolationCountExpr` and `getLiteralCapacityExpr` from `InterpolatedStringLiteralExpr`
compatibility: full

Просмотреть файл

@ -61,10 +61,6 @@ codeql::InterpolatedStringLiteralExpr ExprTranslator::translateInterpolatedStrin
const swift::InterpolatedStringLiteralExpr& expr) {
auto entry = createExprEntry(expr);
entry.interpolation_expr = dispatcher.fetchOptionalLabel(expr.getInterpolationExpr());
// TODO we should be extracting getInterpolationCount and getLiteralCapacity directly to ints
// these expressions here are just an internal thing, the ints are actually directly available
entry.interpolation_count_expr = dispatcher.fetchOptionalLabel(expr.getInterpolationCountExpr());
entry.literal_capacity_expr = dispatcher.fetchOptionalLabel(expr.getLiteralCapacityExpr());
entry.appending_expr = dispatcher.fetchOptionalLabel(expr.getAppendingExpr());
return entry;
}

6
swift/ql/.generated.list сгенерированный
Просмотреть файл

@ -381,10 +381,10 @@ lib/codeql/swift/generated/KeyPathComponent.qll 00b1e586b8532f0193b3f61111e70d4e
lib/codeql/swift/generated/Locatable.qll bfdf2dafae2829cac8d1e863a93676228d131b5a7f3df87c40d2f3b1839962b8 af243098af0955a40862387edf7526826fde62a64e5e6ca28de9e9603a8622bf
lib/codeql/swift/generated/Location.qll 921922352d39449067d9f2788309b5f3490091097ffe35e6aa98f9368626ce2c 0795c63565c4308e745400bc70ea73675160201590a95bb418de4e2ebca32764
lib/codeql/swift/generated/OtherAvailabilitySpec.qll 0e26a203b26ff0581b7396b0c6d1606feec5cc32477f676585cdec4911af91c5 0e26a203b26ff0581b7396b0c6d1606feec5cc32477f676585cdec4911af91c5
lib/codeql/swift/generated/ParentChild.qll f490202e849b9cbd550ee9d758644b85d43e60d81413e6c28df2850fb1e9a2d6 6b95aeab6b53a880b230ad0c96b6deb519a7368898c844632ae96090de59df99
lib/codeql/swift/generated/ParentChild.qll 3808a52565a4abb8ce878fb4aad09e8fb0e860d6379bb86897d0e0282389919c 408c7e6332dccfc98398f04ecbd54af8e0754d466ad7ca4d404b029c7f5bde49
lib/codeql/swift/generated/PlatformVersionAvailabilitySpec.qll f82d9ca416fe8bd59b5531b65b1c74c9f317b3297a6101544a11339a1cffce38 7f5c6d3309e66c134107afe55bae76dfc9a72cb7cdd6d4c3706b6b34cee09fa0
lib/codeql/swift/generated/PureSynthConstructors.qll 173c0dd59396a1de26fe870e3bc2766c46de689da2a4d8807cb62023bbce1a98 173c0dd59396a1de26fe870e3bc2766c46de689da2a4d8807cb62023bbce1a98
lib/codeql/swift/generated/Raw.qll 8d4880e5ee1fdd120adeb7bf0dfa1399e7b1a53b2cc7598aed8e15cbf996d1c0 da0d446347d29f5cd05281c17c24e87610f31c32adb7e05ab8f3a26bed55bd90
lib/codeql/swift/generated/Raw.qll 062d062fada3e3f1b6af04cda724f8204de6b66bbca53d233e9b4d96df7a5c99 3c1e70b5ec4c576c92979b04d6d3ee59159b050c16c47f93463cba28f40ca906
lib/codeql/swift/generated/Synth.qll 551fdf7e4b53f9ee1314d1bb42c2638cf82f45bfa1f40a635dfa7b6072e4418c 9ab178464700a19951fc5285acacda4913addee81515d8e072b3d7055935a814
lib/codeql/swift/generated/SynthConstructors.qll 2f801bd8b0db829b0253cd459ed3253c1fdfc55dce68ebc53e7fec138ef0aca4 2f801bd8b0db829b0253cd459ed3253c1fdfc55dce68ebc53e7fec138ef0aca4
lib/codeql/swift/generated/UnknownFile.qll 0fcf9beb8de79440bcdfff4bb6ab3dd139bd273e6c32754e05e6a632651e85f6 0fcf9beb8de79440bcdfff4bb6ab3dd139bd273e6c32754e05e6a632651e85f6
@ -498,7 +498,7 @@ lib/codeql/swift/generated/expr/InOutToPointerExpr.qll 4b9ceffe43f192fac0c428d66
lib/codeql/swift/generated/expr/InitializerRefCallExpr.qll 4556d49d78566ad70a5e784a6db4897dc78ef1f30e67f0052dbb070eca8350f0 4556d49d78566ad70a5e784a6db4897dc78ef1f30e67f0052dbb070eca8350f0
lib/codeql/swift/generated/expr/InjectIntoOptionalExpr.qll b6fafb589901d73e94eb9bb0f5e87b54378d06ccc04c51a9f4c8003d1f23ead6 b6fafb589901d73e94eb9bb0f5e87b54378d06ccc04c51a9f4c8003d1f23ead6
lib/codeql/swift/generated/expr/IntegerLiteralExpr.qll aa54660c47169a35e396ea44430c3c4ec4353e33df1a00bd82aff7119f5af71b 7ba90cf17dd34080a9923253986b0f2680b44c4a4ba6e0fbad8b39d3b20c44b9
lib/codeql/swift/generated/expr/InterpolatedStringLiteralExpr.qll e2c1aadf140c808a615bdc8732a154f6c1f8b79168779e1ba48753506fbd9516 5e9f20ee16b133269de6874c6776611b6f4eaec202a0e6a955a572c2a082ac40
lib/codeql/swift/generated/expr/InterpolatedStringLiteralExpr.qll 8090616e43d79e03c2250352da722f577c4b6531befe40f2d2910db0db3895bc ba09ffbbe3557e6fc6a3219d656e5ce886d70117eea15334cf910825f2250e6e
lib/codeql/swift/generated/expr/IsExpr.qll b5ca50490cae8ac590b68a1a51b7039a54280d606b42c444808a04fa26c7e1b6 b5ca50490cae8ac590b68a1a51b7039a54280d606b42c444808a04fa26c7e1b6
lib/codeql/swift/generated/expr/KeyPathApplicationExpr.qll 157a9c2fcf229b76d104abfa49f74337e20ac4d1fa1be2eaed1290cbd9bd1232 70ec0e7ee2e2c716ba510916fdf6d1d6dd6fd93b740a46c909ddb9e877427fe1
lib/codeql/swift/generated/expr/KeyPathDotExpr.qll ea73a462801fbe5e27b2f47bca4b39f6936d326d15d6de3f18b7afa6ace35878 ea73a462801fbe5e27b2f47bca4b39f6936d326d15d6de3f18b7afa6ace35878

17
swift/ql/lib/codeql/swift/generated/ParentChild.qll сгенерированный
Просмотреть файл

@ -2515,31 +2515,18 @@ private module Impl {
private Element getImmediateChildOfInterpolatedStringLiteralExpr(
InterpolatedStringLiteralExpr e, int index, string partialPredicateCall
) {
exists(
int b, int bLiteralExpr, int n, int nInterpolationCountExpr, int nLiteralCapacityExpr,
int nAppendingExpr
|
exists(int b, int bLiteralExpr, int n, int nAppendingExpr |
b = 0 and
bLiteralExpr =
b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLiteralExpr(e, i, _)) | i) and
n = bLiteralExpr and
nInterpolationCountExpr = n + 1 and
nLiteralCapacityExpr = nInterpolationCountExpr + 1 and
nAppendingExpr = nLiteralCapacityExpr + 1 and
nAppendingExpr = n + 1 and
(
none()
or
result = getImmediateChildOfLiteralExpr(e, index - b, partialPredicateCall)
or
index = n and
result = e.getImmediateInterpolationCountExpr() and
partialPredicateCall = "InterpolationCountExpr()"
or
index = nInterpolationCountExpr and
result = e.getImmediateLiteralCapacityExpr() and
partialPredicateCall = "LiteralCapacityExpr()"
or
index = nLiteralCapacityExpr and
result = e.getImmediateAppendingExpr() and
partialPredicateCall = "AppendingExpr()"
)

14
swift/ql/lib/codeql/swift/generated/Raw.qll сгенерированный
Просмотреть файл

@ -1961,20 +1961,6 @@ module Raw {
interpolated_string_literal_expr_interpolation_exprs(this, result)
}
/**
* Gets the interpolation count expression of this interpolated string literal expression, if it exists.
*/
Expr getInterpolationCountExpr() {
interpolated_string_literal_expr_interpolation_count_exprs(this, result)
}
/**
* Gets the literal capacity expression of this interpolated string literal expression, if it exists.
*/
Expr getLiteralCapacityExpr() {
interpolated_string_literal_expr_literal_capacity_exprs(this, result)
}
/**
* Gets the appending expression of this interpolated string literal expression, if it exists.
*/

Просмотреть файл

@ -1,7 +1,6 @@
// generated by codegen/codegen.py
private import codeql.swift.generated.Synth
private import codeql.swift.generated.Raw
import codeql.swift.elements.expr.Expr
import codeql.swift.elements.expr.LiteralExpr
import codeql.swift.elements.expr.OpaqueValueExpr
import codeql.swift.elements.expr.TapExpr
@ -38,62 +37,6 @@ module Generated {
*/
final predicate hasInterpolationExpr() { exists(this.getInterpolationExpr()) }
/**
* Gets the interpolation count expression of this interpolated string literal expression, if it exists.
*
* This includes nodes from the "hidden" AST. It can be overridden in subclasses to change the
* behavior of both the `Immediate` and non-`Immediate` versions.
*/
Expr getImmediateInterpolationCountExpr() {
result =
Synth::convertExprFromRaw(Synth::convertInterpolatedStringLiteralExprToRaw(this)
.(Raw::InterpolatedStringLiteralExpr)
.getInterpolationCountExpr())
}
/**
* Gets the interpolation count expression of this interpolated string literal expression, if it exists.
*/
final Expr getInterpolationCountExpr() {
exists(Expr immediate |
immediate = this.getImmediateInterpolationCountExpr() and
if exists(this.getResolveStep()) then result = immediate else result = immediate.resolve()
)
}
/**
* Holds if `getInterpolationCountExpr()` exists.
*/
final predicate hasInterpolationCountExpr() { exists(this.getInterpolationCountExpr()) }
/**
* Gets the literal capacity expression of this interpolated string literal expression, if it exists.
*
* This includes nodes from the "hidden" AST. It can be overridden in subclasses to change the
* behavior of both the `Immediate` and non-`Immediate` versions.
*/
Expr getImmediateLiteralCapacityExpr() {
result =
Synth::convertExprFromRaw(Synth::convertInterpolatedStringLiteralExprToRaw(this)
.(Raw::InterpolatedStringLiteralExpr)
.getLiteralCapacityExpr())
}
/**
* Gets the literal capacity expression of this interpolated string literal expression, if it exists.
*/
final Expr getLiteralCapacityExpr() {
exists(Expr immediate |
immediate = this.getImmediateLiteralCapacityExpr() and
if exists(this.getResolveStep()) then result = immediate else result = immediate.resolve()
)
}
/**
* Holds if `getLiteralCapacityExpr()` exists.
*/
final predicate hasLiteralCapacityExpr() { exists(this.getLiteralCapacityExpr()) }
/**
* Gets the appending expression of this interpolated string literal expression, if it exists.
*

12
swift/ql/lib/swift.dbscheme сгенерированный
Просмотреть файл

@ -1382,18 +1382,6 @@ interpolated_string_literal_expr_interpolation_exprs( //dir=expr
int interpolation_expr: @opaque_value_expr_or_none ref
);
#keyset[id]
interpolated_string_literal_expr_interpolation_count_exprs( //dir=expr
int id: @interpolated_string_literal_expr ref,
int interpolation_count_expr: @expr_or_none ref
);
#keyset[id]
interpolated_string_literal_expr_literal_capacity_exprs( //dir=expr
int id: @interpolated_string_literal_expr ref,
int literal_capacity_expr: @expr_or_none ref
);
#keyset[id]
interpolated_string_literal_expr_appending_exprs( //dir=expr
int id: @interpolated_string_literal_expr ref,

Просмотреть файл

@ -0,0 +1,13 @@
class Element extends @element {
string toString() { none() }
}
from Element i, string value
where
integer_literal_exprs(i, value) and
not exists(Element interpolated |
interpolated_string_literal_expr_interpolation_count_exprs(interpolated, i)
or
interpolated_string_literal_expr_literal_capacity_exprs(interpolated, i)
)
select i, value

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,5 @@
description: Remove `getInterpolationCountExpr` and `getLiteralCapacityExpr` from `InterpolatedStringLiteralExpr`
compatibility: full
interpolated_string_literal_expr_interpolation_count_exprs.rel: delete
interpolated_string_literal_expr_literal_capacity_exprs.rel: delete
integer_literal_exprs.rel: run integer_literal_exprs.ql

Просмотреть файл

@ -206,8 +206,6 @@ cfg.swift:
# 40| getExpr(): [VarargExpansionExpr] [...]
# 40| getSubExpr(): [ArrayExpr] [...]
# 40| getElement(0): [InterpolatedStringLiteralExpr] "..."
#-----| getInterpolationCountExpr(): [IntegerLiteralExpr] 1
#-----| getLiteralCapacityExpr(): [IntegerLiteralExpr] 14
# 40| getAppendingExpr(): [TapExpr] TapExpr
# 40| getSubExpr(): [OpaqueValueExpr] OpaqueValueExpr
# 40| getBody(): [BraceStmt] { ... }
@ -1422,8 +1420,6 @@ cfg.swift:
# 262| getBody(): [BraceStmt] { ... }
# 263| getElement(0): [ReturnStmt] return ...
# 263| getResult(): [InterpolatedStringLiteralExpr] "..."
#-----| getInterpolationCountExpr(): [IntegerLiteralExpr] 4
#-----| getLiteralCapacityExpr(): [IntegerLiteralExpr] 37
# 263| getAppendingExpr(): [TapExpr] TapExpr
# 263| getSubExpr(): [OpaqueValueExpr] OpaqueValueExpr
# 263| getBody(): [BraceStmt] { ... }
@ -4293,8 +4289,6 @@ expressions.swift:
# 7| getBody(): [BraceStmt] { ... }
# 7| getElement(0): [PatternBindingDecl] var ... = ...
# 7| getInit(0): [InterpolatedStringLiteralExpr] "..."
#-----| getInterpolationCountExpr(): [IntegerLiteralExpr] 1
#-----| getLiteralCapacityExpr(): [IntegerLiteralExpr] 6
# 7| getAppendingExpr(): [TapExpr] TapExpr
# 7| getSubExpr(): [OpaqueValueExpr] OpaqueValueExpr
# 7| getBody(): [BraceStmt] { ... }

Просмотреть файл

@ -679,8 +679,6 @@ class InjectIntoOptionalExpr(ImplicitConversionExpr):
class InterpolatedStringLiteralExpr(LiteralExpr):
interpolation_expr: optional[OpaqueValueExpr]
interpolation_count_expr: optional[Expr] | child
literal_capacity_expr: optional[Expr] | child
appending_expr: optional[TapExpr] | child
class LinearFunctionExpr(ImplicitConversionExpr):