mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Merge pull request #9239 from github/redsun82/swift-visitors
Swift: transfer all visitors
This commit is contained in:
@@ -28,12 +28,12 @@ Location:
|
||||
end_line: int
|
||||
end_column: int
|
||||
|
||||
Type: {}
|
||||
# diagnostics_name: string
|
||||
# canonical_type: Type
|
||||
Type:
|
||||
diagnostics_name: string
|
||||
canonical_type: Type
|
||||
|
||||
IterableDeclContext: {}
|
||||
# members: Decl*
|
||||
IterableDeclContext:
|
||||
members: Decl*
|
||||
|
||||
ExtensionDecl:
|
||||
_extends:
|
||||
@@ -45,29 +45,29 @@ NominalTypeDecl:
|
||||
_extends:
|
||||
- IterableDeclContext
|
||||
- GenericTypeDecl
|
||||
# type: Type
|
||||
type: Type
|
||||
|
||||
AstNode:
|
||||
_extends: Locatable
|
||||
|
||||
ConditionElement:
|
||||
_extends: Locatable
|
||||
# boolean: Expr?
|
||||
# pattern: Pattern?
|
||||
# initializer: Expr?
|
||||
boolean: Expr?
|
||||
pattern: Pattern?
|
||||
initializer: Expr?
|
||||
_dir: stmt
|
||||
|
||||
AnyFunctionType:
|
||||
_extends: Type
|
||||
# result: Type
|
||||
# param_types: Type*
|
||||
# param_labels: string*
|
||||
# is_throwing: predicate
|
||||
result: Type
|
||||
param_types: Type*
|
||||
param_labels: string*
|
||||
is_throwing: predicate
|
||||
|
||||
AnyGenericType:
|
||||
_extends: Type
|
||||
# parent: Type?
|
||||
# declaration: Decl
|
||||
parent: Type?
|
||||
declaration: Decl
|
||||
|
||||
AnyMetatypeType:
|
||||
_extends: Type
|
||||
@@ -77,6 +77,8 @@ BuiltinType:
|
||||
|
||||
DependentMemberType:
|
||||
_extends: Type
|
||||
baseType: Type
|
||||
associated_type_decl: AssociatedTypeDecl
|
||||
|
||||
DynamicSelfType:
|
||||
_extends: Type
|
||||
@@ -89,7 +91,7 @@ InOutType:
|
||||
|
||||
LValueType:
|
||||
_extends: Type
|
||||
# object_type: Type
|
||||
object_type: Type
|
||||
|
||||
ModuleType:
|
||||
_extends: Type
|
||||
@@ -126,6 +128,8 @@ SugarType:
|
||||
|
||||
TupleType:
|
||||
_extends: Type
|
||||
types: Type*
|
||||
names: string*
|
||||
|
||||
TypeVariableType:
|
||||
_extends: Type
|
||||
@@ -150,7 +154,7 @@ Decl:
|
||||
|
||||
Expr:
|
||||
_extends: AstNode
|
||||
# type: Type?
|
||||
type: Type?
|
||||
|
||||
Pattern:
|
||||
_extends: AstNode
|
||||
@@ -166,7 +170,7 @@ FunctionType:
|
||||
|
||||
GenericFunctionType:
|
||||
_extends: AnyFunctionType
|
||||
# generic_params: GenericTypeParamType*
|
||||
generic_params: GenericTypeParamType*
|
||||
|
||||
NominalOrBoundGenericNominalType:
|
||||
_extends: AnyGenericType
|
||||
@@ -227,20 +231,22 @@ ArchetypeType:
|
||||
|
||||
GenericTypeParamType:
|
||||
_extends: SubstitutableType
|
||||
# name: string
|
||||
name: string
|
||||
|
||||
ParenType:
|
||||
_extends: SugarType
|
||||
type: Type
|
||||
|
||||
SyntaxSugarType:
|
||||
_extends: SugarType
|
||||
|
||||
TypeAliasType:
|
||||
_extends: SugarType
|
||||
decl: TypeAliasDecl
|
||||
|
||||
EnumCaseDecl:
|
||||
_extends: Decl
|
||||
# elements: EnumElementDecl*
|
||||
elements: EnumElementDecl*
|
||||
|
||||
IfConfigDecl:
|
||||
_extends: Decl
|
||||
@@ -253,11 +259,12 @@ MissingMemberDecl:
|
||||
|
||||
OperatorDecl:
|
||||
_extends: Decl
|
||||
name: string
|
||||
|
||||
PatternBindingDecl:
|
||||
_extends: Decl
|
||||
# inits: Expr?*
|
||||
# patterns: Pattern*
|
||||
inits: Expr?*
|
||||
patterns: Pattern*
|
||||
|
||||
PoundDiagnosticDecl:
|
||||
_extends: Decl
|
||||
@@ -267,48 +274,48 @@ PrecedenceGroupDecl:
|
||||
|
||||
TopLevelCodeDecl:
|
||||
_extends: Decl
|
||||
# body: BraceStmt
|
||||
body: BraceStmt
|
||||
|
||||
ValueDecl:
|
||||
_extends: Decl
|
||||
# interface_type: Type
|
||||
interface_type: Type
|
||||
|
||||
AbstractClosureExpr:
|
||||
_extends: Expr
|
||||
|
||||
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
|
||||
@@ -318,64 +325,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
|
||||
@@ -385,12 +392,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
|
||||
@@ -400,31 +407,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
|
||||
@@ -437,34 +444,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
|
||||
@@ -483,112 +490,113 @@ UnresolvedSpecializeExpr:
|
||||
|
||||
VarargExpansionExpr:
|
||||
_extends: Expr
|
||||
# sub_expr: Expr
|
||||
sub_expr: Expr
|
||||
|
||||
AnyPattern:
|
||||
_extends: Pattern
|
||||
|
||||
BindingPattern:
|
||||
_extends: Pattern
|
||||
# sub_pattern: Pattern
|
||||
sub_pattern: Pattern
|
||||
|
||||
BoolPattern:
|
||||
_extends: Pattern
|
||||
# value: boolean
|
||||
value: boolean
|
||||
|
||||
EnumElementPattern:
|
||||
_extends: Pattern
|
||||
# element: EnumElementDecl
|
||||
# sub_pattern: Pattern?
|
||||
element: EnumElementDecl
|
||||
sub_pattern: Pattern?
|
||||
|
||||
ExprPattern:
|
||||
_extends: Pattern
|
||||
# sub_expr: Expr
|
||||
sub_expr: Expr
|
||||
|
||||
IsPattern:
|
||||
_extends: Pattern
|
||||
# cast_type_repr: TypeRepr?
|
||||
# sub_pattern: Pattern?
|
||||
cast_type_repr: TypeRepr?
|
||||
sub_pattern: Pattern?
|
||||
|
||||
NamedPattern:
|
||||
_extends: Pattern
|
||||
# name: string
|
||||
name: string
|
||||
|
||||
OptionalSomePattern:
|
||||
_extends: Pattern
|
||||
# sub_pattern: Pattern
|
||||
sub_pattern: Pattern
|
||||
|
||||
ParenPattern:
|
||||
_extends: Pattern
|
||||
# sub_pattern: Pattern
|
||||
sub_pattern: Pattern
|
||||
|
||||
TuplePattern:
|
||||
_extends: Pattern
|
||||
# elements: Pattern*
|
||||
elements: Pattern*
|
||||
|
||||
TypedPattern:
|
||||
_extends: Pattern
|
||||
# sub_pattern: Pattern
|
||||
# type_repr: TypeRepr?
|
||||
sub_pattern: Pattern
|
||||
type_repr: TypeRepr?
|
||||
|
||||
BraceStmt:
|
||||
_extends: Stmt
|
||||
# elements: AstNode*
|
||||
elements: AstNode*
|
||||
|
||||
BreakStmt:
|
||||
_extends: Stmt
|
||||
# target_name: string?
|
||||
# target: Stmt?
|
||||
target_name: string?
|
||||
target: Stmt?
|
||||
|
||||
CaseStmt:
|
||||
_extends: Stmt
|
||||
# body: Stmt
|
||||
# labels: CaseLabelItem*
|
||||
# variables: VarDecl*
|
||||
body: Stmt
|
||||
labels: CaseLabelItem*
|
||||
variables: VarDecl*
|
||||
|
||||
CaseLabelItem:
|
||||
_extends: AstNode
|
||||
# pattern: Pattern
|
||||
# guard: Expr?
|
||||
pattern: Pattern
|
||||
guard: Expr?
|
||||
_dir: stmt
|
||||
|
||||
ContinueStmt:
|
||||
_extends: Stmt
|
||||
# target_name: string?
|
||||
# target: Stmt?
|
||||
target_name: string?
|
||||
target: Stmt?
|
||||
|
||||
DeferStmt:
|
||||
_extends: Stmt
|
||||
# body: BraceStmt
|
||||
body: BraceStmt
|
||||
|
||||
FailStmt:
|
||||
_extends: Stmt
|
||||
|
||||
FallthroughStmt:
|
||||
_extends: Stmt
|
||||
# fallthrough_source: CaseStmt
|
||||
# fallthrough_dest: CaseStmt
|
||||
fallthrough_source: CaseStmt
|
||||
fallthrough_dest: CaseStmt
|
||||
|
||||
LabeledStmt:
|
||||
_extends: Stmt
|
||||
# label: string?
|
||||
label: string?
|
||||
|
||||
PoundAssertStmt:
|
||||
_extends: Stmt
|
||||
|
||||
ReturnStmt:
|
||||
_extends: Stmt
|
||||
# result: Expr?
|
||||
result: Expr?
|
||||
|
||||
ThrowStmt:
|
||||
_extends: Stmt
|
||||
# sub_expr: Expr
|
||||
sub_expr: Expr
|
||||
|
||||
YieldStmt:
|
||||
_extends: Stmt
|
||||
|
||||
BoundGenericType:
|
||||
_extends: NominalOrBoundGenericNominalType
|
||||
arg_types: Type*
|
||||
|
||||
NominalType:
|
||||
_extends: NominalOrBoundGenericNominalType
|
||||
@@ -598,6 +606,7 @@ BuiltinIntegerLiteralType:
|
||||
|
||||
BuiltinIntegerType:
|
||||
_extends: AnyBuiltinIntegerType
|
||||
width: int?
|
||||
|
||||
NestedArchetypeType:
|
||||
_extends: ArchetypeType
|
||||
@@ -613,16 +622,20 @@ OpenedArchetypeType:
|
||||
|
||||
PrimaryArchetypeType:
|
||||
_extends: ArchetypeType
|
||||
# interface_type: GenericTypeParamType
|
||||
interface_type: GenericTypeParamType
|
||||
|
||||
DictionaryType:
|
||||
_extends: SyntaxSugarType
|
||||
key_type: Type
|
||||
value_type: Type
|
||||
|
||||
UnarySyntaxSugarType:
|
||||
_extends: SyntaxSugarType
|
||||
base_type: Type
|
||||
|
||||
InfixOperatorDecl:
|
||||
_extends: OperatorDecl
|
||||
precedence_group: PrecedenceGroupDecl?
|
||||
|
||||
PostfixOperatorDecl:
|
||||
_extends: OperatorDecl
|
||||
@@ -634,29 +647,30 @@ AbstractFunctionDecl:
|
||||
_extends:
|
||||
- GenericContext
|
||||
- ValueDecl
|
||||
# name: string
|
||||
# body: BraceStmt?
|
||||
# params: ParamDecl*
|
||||
name: string
|
||||
body: BraceStmt?
|
||||
params: ParamDecl*
|
||||
|
||||
AbstractStorageDecl:
|
||||
_extends: ValueDecl
|
||||
|
||||
EnumElementDecl:
|
||||
_extends: ValueDecl
|
||||
# name: string
|
||||
# params: ParamDecl*
|
||||
name: string
|
||||
params: ParamDecl*
|
||||
|
||||
TypeDecl:
|
||||
_extends: ValueDecl
|
||||
# name: string
|
||||
name: string
|
||||
base_types: Type*
|
||||
|
||||
AutoClosureExpr:
|
||||
_extends: AbstractClosureExpr
|
||||
# body: BraceStmt
|
||||
body: BraceStmt
|
||||
|
||||
ClosureExpr:
|
||||
_extends: AbstractClosureExpr
|
||||
# body: BraceStmt
|
||||
body: BraceStmt
|
||||
|
||||
ForceTryExpr:
|
||||
_extends: AnyTryExpr
|
||||
@@ -681,15 +695,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
|
||||
@@ -807,10 +821,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
|
||||
@@ -826,51 +840,52 @@ 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
|
||||
|
||||
DoCatchStmt:
|
||||
_extends: LabeledStmt
|
||||
# body: Stmt
|
||||
# catches: CaseStmt*
|
||||
body: Stmt
|
||||
catches: CaseStmt*
|
||||
|
||||
DoStmt:
|
||||
_extends: LabeledStmt
|
||||
# body: BraceStmt
|
||||
body: BraceStmt
|
||||
|
||||
ForEachStmt:
|
||||
_extends: LabeledStmt
|
||||
# body: BraceStmt
|
||||
# sequence: Expr
|
||||
# where: Expr?
|
||||
pattern: Pattern
|
||||
sequence: Expr
|
||||
where: Expr?
|
||||
body: BraceStmt
|
||||
|
||||
LabeledConditionalStmt:
|
||||
_extends: LabeledStmt
|
||||
# condition: StmtCondition
|
||||
condition: StmtCondition
|
||||
|
||||
StmtCondition:
|
||||
_extends: AstNode
|
||||
# elements: ConditionElement*
|
||||
elements: ConditionElement*
|
||||
_dir: stmt
|
||||
|
||||
RepeatWhileStmt:
|
||||
_extends: LabeledStmt
|
||||
# condition: Expr
|
||||
# body: Stmt
|
||||
condition: Expr
|
||||
body: Stmt
|
||||
|
||||
SwitchStmt:
|
||||
_extends: LabeledStmt
|
||||
# expr: Expr
|
||||
# cases: CaseStmt*
|
||||
expr: Expr
|
||||
cases: CaseStmt*
|
||||
|
||||
BoundGenericClassType:
|
||||
_extends: BoundGenericType
|
||||
@@ -883,7 +898,6 @@ BoundGenericStructType:
|
||||
|
||||
ClassType:
|
||||
_extends: NominalType
|
||||
# decl: ClassDecl
|
||||
|
||||
EnumType:
|
||||
_extends: NominalType
|
||||
@@ -893,7 +907,6 @@ ProtocolType:
|
||||
|
||||
StructType:
|
||||
_extends: NominalType
|
||||
# decl: StructDecl
|
||||
|
||||
ArraySliceType:
|
||||
_extends: UnarySyntaxSugarType
|
||||
@@ -918,14 +931,17 @@ SubscriptDecl:
|
||||
|
||||
VarDecl:
|
||||
_extends: AbstractStorageDecl
|
||||
# name: string
|
||||
# type: Type
|
||||
name: string
|
||||
type: Type
|
||||
attached_property_wrapper_type: Type?
|
||||
parent_pattern: Pattern?
|
||||
parent_initializer: Expr?
|
||||
|
||||
AbstractTypeParamDecl:
|
||||
_extends: TypeDecl
|
||||
|
||||
GenericContext: {}
|
||||
# generic_type_params: GenericTypeParamDecl*
|
||||
GenericContext:
|
||||
generic_type_params: GenericTypeParamDecl*
|
||||
|
||||
GenericTypeDecl:
|
||||
_extends:
|
||||
@@ -952,18 +968,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
|
||||
@@ -973,16 +989,16 @@ DynamicSubscriptExpr:
|
||||
|
||||
GuardStmt:
|
||||
_extends: LabeledConditionalStmt
|
||||
# body: BraceStmt
|
||||
body: BraceStmt
|
||||
|
||||
IfStmt:
|
||||
_extends: LabeledConditionalStmt
|
||||
# then: Stmt
|
||||
# else: Stmt?
|
||||
then: Stmt
|
||||
else: Stmt?
|
||||
|
||||
WhileStmt:
|
||||
_extends: LabeledConditionalStmt
|
||||
# body: Stmt
|
||||
body: Stmt
|
||||
|
||||
AccessorDecl:
|
||||
_extends: FuncDecl
|
||||
@@ -992,7 +1008,7 @@ ConcreteFuncDecl:
|
||||
|
||||
ConcreteVarDecl:
|
||||
_extends: VarDecl
|
||||
# introducer_int: int
|
||||
introducer_int: int
|
||||
|
||||
ParamDecl:
|
||||
_extends: VarDecl
|
||||
@@ -1011,11 +1027,11 @@ TypeAliasDecl:
|
||||
|
||||
FloatLiteralExpr:
|
||||
_extends: NumberLiteralExpr
|
||||
# string_value: string
|
||||
string_value: string
|
||||
|
||||
IntegerLiteralExpr:
|
||||
_extends: NumberLiteralExpr
|
||||
# string_value: string
|
||||
string_value: string
|
||||
|
||||
ErrorTypeRepr:
|
||||
_extends: TypeRepr
|
||||
|
||||
@@ -38,15 +38,6 @@ class SwiftDispatcher {
|
||||
emit(ElementIsUnknownTrap{label});
|
||||
}
|
||||
|
||||
private:
|
||||
// types to be supported by assignNewLabel/fetchLabel need to be listed here
|
||||
using Store = TrapLabelStore<swift::Decl,
|
||||
swift::Stmt,
|
||||
swift::Expr,
|
||||
swift::Pattern,
|
||||
swift::TypeRepr,
|
||||
swift::TypeBase>;
|
||||
|
||||
// This method gives a TRAP label for already emitted AST node.
|
||||
// If the AST node was not emitted yet, then the emission is dispatched to a corresponding
|
||||
// visitor (see `visit(T *)` methods below).
|
||||
@@ -72,22 +63,38 @@ class SwiftDispatcher {
|
||||
return {};
|
||||
}
|
||||
|
||||
// convenience `fetchLabel` overload for `swift::Type` (which is just a wrapper for
|
||||
// `swift::TypeBase*`)
|
||||
TrapLabel<TypeTag> fetchLabel(swift::Type t) { return fetchLabel(t.getPointer()); }
|
||||
|
||||
TrapLabel<AstNodeTag> fetchLabel(swift::ASTNode node) {
|
||||
return fetchLabelFromUnion<AstNodeTag>(node);
|
||||
}
|
||||
|
||||
// Due to the lazy emission approach, we must assign a label to a corresponding AST node before
|
||||
// it actually gets emitted to handle recursive cases such as recursive calls, or recursive type
|
||||
// declarations
|
||||
template <typename E>
|
||||
TrapLabelOf<E> assignNewLabel(E* e) {
|
||||
assert(waitingForNewLabel == Store::Handle{e} && "assignNewLabel called on wrong entity");
|
||||
auto label = getLabel<TrapTagOf<E>>();
|
||||
trap.assignStar(label);
|
||||
auto label = createLabel<TrapTagOf<E>>();
|
||||
store.insert(e, label);
|
||||
waitingForNewLabel = std::monostate{};
|
||||
return label;
|
||||
}
|
||||
|
||||
template <typename Tag>
|
||||
TrapLabel<Tag> getLabel() {
|
||||
return arena.allocateLabel<Tag>();
|
||||
TrapLabel<Tag> createLabel() {
|
||||
auto ret = arena.allocateLabel<Tag>();
|
||||
trap.assignStar(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename Tag, typename... Args>
|
||||
TrapLabel<Tag> createLabel(Args&&... args) {
|
||||
auto ret = arena.allocateLabel<Tag>();
|
||||
trap.assignKey(ret, std::forward<Args>(args)...);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename Locatable>
|
||||
@@ -95,29 +102,70 @@ class SwiftDispatcher {
|
||||
attachLocation(&locatable, locatableLabel);
|
||||
}
|
||||
|
||||
// Emits a Location TRAP entry and attaches it to an AST node
|
||||
// Emits a Location TRAP entry and attaches it to a `Locatable` trap label
|
||||
template <typename Locatable>
|
||||
void attachLocation(Locatable* locatable, TrapLabel<LocatableTag> locatableLabel) {
|
||||
auto start = locatable->getStartLoc();
|
||||
auto end = locatable->getEndLoc();
|
||||
attachLocation(locatable->getStartLoc(), locatable->getEndLoc(), locatableLabel);
|
||||
}
|
||||
|
||||
// Emits a Location TRAP entry for a list of swift entities and attaches it to a `Locatable` trap
|
||||
// label
|
||||
template <typename Locatable>
|
||||
void attachLocation(llvm::MutableArrayRef<Locatable>* locatables,
|
||||
TrapLabel<LocatableTag> locatableLabel) {
|
||||
if (locatables->empty()) {
|
||||
return;
|
||||
}
|
||||
attachLocation(locatables->front().getStartLoc(), locatables->back().getEndLoc(),
|
||||
locatableLabel);
|
||||
}
|
||||
|
||||
private:
|
||||
// types to be supported by assignNewLabel/fetchLabel need to be listed here
|
||||
using Store = TrapLabelStore<swift::Decl,
|
||||
swift::Stmt,
|
||||
swift::StmtCondition,
|
||||
swift::CaseLabelItem,
|
||||
swift::Expr,
|
||||
swift::Pattern,
|
||||
swift::TypeRepr,
|
||||
swift::TypeBase>;
|
||||
|
||||
void attachLocation(swift::SourceLoc start,
|
||||
swift::SourceLoc end,
|
||||
TrapLabel<LocatableTag> locatableLabel) {
|
||||
if (!start.isValid() || !end.isValid()) {
|
||||
// invalid locations seem to come from entities synthesized by the compiler
|
||||
return;
|
||||
}
|
||||
std::string filepath = getFilepath(start);
|
||||
auto fileLabel = arena.allocateLabel<FileTag>();
|
||||
trap.assignKey(fileLabel, filepath);
|
||||
auto fileLabel = createLabel<FileTag>(filepath);
|
||||
// TODO: do not emit duplicate trap entries for Files
|
||||
trap.emit(FilesTrap{fileLabel, filepath});
|
||||
auto [startLine, startColumn] = sourceManager.getLineAndColumnInBuffer(start);
|
||||
auto [endLine, endColumn] = sourceManager.getLineAndColumnInBuffer(end);
|
||||
auto locLabel = arena.allocateLabel<LocationTag>();
|
||||
trap.assignKey(locLabel, '{', fileLabel, "}:", startLine, ':', startColumn, ':', endLine, ':',
|
||||
endColumn);
|
||||
auto locLabel = createLabel<LocationTag>('{', fileLabel, "}:", startLine, ':', startColumn, ':',
|
||||
endLine, ':', endColumn);
|
||||
trap.emit(LocationsTrap{locLabel, fileLabel, startLine, startColumn, endLine, endColumn});
|
||||
trap.emit(LocatablesTrap{locatableLabel, locLabel});
|
||||
}
|
||||
|
||||
template <typename Tag, typename... Ts>
|
||||
TrapLabel<Tag> fetchLabelFromUnion(const llvm::PointerUnion<Ts...> u) {
|
||||
TrapLabel<Tag> ret{};
|
||||
assert((... || fetchLabelFromUnionCase<Tag, Ts>(u, ret)) && "llvm::PointerUnion not set");
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename Tag, typename T, typename... Ts>
|
||||
bool fetchLabelFromUnionCase(const llvm::PointerUnion<Ts...> u, TrapLabel<Tag>& output) {
|
||||
if (auto e = u.template dyn_cast<T>()) {
|
||||
output = fetchLabel(e);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string getFilepath(swift::SourceLoc loc) {
|
||||
// TODO: this needs more testing
|
||||
// TODO: check canonicaliztion of names on a case insensitive filesystems
|
||||
@@ -135,6 +183,8 @@ class SwiftDispatcher {
|
||||
// which are to be introduced in follow-up PRs
|
||||
virtual void visit(swift::Decl* decl) = 0;
|
||||
virtual void visit(swift::Stmt* stmt) = 0;
|
||||
virtual void visit(swift::StmtCondition* cond) = 0;
|
||||
virtual void visit(swift::CaseLabelItem* item) = 0;
|
||||
virtual void visit(swift::Expr* expr) = 0;
|
||||
virtual void visit(swift::Pattern* pattern) = 0;
|
||||
virtual void visit(swift::TypeRepr* type) = 0;
|
||||
|
||||
@@ -35,6 +35,8 @@ using SILBoxTypeReprTag = SilBoxTypeReprTag;
|
||||
static_assert(std::is_base_of_v<TYPE##Tag, TAG>, "override is not a subtag");
|
||||
|
||||
MAP_TAG(Stmt);
|
||||
MAP_TAG(StmtCondition);
|
||||
MAP_TAG(CaseLabelItem);
|
||||
#define ABSTRACT_STMT(CLASS, PARENT) MAP_SUBTAG(CLASS##Stmt, PARENT)
|
||||
#define STMT(CLASS, PARENT) ABSTRACT_STMT(CLASS, PARENT)
|
||||
#include "swift/AST/StmtNodes.def"
|
||||
|
||||
@@ -22,6 +22,8 @@ class SwiftVisitor : private SwiftDispatcher {
|
||||
private:
|
||||
void visit(swift::Decl* decl) override { declVisitor.visit(decl); }
|
||||
void visit(swift::Stmt* stmt) override { stmtVisitor.visit(stmt); }
|
||||
void visit(swift::StmtCondition* cond) override { stmtVisitor.visitStmtCondition(cond); }
|
||||
void visit(swift::CaseLabelItem* item) override { stmtVisitor.visitCaseLabelItem(item); }
|
||||
void visit(swift::Expr* expr) override { exprVisitor.visit(expr); }
|
||||
void visit(swift::Pattern* pattern) override { patternVisitor.visit(pattern); }
|
||||
void visit(swift::TypeRepr* type) override { typeReprVisitor.visit(type); }
|
||||
|
||||
@@ -13,12 +13,18 @@ class UntypedTrapLabel {
|
||||
template <typename Tag>
|
||||
friend class TrapLabel;
|
||||
|
||||
static constexpr uint64_t undefined = 0xffffffffffffffff;
|
||||
|
||||
protected:
|
||||
UntypedTrapLabel() : id_{0xffffffffffffffff} {}
|
||||
UntypedTrapLabel() : id_{undefined} {}
|
||||
UntypedTrapLabel(uint64_t id) : id_{id} {}
|
||||
|
||||
public:
|
||||
friend std::ostream& operator<<(std::ostream& out, UntypedTrapLabel l) {
|
||||
// TODO: this is a temporary fix to catch us from outputting undefined labels to trap
|
||||
// this should be moved to a validity check, probably aided by code generation and carried out
|
||||
// by `SwiftDispatcher`
|
||||
assert(l.id_ != undefined && "outputting an undefined label!");
|
||||
out << '#' << std::hex << l.id_ << std::dec;
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,256 @@
|
||||
#pragma once
|
||||
|
||||
#include <swift/AST/Decl.h>
|
||||
#include <swift/AST/GenericParamList.h>
|
||||
#include <swift/AST/ParameterList.h>
|
||||
|
||||
#include "swift/extractor/visitors/VisitorBase.h"
|
||||
|
||||
namespace codeql {
|
||||
|
||||
// `swift::Decl` visitor
|
||||
// public `visitXXX(swift::XXX* decl)` methods visit concrete declarations
|
||||
// private `emitXXX(swift::XXX* decl, TrapLabel<XXXTag> label)` are used to fill the properties
|
||||
// related to an abstract `XXX` entity, given the label assigned to the concrete entry
|
||||
// In general, `visitXXX/emitXXX` should call `emitYYY` with `YYY` the direct superclass of `XXX`
|
||||
// (if not `Decl` itself)
|
||||
// TODO: maybe make the above chain of calls automatic with a bit of macro metaprogramming?
|
||||
class DeclVisitor : public AstVisitorBase<DeclVisitor> {
|
||||
public:
|
||||
using AstVisitorBase<DeclVisitor>::AstVisitorBase;
|
||||
|
||||
void visitFuncDecl(swift::FuncDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
dispatcher_.emit(ConcreteFuncDeclsTrap{label});
|
||||
emitAbstractFunctionDecl(decl, label);
|
||||
}
|
||||
|
||||
void visitConstructorDecl(swift::ConstructorDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
dispatcher_.emit(ConstructorDeclsTrap{label});
|
||||
emitConstructorDecl(decl, label);
|
||||
}
|
||||
|
||||
void visitDestructorDecl(swift::DestructorDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
dispatcher_.emit(DestructorDeclsTrap{label});
|
||||
emitDestructorDecl(decl, label);
|
||||
}
|
||||
|
||||
void visitPrefixOperatorDecl(swift::PrefixOperatorDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
dispatcher_.emit(PrefixOperatorDeclsTrap{label});
|
||||
emitOperatorDecl(decl, label);
|
||||
}
|
||||
|
||||
void visitPostfixOperatorDecl(swift::PostfixOperatorDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
dispatcher_.emit(PostfixOperatorDeclsTrap{label});
|
||||
emitOperatorDecl(decl, label);
|
||||
}
|
||||
|
||||
void visitInfixOperatorDecl(swift::InfixOperatorDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
dispatcher_.emit(InfixOperatorDeclsTrap{label});
|
||||
if (auto group = decl->getPrecedenceGroup()) {
|
||||
dispatcher_.emit(InfixOperatorDeclPrecedenceGroupsTrap{label, dispatcher_.fetchLabel(group)});
|
||||
}
|
||||
emitOperatorDecl(decl, label);
|
||||
}
|
||||
|
||||
void visitPrecedenceGroupDecl(swift::PrecedenceGroupDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
dispatcher_.emit(PrecedenceGroupDeclsTrap{label});
|
||||
}
|
||||
|
||||
void visitParamDecl(swift::ParamDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
dispatcher_.emit(ParamDeclsTrap{label});
|
||||
emitVarDecl(decl, label);
|
||||
}
|
||||
|
||||
void visitTopLevelCodeDecl(swift::TopLevelCodeDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
assert(decl->getBody() && "Expect top level code to have body");
|
||||
dispatcher_.emit(TopLevelCodeDeclsTrap{label, dispatcher_.fetchLabel(decl->getBody())});
|
||||
}
|
||||
|
||||
void visitPatternBindingDecl(swift::PatternBindingDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
dispatcher_.emit(PatternBindingDeclsTrap{label});
|
||||
for (unsigned i = 0; i < decl->getNumPatternEntries(); ++i) {
|
||||
auto pattern = decl->getPattern(i);
|
||||
assert(pattern && "Expect pattern binding decl to have all patterns");
|
||||
dispatcher_.emit(PatternBindingDeclPatternsTrap{label, i, dispatcher_.fetchLabel(pattern)});
|
||||
if (auto init = decl->getInit(i)) {
|
||||
dispatcher_.emit(PatternBindingDeclInitsTrap{label, i, dispatcher_.fetchLabel(init)});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void visitVarDecl(swift::VarDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
auto introducer = static_cast<uint8_t>(decl->getIntroducer());
|
||||
dispatcher_.emit(ConcreteVarDeclsTrap{label, introducer});
|
||||
emitVarDecl(decl, label);
|
||||
}
|
||||
|
||||
void visitStructDecl(swift::StructDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
dispatcher_.emit(StructDeclsTrap{label});
|
||||
emitNominalTypeDecl(decl, label);
|
||||
}
|
||||
|
||||
void visitClassDecl(swift::ClassDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
dispatcher_.emit(ClassDeclsTrap{label});
|
||||
emitNominalTypeDecl(decl, label);
|
||||
}
|
||||
|
||||
void visitEnumDecl(swift::EnumDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
dispatcher_.emit(EnumDeclsTrap{label});
|
||||
emitNominalTypeDecl(decl, label);
|
||||
}
|
||||
|
||||
void visitProtocolDecl(swift::ProtocolDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
dispatcher_.emit(ProtocolDeclsTrap{label});
|
||||
emitNominalTypeDecl(decl, label);
|
||||
}
|
||||
|
||||
void visitEnumCaseDecl(swift::EnumCaseDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
dispatcher_.emit(EnumCaseDeclsTrap{label});
|
||||
auto i = 0u;
|
||||
for (auto e : decl->getElements()) {
|
||||
dispatcher_.emit(EnumCaseDeclElementsTrap{label, i++, dispatcher_.fetchLabel(e)});
|
||||
}
|
||||
}
|
||||
|
||||
void visitEnumElementDecl(swift::EnumElementDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
dispatcher_.emit(EnumElementDeclsTrap{label, decl->getNameStr().str()});
|
||||
if (decl->hasParameterList()) {
|
||||
auto i = 0u;
|
||||
for (auto p : *decl->getParameterList()) {
|
||||
dispatcher_.emit(EnumElementDeclParamsTrap{label, i++, dispatcher_.fetchLabel(p)});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void visitGenericTypeParamDecl(swift::GenericTypeParamDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
dispatcher_.emit(GenericTypeParamDeclsTrap{label});
|
||||
emitTypeDecl(decl, label);
|
||||
}
|
||||
|
||||
void visitAssociatedTypeDecl(swift::AssociatedTypeDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
dispatcher_.emit(AssociatedTypeDeclsTrap{label});
|
||||
emitTypeDecl(decl, label);
|
||||
}
|
||||
|
||||
void visitTypeAliasDecl(swift::TypeAliasDecl* decl) {
|
||||
auto label = dispatcher_.assignNewLabel(decl);
|
||||
dispatcher_.emit(TypeAliasDeclsTrap{label});
|
||||
emitTypeDecl(decl, label);
|
||||
}
|
||||
|
||||
private:
|
||||
void emitConstructorDecl(swift::ConstructorDecl* decl, TrapLabel<ConstructorDeclTag> label) {
|
||||
emitAbstractFunctionDecl(decl, label);
|
||||
}
|
||||
|
||||
void emitDestructorDecl(swift::DestructorDecl* decl, TrapLabel<DestructorDeclTag> label) {
|
||||
emitAbstractFunctionDecl(decl, label);
|
||||
}
|
||||
|
||||
void emitAbstractFunctionDecl(swift::AbstractFunctionDecl* decl,
|
||||
TrapLabel<AbstractFunctionDeclTag> label) {
|
||||
assert(decl->hasName() && "Expect functions to have name");
|
||||
assert(decl->hasParameterList() && "Expect functions to have a parameter list");
|
||||
auto name = decl->getName().isSpecial() ? "(unnamed function decl)" : decl->getNameStr().str();
|
||||
dispatcher_.emit(AbstractFunctionDeclsTrap{label, name});
|
||||
if (auto body = decl->getBody()) {
|
||||
dispatcher_.emit(AbstractFunctionDeclBodiesTrap{label, dispatcher_.fetchLabel(body)});
|
||||
}
|
||||
auto params = decl->getParameters();
|
||||
for (auto i = 0u; i < params->size(); ++i) {
|
||||
dispatcher_.emit(
|
||||
AbstractFunctionDeclParamsTrap{label, i, dispatcher_.fetchLabel(params->get(i))});
|
||||
}
|
||||
emitValueDecl(decl, label);
|
||||
emitGenericContext(decl, label);
|
||||
}
|
||||
|
||||
void emitOperatorDecl(swift::OperatorDecl* decl, TrapLabel<OperatorDeclTag> label) {
|
||||
dispatcher_.emit(OperatorDeclsTrap{label, decl->getName().str().str()});
|
||||
}
|
||||
|
||||
void emitTypeDecl(swift::TypeDecl* decl, TrapLabel<TypeDeclTag> label) {
|
||||
dispatcher_.emit(TypeDeclsTrap{label, decl->getNameStr().str()});
|
||||
auto i = 0u;
|
||||
for (auto& typeLoc : decl->getInherited()) {
|
||||
auto type = typeLoc.getType();
|
||||
if (type.isNull()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
dispatcher_.emit(TypeDeclBaseTypesTrap{label, i++, dispatcher_.fetchLabel(type)});
|
||||
}
|
||||
emitValueDecl(decl, label);
|
||||
}
|
||||
|
||||
void emitIterableDeclContext(swift::IterableDeclContext* decl,
|
||||
TrapLabel<IterableDeclContextTag> label) {
|
||||
auto i = 0u;
|
||||
for (auto& member : decl->getAllMembers()) {
|
||||
dispatcher_.emit(IterableDeclContextMembersTrap{label, i++, dispatcher_.fetchLabel(member)});
|
||||
}
|
||||
}
|
||||
|
||||
void emitVarDecl(swift::VarDecl* decl, TrapLabel<VarDeclTag> label) {
|
||||
auto typeLabel = dispatcher_.fetchLabel(decl->getType());
|
||||
dispatcher_.emit(VarDeclsTrap{label, decl->getNameStr().str(), typeLabel});
|
||||
if (auto pattern = decl->getParentPattern()) {
|
||||
dispatcher_.emit(VarDeclParentPatternsTrap{label, dispatcher_.fetchLabel(pattern)});
|
||||
}
|
||||
if (auto init = decl->getParentInitializer()) {
|
||||
dispatcher_.emit(VarDeclParentInitializersTrap{label, dispatcher_.fetchLabel(init)});
|
||||
}
|
||||
if (decl->hasAttachedPropertyWrapper()) {
|
||||
if (auto propertyType = decl->getPropertyWrapperBackingPropertyType();
|
||||
!propertyType.isNull()) {
|
||||
dispatcher_.emit(
|
||||
VarDeclAttachedPropertyWrapperTypesTrap{label, dispatcher_.fetchLabel(propertyType)});
|
||||
}
|
||||
}
|
||||
emitValueDecl(decl, label);
|
||||
}
|
||||
|
||||
void emitNominalTypeDecl(swift::NominalTypeDecl* decl, TrapLabel<NominalTypeDeclTag> label) {
|
||||
auto typeLabel = dispatcher_.fetchLabel(decl->getDeclaredType());
|
||||
dispatcher_.emit(NominalTypeDeclsTrap{label, typeLabel});
|
||||
emitGenericContext(decl, label);
|
||||
emitIterableDeclContext(decl, label);
|
||||
emitTypeDecl(decl, label);
|
||||
}
|
||||
|
||||
void emitGenericContext(const swift::GenericContext* decl, TrapLabel<GenericContextTag> label) {
|
||||
if (auto params = decl->getGenericParams()) {
|
||||
auto i = 0u;
|
||||
for (auto t : *params) {
|
||||
dispatcher_.emit(
|
||||
GenericContextGenericTypeParamsTrap{label, i++, dispatcher_.fetchLabel(t)});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void emitValueDecl(const swift::ValueDecl* decl, TrapLabel<ValueDeclTag> label) {
|
||||
assert(decl->getInterfaceType() && "Expect ValueDecl to have InterfaceType");
|
||||
dispatcher_.emit(ValueDeclsTrap{label, dispatcher_.fetchLabel(decl->getInterfaceType())});
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace codeql
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -7,6 +7,91 @@ namespace codeql {
|
||||
class PatternVisitor : public AstVisitorBase<PatternVisitor> {
|
||||
public:
|
||||
using AstVisitorBase<PatternVisitor>::AstVisitorBase;
|
||||
};
|
||||
|
||||
void visitNamedPattern(swift::NamedPattern* pattern) {
|
||||
auto label = dispatcher_.assignNewLabel(pattern);
|
||||
// TODO: in some (but not all) cases, this seems to introduce a duplicate entry
|
||||
// for example the vars listed in a case stmt have a different pointer than then ones in
|
||||
// patterns.
|
||||
// assert(pattern->getDecl() && "expect NamedPattern to have Decl");
|
||||
// dispatcher_.emit(NamedPatternsTrap{label, pattern->getNameStr().str(),
|
||||
// dispatcher_.fetchLabel(pattern->getDecl())});
|
||||
dispatcher_.emit(NamedPatternsTrap{label, pattern->getNameStr().str()});
|
||||
}
|
||||
|
||||
void visitTypedPattern(swift::TypedPattern* pattern) {
|
||||
auto label = dispatcher_.assignNewLabel(pattern);
|
||||
assert(pattern->getSubPattern() && "expect TypedPattern to have a SubPattern");
|
||||
dispatcher_.emit(TypedPatternsTrap{label, dispatcher_.fetchLabel(pattern->getSubPattern())});
|
||||
if (auto typeRepr = pattern->getTypeRepr()) {
|
||||
dispatcher_.emit(
|
||||
TypedPatternTypeReprsTrap{label, dispatcher_.fetchLabel(pattern->getTypeRepr())});
|
||||
}
|
||||
}
|
||||
|
||||
void visitTuplePattern(swift::TuplePattern* pattern) {
|
||||
auto label = dispatcher_.assignNewLabel(pattern);
|
||||
dispatcher_.emit(TuplePatternsTrap{label});
|
||||
auto i = 0u;
|
||||
for (auto p : pattern->getElements()) {
|
||||
dispatcher_.emit(
|
||||
TuplePatternElementsTrap{label, i++, dispatcher_.fetchLabel(p.getPattern())});
|
||||
}
|
||||
}
|
||||
void visitAnyPattern(swift::AnyPattern* pattern) {
|
||||
dispatcher_.emit(AnyPatternsTrap{dispatcher_.assignNewLabel(pattern)});
|
||||
}
|
||||
|
||||
void visitBindingPattern(swift::BindingPattern* pattern) {
|
||||
auto label = dispatcher_.assignNewLabel(pattern);
|
||||
assert(pattern->getSubPattern() && "expect BindingPattern to have a SubPattern");
|
||||
dispatcher_.emit(BindingPatternsTrap{label, dispatcher_.fetchLabel(pattern->getSubPattern())});
|
||||
}
|
||||
|
||||
void visitEnumElementPattern(swift::EnumElementPattern* pattern) {
|
||||
auto label = dispatcher_.assignNewLabel(pattern);
|
||||
dispatcher_.emit(
|
||||
EnumElementPatternsTrap{label, dispatcher_.fetchLabel(pattern->getElementDecl())});
|
||||
if (auto subPattern = pattern->getSubPattern()) {
|
||||
dispatcher_.emit(EnumElementPatternSubPatternsTrap{
|
||||
label, dispatcher_.fetchLabel(pattern->getSubPattern())});
|
||||
}
|
||||
}
|
||||
|
||||
void visitOptionalSomePattern(swift::OptionalSomePattern* pattern) {
|
||||
auto label = dispatcher_.assignNewLabel(pattern);
|
||||
assert(pattern->getSubPattern() && "expect BindingPattern to have a SubPattern");
|
||||
dispatcher_.emit(
|
||||
OptionalSomePatternsTrap{label, dispatcher_.fetchLabel(pattern->getSubPattern())});
|
||||
}
|
||||
|
||||
void visitIsPattern(swift::IsPattern* pattern) {
|
||||
auto label = dispatcher_.assignNewLabel(pattern);
|
||||
dispatcher_.emit(IsPatternsTrap{label});
|
||||
|
||||
if (auto typeRepr = pattern->getCastTypeRepr()) {
|
||||
dispatcher_.emit(IsPatternCastTypeReprsTrap{label, dispatcher_.fetchLabel(typeRepr)});
|
||||
}
|
||||
if (auto subPattern = pattern->getSubPattern()) {
|
||||
dispatcher_.emit(IsPatternSubPatternsTrap{label, dispatcher_.fetchLabel(subPattern)});
|
||||
}
|
||||
}
|
||||
|
||||
void visitExprPattern(swift::ExprPattern* pattern) {
|
||||
auto label = dispatcher_.assignNewLabel(pattern);
|
||||
assert(pattern->getSubExpr() && "expect ExprPattern to have SubExpr");
|
||||
dispatcher_.emit(ExprPatternsTrap{label, dispatcher_.fetchLabel(pattern->getSubExpr())});
|
||||
}
|
||||
|
||||
void visitParenPattern(swift::ParenPattern* pattern) {
|
||||
auto label = dispatcher_.assignNewLabel(pattern);
|
||||
assert(pattern->getSubPattern() && "expect ParenPattern to have SubPattern");
|
||||
dispatcher_.emit(ParenPatternsTrap{label, dispatcher_.fetchLabel(pattern->getSubPattern())});
|
||||
}
|
||||
|
||||
void visitBoolPattern(swift::BoolPattern* pattern) {
|
||||
auto label = dispatcher_.assignNewLabel(pattern);
|
||||
dispatcher_.emit(BoolPatternsTrap{label, pattern->getValue()});
|
||||
}
|
||||
};
|
||||
} // namespace codeql
|
||||
|
||||
@@ -7,6 +7,217 @@ namespace codeql {
|
||||
class StmtVisitor : public AstVisitorBase<StmtVisitor> {
|
||||
public:
|
||||
using AstVisitorBase<StmtVisitor>::AstVisitorBase;
|
||||
|
||||
void visitLabeledStmt(swift::LabeledStmt* stmt) {
|
||||
auto label = dispatcher_.assignNewLabel(stmt);
|
||||
emitLabeledStmt(stmt, label);
|
||||
}
|
||||
|
||||
void visitStmtCondition(swift::StmtCondition* cond) {
|
||||
auto label = dispatcher_.assignNewLabel(cond);
|
||||
dispatcher_.emit(StmtConditionsTrap{label});
|
||||
unsigned index = 0;
|
||||
for (const auto& cond : *cond) {
|
||||
auto condLabel = dispatcher_.createLabel<ConditionElementTag>();
|
||||
dispatcher_.attachLocation(cond, condLabel);
|
||||
dispatcher_.emit(ConditionElementsTrap{condLabel});
|
||||
dispatcher_.emit(StmtConditionElementsTrap{label, index++, condLabel});
|
||||
if (auto boolean = cond.getBooleanOrNull()) {
|
||||
auto elementLabel = dispatcher_.fetchLabel(boolean);
|
||||
dispatcher_.emit(ConditionElementBooleansTrap{condLabel, elementLabel});
|
||||
} else if (auto pattern = cond.getPatternOrNull()) {
|
||||
auto patternLabel = dispatcher_.fetchLabel(pattern);
|
||||
auto initilizerLabel = dispatcher_.fetchLabel(cond.getInitializer());
|
||||
dispatcher_.emit(ConditionElementPatternsTrap{condLabel, patternLabel});
|
||||
dispatcher_.emit(ConditionElementInitializersTrap{condLabel, initilizerLabel});
|
||||
}
|
||||
/// TODO: Implement availability
|
||||
}
|
||||
}
|
||||
|
||||
void visitLabeledConditionalStmt(swift::LabeledConditionalStmt* stmt) {
|
||||
auto label = dispatcher_.assignNewLabel(stmt);
|
||||
emitLabeledStmt(stmt, label);
|
||||
emitLabeledConditionalStmt(stmt, label);
|
||||
}
|
||||
|
||||
void visitCaseLabelItem(swift::CaseLabelItem* labelItem) {
|
||||
auto label = dispatcher_.assignNewLabel(labelItem);
|
||||
assert(labelItem->getPattern() && "CaseLabelItem has Pattern");
|
||||
dispatcher_.emit(CaseLabelItemsTrap{label, dispatcher_.fetchLabel(labelItem->getPattern())});
|
||||
}
|
||||
|
||||
void visitBraceStmt(swift::BraceStmt* stmt) {
|
||||
auto label = dispatcher_.assignNewLabel(stmt);
|
||||
dispatcher_.emit(BraceStmtsTrap{label});
|
||||
auto i = 0u;
|
||||
for (auto& e : stmt->getElements()) {
|
||||
dispatcher_.emit(BraceStmtElementsTrap{label, i++, dispatcher_.fetchLabel(e)});
|
||||
}
|
||||
}
|
||||
|
||||
void visitReturnStmt(swift::ReturnStmt* stmt) {
|
||||
auto label = dispatcher_.assignNewLabel(stmt);
|
||||
dispatcher_.emit(ReturnStmtsTrap{label});
|
||||
if (stmt->hasResult()) {
|
||||
auto resultLabel = dispatcher_.fetchLabel(stmt->getResult());
|
||||
dispatcher_.emit(ReturnStmtResultsTrap{label, resultLabel});
|
||||
}
|
||||
}
|
||||
|
||||
void visitForEachStmt(swift::ForEachStmt* stmt) {
|
||||
auto label = dispatcher_.assignNewLabel(stmt);
|
||||
assert(stmt->getBody() && "ForEachStmt has getBody()");
|
||||
assert(stmt->getSequence() && "ForEachStmt has getSequence()");
|
||||
assert(stmt->getPattern() && "ForEachStmt has getPattern()");
|
||||
auto bodyLabel = dispatcher_.fetchLabel(stmt->getBody());
|
||||
auto sequenceLabel = dispatcher_.fetchLabel(stmt->getSequence());
|
||||
auto patternLabel = dispatcher_.fetchLabel(stmt->getPattern());
|
||||
emitLabeledStmt(stmt, label);
|
||||
dispatcher_.emit(ForEachStmtsTrap{label, patternLabel, sequenceLabel, bodyLabel});
|
||||
if (auto where = stmt->getWhere()) {
|
||||
auto whereLabel = dispatcher_.fetchLabel(where);
|
||||
dispatcher_.emit(ForEachStmtWheresTrap{label, whereLabel});
|
||||
}
|
||||
}
|
||||
|
||||
void visitIfStmt(swift::IfStmt* stmt) {
|
||||
auto label = dispatcher_.assignNewLabel(stmt);
|
||||
emitLabeledStmt(stmt, label);
|
||||
emitLabeledConditionalStmt(stmt, label);
|
||||
auto thenLabel = dispatcher_.fetchLabel(stmt->getThenStmt());
|
||||
dispatcher_.emit(IfStmtsTrap{label, thenLabel});
|
||||
if (auto* elseStmt = stmt->getElseStmt()) {
|
||||
auto elseLabel = dispatcher_.fetchLabel(elseStmt);
|
||||
dispatcher_.emit(IfStmtElsesTrap{label, elseLabel});
|
||||
}
|
||||
}
|
||||
|
||||
void visitBreakStmt(swift::BreakStmt* stmt) {
|
||||
auto label = dispatcher_.assignNewLabel(stmt);
|
||||
dispatcher_.emit(BreakStmtsTrap{label});
|
||||
if (auto* target = stmt->getTarget()) {
|
||||
auto targetlabel = dispatcher_.fetchLabel(target);
|
||||
dispatcher_.emit(BreakStmtTargetsTrap{label, targetlabel});
|
||||
}
|
||||
auto targetName = stmt->getTargetName();
|
||||
if (!targetName.empty()) {
|
||||
dispatcher_.emit(BreakStmtTargetNamesTrap{label, targetName.str().str()});
|
||||
}
|
||||
}
|
||||
|
||||
void visitContinueStmt(swift::ContinueStmt* stmt) {
|
||||
auto label = dispatcher_.assignNewLabel(stmt);
|
||||
dispatcher_.emit(ContinueStmtsTrap{label});
|
||||
if (auto* target = stmt->getTarget()) {
|
||||
auto targetlabel = dispatcher_.fetchLabel(target);
|
||||
dispatcher_.emit(ContinueStmtTargetsTrap{label, targetlabel});
|
||||
}
|
||||
auto targetName = stmt->getTargetName();
|
||||
if (!targetName.empty()) {
|
||||
dispatcher_.emit(ContinueStmtTargetNamesTrap{label, targetName.str().str()});
|
||||
}
|
||||
}
|
||||
|
||||
void visitWhileStmt(swift::WhileStmt* stmt) {
|
||||
auto label = dispatcher_.assignNewLabel(stmt);
|
||||
emitLabeledStmt(stmt, label);
|
||||
emitLabeledConditionalStmt(stmt, label);
|
||||
dispatcher_.emit(WhileStmtsTrap{label, dispatcher_.fetchLabel(stmt->getBody())});
|
||||
}
|
||||
|
||||
void visitRepeatWhileStmt(swift::RepeatWhileStmt* stmt) {
|
||||
auto label = dispatcher_.assignNewLabel(stmt);
|
||||
emitLabeledStmt(stmt, label);
|
||||
auto bodyLabel = dispatcher_.fetchLabel(stmt->getBody());
|
||||
auto condLabel = dispatcher_.fetchLabel(stmt->getCond());
|
||||
dispatcher_.emit(RepeatWhileStmtsTrap{label, condLabel, bodyLabel});
|
||||
}
|
||||
|
||||
void visitDoCatchStmt(swift::DoCatchStmt* stmt) {
|
||||
auto label = dispatcher_.assignNewLabel(stmt);
|
||||
emitLabeledStmt(stmt, label);
|
||||
auto bodyLabel = dispatcher_.fetchLabel(stmt->getBody());
|
||||
dispatcher_.emit(DoCatchStmtsTrap{label, bodyLabel});
|
||||
auto i = 0u;
|
||||
for (auto* stmtCatch : stmt->getCatches()) {
|
||||
dispatcher_.emit(DoCatchStmtCatchesTrap{label, i++, dispatcher_.fetchLabel(stmtCatch)});
|
||||
}
|
||||
}
|
||||
|
||||
void visitCaseStmt(swift::CaseStmt* stmt) {
|
||||
auto label = dispatcher_.assignNewLabel(stmt);
|
||||
auto bodyLabel = dispatcher_.fetchLabel(stmt->getBody());
|
||||
dispatcher_.emit(CaseStmtsTrap{label, bodyLabel});
|
||||
auto i = 0u;
|
||||
for (auto& item : stmt->getMutableCaseLabelItems()) {
|
||||
dispatcher_.emit(CaseStmtLabelsTrap{label, i++, dispatcher_.fetchLabel(&item)});
|
||||
}
|
||||
if (stmt->hasCaseBodyVariables()) {
|
||||
auto i = 0u;
|
||||
for (auto* var : stmt->getCaseBodyVariables()) {
|
||||
dispatcher_.emit(CaseStmtVariablesTrap{label, i++, dispatcher_.fetchLabel(var)});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void visitGuardStmt(swift::GuardStmt* stmt) {
|
||||
auto label = dispatcher_.assignNewLabel(stmt);
|
||||
emitLabeledStmt(stmt, label);
|
||||
emitLabeledConditionalStmt(stmt, label);
|
||||
auto bodyLabel = dispatcher_.fetchLabel(stmt->getBody());
|
||||
dispatcher_.emit(GuardStmtsTrap{label, bodyLabel});
|
||||
}
|
||||
|
||||
void visitThrowStmt(swift::ThrowStmt* stmt) {
|
||||
auto label = dispatcher_.assignNewLabel(stmt);
|
||||
auto subExprLabel = dispatcher_.fetchLabel(stmt->getSubExpr());
|
||||
dispatcher_.emit(ThrowStmtsTrap{label, subExprLabel});
|
||||
}
|
||||
|
||||
void visitDeferStmt(swift::DeferStmt* stmt) {
|
||||
auto label = dispatcher_.assignNewLabel(stmt);
|
||||
auto bodyLabel = dispatcher_.fetchLabel(stmt->getBodyAsWritten());
|
||||
dispatcher_.emit(DeferStmtsTrap{label, bodyLabel});
|
||||
}
|
||||
|
||||
void visitDoStmt(swift::DoStmt* stmt) {
|
||||
auto label = dispatcher_.assignNewLabel(stmt);
|
||||
emitLabeledStmt(stmt, label);
|
||||
auto bodyLabel = dispatcher_.fetchLabel(stmt->getBody());
|
||||
dispatcher_.emit(DoStmtsTrap{label, bodyLabel});
|
||||
}
|
||||
|
||||
void visitSwitchStmt(swift::SwitchStmt* stmt) {
|
||||
auto label = dispatcher_.assignNewLabel(stmt);
|
||||
emitLabeledStmt(stmt, label);
|
||||
auto subjectLabel = dispatcher_.fetchLabel(stmt->getSubjectExpr());
|
||||
dispatcher_.emit(SwitchStmtsTrap{label, subjectLabel});
|
||||
auto i = 0u;
|
||||
for (auto* c : stmt->getCases()) {
|
||||
dispatcher_.emit(SwitchStmtCasesTrap{label, i++, dispatcher_.fetchLabel(c)});
|
||||
}
|
||||
}
|
||||
|
||||
void visitFallthroughStmt(swift::FallthroughStmt* stmt) {
|
||||
auto label = dispatcher_.assignNewLabel(stmt);
|
||||
auto sourceLabel = dispatcher_.fetchLabel(stmt->getFallthroughSource());
|
||||
auto destLabel = dispatcher_.fetchLabel(stmt->getFallthroughDest());
|
||||
dispatcher_.emit(FallthroughStmtsTrap{label, sourceLabel, destLabel});
|
||||
}
|
||||
|
||||
private:
|
||||
void emitLabeledStmt(const swift::LabeledStmt* stmt, TrapLabel<LabeledStmtTag> label) {
|
||||
if (stmt->getLabelInfo()) {
|
||||
dispatcher_.emit(LabeledStmtLabelsTrap{label, stmt->getLabelInfo().Name.str().str()});
|
||||
}
|
||||
}
|
||||
|
||||
void emitLabeledConditionalStmt(swift::LabeledConditionalStmt* stmt,
|
||||
TrapLabel<LabeledConditionalStmtTag> label) {
|
||||
auto condLabel = dispatcher_.fetchLabel(stmt->getCondPointer());
|
||||
dispatcher_.emit(LabeledConditionalStmtsTrap{label, condLabel});
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace codeql
|
||||
|
||||
@@ -5,6 +5,229 @@ namespace codeql {
|
||||
class TypeVisitor : public TypeVisitorBase<TypeVisitor> {
|
||||
public:
|
||||
using TypeVisitorBase<TypeVisitor>::TypeVisitorBase;
|
||||
|
||||
void visit(swift::TypeBase* type) {
|
||||
TypeVisitorBase<TypeVisitor>::visit(type);
|
||||
auto label = dispatcher_.fetchLabel(type);
|
||||
auto canonical = type->getCanonicalType().getPointer();
|
||||
auto canonicalLabel = (canonical == type) ? label : dispatcher_.fetchLabel(canonical);
|
||||
dispatcher_.emit(TypesTrap{label, type->getString(), canonicalLabel});
|
||||
}
|
||||
|
||||
void visitProtocolType(swift::ProtocolType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
dispatcher_.emit(ProtocolTypesTrap{label});
|
||||
emitAnyGenericType(type, label);
|
||||
}
|
||||
|
||||
void visitEnumType(swift::EnumType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
dispatcher_.emit(EnumTypesTrap{label});
|
||||
emitAnyGenericType(type, label);
|
||||
}
|
||||
|
||||
void visitStructType(swift::StructType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
dispatcher_.emit(StructTypesTrap{label});
|
||||
emitAnyGenericType(type, label);
|
||||
}
|
||||
|
||||
void visitClassType(swift::ClassType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
dispatcher_.emit(ClassTypesTrap{label});
|
||||
emitAnyGenericType(type, label);
|
||||
}
|
||||
|
||||
void visitFunctionType(swift::FunctionType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
dispatcher_.emit(FunctionTypesTrap{label});
|
||||
emitAnyFunctionType(type, label);
|
||||
}
|
||||
|
||||
void visitTupleType(swift::TupleType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
dispatcher_.emit(TupleTypesTrap{label});
|
||||
auto i = 0u;
|
||||
for (const auto& e : type->getElements()) {
|
||||
auto typeTag = dispatcher_.fetchLabel(e.getType());
|
||||
dispatcher_.emit(TupleTypeTypesTrap{label, i, typeTag});
|
||||
if (e.hasName()) {
|
||||
dispatcher_.emit(TupleTypeNamesTrap{label, i, e.getName().str().str()});
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
void visitBoundGenericEnumType(swift::BoundGenericEnumType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
dispatcher_.emit(BoundGenericEnumTypesTrap{label});
|
||||
emitBoundGenericType(type, label);
|
||||
}
|
||||
|
||||
void visitMetatypeType(swift::MetatypeType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
dispatcher_.emit(MetatypeTypesTrap{label});
|
||||
}
|
||||
|
||||
void visitExistentialMetatypeType(swift::ExistentialMetatypeType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
dispatcher_.emit(ExistentialMetatypeTypesTrap{label});
|
||||
}
|
||||
|
||||
void visitBoundGenericStructType(swift::BoundGenericStructType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
dispatcher_.emit(BoundGenericStructTypesTrap{label});
|
||||
emitBoundGenericType(type, label);
|
||||
}
|
||||
|
||||
void visitTypeAliasType(swift::TypeAliasType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
assert(type->getDecl() && "expect TypeAliasType to have Decl");
|
||||
dispatcher_.emit(TypeAliasTypesTrap{label, dispatcher_.fetchLabel(type->getDecl())});
|
||||
}
|
||||
|
||||
void visitBuiltinIntegerLiteralType(swift::BuiltinIntegerLiteralType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
dispatcher_.emit(BuiltinIntegerLiteralTypesTrap{label});
|
||||
}
|
||||
|
||||
void visitBuiltinFloatType(swift::BuiltinFloatType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
dispatcher_.emit(BuiltinFloatTypesTrap{label});
|
||||
}
|
||||
|
||||
void visitBuiltinIntegerType(swift::BuiltinIntegerType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
auto width = type->getWidth();
|
||||
if (width.isFixedWidth()) {
|
||||
dispatcher_.emit(BuiltinIntegerTypeWidthsTrap{label, width.getFixedWidth()});
|
||||
}
|
||||
dispatcher_.emit(BuiltinIntegerTypesTrap{label});
|
||||
}
|
||||
|
||||
void visitBoundGenericClassType(swift::BoundGenericClassType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
dispatcher_.emit(BoundGenericClassTypesTrap{label});
|
||||
emitBoundGenericType(type, label);
|
||||
}
|
||||
|
||||
void visitDependentMemberType(swift::DependentMemberType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
assert(type->getBase() && "expect TypeAliasType to have Base");
|
||||
assert(type->getAssocType() && "expect TypeAliasType to have AssocType");
|
||||
auto baseLabel = dispatcher_.fetchLabel(type->getBase());
|
||||
auto assocTypeDeclLabel = dispatcher_.fetchLabel(type->getAssocType());
|
||||
dispatcher_.emit(DependentMemberTypesTrap{label, baseLabel, assocTypeDeclLabel});
|
||||
}
|
||||
|
||||
void visitParenType(swift::ParenType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
assert(type->getUnderlyingType() && "expect ParenType to have UnderlyingType");
|
||||
auto typeLabel = dispatcher_.fetchLabel(type->getUnderlyingType());
|
||||
dispatcher_.emit(ParenTypesTrap{label, typeLabel});
|
||||
}
|
||||
|
||||
void visitUnarySyntaxSugarType(swift::UnarySyntaxSugarType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
emitUnarySyntaxSugarType(type, label);
|
||||
}
|
||||
|
||||
void visitOptionalType(swift::OptionalType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
dispatcher_.emit(OptionalTypesTrap{label});
|
||||
emitUnarySyntaxSugarType(type, label);
|
||||
}
|
||||
|
||||
void visitArraySliceType(swift::ArraySliceType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
dispatcher_.emit(ArraySliceTypesTrap{label});
|
||||
emitUnarySyntaxSugarType(type, label);
|
||||
}
|
||||
|
||||
void visitDictionaryType(swift::DictionaryType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
auto keyLabel = dispatcher_.fetchLabel(type->getKeyType());
|
||||
auto valueLabel = dispatcher_.fetchLabel(type->getValueType());
|
||||
dispatcher_.emit(DictionaryTypesTrap{label, keyLabel, valueLabel});
|
||||
}
|
||||
|
||||
void visitGenericFunctionType(swift::GenericFunctionType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
dispatcher_.emit(GenericFunctionTypesTrap{label});
|
||||
emitAnyFunctionType(type, label);
|
||||
auto i = 0u;
|
||||
for (auto p : type->getGenericParams()) {
|
||||
dispatcher_.emit(GenericFunctionTypeGenericParamsTrap{label, i++, dispatcher_.fetchLabel(p)});
|
||||
}
|
||||
}
|
||||
|
||||
void visitGenericTypeParamType(swift::GenericTypeParamType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
dispatcher_.emit(GenericTypeParamTypesTrap{label, type->getName().str().str()});
|
||||
}
|
||||
|
||||
void visitLValueType(swift::LValueType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
assert(type->getObjectType() && "expect LValueType to have ObjectType");
|
||||
dispatcher_.emit(LValueTypesTrap{label, dispatcher_.fetchLabel(type->getObjectType())});
|
||||
}
|
||||
|
||||
void visitPrimaryArchetypeType(swift::PrimaryArchetypeType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
assert(type->getInterfaceType() && "expect PrimaryArchetypeType to have InterfaceType");
|
||||
dispatcher_.emit(
|
||||
PrimaryArchetypeTypesTrap{label, dispatcher_.fetchLabel(type->getInterfaceType())});
|
||||
}
|
||||
|
||||
void visitUnboundGenericType(swift::UnboundGenericType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
dispatcher_.emit(UnboundGenericTypesTrap{label});
|
||||
emitAnyGenericType(type, label);
|
||||
}
|
||||
|
||||
void visitBoundGenericType(swift::BoundGenericType* type) {
|
||||
auto label = dispatcher_.assignNewLabel(type);
|
||||
emitBoundGenericType(type, label);
|
||||
}
|
||||
|
||||
private:
|
||||
void emitUnarySyntaxSugarType(const swift::UnarySyntaxSugarType* type,
|
||||
TrapLabel<UnarySyntaxSugarTypeTag> label) {
|
||||
assert(type->getBaseType() && "expect UnarySyntaxSugarType to have BaseType");
|
||||
dispatcher_.emit(UnarySyntaxSugarTypesTrap{label, dispatcher_.fetchLabel(type->getBaseType())});
|
||||
}
|
||||
|
||||
void emitAnyFunctionType(const swift::AnyFunctionType* type,
|
||||
TrapLabel<AnyFunctionTypeTag> label) {
|
||||
assert(type->getResult() && "expect FunctionType to have Result");
|
||||
dispatcher_.emit(AnyFunctionTypesTrap{label, dispatcher_.fetchLabel(type->getResult())});
|
||||
auto i = 0u;
|
||||
for (const auto& p : type->getParams()) {
|
||||
assert(p.getPlainType() && "expect Param to have PlainType");
|
||||
dispatcher_.emit(
|
||||
AnyFunctionTypeParamTypesTrap{label, i, dispatcher_.fetchLabel(p.getPlainType())});
|
||||
if (p.hasLabel()) {
|
||||
dispatcher_.emit(AnyFunctionTypeParamLabelsTrap{label, i, p.getLabel().str().str()});
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
void emitBoundGenericType(swift::BoundGenericType* type, TrapLabel<BoundGenericTypeTag> label) {
|
||||
auto i = 0u;
|
||||
for (const auto& t : type->getGenericArgs()) {
|
||||
dispatcher_.emit(BoundGenericTypeArgTypesTrap{label, i++, dispatcher_.fetchLabel(t)});
|
||||
}
|
||||
emitAnyGenericType(type, label);
|
||||
}
|
||||
|
||||
void emitAnyGenericType(swift::AnyGenericType* type, TrapLabel<AnyGenericTypeTag> label) {
|
||||
assert(type->getDecl() && "expect AnyGenericType to have Decl");
|
||||
dispatcher_.emit(AnyGenericTypesTrap{label, dispatcher_.fetchLabel(type->getDecl())});
|
||||
if (auto parent = type->getParent()) {
|
||||
dispatcher_.emit(AnyGenericTypeParentsTrap{label, dispatcher_.fetchLabel(parent)});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace codeql
|
||||
|
||||
@@ -28,7 +28,7 @@ class VisitorBase {
|
||||
// unknown/TBD entities. Like `swift::ASTVisitor`, this uses CRTP (the Curiously Recurring Template
|
||||
// Pattern)
|
||||
template <typename CrtpSubclass>
|
||||
class AstVisitorBase : public swift::ASTVisitor<CrtpSubclass>, detail::VisitorBase {
|
||||
class AstVisitorBase : public swift::ASTVisitor<CrtpSubclass>, protected detail::VisitorBase {
|
||||
public:
|
||||
using VisitorBase::VisitorBase;
|
||||
|
||||
@@ -52,7 +52,7 @@ class AstVisitorBase : public swift::ASTVisitor<CrtpSubclass>, detail::VisitorBa
|
||||
// unknown/TBD types. Like `swift::TypeVisitor`, this uses CRTP (the Curiously Recurring Template
|
||||
// Pattern)
|
||||
template <typename CrtpSubclass>
|
||||
class TypeVisitorBase : public swift::TypeVisitor<CrtpSubclass>, detail::VisitorBase {
|
||||
class TypeVisitorBase : public swift::TypeVisitor<CrtpSubclass>, protected detail::VisitorBase {
|
||||
public:
|
||||
using VisitorBase::VisitorBase;
|
||||
|
||||
|
||||
@@ -1,5 +1,29 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.stmt.BraceStmt
|
||||
import codeql.swift.elements.decl.GenericContext
|
||||
import codeql.swift.elements.decl.ParamDecl
|
||||
import codeql.swift.elements.decl.ValueDecl
|
||||
|
||||
class AbstractFunctionDeclBase extends @abstract_function_decl, GenericContext, ValueDecl { }
|
||||
class AbstractFunctionDeclBase extends @abstract_function_decl, GenericContext, ValueDecl {
|
||||
string getName() { abstract_function_decls(this, result) }
|
||||
|
||||
BraceStmt getBody() {
|
||||
exists(BraceStmt x |
|
||||
abstract_function_decl_bodies(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasBody() { exists(getBody()) }
|
||||
|
||||
ParamDecl getParam(int index) {
|
||||
exists(ParamDecl x |
|
||||
abstract_function_decl_params(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
ParamDecl getAParam() { result = getParam(_) }
|
||||
|
||||
int getNumberOfParams() { result = count(getAParam()) }
|
||||
}
|
||||
|
||||
@@ -3,4 +3,6 @@ import codeql.swift.elements.decl.VarDecl
|
||||
|
||||
class ConcreteVarDeclBase extends @concrete_var_decl, VarDecl {
|
||||
override string getAPrimaryQlClass() { result = "ConcreteVarDecl" }
|
||||
|
||||
int getIntroducerInt() { concrete_var_decls(this, result) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.decl.Decl
|
||||
import codeql.swift.elements.decl.EnumElementDecl
|
||||
|
||||
class EnumCaseDeclBase extends @enum_case_decl, Decl {
|
||||
override string getAPrimaryQlClass() { result = "EnumCaseDecl" }
|
||||
|
||||
EnumElementDecl getElement(int index) {
|
||||
exists(EnumElementDecl x |
|
||||
enum_case_decl_elements(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
EnumElementDecl getAnElement() { result = getElement(_) }
|
||||
|
||||
int getNumberOfElements() { result = count(getAnElement()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,20 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.decl.ParamDecl
|
||||
import codeql.swift.elements.decl.ValueDecl
|
||||
|
||||
class EnumElementDeclBase extends @enum_element_decl, ValueDecl {
|
||||
override string getAPrimaryQlClass() { result = "EnumElementDecl" }
|
||||
|
||||
string getName() { enum_element_decls(this, result) }
|
||||
|
||||
ParamDecl getParam(int index) {
|
||||
exists(ParamDecl x |
|
||||
enum_element_decl_params(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
ParamDecl getAParam() { result = getParam(_) }
|
||||
|
||||
int getNumberOfParams() { result = count(getAParam()) }
|
||||
}
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.Element
|
||||
import codeql.swift.elements.decl.GenericTypeParamDecl
|
||||
|
||||
class GenericContextBase extends @generic_context, Element { }
|
||||
class GenericContextBase extends @generic_context, Element {
|
||||
GenericTypeParamDecl getGenericTypeParam(int index) {
|
||||
exists(GenericTypeParamDecl x |
|
||||
generic_context_generic_type_params(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
GenericTypeParamDecl getAGenericTypeParam() { result = getGenericTypeParam(_) }
|
||||
|
||||
int getNumberOfGenericTypeParams() { result = count(getAGenericTypeParam()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.decl.OperatorDecl
|
||||
import codeql.swift.elements.decl.PrecedenceGroupDecl
|
||||
|
||||
class InfixOperatorDeclBase extends @infix_operator_decl, OperatorDecl {
|
||||
override string getAPrimaryQlClass() { result = "InfixOperatorDecl" }
|
||||
|
||||
PrecedenceGroupDecl getPrecedenceGroup() {
|
||||
exists(PrecedenceGroupDecl x |
|
||||
infix_operator_decl_precedence_groups(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasPrecedenceGroup() { exists(getPrecedenceGroup()) }
|
||||
}
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.decl.Decl
|
||||
import codeql.swift.elements.Element
|
||||
|
||||
class IterableDeclContextBase extends @iterable_decl_context, Element { }
|
||||
class IterableDeclContextBase extends @iterable_decl_context, Element {
|
||||
Decl getMember(int index) {
|
||||
exists(Decl x |
|
||||
iterable_decl_context_members(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Decl getAMember() { result = getMember(_) }
|
||||
|
||||
int getNumberOfMembers() { result = count(getAMember()) }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.decl.GenericTypeDecl
|
||||
import codeql.swift.elements.decl.IterableDeclContext
|
||||
import codeql.swift.elements.type.Type
|
||||
|
||||
class NominalTypeDeclBase extends @nominal_type_decl, GenericTypeDecl, IterableDeclContext { }
|
||||
class NominalTypeDeclBase extends @nominal_type_decl, GenericTypeDecl, IterableDeclContext {
|
||||
Type getType() {
|
||||
exists(Type x |
|
||||
nominal_type_decls(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.decl.Decl
|
||||
|
||||
class OperatorDeclBase extends @operator_decl, Decl { }
|
||||
class OperatorDeclBase extends @operator_decl, Decl {
|
||||
string getName() { operator_decls(this, result) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,30 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.decl.Decl
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.pattern.Pattern
|
||||
|
||||
class PatternBindingDeclBase extends @pattern_binding_decl, Decl {
|
||||
override string getAPrimaryQlClass() { result = "PatternBindingDecl" }
|
||||
|
||||
Expr getInit(int index) {
|
||||
exists(Expr x |
|
||||
pattern_binding_decl_inits(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasInit(int index) { exists(getInit(index)) }
|
||||
|
||||
Expr getAnInit() { result = getInit(_) }
|
||||
|
||||
Pattern getPattern(int index) {
|
||||
exists(Pattern x |
|
||||
pattern_binding_decl_patterns(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Pattern getAPattern() { result = getPattern(_) }
|
||||
|
||||
int getNumberOfPatterns() { result = count(getAPattern()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.stmt.BraceStmt
|
||||
import codeql.swift.elements.decl.Decl
|
||||
|
||||
class TopLevelCodeDeclBase extends @top_level_code_decl, Decl {
|
||||
override string getAPrimaryQlClass() { result = "TopLevelCodeDecl" }
|
||||
|
||||
BraceStmt getBody() {
|
||||
exists(BraceStmt x |
|
||||
top_level_code_decls(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,18 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.type.Type
|
||||
import codeql.swift.elements.decl.ValueDecl
|
||||
|
||||
class TypeDeclBase extends @type_decl, ValueDecl { }
|
||||
class TypeDeclBase extends @type_decl, ValueDecl {
|
||||
string getName() { type_decls(this, result) }
|
||||
|
||||
Type getBaseType(int index) {
|
||||
exists(Type x |
|
||||
type_decl_base_types(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Type getABaseType() { result = getBaseType(_) }
|
||||
|
||||
int getNumberOfBaseTypes() { result = count(getABaseType()) }
|
||||
}
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.decl.Decl
|
||||
import codeql.swift.elements.type.Type
|
||||
|
||||
class ValueDeclBase extends @value_decl, Decl { }
|
||||
class ValueDeclBase extends @value_decl, Decl {
|
||||
Type getInterfaceType() {
|
||||
exists(Type x |
|
||||
value_decls(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,43 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.decl.AbstractStorageDecl
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.pattern.Pattern
|
||||
import codeql.swift.elements.type.Type
|
||||
|
||||
class VarDeclBase extends @var_decl, AbstractStorageDecl { }
|
||||
class VarDeclBase extends @var_decl, AbstractStorageDecl {
|
||||
string getName() { var_decls(this, result, _) }
|
||||
|
||||
Type getType() {
|
||||
exists(Type x |
|
||||
var_decls(this, _, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Type getAttachedPropertyWrapperType() {
|
||||
exists(Type x |
|
||||
var_decl_attached_property_wrapper_types(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasAttachedPropertyWrapperType() { exists(getAttachedPropertyWrapperType()) }
|
||||
|
||||
Pattern getParentPattern() {
|
||||
exists(Pattern x |
|
||||
var_decl_parent_patterns(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasParentPattern() { exists(getParentPattern()) }
|
||||
|
||||
Expr getParentInitializer() {
|
||||
exists(Expr x |
|
||||
var_decl_parent_initializers(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasParentInitializer() { exists(getParentInitializer()) }
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,11 @@ import codeql.swift.elements.pattern.Pattern
|
||||
|
||||
class BindingPatternBase extends @binding_pattern, Pattern {
|
||||
override string getAPrimaryQlClass() { result = "BindingPattern" }
|
||||
|
||||
Pattern getSubPattern() {
|
||||
exists(Pattern x |
|
||||
binding_patterns(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,6 @@ import codeql.swift.elements.pattern.Pattern
|
||||
|
||||
class BoolPatternBase extends @bool_pattern, Pattern {
|
||||
override string getAPrimaryQlClass() { result = "BoolPattern" }
|
||||
|
||||
boolean getValue() { bool_patterns(this, result) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,23 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.decl.EnumElementDecl
|
||||
import codeql.swift.elements.pattern.Pattern
|
||||
|
||||
class EnumElementPatternBase extends @enum_element_pattern, Pattern {
|
||||
override string getAPrimaryQlClass() { result = "EnumElementPattern" }
|
||||
|
||||
EnumElementDecl getElement() {
|
||||
exists(EnumElementDecl x |
|
||||
enum_element_patterns(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Pattern getSubPattern() {
|
||||
exists(Pattern x |
|
||||
enum_element_pattern_sub_patterns(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasSubPattern() { exists(getSubPattern()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.pattern.Pattern
|
||||
|
||||
class ExprPatternBase extends @expr_pattern, Pattern {
|
||||
override string getAPrimaryQlClass() { result = "ExprPattern" }
|
||||
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
expr_patterns(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,25 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.pattern.Pattern
|
||||
import codeql.swift.elements.typerepr.TypeRepr
|
||||
|
||||
class IsPatternBase extends @is_pattern, Pattern {
|
||||
override string getAPrimaryQlClass() { result = "IsPattern" }
|
||||
|
||||
TypeRepr getCastTypeRepr() {
|
||||
exists(TypeRepr x |
|
||||
is_pattern_cast_type_reprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasCastTypeRepr() { exists(getCastTypeRepr()) }
|
||||
|
||||
Pattern getSubPattern() {
|
||||
exists(Pattern x |
|
||||
is_pattern_sub_patterns(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasSubPattern() { exists(getSubPattern()) }
|
||||
}
|
||||
|
||||
@@ -3,4 +3,6 @@ import codeql.swift.elements.pattern.Pattern
|
||||
|
||||
class NamedPatternBase extends @named_pattern, Pattern {
|
||||
override string getAPrimaryQlClass() { result = "NamedPattern" }
|
||||
|
||||
string getName() { named_patterns(this, result) }
|
||||
}
|
||||
|
||||
@@ -3,4 +3,11 @@ import codeql.swift.elements.pattern.Pattern
|
||||
|
||||
class OptionalSomePatternBase extends @optional_some_pattern, Pattern {
|
||||
override string getAPrimaryQlClass() { result = "OptionalSomePattern" }
|
||||
|
||||
Pattern getSubPattern() {
|
||||
exists(Pattern x |
|
||||
optional_some_patterns(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,11 @@ import codeql.swift.elements.pattern.Pattern
|
||||
|
||||
class ParenPatternBase extends @paren_pattern, Pattern {
|
||||
override string getAPrimaryQlClass() { result = "ParenPattern" }
|
||||
|
||||
Pattern getSubPattern() {
|
||||
exists(Pattern x |
|
||||
paren_patterns(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,15 @@ import codeql.swift.elements.pattern.Pattern
|
||||
|
||||
class TuplePatternBase extends @tuple_pattern, Pattern {
|
||||
override string getAPrimaryQlClass() { result = "TuplePattern" }
|
||||
|
||||
Pattern getElement(int index) {
|
||||
exists(Pattern x |
|
||||
tuple_pattern_elements(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Pattern getAnElement() { result = getElement(_) }
|
||||
|
||||
int getNumberOfElements() { result = count(getAnElement()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,23 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.pattern.Pattern
|
||||
import codeql.swift.elements.typerepr.TypeRepr
|
||||
|
||||
class TypedPatternBase extends @typed_pattern, Pattern {
|
||||
override string getAPrimaryQlClass() { result = "TypedPattern" }
|
||||
|
||||
Pattern getSubPattern() {
|
||||
exists(Pattern x |
|
||||
typed_patterns(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
TypeRepr getTypeRepr() {
|
||||
exists(TypeRepr x |
|
||||
typed_pattern_type_reprs(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasTypeRepr() { exists(getTypeRepr()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.AstNode
|
||||
import codeql.swift.elements.stmt.Stmt
|
||||
|
||||
class BraceStmtBase extends @brace_stmt, Stmt {
|
||||
override string getAPrimaryQlClass() { result = "BraceStmt" }
|
||||
|
||||
AstNode getElement(int index) {
|
||||
exists(AstNode x |
|
||||
brace_stmt_elements(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
AstNode getAnElement() { result = getElement(_) }
|
||||
|
||||
int getNumberOfElements() { result = count(getAnElement()) }
|
||||
}
|
||||
|
||||
@@ -3,4 +3,17 @@ import codeql.swift.elements.stmt.Stmt
|
||||
|
||||
class BreakStmtBase extends @break_stmt, Stmt {
|
||||
override string getAPrimaryQlClass() { result = "BreakStmt" }
|
||||
|
||||
string getTargetName() { break_stmt_target_names(this, result) }
|
||||
|
||||
predicate hasTargetName() { exists(getTargetName()) }
|
||||
|
||||
Stmt getTarget() {
|
||||
exists(Stmt x |
|
||||
break_stmt_targets(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasTarget() { exists(getTarget()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,24 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.AstNode
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.pattern.Pattern
|
||||
|
||||
class CaseLabelItemBase extends @case_label_item, AstNode {
|
||||
override string getAPrimaryQlClass() { result = "CaseLabelItem" }
|
||||
|
||||
Pattern getPattern() {
|
||||
exists(Pattern x |
|
||||
case_label_items(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Expr getGuard() {
|
||||
exists(Expr x |
|
||||
case_label_item_guards(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasGuard() { exists(getGuard()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,37 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.stmt.CaseLabelItem
|
||||
import codeql.swift.elements.stmt.Stmt
|
||||
import codeql.swift.elements.decl.VarDecl
|
||||
|
||||
class CaseStmtBase extends @case_stmt, Stmt {
|
||||
override string getAPrimaryQlClass() { result = "CaseStmt" }
|
||||
|
||||
Stmt getBody() {
|
||||
exists(Stmt x |
|
||||
case_stmts(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
CaseLabelItem getLabel(int index) {
|
||||
exists(CaseLabelItem x |
|
||||
case_stmt_labels(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
CaseLabelItem getALabel() { result = getLabel(_) }
|
||||
|
||||
int getNumberOfLabels() { result = count(getALabel()) }
|
||||
|
||||
VarDecl getVariable(int index) {
|
||||
exists(VarDecl x |
|
||||
case_stmt_variables(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
VarDecl getAVariable() { result = getVariable(_) }
|
||||
|
||||
int getNumberOfVariables() { result = count(getAVariable()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,35 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.Locatable
|
||||
import codeql.swift.elements.pattern.Pattern
|
||||
|
||||
class ConditionElementBase extends @condition_element, Locatable {
|
||||
override string getAPrimaryQlClass() { result = "ConditionElement" }
|
||||
|
||||
Expr getBoolean() {
|
||||
exists(Expr x |
|
||||
condition_element_booleans(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasBoolean() { exists(getBoolean()) }
|
||||
|
||||
Pattern getPattern() {
|
||||
exists(Pattern x |
|
||||
condition_element_patterns(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasPattern() { exists(getPattern()) }
|
||||
|
||||
Expr getInitializer() {
|
||||
exists(Expr x |
|
||||
condition_element_initializers(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasInitializer() { exists(getInitializer()) }
|
||||
}
|
||||
|
||||
@@ -3,4 +3,17 @@ import codeql.swift.elements.stmt.Stmt
|
||||
|
||||
class ContinueStmtBase extends @continue_stmt, Stmt {
|
||||
override string getAPrimaryQlClass() { result = "ContinueStmt" }
|
||||
|
||||
string getTargetName() { continue_stmt_target_names(this, result) }
|
||||
|
||||
predicate hasTargetName() { exists(getTargetName()) }
|
||||
|
||||
Stmt getTarget() {
|
||||
exists(Stmt x |
|
||||
continue_stmt_targets(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasTarget() { exists(getTarget()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.stmt.BraceStmt
|
||||
import codeql.swift.elements.stmt.Stmt
|
||||
|
||||
class DeferStmtBase extends @defer_stmt, Stmt {
|
||||
override string getAPrimaryQlClass() { result = "DeferStmt" }
|
||||
|
||||
BraceStmt getBody() {
|
||||
exists(BraceStmt x |
|
||||
defer_stmts(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,26 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.stmt.CaseStmt
|
||||
import codeql.swift.elements.stmt.LabeledStmt
|
||||
import codeql.swift.elements.stmt.Stmt
|
||||
|
||||
class DoCatchStmtBase extends @do_catch_stmt, LabeledStmt {
|
||||
override string getAPrimaryQlClass() { result = "DoCatchStmt" }
|
||||
|
||||
Stmt getBody() {
|
||||
exists(Stmt x |
|
||||
do_catch_stmts(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
CaseStmt getCatch(int index) {
|
||||
exists(CaseStmt x |
|
||||
do_catch_stmt_catches(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
CaseStmt getACatch() { result = getCatch(_) }
|
||||
|
||||
int getNumberOfCatches() { result = count(getACatch()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.stmt.BraceStmt
|
||||
import codeql.swift.elements.stmt.LabeledStmt
|
||||
|
||||
class DoStmtBase extends @do_stmt, LabeledStmt {
|
||||
override string getAPrimaryQlClass() { result = "DoStmt" }
|
||||
|
||||
BraceStmt getBody() {
|
||||
exists(BraceStmt x |
|
||||
do_stmts(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,21 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.stmt.CaseStmt
|
||||
import codeql.swift.elements.stmt.Stmt
|
||||
|
||||
class FallthroughStmtBase extends @fallthrough_stmt, Stmt {
|
||||
override string getAPrimaryQlClass() { result = "FallthroughStmt" }
|
||||
|
||||
CaseStmt getFallthroughSource() {
|
||||
exists(CaseStmt x |
|
||||
fallthrough_stmts(this, x, _) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
CaseStmt getFallthroughDest() {
|
||||
exists(CaseStmt x |
|
||||
fallthrough_stmts(this, _, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,39 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.stmt.BraceStmt
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.stmt.LabeledStmt
|
||||
import codeql.swift.elements.pattern.Pattern
|
||||
|
||||
class ForEachStmtBase extends @for_each_stmt, LabeledStmt {
|
||||
override string getAPrimaryQlClass() { result = "ForEachStmt" }
|
||||
|
||||
Pattern getPattern() {
|
||||
exists(Pattern x |
|
||||
for_each_stmts(this, x, _, _) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Expr getSequence() {
|
||||
exists(Expr x |
|
||||
for_each_stmts(this, _, x, _) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Expr getWhere() {
|
||||
exists(Expr x |
|
||||
for_each_stmt_wheres(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasWhere() { exists(getWhere()) }
|
||||
|
||||
BraceStmt getBody() {
|
||||
exists(BraceStmt x |
|
||||
for_each_stmts(this, _, _, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.stmt.BraceStmt
|
||||
import codeql.swift.elements.stmt.LabeledConditionalStmt
|
||||
|
||||
class GuardStmtBase extends @guard_stmt, LabeledConditionalStmt {
|
||||
override string getAPrimaryQlClass() { result = "GuardStmt" }
|
||||
|
||||
BraceStmt getBody() {
|
||||
exists(BraceStmt x |
|
||||
guard_stmts(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,23 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.stmt.LabeledConditionalStmt
|
||||
import codeql.swift.elements.stmt.Stmt
|
||||
|
||||
class IfStmtBase extends @if_stmt, LabeledConditionalStmt {
|
||||
override string getAPrimaryQlClass() { result = "IfStmt" }
|
||||
|
||||
Stmt getThen() {
|
||||
exists(Stmt x |
|
||||
if_stmts(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Stmt getElse() {
|
||||
exists(Stmt x |
|
||||
if_stmt_elses(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasElse() { exists(getElse()) }
|
||||
}
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.stmt.LabeledStmt
|
||||
import codeql.swift.elements.stmt.StmtCondition
|
||||
|
||||
class LabeledConditionalStmtBase extends @labeled_conditional_stmt, LabeledStmt { }
|
||||
class LabeledConditionalStmtBase extends @labeled_conditional_stmt, LabeledStmt {
|
||||
StmtCondition getCondition() {
|
||||
exists(StmtCondition x |
|
||||
labeled_conditional_stmts(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.stmt.Stmt
|
||||
|
||||
class LabeledStmtBase extends @labeled_stmt, Stmt { }
|
||||
class LabeledStmtBase extends @labeled_stmt, Stmt {
|
||||
string getLabel() { labeled_stmt_labels(this, result) }
|
||||
|
||||
predicate hasLabel() { exists(getLabel()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,22 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.stmt.LabeledStmt
|
||||
import codeql.swift.elements.stmt.Stmt
|
||||
|
||||
class RepeatWhileStmtBase extends @repeat_while_stmt, LabeledStmt {
|
||||
override string getAPrimaryQlClass() { result = "RepeatWhileStmt" }
|
||||
|
||||
Expr getCondition() {
|
||||
exists(Expr x |
|
||||
repeat_while_stmts(this, x, _) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
Stmt getBody() {
|
||||
exists(Stmt x |
|
||||
repeat_while_stmts(this, _, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.stmt.Stmt
|
||||
|
||||
class ReturnStmtBase extends @return_stmt, Stmt {
|
||||
override string getAPrimaryQlClass() { result = "ReturnStmt" }
|
||||
|
||||
Expr getResult() {
|
||||
exists(Expr x |
|
||||
return_stmt_results(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasResult() { exists(getResult()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.AstNode
|
||||
import codeql.swift.elements.stmt.ConditionElement
|
||||
|
||||
class StmtConditionBase extends @stmt_condition, AstNode {
|
||||
override string getAPrimaryQlClass() { result = "StmtCondition" }
|
||||
|
||||
ConditionElement getElement(int index) {
|
||||
exists(ConditionElement x |
|
||||
stmt_condition_elements(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
ConditionElement getAnElement() { result = getElement(_) }
|
||||
|
||||
int getNumberOfElements() { result = count(getAnElement()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,26 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.stmt.CaseStmt
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.stmt.LabeledStmt
|
||||
|
||||
class SwitchStmtBase extends @switch_stmt, LabeledStmt {
|
||||
override string getAPrimaryQlClass() { result = "SwitchStmt" }
|
||||
|
||||
Expr getExpr() {
|
||||
exists(Expr x |
|
||||
switch_stmts(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
CaseStmt getCase(int index) {
|
||||
exists(CaseStmt x |
|
||||
switch_stmt_cases(this, index, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
CaseStmt getACase() { result = getCase(_) }
|
||||
|
||||
int getNumberOfCases() { result = count(getACase()) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
// generated by codegen/codegen.py
|
||||
import codeql.swift.elements.expr.Expr
|
||||
import codeql.swift.elements.stmt.Stmt
|
||||
|
||||
class ThrowStmtBase extends @throw_stmt, Stmt {
|
||||
override string getAPrimaryQlClass() { result = "ThrowStmt" }
|
||||
|
||||
Expr getSubExpr() {
|
||||
exists(Expr x |
|
||||
throw_stmts(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user