From 354dee6d38884e00fdfaf5fd3b493140d9156001 Mon Sep 17 00:00:00 2001 From: Leafkiller Date: Mon, 16 Nov 2026 17:55:43 -0800 Subject: [PATCH] Add the BY_COPY evaluation strategy A parameter passed by value whose copy shares nothing with the argument, so the callee cannot change the argument. BY_VALUE does not say this: frontends set it on parameters that receive an object, slice or map the callee can change. --- .../generated/EvaluationStrategies.java | 4 ++++ .../codepropertygraph/generated/Properties.scala | 3 ++- .../codepropertygraph/generated/PropertyNames.scala | 3 ++- .../generated/nodes/ClosureBinding.scala | 4 +++- .../generated/nodes/MethodParameterIn.scala | 4 +++- .../generated/nodes/MethodParameterOut.scala | 4 +++- .../generated/nodes/MethodReturn.scala | 4 +++- .../codepropertygraph/schema/CallGraph.scala | 13 +++++++++++-- .../codepropertygraph/schema/ProtoIds.scala | 1 + 9 files changed, 32 insertions(+), 8 deletions(-) diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/EvaluationStrategies.java b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/EvaluationStrategies.java index 34f39d1c9..6c70341e2 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/EvaluationStrategies.java +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/EvaluationStrategies.java @@ -14,10 +14,14 @@ public class EvaluationStrategies { /** A parameter or return of a function passed by value which means a flat copy is used */ public static final String BY_VALUE = "BY_VALUE"; +/** A parameter of a function passed by value whose copy shares nothing with the argument: it holds no pointer or reference, so the callee cannot change the argument */ +public static final String BY_COPY = "BY_COPY"; + public static Set ALL = new HashSet() {{ add(BY_REFERENCE); add(BY_SHARING); add(BY_VALUE); +add(BY_COPY); }}; } \ No newline at end of file diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/Properties.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/Properties.scala index 6a4fe5134..25167b26a 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/Properties.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/Properties.scala @@ -97,7 +97,8 @@ object Properties { * strategy, which is one of the following: 1) `BY_REFERENCE` indicates that the parameter is passed by reference, 2) * `BY_VALUE` indicates that it is passed by value, that is, a copy is made, 3) `BY_SHARING` the parameter is a * pointer/reference and it is shared with the caller/callee. While a copy of the pointer is made, a copy of the - * object that it points to is not made. + * object that it points to is not made, 4) `BY_COPY` indicates that it is passed by value and the copy shares + * nothing with the argument, so the callee cannot change the argument. */ val EvaluationStrategy = flatgraph.SinglePropertyKey[String](kind = 17, name = "EVALUATION_STRATEGY", default = "") diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/PropertyNames.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/PropertyNames.scala index b7a45738f..72d7a970d 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/PropertyNames.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/PropertyNames.scala @@ -98,7 +98,8 @@ object PropertyNames { * strategy, which is one of the following: 1) `BY_REFERENCE` indicates that the parameter is passed by reference, 2) * `BY_VALUE` indicates that it is passed by value, that is, a copy is made, 3) `BY_SHARING` the parameter is a * pointer/reference and it is shared with the caller/callee. While a copy of the pointer is made, a copy of the - * object that it points to is not made. + * object that it points to is not made, 4) `BY_COPY` indicates that it is passed by value and the copy shares + * nothing with the argument, so the callee cannot change the argument. */ val EvaluationStrategy: String = "EVALUATION_STRATEGY" diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/ClosureBinding.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/ClosureBinding.scala index f3b5a3b57..b349e5ade 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/ClosureBinding.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/ClosureBinding.scala @@ -35,7 +35,9 @@ object ClosureBinding { * parameters, output parameters, and return parameters, this field holds the evaluation strategy, which is one of the * following: 1) `BY_REFERENCE` indicates that the parameter is passed by reference, 2) `BY_VALUE` indicates that it is * passed by value, that is, a copy is made, 3) `BY_SHARING` the parameter is a pointer/reference and it is shared with - * the caller/callee. While a copy of the pointer is made, a copy of the object that it points to is not made. + * the caller/callee. While a copy of the pointer is made, a copy of the object that it points to is not made, 4) + * `BY_COPY` indicates that it is passed by value and the copy shares nothing with the argument, so the callee cannot + * change the argument. */ class ClosureBinding(graph_4762: flatgraph.Graph, seq_4762: Int) extends StoredNode(graph_4762, 8, seq_4762) diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodParameterIn.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodParameterIn.scala index 08b52b83d..ee41d0d77 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodParameterIn.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodParameterIn.scala @@ -86,7 +86,9 @@ object MethodParameterIn { * parameters, output parameters, and return parameters, this field holds the evaluation strategy, which is one of the * following: 1) `BY_REFERENCE` indicates that the parameter is passed by reference, 2) `BY_VALUE` indicates that it is * passed by value, that is, a copy is made, 3) `BY_SHARING` the parameter is a pointer/reference and it is shared with - * the caller/callee. While a copy of the pointer is made, a copy of the object that it points to is not made. + * the caller/callee. While a copy of the pointer is made, a copy of the object that it points to is not made, 4) + * `BY_COPY` indicates that it is passed by value and the copy shares nothing with the argument, so the callee cannot + * change the argument. * * ▸ Index (Int); Cardinality `one` (mandatory with default value `-2`); Specifies an index, e.g., for a parameter or * argument. Explicit parameters are numbered from 1 to N, while index 0 is reserved for implicit self / this diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodParameterOut.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodParameterOut.scala index c5f7d5da2..74f9e6ddf 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodParameterOut.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodParameterOut.scala @@ -69,7 +69,9 @@ object MethodParameterOut { * parameters, output parameters, and return parameters, this field holds the evaluation strategy, which is one of the * following: 1) `BY_REFERENCE` indicates that the parameter is passed by reference, 2) `BY_VALUE` indicates that it is * passed by value, that is, a copy is made, 3) `BY_SHARING` the parameter is a pointer/reference and it is shared with - * the caller/callee. While a copy of the pointer is made, a copy of the object that it points to is not made. + * the caller/callee. While a copy of the pointer is made, a copy of the object that it points to is not made, 4) + * `BY_COPY` indicates that it is passed by value and the copy shares nothing with the argument, so the callee cannot + * change the argument. * * ▸ Index (Int); Cardinality `one` (mandatory with default value `-2`); Specifies an index, e.g., for a parameter or * argument. Explicit parameters are numbered from 1 to N, while index 0 is reserved for implicit self / this diff --git a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodReturn.scala b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodReturn.scala index a6e37e264..77fdde522 100644 --- a/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodReturn.scala +++ b/domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/MethodReturn.scala @@ -67,7 +67,9 @@ object MethodReturn { * parameters, output parameters, and return parameters, this field holds the evaluation strategy, which is one of the * following: 1) `BY_REFERENCE` indicates that the parameter is passed by reference, 2) `BY_VALUE` indicates that it is * passed by value, that is, a copy is made, 3) `BY_SHARING` the parameter is a pointer/reference and it is shared with - * the caller/callee. While a copy of the pointer is made, a copy of the object that it points to is not made. + * the caller/callee. While a copy of the pointer is made, a copy of the object that it points to is not made, 4) + * `BY_COPY` indicates that it is passed by value and the copy shares nothing with the argument, so the callee cannot + * change the argument. * * ▸ LineNumber (Int); Cardinality `ZeroOrOne` (optional); This optional field provides the line number of the program * construct represented by the node. diff --git a/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/CallGraph.scala b/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/CallGraph.scala index 2adade14b..f383acd42 100644 --- a/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/CallGraph.scala +++ b/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/CallGraph.scala @@ -91,7 +91,9 @@ object CallGraph extends SchemaBase { |`BY_VALUE` indicates that it is passed by value, that is, a copy is made, |3) `BY_SHARING` the parameter is a pointer/reference and it is shared with |the caller/callee. While a copy of the pointer is made, a copy of the object - |that it points to is not made. + |that it points to is not made, 4) `BY_COPY` indicates that it is passed by + |value and the copy shares nothing with the argument, so the callee cannot + |change the argument. |""".stripMargin ) .mandatory(PropertyDefaults.String) @@ -118,7 +120,14 @@ object CallGraph extends SchemaBase { value = "BY_VALUE", valueType = ValueType.String, comment = "A parameter or return of a function passed by value which means a flat copy is used" - ).protoId(ProtoIds.ByValue) + ).protoId(ProtoIds.ByValue), + Constant( + name = "BY_COPY", + value = "BY_COPY", + valueType = ValueType.String, + comment = + "A parameter of a function passed by value whose copy shares nothing with the argument: it holds no pointer or reference, so the callee cannot change the argument" + ).protoId(ProtoIds.ByCopy) ) methodParameterIn.addProperties(evaluationStrategy) diff --git a/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/ProtoIds.scala b/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/ProtoIds.scala index 138fdff7d..fa94e7542 100644 --- a/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/ProtoIds.scala +++ b/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/ProtoIds.scala @@ -25,6 +25,7 @@ object ProtoIds { val Order = 4 val Do = 4 val CSharp = 4 + val ByCopy = 4 val Abstract = 5 val Annotation = 5 val For = 5