Skip to content

Commit a494515

Browse files
Added ARGUMENT_LABEL property to expressions (#1836)
1 parent 34fa2db commit a494515

139 files changed

Lines changed: 3517 additions & 2543 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/GraphSchema.scala

Lines changed: 1063 additions & 987 deletions
Large diffs are not rendered by default.

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/Properties.scala

Lines changed: 60 additions & 50 deletions
Large diffs are not rendered by default.

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/PropertyNames.scala

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,18 @@ object PropertyNames {
1818
*/
1919
val ArgumentIndex: String = "ARGUMENT_INDEX"
2020

21+
/** This field is used to keep track of the argument label for languages that support them, such as Swift. It is used
22+
* in addition to `ARGUMENT_INDEX` and can be used to reconstruct the original call syntax more faithfully. For
23+
* example, in Swift, a method call may look like `foo(arg1: 42, arg2: "hello")` where `arg1` and `arg2` are argument
24+
* labels. In this case, the `ARGUMENT_LABEL` field for the first argument would be set to `arg1` and for the second
25+
* argument it would be set to `arg2`. Contrary to the `ARGUMENT_NAME` the label should not be expected to match the
26+
* name of any parameter, and is not needed for dataflow purposes at all.
27+
*/
28+
val ArgumentLabel: String = "ARGUMENT_LABEL"
29+
2130
/** For calls involving named parameters, the `ARGUMENT_NAME` field holds the name of the parameter initialized by the
22-
* expression. For all other calls, this field is unset.
31+
* expression. For all other calls, this field is unset. Note that the `ARGUMENT_NAME` should be an exact match of
32+
* the NAME of a METHOD_PARAMETER_{IN,OUT}. It overrides ARGUMENT_INDEX for dataflow purposes.
2333
*/
2434
val ArgumentName: String = "ARGUMENT_NAME"
2535

@@ -293,6 +303,7 @@ object PropertyNames {
293303
Seq(
294304
AliasTypeFullName,
295305
ArgumentIndex,
306+
ArgumentLabel,
296307
ArgumentName,
297308
AstParentFullName,
298309
AstParentType,

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/accessors/Accessors.scala

Lines changed: 60 additions & 49 deletions
Large diffs are not rendered by default.

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/Annotation.scala

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ trait AnnotationBase extends AbstractNode with ExpressionBase with StaticType[An
1515
import io.shiftleft.codepropertygraph.generated.accessors.languagebootstrap.*
1616
val res = new java.util.HashMap[String, Any]()
1717
if ((-1: Int) != this.argumentIndex) res.put("ARGUMENT_INDEX", this.argumentIndex)
18+
this.argumentLabel.foreach { p => res.put("ARGUMENT_LABEL", p) }
1819
this.argumentName.foreach { p => res.put("ARGUMENT_NAME", p) }
1920
if (("<empty>": String) != this.code) res.put("CODE", this.code)
2021
this.columnNumber.foreach { p => res.put("COLUMN_NUMBER", p) }
@@ -41,9 +42,18 @@ object Annotation {
4142
* this case, the last argument index determines the return expression of a BLOCK expression. If the `PARAMETER_NAME`
4243
* field is set, then the `ARGUMENT_INDEX` field is ignored. It is suggested to set it to -1.
4344
*
45+
* ▸ ArgumentLabel (String); Cardinality `ZeroOrOne` (optional); This field is used to keep track of the argument label
46+
* for languages that support them, such as Swift. It is used in addition to `ARGUMENT_INDEX` and can be used to
47+
* reconstruct the original call syntax more faithfully. For example, in Swift, a method call may look like
48+
* `foo(arg1: 42, arg2: "hello")` where `arg1` and `arg2` are argument labels. In this case, the `ARGUMENT_LABEL` field
49+
* for the first argument would be set to `arg1` and for the second argument it would be set to `arg2`. Contrary to the
50+
* `ARGUMENT_NAME` the label should not be expected to match the name of any parameter, and is not needed for dataflow
51+
* purposes at all.
52+
*
4453
* ▸ ArgumentName (String); Cardinality `ZeroOrOne` (optional); For calls involving named parameters, the
4554
* `ARGUMENT_NAME` field holds the name of the parameter initialized by the expression. For all other calls, this field
46-
* is unset.
55+
* is unset. Note that the `ARGUMENT_NAME` should be an exact match of the NAME of a METHOD_PARAMETER_{IN,OUT}. It
56+
* overrides ARGUMENT_INDEX for dataflow purposes.
4757
*
4858
* ▸ Code (String); Cardinality `one` (mandatory with default value `<empty>`); This field holds the code snippet that
4959
* the node represents.
@@ -82,36 +92,38 @@ class Annotation(graph_4762: flatgraph.Graph, seq_4762: Int)
8292

8393
override def productElementName(n: Int): String =
8494
n match {
85-
case 0 => "argumentIndex"
86-
case 1 => "argumentName"
87-
case 2 => "code"
88-
case 3 => "columnNumber"
89-
case 4 => "fullName"
90-
case 5 => "lineNumber"
91-
case 6 => "name"
92-
case 7 => "offset"
93-
case 8 => "offsetEnd"
94-
case 9 => "order"
95-
case _ => ""
95+
case 0 => "argumentIndex"
96+
case 1 => "argumentLabel"
97+
case 2 => "argumentName"
98+
case 3 => "code"
99+
case 4 => "columnNumber"
100+
case 5 => "fullName"
101+
case 6 => "lineNumber"
102+
case 7 => "name"
103+
case 8 => "offset"
104+
case 9 => "offsetEnd"
105+
case 10 => "order"
106+
case _ => ""
96107
}
97108

98109
override def productElement(n: Int): Any =
99110
n match {
100-
case 0 => this.argumentIndex
101-
case 1 => this.argumentName
102-
case 2 => this.code
103-
case 3 => this.columnNumber
104-
case 4 => this.fullName
105-
case 5 => this.lineNumber
106-
case 6 => this.name
107-
case 7 => this.offset
108-
case 8 => this.offsetEnd
109-
case 9 => this.order
110-
case _ => null
111+
case 0 => this.argumentIndex
112+
case 1 => this.argumentLabel
113+
case 2 => this.argumentName
114+
case 3 => this.code
115+
case 4 => this.columnNumber
116+
case 5 => this.fullName
117+
case 6 => this.lineNumber
118+
case 7 => this.name
119+
case 8 => this.offset
120+
case 9 => this.offsetEnd
121+
case 10 => this.order
122+
case _ => null
111123
}
112124

113125
override def productPrefix = "Annotation"
114-
override def productArity = 10
126+
override def productArity = 11
115127

116128
override def canEqual(that: Any): Boolean = that != null && that.isInstanceOf[Annotation]
117129
}

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/AnnotationLiteral.scala

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ trait AnnotationLiteralBase extends AbstractNode with ExpressionBase with Static
1515
import io.shiftleft.codepropertygraph.generated.accessors.languagebootstrap.*
1616
val res = new java.util.HashMap[String, Any]()
1717
if ((-1: Int) != this.argumentIndex) res.put("ARGUMENT_INDEX", this.argumentIndex)
18+
this.argumentLabel.foreach { p => res.put("ARGUMENT_LABEL", p) }
1819
this.argumentName.foreach { p => res.put("ARGUMENT_NAME", p) }
1920
if (("<empty>": String) != this.code) res.put("CODE", this.code)
2021
this.columnNumber.foreach { p => res.put("COLUMN_NUMBER", p) }
@@ -40,9 +41,18 @@ object AnnotationLiteral {
4041
* this case, the last argument index determines the return expression of a BLOCK expression. If the `PARAMETER_NAME`
4142
* field is set, then the `ARGUMENT_INDEX` field is ignored. It is suggested to set it to -1.
4243
*
44+
* ▸ ArgumentLabel (String); Cardinality `ZeroOrOne` (optional); This field is used to keep track of the argument label
45+
* for languages that support them, such as Swift. It is used in addition to `ARGUMENT_INDEX` and can be used to
46+
* reconstruct the original call syntax more faithfully. For example, in Swift, a method call may look like
47+
* `foo(arg1: 42, arg2: "hello")` where `arg1` and `arg2` are argument labels. In this case, the `ARGUMENT_LABEL` field
48+
* for the first argument would be set to `arg1` and for the second argument it would be set to `arg2`. Contrary to the
49+
* `ARGUMENT_NAME` the label should not be expected to match the name of any parameter, and is not needed for dataflow
50+
* purposes at all.
51+
*
4352
* ▸ ArgumentName (String); Cardinality `ZeroOrOne` (optional); For calls involving named parameters, the
4453
* `ARGUMENT_NAME` field holds the name of the parameter initialized by the expression. For all other calls, this field
45-
* is unset.
54+
* is unset. Note that the `ARGUMENT_NAME` should be an exact match of the NAME of a METHOD_PARAMETER_{IN,OUT}. It
55+
* overrides ARGUMENT_INDEX for dataflow purposes.
4656
*
4757
* ▸ Code (String); Cardinality `one` (mandatory with default value `<empty>`); This field holds the code snippet that
4858
* the node represents.
@@ -78,33 +88,35 @@ class AnnotationLiteral(graph_4762: flatgraph.Graph, seq_4762: Int)
7888
override def productElementName(n: Int): String =
7989
n match {
8090
case 0 => "argumentIndex"
81-
case 1 => "argumentName"
82-
case 2 => "code"
83-
case 3 => "columnNumber"
84-
case 4 => "lineNumber"
85-
case 5 => "name"
86-
case 6 => "offset"
87-
case 7 => "offsetEnd"
88-
case 8 => "order"
91+
case 1 => "argumentLabel"
92+
case 2 => "argumentName"
93+
case 3 => "code"
94+
case 4 => "columnNumber"
95+
case 5 => "lineNumber"
96+
case 6 => "name"
97+
case 7 => "offset"
98+
case 8 => "offsetEnd"
99+
case 9 => "order"
89100
case _ => ""
90101
}
91102

92103
override def productElement(n: Int): Any =
93104
n match {
94105
case 0 => this.argumentIndex
95-
case 1 => this.argumentName
96-
case 2 => this.code
97-
case 3 => this.columnNumber
98-
case 4 => this.lineNumber
99-
case 5 => this.name
100-
case 6 => this.offset
101-
case 7 => this.offsetEnd
102-
case 8 => this.order
106+
case 1 => this.argumentLabel
107+
case 2 => this.argumentName
108+
case 3 => this.code
109+
case 4 => this.columnNumber
110+
case 5 => this.lineNumber
111+
case 6 => this.name
112+
case 7 => this.offset
113+
case 8 => this.offsetEnd
114+
case 9 => this.order
103115
case _ => null
104116
}
105117

106118
override def productPrefix = "AnnotationLiteral"
107-
override def productArity = 9
119+
override def productArity = 10
108120

109121
override def canEqual(that: Any): Boolean = that != null && that.isInstanceOf[AnnotationLiteral]
110122
}

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/ArrayInitializer.scala

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ trait ArrayInitializerBase extends AbstractNode with ExpressionBase with StaticT
1515
import io.shiftleft.codepropertygraph.generated.accessors.languagebootstrap.*
1616
val res = new java.util.HashMap[String, Any]()
1717
if ((-1: Int) != this.argumentIndex) res.put("ARGUMENT_INDEX", this.argumentIndex)
18+
this.argumentLabel.foreach { p => res.put("ARGUMENT_LABEL", p) }
1819
this.argumentName.foreach { p => res.put("ARGUMENT_NAME", p) }
1920
if (("<empty>": String) != this.code) res.put("CODE", this.code)
2021
this.columnNumber.foreach { p => res.put("COLUMN_NUMBER", p) }
@@ -39,9 +40,18 @@ object ArrayInitializer {
3940
* this case, the last argument index determines the return expression of a BLOCK expression. If the `PARAMETER_NAME`
4041
* field is set, then the `ARGUMENT_INDEX` field is ignored. It is suggested to set it to -1.
4142
*
43+
* ▸ ArgumentLabel (String); Cardinality `ZeroOrOne` (optional); This field is used to keep track of the argument label
44+
* for languages that support them, such as Swift. It is used in addition to `ARGUMENT_INDEX` and can be used to
45+
* reconstruct the original call syntax more faithfully. For example, in Swift, a method call may look like
46+
* `foo(arg1: 42, arg2: "hello")` where `arg1` and `arg2` are argument labels. In this case, the `ARGUMENT_LABEL` field
47+
* for the first argument would be set to `arg1` and for the second argument it would be set to `arg2`. Contrary to the
48+
* `ARGUMENT_NAME` the label should not be expected to match the name of any parameter, and is not needed for dataflow
49+
* purposes at all.
50+
*
4251
* ▸ ArgumentName (String); Cardinality `ZeroOrOne` (optional); For calls involving named parameters, the
4352
* `ARGUMENT_NAME` field holds the name of the parameter initialized by the expression. For all other calls, this field
44-
* is unset.
53+
* is unset. Note that the `ARGUMENT_NAME` should be an exact match of the NAME of a METHOD_PARAMETER_{IN,OUT}. It
54+
* overrides ARGUMENT_INDEX for dataflow purposes.
4555
*
4656
* ▸ Code (String); Cardinality `one` (mandatory with default value `<empty>`); This field holds the code snippet that
4757
* the node represents.
@@ -74,31 +84,33 @@ class ArrayInitializer(graph_4762: flatgraph.Graph, seq_4762: Int)
7484
override def productElementName(n: Int): String =
7585
n match {
7686
case 0 => "argumentIndex"
77-
case 1 => "argumentName"
78-
case 2 => "code"
79-
case 3 => "columnNumber"
80-
case 4 => "lineNumber"
81-
case 5 => "offset"
82-
case 6 => "offsetEnd"
83-
case 7 => "order"
87+
case 1 => "argumentLabel"
88+
case 2 => "argumentName"
89+
case 3 => "code"
90+
case 4 => "columnNumber"
91+
case 5 => "lineNumber"
92+
case 6 => "offset"
93+
case 7 => "offsetEnd"
94+
case 8 => "order"
8495
case _ => ""
8596
}
8697

8798
override def productElement(n: Int): Any =
8899
n match {
89100
case 0 => this.argumentIndex
90-
case 1 => this.argumentName
91-
case 2 => this.code
92-
case 3 => this.columnNumber
93-
case 4 => this.lineNumber
94-
case 5 => this.offset
95-
case 6 => this.offsetEnd
96-
case 7 => this.order
101+
case 1 => this.argumentLabel
102+
case 2 => this.argumentName
103+
case 3 => this.code
104+
case 4 => this.columnNumber
105+
case 5 => this.lineNumber
106+
case 6 => this.offset
107+
case 7 => this.offsetEnd
108+
case 8 => this.order
97109
case _ => null
98110
}
99111

100112
override def productPrefix = "ArrayInitializer"
101-
override def productArity = 8
113+
override def productArity = 9
102114

103115
override def canEqual(that: Any): Boolean = that != null && that.isInstanceOf[ArrayInitializer]
104116
}

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/BaseTypes.scala

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,15 @@ trait DeclarationNew extends NewNode with DeclarationBase with StaticType[Declar
8585
def name(value: String): this.type
8686
}
8787

88-
trait ExpressionEMT extends AnyRef with CfgNodeEMT with HasArgumentIndexEMT with HasArgumentNameEMT
88+
trait ExpressionEMT
89+
extends AnyRef
90+
with CfgNodeEMT
91+
with HasArgumentIndexEMT
92+
with HasArgumentLabelEMT
93+
with HasArgumentNameEMT
8994

9095
trait ExpressionBase extends AbstractNode with CfgNodeBase with StaticType[ExpressionEMT]
91-
// new properties: ARGUMENT_INDEX, ARGUMENT_NAME
96+
// new properties: ARGUMENT_INDEX, ARGUMENT_LABEL, ARGUMENT_NAME
9297
// inherited properties: CODE, COLUMN_NUMBER, LINE_NUMBER, OFFSET, OFFSET_END, ORDER
9398
// inherited interfaces: AST_NODE
9499
// implementing nodes: ANNOTATION, ANNOTATION_LITERAL, ARRAY_INITIALIZER, BLOCK, CALL, CONTROL_STRUCTURE, FIELD_IDENTIFIER, IDENTIFIER, LITERAL, METHOD_REF, RETURN, TEMPLATE_DOM, TYPE_REF, UNKNOWN
@@ -98,6 +103,10 @@ trait ExpressionNew extends NewNode with ExpressionBase with AstNodeNew with Cfg
98103
def argumentIndex: Int
99104
def argumentIndex_=(value: Int): Unit
100105
def argumentIndex(value: Int): this.type
106+
def argumentLabel: Option[String]
107+
def argumentLabel_=(value: Option[String]): Unit
108+
def argumentLabel(value: Option[String]): this.type
109+
def argumentLabel(value: String): this.type
101110
def argumentName: Option[String]
102111
def argumentName_=(value: Option[String]): Unit
103112
def argumentName(value: Option[String]): this.type
@@ -114,6 +123,11 @@ trait HasAliasTypeFullNameEMT
114123
*/
115124
trait HasArgumentIndexEMT
116125

126+
/** Node types with this marker trait are guaranteed to have the ARGUMENT_LABEL property. EMT stands for: "erased marker
127+
* trait", it exists only at compile time in order to improve type safety.
128+
*/
129+
trait HasArgumentLabelEMT
130+
117131
/** Node types with this marker trait are guaranteed to have the ARGUMENT_NAME property. EMT stands for: "erased marker
118132
* trait", it exists only at compile time in order to improve type safety.
119133
*/

0 commit comments

Comments
 (0)