mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Swift: expression visitor
This transfers the current status of `ExprVisitor` from the proof-of-concept, together with some changes required for swift 5.6.
This commit is contained in:
@@ -150,7 +150,7 @@ Decl:
|
||||
|
||||
Expr:
|
||||
_extends: AstNode
|
||||
# type: Type?
|
||||
type: Type?
|
||||
|
||||
Pattern:
|
||||
_extends: AstNode
|
||||
@@ -279,37 +279,37 @@ AbstractClosureExpr:
|
||||
|
||||
AnyTryExpr:
|
||||
_extends: Expr
|
||||
# sub_expr: Expr
|
||||
sub_expr: Expr
|
||||
|
||||
AppliedPropertyWrapperExpr:
|
||||
_extends: Expr
|
||||
|
||||
Argument:
|
||||
# label: string
|
||||
# expr: Expr
|
||||
label: string
|
||||
expr: Expr
|
||||
_dir: expr
|
||||
|
||||
ApplyExpr:
|
||||
_extends: Expr
|
||||
# function: Expr
|
||||
# arguments: Argument*
|
||||
function: Expr
|
||||
arguments: Argument*
|
||||
|
||||
ArrowExpr:
|
||||
_extends: Expr
|
||||
|
||||
AssignExpr:
|
||||
_extends: Expr
|
||||
# dest: Expr
|
||||
# source: Expr
|
||||
dest: Expr
|
||||
source: Expr
|
||||
|
||||
BindOptionalExpr:
|
||||
_extends: Expr
|
||||
# sub_expr: Expr
|
||||
sub_expr: Expr
|
||||
|
||||
CaptureListExpr:
|
||||
_extends: Expr
|
||||
# binding_decls: PatternBindingDecl*
|
||||
# closure_body: ClosureExpr
|
||||
binding_decls: PatternBindingDecl*
|
||||
closure_body: ClosureExpr
|
||||
|
||||
CodeCompletionExpr:
|
||||
_extends: Expr
|
||||
@@ -319,64 +319,64 @@ CollectionExpr:
|
||||
|
||||
DeclRefExpr:
|
||||
_extends: Expr
|
||||
# decl: Decl
|
||||
# replacement_types: Type*
|
||||
decl: Decl
|
||||
replacement_types: Type*
|
||||
|
||||
DefaultArgumentExpr:
|
||||
_extends: Expr
|
||||
# param_decl: ParamDecl
|
||||
# param_index: int
|
||||
# caller_side_default: Expr?
|
||||
param_decl: ParamDecl
|
||||
param_index: int
|
||||
caller_side_default: Expr?
|
||||
|
||||
DiscardAssignmentExpr:
|
||||
_extends: Expr
|
||||
|
||||
DotSyntaxBaseIgnoredExpr:
|
||||
_extends: Expr
|
||||
# qualifier: Expr
|
||||
# sub_expr: Expr
|
||||
qualifier: Expr
|
||||
sub_expr: Expr
|
||||
|
||||
DynamicTypeExpr:
|
||||
_extends: Expr
|
||||
# base_expr: Expr
|
||||
base_expr: Expr
|
||||
|
||||
EditorPlaceholderExpr:
|
||||
_extends: Expr
|
||||
|
||||
EnumIsCaseExpr:
|
||||
_extends: Expr
|
||||
# sub_expr: Expr
|
||||
# type_repr: TypeRepr
|
||||
# element: EnumElementDecl
|
||||
sub_expr: Expr
|
||||
type_repr: TypeRepr
|
||||
element: EnumElementDecl
|
||||
|
||||
ErrorExpr:
|
||||
_extends: Expr
|
||||
|
||||
ExplicitCastExpr:
|
||||
_extends: Expr
|
||||
# sub_expr: Expr
|
||||
sub_expr: Expr
|
||||
|
||||
ForceValueExpr:
|
||||
_extends: Expr
|
||||
# sub_expr: Expr
|
||||
sub_expr: Expr
|
||||
|
||||
IdentityExpr:
|
||||
_extends: Expr
|
||||
# sub_expr: Expr
|
||||
sub_expr: Expr
|
||||
|
||||
IfExpr:
|
||||
_extends: Expr
|
||||
# condition: Expr
|
||||
# then_expr: Expr
|
||||
# else_expr: Expr
|
||||
condition: Expr
|
||||
then_expr: Expr
|
||||
else_expr: Expr
|
||||
|
||||
ImplicitConversionExpr:
|
||||
_extends: Expr
|
||||
# sub_expr: Expr
|
||||
sub_expr: Expr
|
||||
|
||||
InOutExpr:
|
||||
_extends: Expr
|
||||
# sub_expr: Expr
|
||||
sub_expr: Expr
|
||||
|
||||
KeyPathApplicationExpr:
|
||||
_extends: Expr
|
||||
@@ -386,12 +386,12 @@ KeyPathDotExpr:
|
||||
|
||||
KeyPathExpr:
|
||||
_extends: Expr
|
||||
# parsed_root: Expr?
|
||||
# parsed_path: Expr?
|
||||
parsed_root: Expr?
|
||||
parsed_path: Expr?
|
||||
|
||||
LazyInitializerExpr:
|
||||
_extends: Expr
|
||||
# sub_expr: Expr
|
||||
sub_expr: Expr
|
||||
|
||||
LiteralExpr:
|
||||
_extends: Expr
|
||||
@@ -401,31 +401,31 @@ LookupExpr:
|
||||
|
||||
MakeTemporarilyEscapableExpr:
|
||||
_extends: Expr
|
||||
# escaping_closure: OpaqueValueExpr
|
||||
# nonescaping_closure: Expr
|
||||
# sub_expr: Expr
|
||||
escaping_closure: OpaqueValueExpr
|
||||
nonescaping_closure: Expr
|
||||
sub_expr: Expr
|
||||
|
||||
ObjCSelectorExpr:
|
||||
_extends: Expr
|
||||
# sub_expr: Expr
|
||||
# method: AbstractFunctionDecl
|
||||
sub_expr: Expr
|
||||
method: AbstractFunctionDecl
|
||||
|
||||
OneWayExpr:
|
||||
_extends: Expr
|
||||
# sub_expr: Expr
|
||||
sub_expr: Expr
|
||||
|
||||
OpaqueValueExpr:
|
||||
_extends: Expr
|
||||
|
||||
OpenExistentialExpr:
|
||||
_extends: Expr
|
||||
# sub_expr: Expr
|
||||
# existential: Expr
|
||||
# opaque_expr: OpaqueValueExpr
|
||||
sub_expr: Expr
|
||||
existential: Expr
|
||||
opaque_expr: OpaqueValueExpr
|
||||
|
||||
OptionalEvaluationExpr:
|
||||
_extends: Expr
|
||||
# sub_expr: Expr
|
||||
sub_expr: Expr
|
||||
|
||||
OtherConstructorDeclRefExpr:
|
||||
_extends: Expr
|
||||
@@ -438,34 +438,34 @@ PropertyWrapperValuePlaceholderExpr:
|
||||
|
||||
RebindSelfInConstructorExpr:
|
||||
_extends: Expr
|
||||
# sub_expr: Expr
|
||||
# self: VarDecl
|
||||
sub_expr: Expr
|
||||
self: VarDecl
|
||||
|
||||
SequenceExpr:
|
||||
_extends: Expr
|
||||
|
||||
SuperRefExpr:
|
||||
_extends: Expr
|
||||
# self: VarDecl
|
||||
self: VarDecl
|
||||
|
||||
TapExpr:
|
||||
_extends: Expr
|
||||
# sub_expr: Expr?
|
||||
# var: VarDecl
|
||||
# body: BraceStmt
|
||||
sub_expr: Expr?
|
||||
var: VarDecl
|
||||
body: BraceStmt
|
||||
|
||||
TupleElementExpr:
|
||||
_extends: Expr
|
||||
# sub_expr: Expr
|
||||
# index: int
|
||||
sub_expr: Expr
|
||||
index: int
|
||||
|
||||
TupleExpr:
|
||||
_extends: Expr
|
||||
# elements: Expr*
|
||||
elements: Expr*
|
||||
|
||||
TypeExpr:
|
||||
_extends: Expr
|
||||
# type_repr: TypeRepr?
|
||||
type_repr: TypeRepr?
|
||||
|
||||
UnresolvedDeclRefExpr:
|
||||
_extends: Expr
|
||||
@@ -484,7 +484,7 @@ UnresolvedSpecializeExpr:
|
||||
|
||||
VarargExpansionExpr:
|
||||
_extends: Expr
|
||||
# sub_expr: Expr
|
||||
sub_expr: Expr
|
||||
|
||||
AnyPattern:
|
||||
_extends: Pattern
|
||||
@@ -655,11 +655,11 @@ TypeDecl:
|
||||
|
||||
AutoClosureExpr:
|
||||
_extends: AbstractClosureExpr
|
||||
# body: BraceStmt
|
||||
body: BraceStmt
|
||||
|
||||
ClosureExpr:
|
||||
_extends: AbstractClosureExpr
|
||||
# body: BraceStmt
|
||||
body: BraceStmt
|
||||
|
||||
ForceTryExpr:
|
||||
_extends: AnyTryExpr
|
||||
@@ -684,15 +684,15 @@ PrefixUnaryExpr:
|
||||
|
||||
SelfApplyExpr:
|
||||
_extends: ApplyExpr
|
||||
# base_expr: Expr
|
||||
base_expr: Expr
|
||||
|
||||
ArrayExpr:
|
||||
_extends: CollectionExpr
|
||||
# elements: Expr*
|
||||
elements: Expr*
|
||||
|
||||
DictionaryExpr:
|
||||
_extends: CollectionExpr
|
||||
# elements: Expr*
|
||||
elements: Expr*
|
||||
|
||||
CheckedCastExpr:
|
||||
_extends: ExplicitCastExpr
|
||||
@@ -810,10 +810,10 @@ BuiltinLiteralExpr:
|
||||
|
||||
InterpolatedStringLiteralExpr:
|
||||
_extends: LiteralExpr
|
||||
# interpolation_expr: OpaqueValueExpr?
|
||||
# interpolation_count_expr: Expr?
|
||||
# literal_capacity_expr: Expr?
|
||||
# appending_expr: TapExpr?
|
||||
interpolation_expr: OpaqueValueExpr?
|
||||
interpolation_count_expr: Expr?
|
||||
literal_capacity_expr: Expr?
|
||||
appending_expr: TapExpr?
|
||||
|
||||
RegexLiteralExpr:
|
||||
_extends: LiteralExpr
|
||||
@@ -829,14 +829,14 @@ DynamicLookupExpr:
|
||||
|
||||
MemberRefExpr:
|
||||
_extends: LookupExpr
|
||||
# base_expr: Expr
|
||||
base_expr: Expr
|
||||
|
||||
SubscriptExpr:
|
||||
_extends:
|
||||
- GenericContext
|
||||
- LookupExpr
|
||||
# base_expr: Expr
|
||||
# arguments: Argument*
|
||||
base_expr: Expr
|
||||
arguments: Argument*
|
||||
|
||||
OverloadedDeclRefExpr:
|
||||
_extends: OverloadSetRefExpr
|
||||
@@ -959,18 +959,18 @@ IsExpr:
|
||||
|
||||
BooleanLiteralExpr:
|
||||
_extends: BuiltinLiteralExpr
|
||||
# value: boolean
|
||||
value: boolean
|
||||
|
||||
MagicIdentifierLiteralExpr:
|
||||
_extends: BuiltinLiteralExpr
|
||||
# kind: string
|
||||
kind: string
|
||||
|
||||
NumberLiteralExpr:
|
||||
_extends: BuiltinLiteralExpr
|
||||
|
||||
StringLiteralExpr:
|
||||
_extends: BuiltinLiteralExpr
|
||||
# value: string
|
||||
value: string
|
||||
|
||||
DynamicMemberRefExpr:
|
||||
_extends: DynamicLookupExpr
|
||||
@@ -1018,11 +1018,11 @@ TypeAliasDecl:
|
||||
|
||||
FloatLiteralExpr:
|
||||
_extends: NumberLiteralExpr
|
||||
# string_value: string
|
||||
string_value: string
|
||||
|
||||
IntegerLiteralExpr:
|
||||
_extends: NumberLiteralExpr
|
||||
# string_value: string
|
||||
string_value: string
|
||||
|
||||
ErrorTypeRepr:
|
||||
_extends: TypeRepr
|
||||
|
||||
@@ -7,6 +7,541 @@ namespace codeql {
|
||||
class ExprVisitor : public AstVisitorBase<ExprVisitor> {
|
||||
public:
|
||||
using AstVisitorBase<ExprVisitor>::AstVisitorBase;
|
||||
|
||||
void visit(swift::Expr* expr) {
|
||||
swift::ExprVisitor<ExprVisitor, void>::visit(expr);
|
||||
auto label = dispatcher_.fetchLabel(expr);
|
||||
if (auto type = expr->getType()) {
|
||||
dispatcher_.emit(ExprTypesTrap{label, dispatcher_.fetchLabel(type)});
|
||||
}
|
||||
}
|
||||
|
||||
void visitIntegerLiteralExpr(swift::IntegerLiteralExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
auto value = (expr->isNegative() ? "-" : "") + expr->getDigitsText().str();
|
||||
dispatcher_.emit(IntegerLiteralExprsTrap{label, value});
|
||||
}
|
||||
|
||||
void visitFloatLiteralExpr(swift::FloatLiteralExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
auto value = (expr->isNegative() ? "-" : "") + expr->getDigitsText().str();
|
||||
dispatcher_.emit(FloatLiteralExprsTrap{label, value});
|
||||
}
|
||||
|
||||
void visitBooleanLiteralExpr(swift::BooleanLiteralExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(BooleanLiteralExprsTrap{label, expr->getValue()});
|
||||
}
|
||||
|
||||
void visitMagicIdentifierLiteralExpr(swift::MagicIdentifierLiteralExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
auto kind = swift::MagicIdentifierLiteralExpr::getKindString(expr->getKind()).str();
|
||||
dispatcher_.emit(MagicIdentifierLiteralExprsTrap{label, kind});
|
||||
}
|
||||
|
||||
void visitStringLiteralExpr(swift::StringLiteralExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(StringLiteralExprsTrap{label, expr->getValue().str()});
|
||||
}
|
||||
|
||||
void visitInterpolatedStringLiteralExpr(swift::InterpolatedStringLiteralExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(InterpolatedStringLiteralExprsTrap{label});
|
||||
if (auto interpolation = expr->getInterpolationExpr()) {
|
||||
auto ref = dispatcher_.fetchLabel(interpolation);
|
||||
dispatcher_.emit(InterpolatedStringLiteralExprInterpolationExprsTrap{label, ref});
|
||||
}
|
||||
if (auto count = expr->getInterpolationCountExpr()) {
|
||||
auto ref = dispatcher_.fetchLabel(count);
|
||||
dispatcher_.emit(InterpolatedStringLiteralExprInterpolationCountExprsTrap{label, ref});
|
||||
}
|
||||
if (auto capacity = expr->getLiteralCapacityExpr()) {
|
||||
auto ref = dispatcher_.fetchLabel(capacity);
|
||||
dispatcher_.emit(InterpolatedStringLiteralExprLiteralCapacityExprsTrap{label, ref});
|
||||
}
|
||||
if (auto appending = expr->getAppendingExpr()) {
|
||||
auto ref = dispatcher_.fetchLabel(appending);
|
||||
dispatcher_.emit(InterpolatedStringLiteralExprAppendingExprsTrap{label, ref});
|
||||
}
|
||||
}
|
||||
|
||||
void visitNilLiteralExpr(swift::NilLiteralExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(NilLiteralExprsTrap{label});
|
||||
}
|
||||
|
||||
void visitCallExpr(swift::CallExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(CallExprsTrap{label});
|
||||
emitApplyExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitPrefixUnaryExpr(swift::PrefixUnaryExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(PrefixUnaryExprsTrap{label});
|
||||
emitApplyExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitDeclRefExpr(swift::DeclRefExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(DeclRefExprsTrap{label, dispatcher_.fetchLabel(expr->getDecl())});
|
||||
auto i = 0u;
|
||||
for (auto t : expr->getDeclRef().getSubstitutions().getReplacementTypes()) {
|
||||
dispatcher_.emit(DeclRefExprReplacementTypesTrap{label, i++, dispatcher_.fetchLabel(t)});
|
||||
}
|
||||
}
|
||||
|
||||
void visitAssignExpr(swift::AssignExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getDest() && "AssignExpr has Dest");
|
||||
assert(expr->getSrc() && "AssignExpr has Src");
|
||||
auto dest = dispatcher_.fetchLabel(expr->getDest());
|
||||
auto src = dispatcher_.fetchLabel(expr->getSrc());
|
||||
dispatcher_.emit(AssignExprsTrap{label, dest, src});
|
||||
}
|
||||
|
||||
void visitBindOptionalExpr(swift::BindOptionalExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getSubExpr() && "BindOptionalExpr has SubExpr");
|
||||
auto subExpr = dispatcher_.fetchLabel(expr->getSubExpr());
|
||||
dispatcher_.emit(BindOptionalExprsTrap{label, subExpr});
|
||||
}
|
||||
|
||||
void visitCaptureListExpr(swift::CaptureListExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getClosureBody() && "CaptureListExpr has ClosureBody");
|
||||
auto closureBody = dispatcher_.fetchLabel(expr->getClosureBody());
|
||||
dispatcher_.emit(CaptureListExprsTrap{label, closureBody});
|
||||
unsigned index = 0;
|
||||
for (auto& entry : expr->getCaptureList()) {
|
||||
auto captureLabel = dispatcher_.fetchLabel(entry.PBD);
|
||||
dispatcher_.emit(CaptureListExprBindingDeclsTrap{label, index++, captureLabel});
|
||||
}
|
||||
}
|
||||
|
||||
void visitBinaryExpr(swift::BinaryExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(BinaryExprsTrap{label});
|
||||
emitApplyExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitTupleExpr(swift::TupleExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(TupleExprsTrap{label});
|
||||
unsigned index = 0;
|
||||
for (auto element : expr->getElements()) {
|
||||
auto elementLabel = dispatcher_.fetchLabel(element);
|
||||
dispatcher_.emit(TupleExprElementsTrap{label, index++, elementLabel});
|
||||
}
|
||||
}
|
||||
|
||||
void visitDefaultArgumentExpr(swift::DefaultArgumentExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getParamDecl() && "DefaultArgumentExpr has getParamDecl");
|
||||
/// TODO: suddenly, getParamDecl is const, monkey-patching it here
|
||||
auto paramLabel = dispatcher_.fetchLabel((swift::ParamDecl*)expr->getParamDecl());
|
||||
dispatcher_.emit(
|
||||
DefaultArgumentExprsTrap{label, paramLabel, static_cast<int>(expr->getParamIndex())});
|
||||
if (expr->isCallerSide()) {
|
||||
auto callSiteDefaultLabel = dispatcher_.fetchLabel(expr->getCallerSideDefaultExpr());
|
||||
dispatcher_.emit(DefaultArgumentExprCallerSideDefaultsTrap{label, callSiteDefaultLabel});
|
||||
}
|
||||
}
|
||||
|
||||
void visitDotSyntaxBaseIgnoredExpr(swift::DotSyntaxBaseIgnoredExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getLHS() && "DotSyntaxBaseIgnoredExpr has LHS");
|
||||
assert(expr->getRHS() && "DotSyntaxBaseIgnoredExpr has RHS");
|
||||
auto lhs = dispatcher_.fetchLabel(expr->getLHS());
|
||||
auto rhs = dispatcher_.fetchLabel(expr->getRHS());
|
||||
dispatcher_.emit(DotSyntaxBaseIgnoredExprsTrap{label, lhs, rhs});
|
||||
}
|
||||
|
||||
void visitDynamicTypeExpr(swift::DynamicTypeExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getBase() && "DynamicTypeExpr has Base");
|
||||
auto base = dispatcher_.fetchLabel(expr->getBase());
|
||||
dispatcher_.emit(DynamicTypeExprsTrap{label, base});
|
||||
}
|
||||
|
||||
void visitEnumIsCaseExpr(swift::EnumIsCaseExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getSubExpr() && "EnumIsCaseExpr has SubExpr");
|
||||
assert(expr->getCaseTypeRepr() && "EnumIsCaseExpr has CaseTypeRepr");
|
||||
assert(expr->getEnumElement() && "EnumIsCaseExpr has EnumElement");
|
||||
auto subExpr = dispatcher_.fetchLabel(expr->getSubExpr());
|
||||
auto typeRepr = dispatcher_.fetchLabel(expr->getCaseTypeRepr());
|
||||
auto enumElement = dispatcher_.fetchLabel(expr->getEnumElement());
|
||||
dispatcher_.emit(EnumIsCaseExprsTrap{label, subExpr, typeRepr, enumElement});
|
||||
}
|
||||
|
||||
void visitMakeTemporarilyEscapableExpr(swift::MakeTemporarilyEscapableExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getOpaqueValue() && "MakeTemporarilyEscapableExpr has OpaqueValue");
|
||||
assert(expr->getNonescapingClosureValue() &&
|
||||
"MakeTemporarilyEscapableExpr has NonescapingClosureValue");
|
||||
assert(expr->getSubExpr() && "MakeTemporarilyEscapableExpr has SubExpr");
|
||||
auto opaqueValue = dispatcher_.fetchLabel(expr->getOpaqueValue());
|
||||
auto nonescapingClosureValue = dispatcher_.fetchLabel(expr->getNonescapingClosureValue());
|
||||
auto subExpr = dispatcher_.fetchLabel(expr->getSubExpr());
|
||||
dispatcher_.emit(
|
||||
MakeTemporarilyEscapableExprsTrap{label, opaqueValue, nonescapingClosureValue, subExpr});
|
||||
}
|
||||
|
||||
void visitObjCSelectorExpr(swift::ObjCSelectorExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getSubExpr() && "ObjCSelectorExpr has SubExpr");
|
||||
assert(expr->getMethod() && "ObjCSelectorExpr has Method");
|
||||
auto subExpr = dispatcher_.fetchLabel(expr->getSubExpr());
|
||||
auto method = dispatcher_.fetchLabel(expr->getMethod());
|
||||
dispatcher_.emit(ObjCSelectorExprsTrap{label, subExpr, method});
|
||||
}
|
||||
|
||||
void visitOneWayExpr(swift::OneWayExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getSubExpr() && "OneWayExpr has SubExpr");
|
||||
auto subExpr = dispatcher_.fetchLabel(expr->getSubExpr());
|
||||
dispatcher_.emit(OneWayExprsTrap{label, subExpr});
|
||||
}
|
||||
|
||||
void visitOpenExistentialExpr(swift::OpenExistentialExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getSubExpr() && "OpenExistentialExpr has SubExpr");
|
||||
assert(expr->getExistentialValue() && "OpenExistentialExpr has ExistentialValue");
|
||||
assert(expr->getOpaqueValue() && "OpenExistentialExpr has OpaqueValue");
|
||||
auto subExpr = dispatcher_.fetchLabel(expr->getSubExpr());
|
||||
auto existentialValue = dispatcher_.fetchLabel(expr->getExistentialValue());
|
||||
auto opaqueValue = dispatcher_.fetchLabel(expr->getOpaqueValue());
|
||||
dispatcher_.emit(OpenExistentialExprsTrap{label, subExpr, existentialValue, opaqueValue});
|
||||
}
|
||||
|
||||
void visitOptionalEvaluationExpr(swift::OptionalEvaluationExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getSubExpr() && "OptionalEvaluationExpr has SubExpr");
|
||||
auto subExpr = dispatcher_.fetchLabel(expr->getSubExpr());
|
||||
dispatcher_.emit(OptionalEvaluationExprsTrap{label, subExpr});
|
||||
}
|
||||
|
||||
void visitRebindSelfInConstructorExpr(swift::RebindSelfInConstructorExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getSubExpr() && "RebindSelfInConstructorExpr has SubExpr");
|
||||
assert(expr->getSelf() && "RebindSelfInConstructorExpr has Self");
|
||||
auto subExpr = dispatcher_.fetchLabel(expr->getSubExpr());
|
||||
auto self = dispatcher_.fetchLabel(expr->getSelf());
|
||||
dispatcher_.emit(RebindSelfInConstructorExprsTrap{label, subExpr, self});
|
||||
}
|
||||
|
||||
void visitSuperRefExpr(swift::SuperRefExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getSelf() && "SuperRefExpr has Self");
|
||||
auto self = dispatcher_.fetchLabel(expr->getSelf());
|
||||
dispatcher_.emit(SuperRefExprsTrap{label, self});
|
||||
}
|
||||
|
||||
void visitDotSyntaxCallExpr(swift::DotSyntaxCallExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(DotSyntaxCallExprsTrap{label});
|
||||
emitSelfApplyExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitVarargExpansionExpr(swift::VarargExpansionExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getSubExpr() && "VarargExpansionExpr has getSubExpr()");
|
||||
|
||||
auto subExprLabel = dispatcher_.fetchLabel(expr->getSubExpr());
|
||||
dispatcher_.emit(VarargExpansionExprsTrap{label, subExprLabel});
|
||||
}
|
||||
|
||||
void visitArrayExpr(swift::ArrayExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(ArrayExprsTrap{label});
|
||||
unsigned index = 0;
|
||||
for (auto element : expr->getElements()) {
|
||||
auto elementLabel = dispatcher_.fetchLabel(element);
|
||||
dispatcher_.emit(ArrayExprElementsTrap{label, index++, elementLabel});
|
||||
}
|
||||
}
|
||||
|
||||
void visitErasureExpr(swift::ErasureExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(ErasureExprsTrap{label});
|
||||
emitImplicitConversionExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitTypeExpr(swift::TypeExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(TypeExprsTrap{label});
|
||||
if (auto repr = expr->getTypeRepr()) {
|
||||
auto typeLabel = dispatcher_.fetchLabel(repr);
|
||||
dispatcher_.emit(TypeExprTypeReprsTrap{label, typeLabel});
|
||||
}
|
||||
}
|
||||
|
||||
void visitParenExpr(swift::ParenExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(ParenExprsTrap{label});
|
||||
emitIdentityExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitLoadExpr(swift::LoadExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(LoadExprsTrap{label});
|
||||
emitImplicitConversionExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitInOutExpr(swift::InOutExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getSubExpr() && "InOutExpr has getSubExpr()");
|
||||
|
||||
auto subExprLabel = dispatcher_.fetchLabel(expr->getSubExpr());
|
||||
dispatcher_.emit(InOutExprsTrap{label, subExprLabel});
|
||||
}
|
||||
|
||||
void visitOpaqueValueExpr(swift::OpaqueValueExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(OpaqueValueExprsTrap{label});
|
||||
}
|
||||
|
||||
void visitTapExpr(swift::TapExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getVar() && "TapExpr has getVar()");
|
||||
assert(expr->getBody() && "TapExpr has getBody()");
|
||||
|
||||
auto varLabel = dispatcher_.fetchLabel(expr->getVar());
|
||||
auto bodyLabel = dispatcher_.fetchLabel(expr->getBody());
|
||||
|
||||
dispatcher_.emit(TapExprsTrap{label, varLabel, bodyLabel});
|
||||
if (auto subExpr = expr->getSubExpr()) {
|
||||
dispatcher_.emit(TapExprSubExprsTrap{label, dispatcher_.fetchLabel(subExpr)});
|
||||
}
|
||||
}
|
||||
|
||||
void visitTupleElementExpr(swift::TupleElementExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getBase() && "TupleElementExpr has getBase()");
|
||||
|
||||
auto base = dispatcher_.fetchLabel(expr->getBase());
|
||||
auto index = expr->getFieldNumber();
|
||||
dispatcher_.emit(TupleElementExprsTrap{label, base, index});
|
||||
}
|
||||
|
||||
void visitTryExpr(swift::TryExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(TryExprsTrap{label});
|
||||
emitAnyTryExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitForceTryExpr(swift::ForceTryExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(ForceTryExprsTrap{label});
|
||||
emitAnyTryExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitOptionalTryExpr(swift::OptionalTryExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(OptionalTryExprsTrap{label});
|
||||
emitAnyTryExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitInjectIntoOptionalExpr(swift::InjectIntoOptionalExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(InjectIntoOptionalExprsTrap{label});
|
||||
emitImplicitConversionExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitConstructorRefCallExpr(swift::ConstructorRefCallExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(ConstructorRefCallExprsTrap{label});
|
||||
emitSelfApplyExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitDiscardAssignmentExpr(swift::DiscardAssignmentExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(DiscardAssignmentExprsTrap{label});
|
||||
}
|
||||
|
||||
void visitClosureExpr(swift::ClosureExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getBody() && "ClosureExpr has getBody()");
|
||||
auto bodyLabel = dispatcher_.fetchLabel(expr->getBody());
|
||||
dispatcher_.emit(ClosureExprsTrap{label, bodyLabel});
|
||||
}
|
||||
|
||||
void visitAutoClosureExpr(swift::AutoClosureExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getBody() && "AutoClosureExpr has getBody()");
|
||||
auto bodyLabel = dispatcher_.fetchLabel(expr->getBody());
|
||||
dispatcher_.emit(AutoClosureExprsTrap{label, bodyLabel});
|
||||
}
|
||||
|
||||
void visitCoerceExpr(swift::CoerceExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(CoerceExprsTrap{label});
|
||||
emitExplicitCastExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitConditionalCheckedCastExpr(swift::ConditionalCheckedCastExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(ConditionalCheckedCastExprsTrap{label});
|
||||
emitExplicitCastExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitForcedCheckedCastExpr(swift::ForcedCheckedCastExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(ForcedCheckedCastExprsTrap{label});
|
||||
emitExplicitCastExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitIsExpr(swift::IsExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(IsExprsTrap{label});
|
||||
emitExplicitCastExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitSubscriptExpr(swift::SubscriptExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getBase() && "SubscriptExpr has getBase()");
|
||||
auto baseLabel = dispatcher_.fetchLabel(expr->getBase());
|
||||
dispatcher_.emit(SubscriptExprsTrap{label, baseLabel});
|
||||
|
||||
auto i = 0u;
|
||||
for (const auto& arg : *expr->getArgs()) {
|
||||
dispatcher_.emit(SubscriptExprArgumentsTrap{label, i++, emitArgument(arg)});
|
||||
}
|
||||
}
|
||||
|
||||
void visitDictionaryExpr(swift::DictionaryExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(DictionaryExprsTrap{label});
|
||||
unsigned index = 0;
|
||||
for (auto element : expr->getElements()) {
|
||||
auto elementLabel = dispatcher_.fetchLabel(element);
|
||||
dispatcher_.emit(DictionaryExprElementsTrap{label, index++, elementLabel});
|
||||
}
|
||||
}
|
||||
|
||||
void visitFunctionConversionExpr(swift::FunctionConversionExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(FunctionConversionExprsTrap{label});
|
||||
emitImplicitConversionExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitInOutToPointerExpr(swift::InOutToPointerExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(InOutToPointerExprsTrap{label});
|
||||
emitImplicitConversionExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitMemberRefExpr(swift::MemberRefExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getBase() && "MemberRefExpr has getBase()");
|
||||
|
||||
auto baseLabel = dispatcher_.fetchLabel(expr->getBase());
|
||||
dispatcher_.emit(MemberRefExprsTrap{label, baseLabel});
|
||||
}
|
||||
|
||||
void visitDerivedToBaseExpr(swift::DerivedToBaseExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(DerivedToBaseExprsTrap{label});
|
||||
emitImplicitConversionExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitKeyPathExpr(swift::KeyPathExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(KeyPathExprsTrap{label});
|
||||
if (!expr->isObjC()) {
|
||||
if (auto path = expr->getParsedPath()) {
|
||||
auto pathLabel = dispatcher_.fetchLabel(path);
|
||||
dispatcher_.emit(KeyPathExprParsedPathsTrap{label, pathLabel});
|
||||
}
|
||||
if (auto root = expr->getParsedPath()) {
|
||||
auto rootLabel = dispatcher_.fetchLabel(root);
|
||||
dispatcher_.emit(KeyPathExprParsedRootsTrap{label, rootLabel});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void visitLazyInitializerExpr(swift::LazyInitializerExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getSubExpr() && "LazyInitializerExpr has getSubExpr()");
|
||||
auto subExprLabel = dispatcher_.fetchLabel(expr->getSubExpr());
|
||||
dispatcher_.emit(LazyInitializerExprsTrap{label, subExprLabel});
|
||||
}
|
||||
|
||||
void visitForceValueExpr(swift::ForceValueExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getSubExpr() && "ForceValueExpr has getSubExpr()");
|
||||
|
||||
auto subExprLabel = dispatcher_.fetchLabel(expr->getSubExpr());
|
||||
dispatcher_.emit(ForceValueExprsTrap{label, subExprLabel});
|
||||
}
|
||||
|
||||
void visitPointerToPointerExpr(swift::PointerToPointerExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
dispatcher_.emit(PointerToPointerExprsTrap{label});
|
||||
emitImplicitConversionExpr(expr, label);
|
||||
}
|
||||
|
||||
void visitIfExpr(swift::IfExpr* expr) {
|
||||
auto label = dispatcher_.assignNewLabel(expr);
|
||||
assert(expr->getCondExpr() && "IfExpr has getCond()");
|
||||
assert(expr->getThenExpr() && "IfExpr has getThenExpr()");
|
||||
assert(expr->getElseExpr() && "IfExpr has getElseExpr()");
|
||||
|
||||
auto condLabel = dispatcher_.fetchLabel(expr->getCondExpr());
|
||||
auto thenLabel = dispatcher_.fetchLabel(expr->getThenExpr());
|
||||
auto elseLabel = dispatcher_.fetchLabel(expr->getElseExpr());
|
||||
|
||||
dispatcher_.emit(IfExprsTrap{label, condLabel, thenLabel, elseLabel});
|
||||
}
|
||||
|
||||
private:
|
||||
TrapLabel<ArgumentTag> emitArgument(const swift::Argument& arg) {
|
||||
auto argLabel = dispatcher_.createLabel<ArgumentTag>();
|
||||
assert(arg.getExpr() && "Argument has getExpr");
|
||||
dispatcher_.emit(
|
||||
ArgumentsTrap{argLabel, arg.getLabel().str().str(), dispatcher_.fetchLabel(arg.getExpr())});
|
||||
return argLabel;
|
||||
}
|
||||
|
||||
void emitImplicitConversionExpr(swift::ImplicitConversionExpr* expr,
|
||||
TrapLabel<ImplicitConversionExprTag> label) {
|
||||
assert(expr->getSubExpr() && "ImplicitConversionExpr has getSubExpr()");
|
||||
dispatcher_.emit(
|
||||
ImplicitConversionExprsTrap{label, dispatcher_.fetchLabel(expr->getSubExpr())});
|
||||
}
|
||||
|
||||
void emitExplicitCastExpr(swift::ExplicitCastExpr* expr, TrapLabel<ExplicitCastExprTag> label) {
|
||||
assert(expr->getSubExpr() && "ExplicitCastExpr has getSubExpr()");
|
||||
dispatcher_.emit(ExplicitCastExprsTrap{label, dispatcher_.fetchLabel(expr->getSubExpr())});
|
||||
}
|
||||
|
||||
void emitIdentityExpr(swift::IdentityExpr* expr, TrapLabel<IdentityExprTag> label) {
|
||||
assert(expr->getSubExpr() && "IdentityExpr has getSubExpr()");
|
||||
dispatcher_.emit(IdentityExprsTrap{label, dispatcher_.fetchLabel(expr->getSubExpr())});
|
||||
}
|
||||
|
||||
void emitAnyTryExpr(swift::AnyTryExpr* expr, TrapLabel<AnyTryExprTag> label) {
|
||||
assert(expr->getSubExpr() && "AnyTryExpr has getSubExpr()");
|
||||
dispatcher_.emit(AnyTryExprsTrap{label, dispatcher_.fetchLabel(expr->getSubExpr())});
|
||||
}
|
||||
|
||||
void emitApplyExpr(const swift::ApplyExpr* expr, TrapLabel<ApplyExprTag> label) {
|
||||
assert(expr->getFn() && "CallExpr has Fn");
|
||||
auto fnLabel = dispatcher_.fetchLabel(expr->getFn());
|
||||
dispatcher_.emit(ApplyExprsTrap{label, fnLabel});
|
||||
auto i = 0u;
|
||||
for (const auto& arg : *expr->getArgs()) {
|
||||
dispatcher_.emit(ApplyExprArgumentsTrap{label, i++, emitArgument(arg)});
|
||||
}
|
||||
}
|
||||
|
||||
void emitSelfApplyExpr(const swift::SelfApplyExpr* expr, TrapLabel<SelfApplyExprTag> label) {
|
||||
assert(expr->getBase() && "SelfApplyExpr has getBase()");
|
||||
auto baseLabel = dispatcher_.fetchLabel(expr->getBase());
|
||||
dispatcher_.emit(SelfApplyExprsTrap{label, baseLabel});
|
||||
emitApplyExpr(expr, label);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace codeql
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.Expr
|
||||
|
||||
class AnyTryExprBase extends @any_try_expr, Expr { }
|
||||
class AnyTryExprBase extends @any_try_expr, Expr {
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
any_try_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,23 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.Argument
|
||||
import codeql.swift.elements.expr.Expr
|
||||
|
||||
class ApplyExprBase extends @apply_expr, Expr { }
|
||||
class ApplyExprBase extends @apply_expr, Expr {
|
||||
Expr getFunction() {
|
||||
exists(Expr x |
|
||||
apply_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Argument getArgument(int index) {
|
||||
exists(Argument x |
|
||||
apply_expr_arguments(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Argument getAnArgument() { result = getArgument(_) }
|
||||
|
||||
int getNumberOfArguments() { result = count(getAnArgument()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.Element
|
||||
import codeql.swift.elements.expr.Expr
|
||||
|
||||
class ArgumentBase extends @argument, Element {
|
||||
override string getAPrimaryQlClass() { result = "Argument" }
|
||||
|
||||
string getLabel() { arguments(this, result, _) }
|
||||
|
||||
Expr getExpr() {
|
||||
exists(Expr x |
|
||||
arguments(this, _, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.CollectionExpr
|
||||
import codeql.swift.elements.expr.Expr
|
||||
|
||||
class ArrayExprBase extends @array_expr, CollectionExpr {
|
||||
override string getAPrimaryQlClass() { result = "ArrayExpr" }
|
||||
|
||||
Expr getElement(int index) {
|
||||
exists(Expr x |
|
||||
array_expr_elements(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Expr getAnElement() { result = getElement(_) }
|
||||
|
||||
int getNumberOfElements() { result = count(getAnElement()) }
|
||||
}
|
||||
|
||||
@@ -3,4 +3,18 @@ import codeql.swift.elements.expr.Expr
|
||||
|
||||
class AssignExprBase extends @assign_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "AssignExpr" }
|
||||
|
||||
Expr getDest() {
|
||||
exists(Expr x |
|
||||
assign_exprs(this, x, _) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Expr getSource() {
|
||||
exists(Expr x |
|
||||
assign_exprs(this, _, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.AbstractClosureExpr
|
||||
import codeql.swift.elements.stmt.BraceStmt
|
||||
|
||||
class AutoClosureExprBase extends @auto_closure_expr, AbstractClosureExpr {
|
||||
override string getAPrimaryQlClass() { result = "AutoClosureExpr" }
|
||||
|
||||
BraceStmt getBody() {
|
||||
exists(BraceStmt x |
|
||||
auto_closure_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,11 @@ import codeql.swift.elements.expr.Expr
|
||||
|
||||
class BindOptionalExprBase extends @bind_optional_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "BindOptionalExpr" }
|
||||
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
bind_optional_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,6 @@ import codeql.swift.elements.expr.BuiltinLiteralExpr
|
||||
|
||||
class BooleanLiteralExprBase extends @boolean_literal_expr, BuiltinLiteralExpr {
|
||||
override string getAPrimaryQlClass() { result = "BooleanLiteralExpr" }
|
||||
|
||||
boolean getValue() { boolean_literal_exprs(this, result) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,26 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.ClosureExpr
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.decl.PatternBindingDecl
|
||||
|
||||
class CaptureListExprBase extends @capture_list_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "CaptureListExpr" }
|
||||
|
||||
PatternBindingDecl getBindingDecl(int index) {
|
||||
exists(PatternBindingDecl x |
|
||||
capture_list_expr_binding_decls(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
PatternBindingDecl getABindingDecl() { result = getBindingDecl(_) }
|
||||
|
||||
int getNumberOfBindingDecls() { result = count(getABindingDecl()) }
|
||||
|
||||
ClosureExpr getClosureBody() {
|
||||
exists(ClosureExpr x |
|
||||
capture_list_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.AbstractClosureExpr
|
||||
import codeql.swift.elements.stmt.BraceStmt
|
||||
|
||||
class ClosureExprBase extends @closure_expr, AbstractClosureExpr {
|
||||
override string getAPrimaryQlClass() { result = "ClosureExpr" }
|
||||
|
||||
BraceStmt getBody() {
|
||||
exists(BraceStmt x |
|
||||
closure_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,26 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.decl.Decl
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.type.Type
|
||||
|
||||
class DeclRefExprBase extends @decl_ref_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "DeclRefExpr" }
|
||||
|
||||
Decl getDecl() {
|
||||
exists(Decl x |
|
||||
decl_ref_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Type getReplacementType(int index) {
|
||||
exists(Type x |
|
||||
decl_ref_expr_replacement_types(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Type getAReplacementType() { result = getReplacementType(_) }
|
||||
|
||||
int getNumberOfReplacementTypes() { result = count(getAReplacementType()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,25 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.decl.ParamDecl
|
||||
|
||||
class DefaultArgumentExprBase extends @default_argument_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "DefaultArgumentExpr" }
|
||||
|
||||
ParamDecl getParamDecl() {
|
||||
exists(ParamDecl x |
|
||||
default_argument_exprs(this, x, _) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
int getParamIndex() { default_argument_exprs(this, _, result) }
|
||||
|
||||
Expr getCallerSideDefault() {
|
||||
exists(Expr x |
|
||||
default_argument_expr_caller_side_defaults(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasCallerSideDefault() { exists(getCallerSideDefault()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.CollectionExpr
|
||||
import codeql.swift.elements.expr.Expr
|
||||
|
||||
class DictionaryExprBase extends @dictionary_expr, CollectionExpr {
|
||||
override string getAPrimaryQlClass() { result = "DictionaryExpr" }
|
||||
|
||||
Expr getElement(int index) {
|
||||
exists(Expr x |
|
||||
dictionary_expr_elements(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Expr getAnElement() { result = getElement(_) }
|
||||
|
||||
int getNumberOfElements() { result = count(getAnElement()) }
|
||||
}
|
||||
|
||||
@@ -3,4 +3,18 @@ import codeql.swift.elements.expr.Expr
|
||||
|
||||
class DotSyntaxBaseIgnoredExprBase extends @dot_syntax_base_ignored_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "DotSyntaxBaseIgnoredExpr" }
|
||||
|
||||
Expr getQualifier() {
|
||||
exists(Expr x |
|
||||
dot_syntax_base_ignored_exprs(this, x, _) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
dot_syntax_base_ignored_exprs(this, _, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,11 @@ import codeql.swift.elements.expr.Expr
|
||||
|
||||
class DynamicTypeExprBase extends @dynamic_type_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "DynamicTypeExpr" }
|
||||
|
||||
Expr getBaseExpr() {
|
||||
exists(Expr x |
|
||||
dynamic_type_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,29 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.decl.EnumElementDecl
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.typerepr.TypeRepr
|
||||
|
||||
class EnumIsCaseExprBase extends @enum_is_case_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "EnumIsCaseExpr" }
|
||||
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
enum_is_case_exprs(this, x, _, _) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
TypeRepr getTypeRepr() {
|
||||
exists(TypeRepr x |
|
||||
enum_is_case_exprs(this, _, x, _) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
EnumElementDecl getElement() {
|
||||
exists(EnumElementDecl x |
|
||||
enum_is_case_exprs(this, _, _, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.Expr
|
||||
|
||||
class ExplicitCastExprBase extends @explicit_cast_expr, Expr { }
|
||||
class ExplicitCastExprBase extends @explicit_cast_expr, Expr {
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
explicit_cast_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.AstNode
|
||||
import codeql.swift.elements.type.Type
|
||||
|
||||
class ExprBase extends @expr, AstNode { }
|
||||
class ExprBase extends @expr, AstNode {
|
||||
Type getType() {
|
||||
exists(Type x |
|
||||
expr_types(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasType() { exists(getType()) }
|
||||
}
|
||||
|
||||
@@ -3,4 +3,6 @@ import codeql.swift.elements.expr.NumberLiteralExpr
|
||||
|
||||
class FloatLiteralExprBase extends @float_literal_expr, NumberLiteralExpr {
|
||||
override string getAPrimaryQlClass() { result = "FloatLiteralExpr" }
|
||||
|
||||
string getStringValue() { float_literal_exprs(this, result) }
|
||||
}
|
||||
|
||||
@@ -3,4 +3,11 @@ import codeql.swift.elements.expr.Expr
|
||||
|
||||
class ForceValueExprBase extends @force_value_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "ForceValueExpr" }
|
||||
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
force_value_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.Expr
|
||||
|
||||
class IdentityExprBase extends @identity_expr, Expr { }
|
||||
class IdentityExprBase extends @identity_expr, Expr {
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
identity_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,25 @@ import codeql.swift.elements.expr.Expr
|
||||
|
||||
class IfExprBase extends @if_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "IfExpr" }
|
||||
|
||||
Expr getCondition() {
|
||||
exists(Expr x |
|
||||
if_exprs(this, x, _, _) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Expr getThenExpr() {
|
||||
exists(Expr x |
|
||||
if_exprs(this, _, x, _) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Expr getElseExpr() {
|
||||
exists(Expr x |
|
||||
if_exprs(this, _, _, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.Expr
|
||||
|
||||
class ImplicitConversionExprBase extends @implicit_conversion_expr, Expr { }
|
||||
class ImplicitConversionExprBase extends @implicit_conversion_expr, Expr {
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
implicit_conversion_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,11 @@ import codeql.swift.elements.expr.Expr
|
||||
|
||||
class InOutExprBase extends @in_out_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "InOutExpr" }
|
||||
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
in_out_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,6 @@ import codeql.swift.elements.expr.NumberLiteralExpr
|
||||
|
||||
class IntegerLiteralExprBase extends @integer_literal_expr, NumberLiteralExpr {
|
||||
override string getAPrimaryQlClass() { result = "IntegerLiteralExpr" }
|
||||
|
||||
string getStringValue() { integer_literal_exprs(this, result) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,45 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.expr.LiteralExpr
|
||||
import codeql.swift.elements.expr.OpaqueValueExpr
|
||||
import codeql.swift.elements.expr.TapExpr
|
||||
|
||||
class InterpolatedStringLiteralExprBase extends @interpolated_string_literal_expr, LiteralExpr {
|
||||
override string getAPrimaryQlClass() { result = "InterpolatedStringLiteralExpr" }
|
||||
|
||||
OpaqueValueExpr getInterpolationExpr() {
|
||||
exists(OpaqueValueExpr x |
|
||||
interpolated_string_literal_expr_interpolation_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasInterpolationExpr() { exists(getInterpolationExpr()) }
|
||||
|
||||
Expr getInterpolationCountExpr() {
|
||||
exists(Expr x |
|
||||
interpolated_string_literal_expr_interpolation_count_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasInterpolationCountExpr() { exists(getInterpolationCountExpr()) }
|
||||
|
||||
Expr getLiteralCapacityExpr() {
|
||||
exists(Expr x |
|
||||
interpolated_string_literal_expr_literal_capacity_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasLiteralCapacityExpr() { exists(getLiteralCapacityExpr()) }
|
||||
|
||||
TapExpr getAppendingExpr() {
|
||||
exists(TapExpr x |
|
||||
interpolated_string_literal_expr_appending_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasAppendingExpr() { exists(getAppendingExpr()) }
|
||||
}
|
||||
|
||||
@@ -3,4 +3,22 @@ import codeql.swift.elements.expr.Expr
|
||||
|
||||
class KeyPathExprBase extends @key_path_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "KeyPathExpr" }
|
||||
|
||||
Expr getParsedRoot() {
|
||||
exists(Expr x |
|
||||
key_path_expr_parsed_roots(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasParsedRoot() { exists(getParsedRoot()) }
|
||||
|
||||
Expr getParsedPath() {
|
||||
exists(Expr x |
|
||||
key_path_expr_parsed_paths(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasParsedPath() { exists(getParsedPath()) }
|
||||
}
|
||||
|
||||
@@ -3,4 +3,11 @@ import codeql.swift.elements.expr.Expr
|
||||
|
||||
class LazyInitializerExprBase extends @lazy_initializer_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "LazyInitializerExpr" }
|
||||
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
lazy_initializer_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,6 @@ import codeql.swift.elements.expr.BuiltinLiteralExpr
|
||||
|
||||
class MagicIdentifierLiteralExprBase extends @magic_identifier_literal_expr, BuiltinLiteralExpr {
|
||||
override string getAPrimaryQlClass() { result = "MagicIdentifierLiteralExpr" }
|
||||
|
||||
string getKind() { magic_identifier_literal_exprs(this, result) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,28 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.expr.OpaqueValueExpr
|
||||
|
||||
class MakeTemporarilyEscapableExprBase extends @make_temporarily_escapable_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "MakeTemporarilyEscapableExpr" }
|
||||
|
||||
OpaqueValueExpr getEscapingClosure() {
|
||||
exists(OpaqueValueExpr x |
|
||||
make_temporarily_escapable_exprs(this, x, _, _) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Expr getNonescapingClosure() {
|
||||
exists(Expr x |
|
||||
make_temporarily_escapable_exprs(this, _, x, _) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
make_temporarily_escapable_exprs(this, _, _, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.expr.LookupExpr
|
||||
|
||||
class MemberRefExprBase extends @member_ref_expr, LookupExpr {
|
||||
override string getAPrimaryQlClass() { result = "MemberRefExpr" }
|
||||
|
||||
Expr getBaseExpr() {
|
||||
exists(Expr x |
|
||||
member_ref_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,21 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.decl.AbstractFunctionDecl
|
||||
import codeql.swift.elements.expr.Expr
|
||||
|
||||
class ObjCSelectorExprBase extends @obj_c_selector_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "ObjCSelectorExpr" }
|
||||
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
obj_c_selector_exprs(this, x, _) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
AbstractFunctionDecl getMethod() {
|
||||
exists(AbstractFunctionDecl x |
|
||||
obj_c_selector_exprs(this, _, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,11 @@ import codeql.swift.elements.expr.Expr
|
||||
|
||||
class OneWayExprBase extends @one_way_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "OneWayExpr" }
|
||||
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
one_way_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,28 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.expr.OpaqueValueExpr
|
||||
|
||||
class OpenExistentialExprBase extends @open_existential_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "OpenExistentialExpr" }
|
||||
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
open_existential_exprs(this, x, _, _) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Expr getExistential() {
|
||||
exists(Expr x |
|
||||
open_existential_exprs(this, _, x, _) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
OpaqueValueExpr getOpaqueExpr() {
|
||||
exists(OpaqueValueExpr x |
|
||||
open_existential_exprs(this, _, _, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,11 @@ import codeql.swift.elements.expr.Expr
|
||||
|
||||
class OptionalEvaluationExprBase extends @optional_evaluation_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "OptionalEvaluationExpr" }
|
||||
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
optional_evaluation_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,21 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.decl.VarDecl
|
||||
|
||||
class RebindSelfInConstructorExprBase extends @rebind_self_in_constructor_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "RebindSelfInConstructorExpr" }
|
||||
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
rebind_self_in_constructor_exprs(this, x, _) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
VarDecl getSelf() {
|
||||
exists(VarDecl x |
|
||||
rebind_self_in_constructor_exprs(this, _, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.ApplyExpr
|
||||
import codeql.swift.elements.expr.Expr
|
||||
|
||||
class SelfApplyExprBase extends @self_apply_expr, ApplyExpr { }
|
||||
class SelfApplyExprBase extends @self_apply_expr, ApplyExpr {
|
||||
Expr getBaseExpr() {
|
||||
exists(Expr x |
|
||||
self_apply_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,6 @@ import codeql.swift.elements.expr.BuiltinLiteralExpr
|
||||
|
||||
class StringLiteralExprBase extends @string_literal_expr, BuiltinLiteralExpr {
|
||||
override string getAPrimaryQlClass() { result = "StringLiteralExpr" }
|
||||
|
||||
string getValue() { string_literal_exprs(this, result) }
|
||||
}
|
||||
|
||||
@@ -1,7 +1,27 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.Argument
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.decl.GenericContext
|
||||
import codeql.swift.elements.expr.LookupExpr
|
||||
|
||||
class SubscriptExprBase extends @subscript_expr, GenericContext, LookupExpr {
|
||||
override string getAPrimaryQlClass() { result = "SubscriptExpr" }
|
||||
|
||||
Expr getBaseExpr() {
|
||||
exists(Expr x |
|
||||
subscript_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Argument getArgument(int index) {
|
||||
exists(Argument x |
|
||||
subscript_expr_arguments(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Argument getAnArgument() { result = getArgument(_) }
|
||||
|
||||
int getNumberOfArguments() { result = count(getAnArgument()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.decl.VarDecl
|
||||
|
||||
class SuperRefExprBase extends @super_ref_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "SuperRefExpr" }
|
||||
|
||||
VarDecl getSelf() {
|
||||
exists(VarDecl x |
|
||||
super_ref_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,31 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.stmt.BraceStmt
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.decl.VarDecl
|
||||
|
||||
class TapExprBase extends @tap_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "TapExpr" }
|
||||
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
tap_expr_sub_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasSubExpr() { exists(getSubExpr()) }
|
||||
|
||||
VarDecl getVar() {
|
||||
exists(VarDecl x |
|
||||
tap_exprs(this, x, _) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
BraceStmt getBody() {
|
||||
exists(BraceStmt x |
|
||||
tap_exprs(this, _, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,13 @@ import codeql.swift.elements.expr.Expr
|
||||
|
||||
class TupleElementExprBase extends @tuple_element_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "TupleElementExpr" }
|
||||
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
tuple_element_exprs(this, x, _) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
int getIndex() { tuple_element_exprs(this, _, result) }
|
||||
}
|
||||
|
||||
@@ -3,4 +3,15 @@ import codeql.swift.elements.expr.Expr
|
||||
|
||||
class TupleExprBase extends @tuple_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "TupleExpr" }
|
||||
|
||||
Expr getElement(int index) {
|
||||
exists(Expr x |
|
||||
tuple_expr_elements(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Expr getAnElement() { result = getElement(_) }
|
||||
|
||||
int getNumberOfElements() { result = count(getAnElement()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.typerepr.TypeRepr
|
||||
|
||||
class TypeExprBase extends @type_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "TypeExpr" }
|
||||
|
||||
TypeRepr getTypeRepr() {
|
||||
exists(TypeRepr x |
|
||||
type_expr_type_reprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasTypeRepr() { exists(getTypeRepr()) }
|
||||
}
|
||||
|
||||
@@ -3,4 +3,11 @@ import codeql.swift.elements.expr.Expr
|
||||
|
||||
class VarargExpansionExprBase extends @vararg_expansion_expr, Expr {
|
||||
override string getAPrimaryQlClass() { result = "VarargExpansionExpr" }
|
||||
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
vararg_expansion_exprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,6 +334,12 @@ struct_decls(
|
||||
| @vararg_expansion_expr
|
||||
;
|
||||
|
||||
#keyset[id]
|
||||
expr_types(
|
||||
int id: @expr ref,
|
||||
int type_: @type ref
|
||||
);
|
||||
|
||||
@pattern =
|
||||
@any_pattern
|
||||
| @binding_pattern
|
||||
@@ -582,12 +588,20 @@ value_decls(
|
||||
| @try_expr
|
||||
;
|
||||
|
||||
#keyset[id]
|
||||
any_try_exprs(
|
||||
int id: @any_try_expr ref,
|
||||
int sub_expr: @expr ref
|
||||
);
|
||||
|
||||
applied_property_wrapper_exprs(
|
||||
unique int id: @applied_property_wrapper_expr
|
||||
);
|
||||
|
||||
arguments(
|
||||
unique int id: @argument
|
||||
unique int id: @argument,
|
||||
string label: string ref,
|
||||
int expr: @expr ref
|
||||
);
|
||||
|
||||
@apply_expr =
|
||||
@@ -598,20 +612,44 @@ arguments(
|
||||
| @self_apply_expr
|
||||
;
|
||||
|
||||
#keyset[id]
|
||||
apply_exprs(
|
||||
int id: @apply_expr ref,
|
||||
int function: @expr ref
|
||||
);
|
||||
|
||||
#keyset[id, index]
|
||||
apply_expr_arguments(
|
||||
int id: @apply_expr ref,
|
||||
int index: int ref,
|
||||
int argument: @argument ref
|
||||
);
|
||||
|
||||
arrow_exprs(
|
||||
unique int id: @arrow_expr
|
||||
);
|
||||
|
||||
assign_exprs(
|
||||
unique int id: @assign_expr
|
||||
unique int id: @assign_expr,
|
||||
int dest: @expr ref,
|
||||
int source: @expr ref
|
||||
);
|
||||
|
||||
bind_optional_exprs(
|
||||
unique int id: @bind_optional_expr
|
||||
unique int id: @bind_optional_expr,
|
||||
int sub_expr: @expr ref
|
||||
);
|
||||
|
||||
capture_list_exprs(
|
||||
unique int id: @capture_list_expr
|
||||
unique int id: @capture_list_expr,
|
||||
int closure_body: @closure_expr ref
|
||||
);
|
||||
|
||||
#keyset[id, index]
|
||||
capture_list_expr_binding_decls(
|
||||
int id: @capture_list_expr ref,
|
||||
int index: int ref,
|
||||
int binding_decl: @pattern_binding_decl ref
|
||||
);
|
||||
|
||||
code_completion_exprs(
|
||||
@@ -624,11 +662,27 @@ code_completion_exprs(
|
||||
;
|
||||
|
||||
decl_ref_exprs(
|
||||
unique int id: @decl_ref_expr
|
||||
unique int id: @decl_ref_expr,
|
||||
int decl: @decl ref
|
||||
);
|
||||
|
||||
#keyset[id, index]
|
||||
decl_ref_expr_replacement_types(
|
||||
int id: @decl_ref_expr ref,
|
||||
int index: int ref,
|
||||
int replacement_type: @type ref
|
||||
);
|
||||
|
||||
default_argument_exprs(
|
||||
unique int id: @default_argument_expr
|
||||
unique int id: @default_argument_expr,
|
||||
int param_decl: @param_decl ref,
|
||||
int param_index: int ref
|
||||
);
|
||||
|
||||
#keyset[id]
|
||||
default_argument_expr_caller_side_defaults(
|
||||
int id: @default_argument_expr ref,
|
||||
int caller_side_default: @expr ref
|
||||
);
|
||||
|
||||
discard_assignment_exprs(
|
||||
@@ -636,11 +690,14 @@ discard_assignment_exprs(
|
||||
);
|
||||
|
||||
dot_syntax_base_ignored_exprs(
|
||||
unique int id: @dot_syntax_base_ignored_expr
|
||||
unique int id: @dot_syntax_base_ignored_expr,
|
||||
int qualifier: @expr ref,
|
||||
int sub_expr: @expr ref
|
||||
);
|
||||
|
||||
dynamic_type_exprs(
|
||||
unique int id: @dynamic_type_expr
|
||||
unique int id: @dynamic_type_expr,
|
||||
int base_expr: @expr ref
|
||||
);
|
||||
|
||||
editor_placeholder_exprs(
|
||||
@@ -648,7 +705,10 @@ editor_placeholder_exprs(
|
||||
);
|
||||
|
||||
enum_is_case_exprs(
|
||||
unique int id: @enum_is_case_expr
|
||||
unique int id: @enum_is_case_expr,
|
||||
int sub_expr: @expr ref,
|
||||
int type_repr: @type_repr ref,
|
||||
int element: @enum_element_decl ref
|
||||
);
|
||||
|
||||
error_exprs(
|
||||
@@ -660,8 +720,15 @@ error_exprs(
|
||||
| @coerce_expr
|
||||
;
|
||||
|
||||
#keyset[id]
|
||||
explicit_cast_exprs(
|
||||
int id: @explicit_cast_expr ref,
|
||||
int sub_expr: @expr ref
|
||||
);
|
||||
|
||||
force_value_exprs(
|
||||
unique int id: @force_value_expr
|
||||
unique int id: @force_value_expr,
|
||||
int sub_expr: @expr ref
|
||||
);
|
||||
|
||||
@identity_expr =
|
||||
@@ -671,8 +738,17 @@ force_value_exprs(
|
||||
| @unresolved_member_chain_result_expr
|
||||
;
|
||||
|
||||
#keyset[id]
|
||||
identity_exprs(
|
||||
int id: @identity_expr ref,
|
||||
int sub_expr: @expr ref
|
||||
);
|
||||
|
||||
if_exprs(
|
||||
unique int id: @if_expr
|
||||
unique int id: @if_expr,
|
||||
int condition: @expr ref,
|
||||
int then_expr: @expr ref,
|
||||
int else_expr: @expr ref
|
||||
);
|
||||
|
||||
@implicit_conversion_expr =
|
||||
@@ -709,8 +785,15 @@ if_exprs(
|
||||
| @unresolved_type_conversion_expr
|
||||
;
|
||||
|
||||
#keyset[id]
|
||||
implicit_conversion_exprs(
|
||||
int id: @implicit_conversion_expr ref,
|
||||
int sub_expr: @expr ref
|
||||
);
|
||||
|
||||
in_out_exprs(
|
||||
unique int id: @in_out_expr
|
||||
unique int id: @in_out_expr,
|
||||
int sub_expr: @expr ref
|
||||
);
|
||||
|
||||
key_path_application_exprs(
|
||||
@@ -725,8 +808,21 @@ key_path_exprs(
|
||||
unique int id: @key_path_expr
|
||||
);
|
||||
|
||||
#keyset[id]
|
||||
key_path_expr_parsed_roots(
|
||||
int id: @key_path_expr ref,
|
||||
int parsed_root: @expr ref
|
||||
);
|
||||
|
||||
#keyset[id]
|
||||
key_path_expr_parsed_paths(
|
||||
int id: @key_path_expr ref,
|
||||
int parsed_path: @expr ref
|
||||
);
|
||||
|
||||
lazy_initializer_exprs(
|
||||
unique int id: @lazy_initializer_expr
|
||||
unique int id: @lazy_initializer_expr,
|
||||
int sub_expr: @expr ref
|
||||
);
|
||||
|
||||
@literal_expr =
|
||||
@@ -744,15 +840,21 @@ lazy_initializer_exprs(
|
||||
;
|
||||
|
||||
make_temporarily_escapable_exprs(
|
||||
unique int id: @make_temporarily_escapable_expr
|
||||
unique int id: @make_temporarily_escapable_expr,
|
||||
int escaping_closure: @opaque_value_expr ref,
|
||||
int nonescaping_closure: @expr ref,
|
||||
int sub_expr: @expr ref
|
||||
);
|
||||
|
||||
obj_c_selector_exprs(
|
||||
unique int id: @obj_c_selector_expr
|
||||
unique int id: @obj_c_selector_expr,
|
||||
int sub_expr: @expr ref,
|
||||
int method: @abstract_function_decl ref
|
||||
);
|
||||
|
||||
one_way_exprs(
|
||||
unique int id: @one_way_expr
|
||||
unique int id: @one_way_expr,
|
||||
int sub_expr: @expr ref
|
||||
);
|
||||
|
||||
opaque_value_exprs(
|
||||
@@ -760,11 +862,15 @@ opaque_value_exprs(
|
||||
);
|
||||
|
||||
open_existential_exprs(
|
||||
unique int id: @open_existential_expr
|
||||
unique int id: @open_existential_expr,
|
||||
int sub_expr: @expr ref,
|
||||
int existential: @expr ref,
|
||||
int opaque_expr: @opaque_value_expr ref
|
||||
);
|
||||
|
||||
optional_evaluation_exprs(
|
||||
unique int id: @optional_evaluation_expr
|
||||
unique int id: @optional_evaluation_expr,
|
||||
int sub_expr: @expr ref
|
||||
);
|
||||
|
||||
other_constructor_decl_ref_exprs(
|
||||
@@ -780,7 +886,9 @@ property_wrapper_value_placeholder_exprs(
|
||||
);
|
||||
|
||||
rebind_self_in_constructor_exprs(
|
||||
unique int id: @rebind_self_in_constructor_expr
|
||||
unique int id: @rebind_self_in_constructor_expr,
|
||||
int sub_expr: @expr ref,
|
||||
int self: @var_decl ref
|
||||
);
|
||||
|
||||
sequence_exprs(
|
||||
@@ -788,25 +896,49 @@ sequence_exprs(
|
||||
);
|
||||
|
||||
super_ref_exprs(
|
||||
unique int id: @super_ref_expr
|
||||
unique int id: @super_ref_expr,
|
||||
int self: @var_decl ref
|
||||
);
|
||||
|
||||
tap_exprs(
|
||||
unique int id: @tap_expr
|
||||
unique int id: @tap_expr,
|
||||
int var: @var_decl ref,
|
||||
int body: @brace_stmt ref
|
||||
);
|
||||
|
||||
#keyset[id]
|
||||
tap_expr_sub_exprs(
|
||||
int id: @tap_expr ref,
|
||||
int sub_expr: @expr ref
|
||||
);
|
||||
|
||||
tuple_element_exprs(
|
||||
unique int id: @tuple_element_expr
|
||||
unique int id: @tuple_element_expr,
|
||||
int sub_expr: @expr ref,
|
||||
int index: int ref
|
||||
);
|
||||
|
||||
tuple_exprs(
|
||||
unique int id: @tuple_expr
|
||||
);
|
||||
|
||||
#keyset[id, index]
|
||||
tuple_expr_elements(
|
||||
int id: @tuple_expr ref,
|
||||
int index: int ref,
|
||||
int element: @expr ref
|
||||
);
|
||||
|
||||
type_exprs(
|
||||
unique int id: @type_expr
|
||||
);
|
||||
|
||||
#keyset[id]
|
||||
type_expr_type_reprs(
|
||||
int id: @type_expr ref,
|
||||
int type_repr: @type_repr ref
|
||||
);
|
||||
|
||||
unresolved_decl_ref_exprs(
|
||||
unique int id: @unresolved_decl_ref_expr
|
||||
);
|
||||
@@ -828,7 +960,8 @@ unresolved_specialize_exprs(
|
||||
);
|
||||
|
||||
vararg_expansion_exprs(
|
||||
unique int id: @vararg_expansion_expr
|
||||
unique int id: @vararg_expansion_expr,
|
||||
int sub_expr: @expr ref
|
||||
);
|
||||
|
||||
any_patterns(
|
||||
@@ -1171,11 +1304,13 @@ type_decl_base_types(
|
||||
);
|
||||
|
||||
auto_closure_exprs(
|
||||
unique int id: @auto_closure_expr
|
||||
unique int id: @auto_closure_expr,
|
||||
int body: @brace_stmt ref
|
||||
);
|
||||
|
||||
closure_exprs(
|
||||
unique int id: @closure_expr
|
||||
unique int id: @closure_expr,
|
||||
int body: @brace_stmt ref
|
||||
);
|
||||
|
||||
force_try_exprs(
|
||||
@@ -1211,14 +1346,34 @@ prefix_unary_exprs(
|
||||
| @dot_syntax_call_expr
|
||||
;
|
||||
|
||||
#keyset[id]
|
||||
self_apply_exprs(
|
||||
int id: @self_apply_expr ref,
|
||||
int base_expr: @expr ref
|
||||
);
|
||||
|
||||
array_exprs(
|
||||
unique int id: @array_expr
|
||||
);
|
||||
|
||||
#keyset[id, index]
|
||||
array_expr_elements(
|
||||
int id: @array_expr ref,
|
||||
int index: int ref,
|
||||
int element: @expr ref
|
||||
);
|
||||
|
||||
dictionary_exprs(
|
||||
unique int id: @dictionary_expr
|
||||
);
|
||||
|
||||
#keyset[id, index]
|
||||
dictionary_expr_elements(
|
||||
int id: @dictionary_expr ref,
|
||||
int index: int ref,
|
||||
int element: @expr ref
|
||||
);
|
||||
|
||||
@checked_cast_expr =
|
||||
@conditional_checked_cast_expr
|
||||
| @forced_checked_cast_expr
|
||||
@@ -1380,6 +1535,30 @@ interpolated_string_literal_exprs(
|
||||
unique int id: @interpolated_string_literal_expr
|
||||
);
|
||||
|
||||
#keyset[id]
|
||||
interpolated_string_literal_expr_interpolation_exprs(
|
||||
int id: @interpolated_string_literal_expr ref,
|
||||
int interpolation_expr: @opaque_value_expr ref
|
||||
);
|
||||
|
||||
#keyset[id]
|
||||
interpolated_string_literal_expr_interpolation_count_exprs(
|
||||
int id: @interpolated_string_literal_expr ref,
|
||||
int interpolation_count_expr: @expr ref
|
||||
);
|
||||
|
||||
#keyset[id]
|
||||
interpolated_string_literal_expr_literal_capacity_exprs(
|
||||
int id: @interpolated_string_literal_expr ref,
|
||||
int literal_capacity_expr: @expr ref
|
||||
);
|
||||
|
||||
#keyset[id]
|
||||
interpolated_string_literal_expr_appending_exprs(
|
||||
int id: @interpolated_string_literal_expr ref,
|
||||
int appending_expr: @tap_expr ref
|
||||
);
|
||||
|
||||
regex_literal_exprs(
|
||||
unique int id: @regex_literal_expr
|
||||
);
|
||||
@@ -1398,11 +1577,20 @@ object_literal_exprs(
|
||||
;
|
||||
|
||||
member_ref_exprs(
|
||||
unique int id: @member_ref_expr
|
||||
unique int id: @member_ref_expr,
|
||||
int base_expr: @expr ref
|
||||
);
|
||||
|
||||
subscript_exprs(
|
||||
unique int id: @subscript_expr
|
||||
unique int id: @subscript_expr,
|
||||
int base_expr: @expr ref
|
||||
);
|
||||
|
||||
#keyset[id, index]
|
||||
subscript_expr_arguments(
|
||||
int id: @subscript_expr ref,
|
||||
int index: int ref,
|
||||
int argument: @argument ref
|
||||
);
|
||||
|
||||
overloaded_decl_ref_exprs(
|
||||
@@ -1617,11 +1805,13 @@ is_exprs(
|
||||
);
|
||||
|
||||
boolean_literal_exprs(
|
||||
unique int id: @boolean_literal_expr
|
||||
unique int id: @boolean_literal_expr,
|
||||
boolean value: boolean ref
|
||||
);
|
||||
|
||||
magic_identifier_literal_exprs(
|
||||
unique int id: @magic_identifier_literal_expr
|
||||
unique int id: @magic_identifier_literal_expr,
|
||||
string kind: string ref
|
||||
);
|
||||
|
||||
@number_literal_expr =
|
||||
@@ -1630,7 +1820,8 @@ magic_identifier_literal_exprs(
|
||||
;
|
||||
|
||||
string_literal_exprs(
|
||||
unique int id: @string_literal_expr
|
||||
unique int id: @string_literal_expr,
|
||||
string value: string ref
|
||||
);
|
||||
|
||||
dynamic_member_ref_exprs(
|
||||
@@ -1696,11 +1887,13 @@ type_alias_decls(
|
||||
);
|
||||
|
||||
float_literal_exprs(
|
||||
unique int id: @float_literal_expr
|
||||
unique int id: @float_literal_expr,
|
||||
string string_value: string ref
|
||||
);
|
||||
|
||||
integer_literal_exprs(
|
||||
unique int id: @integer_literal_expr
|
||||
unique int id: @integer_literal_expr,
|
||||
string string_value: string ref
|
||||
);
|
||||
|
||||
error_type_reprs(
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
| file://:0:0:0:0 | ConcreteFuncDecl |
|
||||
| file://:0:0:0:0 | ConcreteFuncDecl |
|
||||
| file://:0:0:0:0 | ConcreteFuncDecl |
|
||||
| file://:0:0:0:0 | ConcreteFuncDecl |
|
||||
| file://:0:0:0:0 | ConcreteVarDecl |
|
||||
| file://:0:0:0:0 | ConcreteVarDecl |
|
||||
| file://:0:0:0:0 | ConcreteVarDecl |
|
||||
| file://:0:0:0:0 | ConcreteVarDecl |
|
||||
| file://:0:0:0:0 | GenericTypeParamDecl |
|
||||
| file://:0:0:0:0 | ParamDecl |
|
||||
| file://:0:0:0:0 | ParamDecl |
|
||||
| file://:0:0:0:0 | ParamDecl |
|
||||
| file://:0:0:0:0 | ParamDecl |
|
||||
| file://:0:0:0:0 | ParamDecl |
|
||||
| file://:0:0:0:0 | ParamDecl |
|
||||
| file://:0:0:0:0 | ParamDecl |
|
||||
| file://:0:0:0:0 | ParamDecl |
|
||||
| file://:0:0:0:0 | ParamDecl |
|
||||
| file://:0:0:0:0 | PatternBindingDecl |
|
||||
| file://:0:0:0:0 | PatternBindingDecl |
|
||||
| file://:0:0:0:0 | PatternBindingDecl |
|
||||
@@ -61,7 +72,9 @@
|
||||
| test.swift:40:1:53:1 | ClassDecl |
|
||||
| test.swift:41:3:41:14 | PatternBindingDecl |
|
||||
| test.swift:41:7:41:7 | ConcreteVarDecl |
|
||||
| test.swift:42:3:42:3 | ParamDecl |
|
||||
| test.swift:42:3:44:3 | ConstructorDecl |
|
||||
| test.swift:46:3:46:3 | ParamDecl |
|
||||
| test.swift:46:3:48:3 | DestructorDecl |
|
||||
| test.swift:50:3:52:3 | ConcreteFuncDecl |
|
||||
| test.swift:50:26:50:33 | ParamDecl |
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
| file://:0:0:0:0 | ConcreteFuncDecl | == |
|
||||
| file://:0:0:0:0 | ConcreteFuncDecl | __derived_enum_equals |
|
||||
| file://:0:0:0:0 | ConcreteFuncDecl | hash |
|
||||
| file://:0:0:0:0 | ConcreteFuncDecl | print |
|
||||
| test.swift:25:5:25:22 | ConcreteFuncDecl | random |
|
||||
| test.swift:28:1:28:37 | ConcreteFuncDecl | a_function |
|
||||
| test.swift:50:3:52:3 | ConcreteFuncDecl | +- |
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
| file://:0:0:0:0 | ConcreteFuncDecl | 0 | file://:0:0:0:0 | ParamDecl |
|
||||
| file://:0:0:0:0 | ConcreteFuncDecl | 0 | file://:0:0:0:0 | ParamDecl |
|
||||
| file://:0:0:0:0 | ConcreteFuncDecl | 0 | file://:0:0:0:0 | ParamDecl |
|
||||
| file://:0:0:0:0 | ConcreteFuncDecl | 0 | file://:0:0:0:0 | ParamDecl |
|
||||
| file://:0:0:0:0 | ConcreteFuncDecl | 1 | file://:0:0:0:0 | ParamDecl |
|
||||
| file://:0:0:0:0 | ConcreteFuncDecl | 1 | file://:0:0:0:0 | ParamDecl |
|
||||
| file://:0:0:0:0 | ConcreteFuncDecl | 1 | file://:0:0:0:0 | ParamDecl |
|
||||
| file://:0:0:0:0 | ConcreteFuncDecl | 2 | file://:0:0:0:0 | ParamDecl |
|
||||
| test.swift:28:1:28:37 | ConcreteFuncDecl | 0 | test.swift:28:17:28:31 | ParamDecl |
|
||||
| test.swift:50:3:52:3 | ConcreteFuncDecl | 0 | test.swift:50:26:50:33 | ParamDecl |
|
||||
|
||||
221
swift/ql/test/extractor-tests/expressions/all.expected
Normal file
221
swift/ql/test/extractor-tests/expressions/all.expected
Normal file
@@ -0,0 +1,221 @@
|
||||
| expressions.swift:1:9:1:9 | IntegerLiteralExpr |
|
||||
| expressions.swift:2:9:2:9 | FloatLiteralExpr |
|
||||
| expressions.swift:3:10:3:10 | BooleanLiteralExpr |
|
||||
| expressions.swift:4:10:4:10 | BooleanLiteralExpr |
|
||||
| expressions.swift:5:9:5:9 | MagicIdentifierLiteralExpr |
|
||||
| expressions.swift:6:9:6:9 | StringLiteralExpr |
|
||||
| expressions.swift:7:10:7:10 | InterpolatedStringLiteralExpr |
|
||||
| expressions.swift:7:10:7:10 | OpaqueValueExpr |
|
||||
| expressions.swift:7:10:7:10 | StringLiteralExpr |
|
||||
| expressions.swift:7:10:7:10 | TapExpr |
|
||||
| expressions.swift:7:11:7:10 | CallExpr |
|
||||
| expressions.swift:7:11:7:11 | DeclRefExpr |
|
||||
| expressions.swift:7:11:7:11 | DotSyntaxCallExpr |
|
||||
| expressions.swift:7:11:7:11 | InOutExpr |
|
||||
| expressions.swift:7:18:7:18 | DeclRefExpr |
|
||||
| expressions.swift:7:18:7:18 | DeclRefExpr |
|
||||
| expressions.swift:7:18:7:18 | DotSyntaxCallExpr |
|
||||
| expressions.swift:7:18:7:18 | InOutExpr |
|
||||
| expressions.swift:7:18:7:20 | CallExpr |
|
||||
| expressions.swift:7:19:7:19 | DeclRefExpr |
|
||||
| expressions.swift:7:21:7:21 | CallExpr |
|
||||
| expressions.swift:7:21:7:21 | DeclRefExpr |
|
||||
| expressions.swift:7:21:7:21 | DotSyntaxCallExpr |
|
||||
| expressions.swift:7:21:7:21 | InOutExpr |
|
||||
| expressions.swift:7:21:7:21 | StringLiteralExpr |
|
||||
| expressions.swift:8:15:8:15 | NilLiteralExpr |
|
||||
| expressions.swift:15:9:15:9 | DeclRefExpr |
|
||||
| expressions.swift:15:9:15:14 | BinaryExpr |
|
||||
| expressions.swift:15:11:15:11 | DeclRefExpr |
|
||||
| expressions.swift:15:11:15:11 | DotSyntaxCallExpr |
|
||||
| expressions.swift:15:11:15:11 | TypeExpr |
|
||||
| expressions.swift:15:14:15:14 | IntegerLiteralExpr |
|
||||
| expressions.swift:16:11:16:11 | TypeExpr |
|
||||
| expressions.swift:16:11:16:19 | DotSyntaxCallExpr |
|
||||
| expressions.swift:16:11:16:19 | ErasureExpr |
|
||||
| expressions.swift:16:19:16:19 | DeclRefExpr |
|
||||
| expressions.swift:20:1:20:16 | ForceTryExpr |
|
||||
| expressions.swift:20:6:20:6 | DeclRefExpr |
|
||||
| expressions.swift:20:6:20:16 | CallExpr |
|
||||
| expressions.swift:20:14:20:14 | IntegerLiteralExpr |
|
||||
| expressions.swift:21:1:21:16 | OptionalTryExpr |
|
||||
| expressions.swift:21:6:21:6 | DeclRefExpr |
|
||||
| expressions.swift:21:6:21:16 | CallExpr |
|
||||
| expressions.swift:21:6:21:16 | InjectIntoOptionalExpr |
|
||||
| expressions.swift:21:14:21:14 | IntegerLiteralExpr |
|
||||
| expressions.swift:27:13:27:13 | ConstructorRefCallExpr |
|
||||
| expressions.swift:27:13:27:13 | DeclRefExpr |
|
||||
| expressions.swift:27:13:27:13 | TypeExpr |
|
||||
| expressions.swift:27:13:27:19 | CallExpr |
|
||||
| expressions.swift:29:9:29:19 | DictionaryExpr |
|
||||
| expressions.swift:29:10:29:10 | StringLiteralExpr |
|
||||
| expressions.swift:29:10:29:16 | TupleExpr |
|
||||
| expressions.swift:29:16:29:16 | StringLiteralExpr |
|
||||
| expressions.swift:30:1:30:1 | DiscardAssignmentExpr |
|
||||
| expressions.swift:30:1:30:5 | AssignExpr |
|
||||
| expressions.swift:30:5:30:5 | IntegerLiteralExpr |
|
||||
| expressions.swift:31:1:31:1 | DiscardAssignmentExpr |
|
||||
| expressions.swift:31:1:31:11 | AssignExpr |
|
||||
| expressions.swift:31:5:31:5 | IntegerLiteralExpr |
|
||||
| expressions.swift:31:5:31:11 | IsExpr |
|
||||
| expressions.swift:32:1:32:1 | DiscardAssignmentExpr |
|
||||
| expressions.swift:32:1:32:11 | AssignExpr |
|
||||
| expressions.swift:32:5:32:5 | IntegerLiteralExpr |
|
||||
| expressions.swift:32:5:32:11 | CoerceExpr |
|
||||
| expressions.swift:33:1:33:1 | DiscardAssignmentExpr |
|
||||
| expressions.swift:33:1:33:12 | AssignExpr |
|
||||
| expressions.swift:33:5:33:5 | IntegerLiteralExpr |
|
||||
| expressions.swift:33:5:33:12 | ConditionalCheckedCastExpr |
|
||||
| expressions.swift:34:1:34:1 | DiscardAssignmentExpr |
|
||||
| expressions.swift:34:1:34:12 | AssignExpr |
|
||||
| expressions.swift:34:5:34:5 | IntegerLiteralExpr |
|
||||
| expressions.swift:34:5:34:12 | ForcedCheckedCastExpr |
|
||||
| expressions.swift:35:1:35:1 | DeclRefExpr |
|
||||
| expressions.swift:35:1:35:13 | CallExpr |
|
||||
| expressions.swift:35:6:35:6 | DefaultArgumentExpr |
|
||||
| expressions.swift:35:6:35:6 | DefaultArgumentExpr |
|
||||
| expressions.swift:35:7:35:7 | DeclRefExpr |
|
||||
| expressions.swift:35:7:35:12 | ArrayExpr |
|
||||
| expressions.swift:35:7:35:12 | ErasureExpr |
|
||||
| expressions.swift:35:7:35:12 | SubscriptExpr |
|
||||
| expressions.swift:35:7:35:12 | VarargExpansionExpr |
|
||||
| expressions.swift:35:9:35:9 | StringLiteralExpr |
|
||||
| expressions.swift:38:3:38:3 | DeclRefExpr |
|
||||
| expressions.swift:38:3:38:15 | CallExpr |
|
||||
| expressions.swift:38:11:38:11 | IntegerLiteralExpr |
|
||||
| expressions.swift:38:14:38:14 | IntegerLiteralExpr |
|
||||
| expressions.swift:41:1:41:1 | DeclRefExpr |
|
||||
| expressions.swift:41:1:43:1 | CallExpr |
|
||||
| expressions.swift:41:10:43:1 | ClosureExpr |
|
||||
| expressions.swift:42:12:42:12 | DeclRefExpr |
|
||||
| expressions.swift:42:12:42:16 | BinaryExpr |
|
||||
| expressions.swift:42:14:42:14 | DeclRefExpr |
|
||||
| expressions.swift:42:14:42:14 | DotSyntaxCallExpr |
|
||||
| expressions.swift:42:14:42:14 | TypeExpr |
|
||||
| expressions.swift:42:16:42:16 | DeclRefExpr |
|
||||
| expressions.swift:44:1:44:1 | DeclRefExpr |
|
||||
| expressions.swift:44:1:46:1 | CallExpr |
|
||||
| expressions.swift:44:10:46:1 | ClosureExpr |
|
||||
| expressions.swift:45:12:45:12 | DeclRefExpr |
|
||||
| expressions.swift:45:12:45:16 | BinaryExpr |
|
||||
| expressions.swift:45:14:45:14 | DeclRefExpr |
|
||||
| expressions.swift:45:14:45:14 | DotSyntaxCallExpr |
|
||||
| expressions.swift:45:14:45:14 | TypeExpr |
|
||||
| expressions.swift:45:16:45:16 | DeclRefExpr |
|
||||
| expressions.swift:47:1:47:1 | DeclRefExpr |
|
||||
| expressions.swift:47:1:47:27 | CallExpr |
|
||||
| expressions.swift:47:10:47:27 | ClosureExpr |
|
||||
| expressions.swift:47:19:47:19 | DeclRefExpr |
|
||||
| expressions.swift:47:19:47:24 | BinaryExpr |
|
||||
| expressions.swift:47:22:47:22 | DeclRefExpr |
|
||||
| expressions.swift:47:22:47:22 | DotSyntaxCallExpr |
|
||||
| expressions.swift:47:22:47:22 | TypeExpr |
|
||||
| expressions.swift:47:24:47:24 | DeclRefExpr |
|
||||
| expressions.swift:48:1:48:1 | DeclRefExpr |
|
||||
| expressions.swift:48:1:48:20 | CallExpr |
|
||||
| expressions.swift:48:10:48:20 | ClosureExpr |
|
||||
| expressions.swift:48:12:48:12 | DeclRefExpr |
|
||||
| expressions.swift:48:12:48:17 | BinaryExpr |
|
||||
| expressions.swift:48:15:48:15 | DeclRefExpr |
|
||||
| expressions.swift:48:15:48:15 | DotSyntaxCallExpr |
|
||||
| expressions.swift:48:15:48:15 | TypeExpr |
|
||||
| expressions.swift:48:17:48:17 | DeclRefExpr |
|
||||
| expressions.swift:54:1:54:1 | DiscardAssignmentExpr |
|
||||
| expressions.swift:54:1:54:8 | AssignExpr |
|
||||
| expressions.swift:54:5:54:8 | KeyPathExpr |
|
||||
| expressions.swift:58:16:58:16 | IntegerLiteralExpr |
|
||||
| expressions.swift:59:1:59:1 | DeclRefExpr |
|
||||
| expressions.swift:59:1:59:34 | CallExpr |
|
||||
| expressions.swift:59:25:59:26 | InOutExpr |
|
||||
| expressions.swift:59:25:59:26 | InOutToPointerExpr |
|
||||
| expressions.swift:59:26:59:26 | DeclRefExpr |
|
||||
| expressions.swift:60:1:60:1 | DeclRefExpr |
|
||||
| expressions.swift:60:1:60:63 | CallExpr |
|
||||
| expressions.swift:60:23:60:23 | DeclRefExpr |
|
||||
| expressions.swift:60:23:60:23 | LoadExpr |
|
||||
| expressions.swift:60:33:60:63 | ClosureExpr |
|
||||
| expressions.swift:60:33:60:63 | FunctionConversionExpr |
|
||||
| expressions.swift:60:35:60:35 | DeclRefExpr |
|
||||
| expressions.swift:60:35:60:61 | CallExpr |
|
||||
| expressions.swift:60:59:60:59 | DeclRefExpr |
|
||||
| expressions.swift:64:8:64:8 | DeclRefExpr |
|
||||
| expressions.swift:64:8:64:12 | BinaryExpr |
|
||||
| expressions.swift:64:10:64:10 | DeclRefExpr |
|
||||
| expressions.swift:64:10:64:10 | DotSyntaxCallExpr |
|
||||
| expressions.swift:64:10:64:10 | TypeExpr |
|
||||
| expressions.swift:64:12:64:12 | IntegerLiteralExpr |
|
||||
| expressions.swift:73:5:73:5 | DeclRefExpr |
|
||||
| expressions.swift:73:5:73:5 | MemberRefExpr |
|
||||
| expressions.swift:73:5:73:10 | AssignExpr |
|
||||
| expressions.swift:73:10:73:10 | DeclRefExpr |
|
||||
| expressions.swift:77:7:77:7 | CallExpr |
|
||||
| expressions.swift:77:7:77:7 | DeclRefExpr |
|
||||
| expressions.swift:77:7:77:7 | MagicIdentifierLiteralExpr |
|
||||
| expressions.swift:77:7:77:7 | MagicIdentifierLiteralExpr |
|
||||
| expressions.swift:77:7:77:7 | MagicIdentifierLiteralExpr |
|
||||
| expressions.swift:77:7:77:7 | MagicIdentifierLiteralExpr |
|
||||
| expressions.swift:77:7:77:7 | StringLiteralExpr |
|
||||
| expressions.swift:79:5:79:5 | SuperRefExpr |
|
||||
| expressions.swift:79:5:79:11 | DotSyntaxCallExpr |
|
||||
| expressions.swift:79:5:79:21 | CallExpr |
|
||||
| expressions.swift:79:5:79:21 | RebindSelfInConstructorExpr |
|
||||
| expressions.swift:79:11:79:11 | TBD (OtherConstructorDeclRefExpr) |
|
||||
| expressions.swift:79:19:79:19 | IntegerLiteralExpr |
|
||||
| expressions.swift:83:15:83:15 | ConstructorRefCallExpr |
|
||||
| expressions.swift:83:15:83:15 | DeclRefExpr |
|
||||
| expressions.swift:83:15:83:15 | TypeExpr |
|
||||
| expressions.swift:83:15:83:23 | CallExpr |
|
||||
| expressions.swift:84:1:84:1 | DiscardAssignmentExpr |
|
||||
| expressions.swift:84:1:84:13 | AssignExpr |
|
||||
| expressions.swift:84:5:84:5 | DeclRefExpr |
|
||||
| expressions.swift:84:5:84:5 | DerivedToBaseExpr |
|
||||
| expressions.swift:84:5:84:13 | MemberRefExpr |
|
||||
| expressions.swift:87:1:87:1 | DeclRefExpr |
|
||||
| expressions.swift:87:1:87:4 | ForceValueExpr |
|
||||
| expressions.swift:88:1:88:1 | DeclRefExpr |
|
||||
| expressions.swift:88:1:88:6 | SubscriptExpr |
|
||||
| expressions.swift:88:1:88:7 | ForceValueExpr |
|
||||
| expressions.swift:88:3:88:3 | StringLiteralExpr |
|
||||
| expressions.swift:92:14:92:14 | TypeExpr |
|
||||
| expressions.swift:92:14:92:24 | DotSyntaxCallExpr |
|
||||
| expressions.swift:92:14:92:44 | CallExpr |
|
||||
| expressions.swift:92:14:92:46 | DotSyntaxCallExpr |
|
||||
| expressions.swift:92:14:92:55 | CallExpr |
|
||||
| expressions.swift:92:24:92:24 | DeclRefExpr |
|
||||
| expressions.swift:92:37:92:37 | ConstructorRefCallExpr |
|
||||
| expressions.swift:92:37:92:37 | DeclRefExpr |
|
||||
| expressions.swift:92:37:92:37 | TypeExpr |
|
||||
| expressions.swift:92:37:92:43 | CallExpr |
|
||||
| expressions.swift:92:46:92:46 | DeclRefExpr |
|
||||
| expressions.swift:93:1:93:16 | TypeExpr |
|
||||
| expressions.swift:93:1:93:18 | DotSyntaxCallExpr |
|
||||
| expressions.swift:93:1:93:35 | CallExpr |
|
||||
| expressions.swift:93:18:93:18 | DeclRefExpr |
|
||||
| expressions.swift:93:29:93:29 | DeclRefExpr |
|
||||
| expressions.swift:93:29:93:29 | PointerToPointerExpr |
|
||||
| file://:0:0:0:0 | AssignExpr |
|
||||
| file://:0:0:0:0 | AssignExpr |
|
||||
| file://:0:0:0:0 | AssignExpr |
|
||||
| file://:0:0:0:0 | BinaryExpr |
|
||||
| file://:0:0:0:0 | CallExpr |
|
||||
| file://:0:0:0:0 | DeclRefExpr |
|
||||
| file://:0:0:0:0 | DeclRefExpr |
|
||||
| file://:0:0:0:0 | DeclRefExpr |
|
||||
| file://:0:0:0:0 | DeclRefExpr |
|
||||
| file://:0:0:0:0 | DeclRefExpr |
|
||||
| file://:0:0:0:0 | DeclRefExpr |
|
||||
| file://:0:0:0:0 | DeclRefExpr |
|
||||
| file://:0:0:0:0 | DeclRefExpr |
|
||||
| file://:0:0:0:0 | DeclRefExpr |
|
||||
| file://:0:0:0:0 | DeclRefExpr |
|
||||
| file://:0:0:0:0 | DeclRefExpr |
|
||||
| file://:0:0:0:0 | DeclRefExpr |
|
||||
| file://:0:0:0:0 | DotSyntaxCallExpr |
|
||||
| file://:0:0:0:0 | IntegerLiteralExpr |
|
||||
| file://:0:0:0:0 | IntegerLiteralExpr |
|
||||
| file://:0:0:0:0 | IntegerLiteralExpr |
|
||||
| file://:0:0:0:0 | IntegerLiteralExpr |
|
||||
| file://:0:0:0:0 | IntegerLiteralExpr |
|
||||
| file://:0:0:0:0 | NilLiteralExpr |
|
||||
| file://:0:0:0:0 | TBD (UnresolvedDotExpr) |
|
||||
| file://:0:0:0:0 | TypeExpr |
|
||||
4
swift/ql/test/extractor-tests/expressions/all.ql
Normal file
4
swift/ql/test/extractor-tests/expressions/all.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import swift
|
||||
|
||||
from Expr expr
|
||||
select expr
|
||||
93
swift/ql/test/extractor-tests/expressions/expressions.swift
Normal file
93
swift/ql/test/extractor-tests/expressions/expressions.swift
Normal file
@@ -0,0 +1,93 @@
|
||||
let a = 15
|
||||
let b = 15.15
|
||||
let b1 = true
|
||||
let b2 = false
|
||||
let m = #file
|
||||
let s = "hello world"
|
||||
let s1 = "hello \(a)"
|
||||
let n: Int? = nil
|
||||
|
||||
enum AnError: Error {
|
||||
case failed
|
||||
}
|
||||
|
||||
func failure(_ x: Int) throws {
|
||||
guard x != 0 else {
|
||||
throw AnError.failed
|
||||
}
|
||||
}
|
||||
|
||||
try! failure(11)
|
||||
try? failure(11)
|
||||
|
||||
class Klass {
|
||||
init() {}
|
||||
}
|
||||
|
||||
let klass = Klass()
|
||||
|
||||
let d = ["1" : "2"]
|
||||
_ = 15
|
||||
_ = 15 is Int
|
||||
_ = 15 as Double
|
||||
_ = 15 as? Double
|
||||
_ = 15 as! Double
|
||||
print(d["1"])
|
||||
|
||||
func closured(closure: (Int, Int) -> Int) {
|
||||
closure(5, 7)
|
||||
}
|
||||
|
||||
closured { (x: Int, y: Int) -> Int in
|
||||
return x + y
|
||||
}
|
||||
closured { x, y in
|
||||
return x + y
|
||||
}
|
||||
closured { return $0 + $1 }
|
||||
closured { $0 + $1 }
|
||||
|
||||
struct S {
|
||||
let x: Int
|
||||
}
|
||||
|
||||
_ = \S.x
|
||||
|
||||
func unsafeFunction(pointer: UnsafePointer<Int>) {
|
||||
}
|
||||
var myNumber = 1234
|
||||
unsafeFunction(pointer: &myNumber)
|
||||
withUnsafePointer(to: myNumber) { unsafeFunction(pointer: $0) }
|
||||
|
||||
class FailingToInit {
|
||||
init?(x: Int) {
|
||||
if x < 0 {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Base {
|
||||
let xx: Int
|
||||
init(x: Int) {
|
||||
xx = x
|
||||
}
|
||||
}
|
||||
|
||||
class Derived: Base {
|
||||
init() {
|
||||
super.init(x: 22)
|
||||
}
|
||||
}
|
||||
|
||||
let derived = Derived()
|
||||
_ = derived.xx
|
||||
|
||||
var opt: Int?
|
||||
opt!
|
||||
d["a"]!
|
||||
|
||||
class ToPtr {}
|
||||
|
||||
let opaque = Unmanaged.passRetained(ToPtr()).toOpaque()
|
||||
Unmanaged<ToPtr>.fromOpaque(opaque)
|
||||
@@ -1,6 +1,6 @@
|
||||
| patterns.swift:2:9:2:9 | NamedPattern |
|
||||
| patterns.swift:3:9:3:9 | NamedPattern |
|
||||
| patterns.swift:3:9:3:20 | TypedPattern |
|
||||
| patterns.swift:3:9:3:19 | TypedPattern |
|
||||
| patterns.swift:4:9:4:17 | TuplePattern |
|
||||
| patterns.swift:4:10:4:10 | NamedPattern |
|
||||
| patterns.swift:4:13:4:13 | NamedPattern |
|
||||
@@ -16,7 +16,7 @@
|
||||
| patterns.swift:16:10:16:14 | ExprPattern |
|
||||
| patterns.swift:17:10:17:10 | AnyPattern |
|
||||
| patterns.swift:24:9:24:9 | NamedPattern |
|
||||
| patterns.swift:24:9:24:13 | TypedPattern |
|
||||
| patterns.swift:24:9:24:12 | TypedPattern |
|
||||
| patterns.swift:27:10:27:11 | EnumElementPattern |
|
||||
| patterns.swift:28:10:28:23 | BindingPattern |
|
||||
| patterns.swift:28:14:28:23 | EnumElementPattern |
|
||||
@@ -24,13 +24,13 @@
|
||||
| patterns.swift:28:19:28:19 | NamedPattern |
|
||||
| patterns.swift:28:22:28:22 | NamedPattern |
|
||||
| patterns.swift:31:9:31:9 | NamedPattern |
|
||||
| patterns.swift:31:9:31:16 | TypedPattern |
|
||||
| patterns.swift:31:9:31:15 | TypedPattern |
|
||||
| patterns.swift:34:10:34:15 | BindingPattern |
|
||||
| patterns.swift:34:14:34:14 | NamedPattern |
|
||||
| patterns.swift:34:14:34:15 | OptionalSomePattern |
|
||||
| patterns.swift:35:10:35:10 | AnyPattern |
|
||||
| patterns.swift:38:9:38:9 | NamedPattern |
|
||||
| patterns.swift:38:9:38:13 | TypedPattern |
|
||||
| patterns.swift:38:9:38:12 | TypedPattern |
|
||||
| patterns.swift:41:10:41:13 | IsPattern |
|
||||
| patterns.swift:42:10:42:19 | BindingPattern |
|
||||
| patterns.swift:42:14:42:14 | NamedPattern |
|
||||
|
||||
Reference in New Issue
Block a user