From 02ad6c60501e471b22da2e0fd4af2ddba05772f3 Mon Sep 17 00:00:00 2001 From: Markus Lottmann Date: Fri, 11 Nov 2022 11:36:42 +0100 Subject: [PATCH] Move depth first order numbering of CFG nodes to codepropertygraph repo. This is a preparation step to avoid calculation the depth first order numbering multiple times. --- .../shiftleft/codepropertygraph/schema/Cfg.scala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/Cfg.scala b/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/Cfg.scala index 67fd01448..d28387399 100644 --- a/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/Cfg.scala +++ b/schema/src/main/scala/io/shiftleft/codepropertygraph/schema/Cfg.scala @@ -1,6 +1,7 @@ package io.shiftleft.codepropertygraph.schema import overflowdb.schema.EdgeType.Cardinality +import overflowdb.schema.Property.ValueType import overflowdb.schema.{SchemaBuilder, SchemaInfo} object Cfg extends SchemaBase { @@ -101,6 +102,20 @@ object Cfg extends SchemaBase { methodRef.addOutEdge(edge = cfg, inNode = methodReturn) typeRef.addOutEdge(edge = cfg, inNode = methodReturn) + + val depthFirstOrder = builder + .addProperty( + name = "DEPTH_FIRST_ORDER", + valueType = ValueType.Int, + comment = s"""The depth first ordering number. This is the reverse of a post order numbering. + |Among other things this can be to detect retreating CFG edges and back edges + |in reducible CFGs""".stripMargin + ) + .mandatory(-1) + .protoId(17) + + cfgNode.addProperties(depthFirstOrder) + } }