mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Merge branch 'main' into redsun82/swift-regex
This commit is contained in:
@@ -77,6 +77,7 @@ class Type(Element):
|
||||
@group("decl")
|
||||
class Decl(AstNode):
|
||||
module: "ModuleDecl"
|
||||
members: list["Decl"] | child
|
||||
|
||||
@group("expr")
|
||||
class Expr(AstNode):
|
||||
@@ -95,15 +96,12 @@ class Stmt(AstNode):
|
||||
class GenericContext(Element):
|
||||
generic_type_params: list["GenericTypeParamDecl"] | child
|
||||
|
||||
@group("decl")
|
||||
class IterableDeclContext(Element):
|
||||
members: list[Decl] | child
|
||||
|
||||
class EnumCaseDecl(Decl):
|
||||
elements: list["EnumElementDecl"]
|
||||
|
||||
class ExtensionDecl(GenericContext, IterableDeclContext, Decl):
|
||||
class ExtensionDecl(GenericContext, Decl):
|
||||
extended_type_decl: "NominalTypeDecl"
|
||||
protocols: list["ProtocolDecl"]
|
||||
|
||||
class IfConfigDecl(Decl):
|
||||
active_elements: list[AstNode]
|
||||
@@ -127,7 +125,7 @@ class PatternBindingDecl(Decl):
|
||||
|
||||
class PoundDiagnosticDecl(Decl):
|
||||
""" A diagnostic directive, which is either `#error` or `#warning`."""
|
||||
kind: int | doc("""This is 1 for `#error` and 2 for `#warning`""")
|
||||
kind: int | desc("""This is 1 for `#error` and 2 for `#warning`.""")
|
||||
message: "StringLiteralExpr" | child
|
||||
|
||||
class PrecedenceGroupDecl(Decl):
|
||||
@@ -143,6 +141,24 @@ class AbstractStorageDecl(ValueDecl):
|
||||
accessor_decls: list["AccessorDecl"] | child
|
||||
|
||||
class VarDecl(AbstractStorageDecl):
|
||||
"""
|
||||
A declaration of a variable such as
|
||||
* a local variable in a function:
|
||||
```
|
||||
func foo() {
|
||||
var x = 42 // <-
|
||||
let y = "hello" // <-
|
||||
...
|
||||
}
|
||||
```
|
||||
* a member of a `struct` or `class`:
|
||||
```
|
||||
struct S {
|
||||
var size : Int // <-
|
||||
}
|
||||
```
|
||||
* ...
|
||||
"""
|
||||
name: string
|
||||
type: Type
|
||||
attached_property_wrapper_type: optional[Type]
|
||||
@@ -150,19 +166,51 @@ class VarDecl(AbstractStorageDecl):
|
||||
parent_initializer: optional[Expr]
|
||||
property_wrapper_backing_var_binding: optional[PatternBindingDecl] | child | desc("""
|
||||
This is the synthesized binding introducing the property wrapper backing variable for this
|
||||
variable, if any.
|
||||
variable, if any. See `getPropertyWrapperBackingVar`.
|
||||
""")
|
||||
property_wrapper_backing_var: optional["VarDecl"] | child | desc("""
|
||||
This is the synthesized variable holding the property wrapper for this variable, if any.
|
||||
This is the compiler synthesized variable holding the property wrapper for this variable, if any.
|
||||
|
||||
For a property wrapper like
|
||||
```
|
||||
@propertyWrapper struct MyWrapper { ... }
|
||||
|
||||
struct S {
|
||||
@MyWrapper var x : Int = 42
|
||||
}
|
||||
```
|
||||
the compiler synthesizes a variable in `S` along the lines of
|
||||
```
|
||||
var _x = MyWrapper(wrappedValue: 42)
|
||||
```
|
||||
This predicate returns such variable declaration.
|
||||
""")
|
||||
property_wrapper_projection_var_binding: optional[PatternBindingDecl] | child | desc("""
|
||||
This is the synthesized binding introducing the property wrapper projection variable for this
|
||||
variable, if any.
|
||||
variable, if any. See `getPropertyWrapperProjectionVar`.
|
||||
""")
|
||||
property_wrapper_projection_var: optional["VarDecl"] | child | desc("""
|
||||
If this variable has a property wrapper with a projected value, this is the corresponding
|
||||
synthesized variable holding that projected value, accessible with this variable's name
|
||||
prefixed with `$`.
|
||||
|
||||
For a property wrapper like
|
||||
```
|
||||
@propertyWrapper struct MyWrapper {
|
||||
var projectedValue : Bool
|
||||
...
|
||||
}
|
||||
|
||||
struct S {
|
||||
@MyWrapper var x : Int = 42
|
||||
}
|
||||
```
|
||||
```
|
||||
the compiler synthesizes a variable in `S` along the lines of
|
||||
```
|
||||
var $x : Bool { ... }
|
||||
```
|
||||
This predicate returns such variable declaration.
|
||||
""")
|
||||
|
||||
class ParamDecl(VarDecl):
|
||||
@@ -177,12 +225,14 @@ class ParamDecl(VarDecl):
|
||||
""")
|
||||
|
||||
class Callable(Element):
|
||||
name: optional[string] | doc("name of this callable")
|
||||
self_param: optional[ParamDecl] | child
|
||||
params: list[ParamDecl] | child
|
||||
body: optional["BraceStmt"] | child | desc("The body is absent within protocol declarations.")
|
||||
captures: list["CapturedDecl"] | child
|
||||
|
||||
class AbstractFunctionDecl(GenericContext, ValueDecl, Callable):
|
||||
name: string | doc("name of this function")
|
||||
pass
|
||||
|
||||
class EnumElementDecl(ValueDecl):
|
||||
name: string
|
||||
@@ -251,7 +301,7 @@ class ConcreteVarDecl(VarDecl):
|
||||
class GenericTypeParamDecl(AbstractTypeParamDecl):
|
||||
pass
|
||||
|
||||
class NominalTypeDecl(GenericTypeDecl, IterableDeclContext):
|
||||
class NominalTypeDecl(GenericTypeDecl):
|
||||
type: Type
|
||||
|
||||
class OpaqueTypeDecl(GenericTypeDecl):
|
||||
@@ -313,6 +363,11 @@ class AssignExpr(Expr):
|
||||
class BindOptionalExpr(Expr):
|
||||
sub_expr: Expr | child
|
||||
|
||||
class CapturedDecl(Decl):
|
||||
decl: ValueDecl | doc("the declaration captured by the parent closure")
|
||||
is_direct: predicate
|
||||
is_escaping: predicate
|
||||
|
||||
class CaptureListExpr(Expr):
|
||||
binding_decls: list[PatternBindingDecl] | child
|
||||
closure_body: "ClosureExpr" | child
|
||||
@@ -639,7 +694,12 @@ class RegexLiteralExpr(LiteralExpr):
|
||||
version: int
|
||||
|
||||
|
||||
@ql.internal
|
||||
class SelfApplyExpr(ApplyExpr):
|
||||
"""
|
||||
An internal raw instance of method lookups like `x.foo` in `x.foo()`.
|
||||
This is completely replaced by the synthesized type `MethodLookupExpr`.
|
||||
"""
|
||||
base: Expr
|
||||
|
||||
class StringToPointerExpr(ImplicitConversionExpr):
|
||||
@@ -676,9 +736,9 @@ class ConstructorRefCallExpr(SelfApplyExpr):
|
||||
class DotSyntaxCallExpr(SelfApplyExpr):
|
||||
pass
|
||||
|
||||
@synth.from_class(DotSyntaxCallExpr)
|
||||
class MethodRefExpr(LookupExpr):
|
||||
pass
|
||||
@synth.from_class(SelfApplyExpr)
|
||||
class MethodLookupExpr(LookupExpr):
|
||||
method_ref: Expr | child | doc("the underlying method declaration reference expression")
|
||||
|
||||
class DynamicMemberRefExpr(DynamicLookupExpr):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user