Skip to content

Commit 1d794da

Browse files
Explicit control-structure schema edges (#1849)
* Explicit control-structure schema edges * Remove test
1 parent bbedec6 commit 1d794da

50 files changed

Lines changed: 25916 additions & 976 deletions

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/EdgeTypes.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ other words, there is a (name, signature) pair that can be resolved for the type
4141
/** Connection between a captured LOCAL and the corresponding CLOSURE_BINDING */
4242
public static final String CAPTURED_BY = "CAPTURED_BY";
4343

44+
/** The edge connects try control structure nodes to catch/handler bodies. */
45+
public static final String CATCH_BODY = "CATCH_BODY";
46+
4447
/** A CDG edge expresses that the destination node is control dependent on the source node. */
4548
public static final String CDG = "CDG";
4649

@@ -53,12 +56,30 @@ other words, there is a (name, signature) pair that can be resolved for the type
5356
/** This edge connects a node to the method that contains it. */
5457
public static final String CONTAINS = "CONTAINS";
5558

59+
/** The edge connects do-while control structure nodes to their body. */
60+
public static final String DO_BODY = "DO_BODY";
61+
5662
/** This edge indicates that the source node immediately dominates the destination node. */
5763
public static final String DOMINATE = "DOMINATE";
5864

5965
/** This edge connects a node to its evaluation type. */
6066
public static final String EVAL_TYPE = "EVAL_TYPE";
6167

68+
/** The edge connects control structure nodes to their false branch/body. */
69+
public static final String FALSE_BODY = "FALSE_BODY";
70+
71+
/** The edge connects try control structure nodes to their finally body. */
72+
public static final String FINALLY_BODY = "FINALLY_BODY";
73+
74+
/** The edge connects for-loop control structure nodes to their body. */
75+
public static final String FOR_BODY = "FOR_BODY";
76+
77+
/** The edge connects for-loop control structure nodes to their initialization expression(s). */
78+
public static final String FOR_INIT = "FOR_INIT";
79+
80+
/** The edge connects for-loop control structure nodes to their update/step expression(s). */
81+
public static final String FOR_UPDATE = "FOR_UPDATE";
82+
6283
/** Edge from imports to dependencies */
6384
public static final String IMPORTS = "IMPORTS";
6485

@@ -104,6 +125,12 @@ other words, there is a (name, signature) pair that can be resolved for the type
104125
/** Edges from nodes to the tags they are tagged by. */
105126
public static final String TAGGED_BY = "TAGGED_BY";
106127

128+
/** The edge connects control structure nodes to their true branch/body. */
129+
public static final String TRUE_BODY = "TRUE_BODY";
130+
131+
/** The edge connects try control structure nodes to their try body. */
132+
public static final String TRY_BODY = "TRY_BODY";
133+
107134
public static Set<String> ALL = new HashSet<String>() {{
108135
add(ALIAS_OF);
109136
add(ARGUMENT);
@@ -113,12 +140,19 @@ other words, there is a (name, signature) pair that can be resolved for the type
113140
add(CALL);
114141
add(CAPTURE);
115142
add(CAPTURED_BY);
143+
add(CATCH_BODY);
116144
add(CDG);
117145
add(CFG);
118146
add(CONDITION);
119147
add(CONTAINS);
148+
add(DO_BODY);
120149
add(DOMINATE);
121150
add(EVAL_TYPE);
151+
add(FALSE_BODY);
152+
add(FINALLY_BODY);
153+
add(FOR_BODY);
154+
add(FOR_INIT);
155+
add(FOR_UPDATE);
122156
add(IMPORTS);
123157
add(INHERITS_FROM);
124158
add(IS_CALL_FOR_IMPORT);
@@ -129,6 +163,8 @@ other words, there is a (name, signature) pair that can be resolved for the type
129163
add(REF);
130164
add(SOURCE_FILE);
131165
add(TAGGED_BY);
166+
add(TRUE_BODY);
167+
add(TRY_BODY);
132168
}};
133169

134170
}

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

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,19 @@ object GraphSchema extends flatgraph.Schema {
5858
"CALL",
5959
"CAPTURE",
6060
"CAPTURED_BY",
61+
"CATCH_BODY",
6162
"CDG",
6263
"CFG",
6364
"CONDITION",
6465
"CONTAINS",
6566
"DOMINATE",
67+
"DO_BODY",
6668
"EVAL_TYPE",
69+
"FALSE_BODY",
70+
"FINALLY_BODY",
71+
"FOR_BODY",
72+
"FOR_INIT",
73+
"FOR_UPDATE",
6774
"IMPORTS",
6875
"INHERITS_FROM",
6976
"IS_CALL_FOR_IMPORT",
@@ -73,7 +80,9 @@ object GraphSchema extends flatgraph.Schema {
7380
"RECEIVER",
7481
"REF",
7582
"SOURCE_FILE",
76-
"TAGGED_BY"
83+
"TAGGED_BY",
84+
"TRUE_BODY",
85+
"TRY_BODY"
7786
)
7887
val edgeKindByLabel = edgeLabels.zipWithIndex.toMap
7988
val edgePropertyAllocators: Array[Int => Array[?]] = Array(
@@ -96,7 +105,16 @@ object GraphSchema extends flatgraph.Schema {
96105
size => null,
97106
size => null,
98107
size => null,
99-
size => Array.fill(size)("<empty>") /* label = REACHING_DEF, id = 19 */,
108+
size => null,
109+
size => null,
110+
size => null,
111+
size => null,
112+
size => null,
113+
size => null,
114+
size => null,
115+
size => Array.fill(size)("<empty>") /* label = REACHING_DEF, id = 26 */,
116+
size => null,
117+
size => null,
100118
size => null,
101119
size => null,
102120
size => null,
@@ -156,12 +174,19 @@ object GraphSchema extends flatgraph.Schema {
156174
(s, d, subseq, p) => new edges.Call(s, d, subseq, p),
157175
(s, d, subseq, p) => new edges.Capture(s, d, subseq, p),
158176
(s, d, subseq, p) => new edges.CapturedBy(s, d, subseq, p),
177+
(s, d, subseq, p) => new edges.CatchBody(s, d, subseq, p),
159178
(s, d, subseq, p) => new edges.Cdg(s, d, subseq, p),
160179
(s, d, subseq, p) => new edges.Cfg(s, d, subseq, p),
161180
(s, d, subseq, p) => new edges.Condition(s, d, subseq, p),
162181
(s, d, subseq, p) => new edges.Contains(s, d, subseq, p),
163182
(s, d, subseq, p) => new edges.Dominate(s, d, subseq, p),
183+
(s, d, subseq, p) => new edges.DoBody(s, d, subseq, p),
164184
(s, d, subseq, p) => new edges.EvalType(s, d, subseq, p),
185+
(s, d, subseq, p) => new edges.FalseBody(s, d, subseq, p),
186+
(s, d, subseq, p) => new edges.FinallyBody(s, d, subseq, p),
187+
(s, d, subseq, p) => new edges.ForBody(s, d, subseq, p),
188+
(s, d, subseq, p) => new edges.ForInit(s, d, subseq, p),
189+
(s, d, subseq, p) => new edges.ForUpdate(s, d, subseq, p),
165190
(s, d, subseq, p) => new edges.Imports(s, d, subseq, p),
166191
(s, d, subseq, p) => new edges.InheritsFrom(s, d, subseq, p),
167192
(s, d, subseq, p) => new edges.IsCallForImport(s, d, subseq, p),
@@ -171,7 +196,9 @@ object GraphSchema extends flatgraph.Schema {
171196
(s, d, subseq, p) => new edges.Receiver(s, d, subseq, p),
172197
(s, d, subseq, p) => new edges.Ref(s, d, subseq, p),
173198
(s, d, subseq, p) => new edges.SourceFile(s, d, subseq, p),
174-
(s, d, subseq, p) => new edges.TaggedBy(s, d, subseq, p)
199+
(s, d, subseq, p) => new edges.TaggedBy(s, d, subseq, p),
200+
(s, d, subseq, p) => new edges.TrueBody(s, d, subseq, p),
201+
(s, d, subseq, p) => new edges.TryBody(s, d, subseq, p)
175202
)
176203
val nodePropertyAllocators: Array[Int => Array[?]] = Array(
177204
size => new Array[String](size),
@@ -1450,7 +1477,7 @@ object GraphSchema extends flatgraph.Schema {
14501477
_newNodeInserters
14511478
}
14521479
override def getNumberOfNodeKinds: Int = 43
1453-
override def getNumberOfEdgeKinds: Int = 24
1480+
override def getNumberOfEdgeKinds: Int = 33
14541481
override def getNodeLabel(nodeKind: Int): String = nodeLabels(nodeKind)
14551482
override def getNodeKindByLabel(label: String): Int = nodeKindByLabel.getOrElse(label, flatgraph.Schema.UndefinedKind)
14561483
override def getEdgeLabel(nodeKind: Int, edgeKind: Int): String = edgeLabels(edgeKind)

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/edges/EdgeTypes.scala

Lines changed: 88 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,101 +64,157 @@ object CapturedBy {
6464
class CapturedBy(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
6565
extends flatgraph.Edge(src_4762, dst_4762, 7, subSeq_4862, property_4862) {}
6666

67+
object CatchBody {
68+
val Label = "CATCH_BODY"
69+
70+
}
71+
72+
class CatchBody(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
73+
extends flatgraph.Edge(src_4762, dst_4762, 8, subSeq_4862, property_4862) {}
74+
6775
object Cdg {
6876
val Label = "CDG"
6977

7078
}
7179

7280
class Cdg(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
73-
extends flatgraph.Edge(src_4762, dst_4762, 8, subSeq_4862, property_4862) {}
81+
extends flatgraph.Edge(src_4762, dst_4762, 9, subSeq_4862, property_4862) {}
7482

7583
object Cfg {
7684
val Label = "CFG"
7785

7886
}
7987

8088
class Cfg(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
81-
extends flatgraph.Edge(src_4762, dst_4762, 9, subSeq_4862, property_4862) {}
89+
extends flatgraph.Edge(src_4762, dst_4762, 10, subSeq_4862, property_4862) {}
8290

8391
object Condition {
8492
val Label = "CONDITION"
8593

8694
}
8795

8896
class Condition(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
89-
extends flatgraph.Edge(src_4762, dst_4762, 10, subSeq_4862, property_4862) {}
97+
extends flatgraph.Edge(src_4762, dst_4762, 11, subSeq_4862, property_4862) {}
9098

9199
object Contains {
92100
val Label = "CONTAINS"
93101

94102
}
95103

96104
class Contains(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
97-
extends flatgraph.Edge(src_4762, dst_4762, 11, subSeq_4862, property_4862) {}
105+
extends flatgraph.Edge(src_4762, dst_4762, 12, subSeq_4862, property_4862) {}
98106

99107
object Dominate {
100108
val Label = "DOMINATE"
101109

102110
}
103111

104112
class Dominate(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
105-
extends flatgraph.Edge(src_4762, dst_4762, 12, subSeq_4862, property_4862) {}
113+
extends flatgraph.Edge(src_4762, dst_4762, 13, subSeq_4862, property_4862) {}
114+
115+
object DoBody {
116+
val Label = "DO_BODY"
117+
118+
}
119+
120+
class DoBody(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
121+
extends flatgraph.Edge(src_4762, dst_4762, 14, subSeq_4862, property_4862) {}
106122

107123
object EvalType {
108124
val Label = "EVAL_TYPE"
109125

110126
}
111127

112128
class EvalType(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
113-
extends flatgraph.Edge(src_4762, dst_4762, 13, subSeq_4862, property_4862) {}
129+
extends flatgraph.Edge(src_4762, dst_4762, 15, subSeq_4862, property_4862) {}
130+
131+
object FalseBody {
132+
val Label = "FALSE_BODY"
133+
134+
}
135+
136+
class FalseBody(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
137+
extends flatgraph.Edge(src_4762, dst_4762, 16, subSeq_4862, property_4862) {}
138+
139+
object FinallyBody {
140+
val Label = "FINALLY_BODY"
141+
142+
}
143+
144+
class FinallyBody(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
145+
extends flatgraph.Edge(src_4762, dst_4762, 17, subSeq_4862, property_4862) {}
146+
147+
object ForBody {
148+
val Label = "FOR_BODY"
149+
150+
}
151+
152+
class ForBody(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
153+
extends flatgraph.Edge(src_4762, dst_4762, 18, subSeq_4862, property_4862) {}
154+
155+
object ForInit {
156+
val Label = "FOR_INIT"
157+
158+
}
159+
160+
class ForInit(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
161+
extends flatgraph.Edge(src_4762, dst_4762, 19, subSeq_4862, property_4862) {}
162+
163+
object ForUpdate {
164+
val Label = "FOR_UPDATE"
165+
166+
}
167+
168+
class ForUpdate(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
169+
extends flatgraph.Edge(src_4762, dst_4762, 20, subSeq_4862, property_4862) {}
114170

115171
object Imports {
116172
val Label = "IMPORTS"
117173

118174
}
119175

120176
class Imports(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
121-
extends flatgraph.Edge(src_4762, dst_4762, 14, subSeq_4862, property_4862) {}
177+
extends flatgraph.Edge(src_4762, dst_4762, 21, subSeq_4862, property_4862) {}
122178

123179
object InheritsFrom {
124180
val Label = "INHERITS_FROM"
125181

126182
}
127183

128184
class InheritsFrom(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
129-
extends flatgraph.Edge(src_4762, dst_4762, 15, subSeq_4862, property_4862) {}
185+
extends flatgraph.Edge(src_4762, dst_4762, 22, subSeq_4862, property_4862) {}
130186

131187
object IsCallForImport {
132188
val Label = "IS_CALL_FOR_IMPORT"
133189

134190
}
135191

136192
class IsCallForImport(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
137-
extends flatgraph.Edge(src_4762, dst_4762, 16, subSeq_4862, property_4862) {}
193+
extends flatgraph.Edge(src_4762, dst_4762, 23, subSeq_4862, property_4862) {}
138194

139195
object ParameterLink {
140196
val Label = "PARAMETER_LINK"
141197

142198
}
143199

144200
class ParameterLink(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
145-
extends flatgraph.Edge(src_4762, dst_4762, 17, subSeq_4862, property_4862) {}
201+
extends flatgraph.Edge(src_4762, dst_4762, 24, subSeq_4862, property_4862) {}
146202

147203
object PostDominate {
148204
val Label = "POST_DOMINATE"
149205

150206
}
151207

152208
class PostDominate(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
153-
extends flatgraph.Edge(src_4762, dst_4762, 18, subSeq_4862, property_4862) {}
209+
extends flatgraph.Edge(src_4762, dst_4762, 25, subSeq_4862, property_4862) {}
154210

155211
object ReachingDef {
156212
val Label = "REACHING_DEF"
157213
val propertyName: Option[String] = Some("VARIABLE")
158214
}
159215

160216
class ReachingDef(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
161-
extends flatgraph.Edge(src_4762, dst_4762, 19, subSeq_4862, property_4862) {
217+
extends flatgraph.Edge(src_4762, dst_4762, 26, subSeq_4862, property_4862) {
162218
override def propertyName: Option[String] = ReachingDef.propertyName
163219
}
164220

@@ -168,28 +224,44 @@ object Receiver {
168224
}
169225

170226
class Receiver(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
171-
extends flatgraph.Edge(src_4762, dst_4762, 20, subSeq_4862, property_4862) {}
227+
extends flatgraph.Edge(src_4762, dst_4762, 27, subSeq_4862, property_4862) {}
172228

173229
object Ref {
174230
val Label = "REF"
175231

176232
}
177233

178234
class Ref(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
179-
extends flatgraph.Edge(src_4762, dst_4762, 21, subSeq_4862, property_4862) {}
235+
extends flatgraph.Edge(src_4762, dst_4762, 28, subSeq_4862, property_4862) {}
180236

181237
object SourceFile {
182238
val Label = "SOURCE_FILE"
183239

184240
}
185241

186242
class SourceFile(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
187-
extends flatgraph.Edge(src_4762, dst_4762, 22, subSeq_4862, property_4862) {}
243+
extends flatgraph.Edge(src_4762, dst_4762, 29, subSeq_4862, property_4862) {}
188244

189245
object TaggedBy {
190246
val Label = "TAGGED_BY"
191247

192248
}
193249

194250
class TaggedBy(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
195-
extends flatgraph.Edge(src_4762, dst_4762, 23, subSeq_4862, property_4862) {}
251+
extends flatgraph.Edge(src_4762, dst_4762, 30, subSeq_4862, property_4862) {}
252+
253+
object TrueBody {
254+
val Label = "TRUE_BODY"
255+
256+
}
257+
258+
class TrueBody(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
259+
extends flatgraph.Edge(src_4762, dst_4762, 31, subSeq_4862, property_4862) {}
260+
261+
object TryBody {
262+
val Label = "TRY_BODY"
263+
264+
}
265+
266+
class TryBody(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
267+
extends flatgraph.Edge(src_4762, dst_4762, 32, subSeq_4862, property_4862) {}

0 commit comments

Comments
 (0)