Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
Use type JUMP_TARGET for labels (#194)
Browse files Browse the repository at this point in the history
* Create JUMP_TARGET nodes for labels.

* Set correct CPG version.
  • Loading branch information
fabsx00 authored Jun 6, 2020
1 parent 7bfce50 commit c721a88
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ organization := "io.shiftleft"
scalaVersion := "2.13.1"
enablePlugins(GitVersioning)

val cpgVersion = "0.11.239"
val cpgVersion = "0.11.259"
val antlrVersion = "4.7.2"

libraryDependencies ++= Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ object NodeProperty extends Enumeration {

object NodeKind extends Enumeration {
type NodeKind = Value
val METHOD, METHOD_RETURN, METHOD_PARAMETER_IN, METHOD_INST, CALL, LITERAL, IDENTIFIER, BLOCK, RETURN, LOCAL, TYPE,
TYPE_DECL, MEMBER, NAMESPACE_BLOCK, CONTROL_STRUCTURE, UNKNOWN, FIELD_IDENTIFIER = Value
val METHOD, METHOD_RETURN, METHOD_PARAMETER_IN, METHOD_INST, CALL, LITERAL, IDENTIFIER, JUMP_TARGET, BLOCK, RETURN,
LOCAL, TYPE, TYPE_DECL, MEMBER, NAMESPACE_BLOCK, CONTROL_STRUCTURE, UNKNOWN, FIELD_IDENTIFIER = Value
}

object EdgeProperty extends Enumeration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class ProtoCpgAdapter(targetCpg: CpgStruct.Builder) extends CpgAdapter[Node.Buil
case NodeKind.CONTROL_STRUCTURE => Node.NodeType.CONTROL_STRUCTURE
case NodeKind.UNKNOWN => Node.NodeType.UNKNOWN
case NodeKind.FIELD_IDENTIFIER => Node.NodeType.FIELD_IDENTIFIER
case NodeKind.JUMP_TARGET => Node.NodeType.JUMP_TARGET
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,12 @@ class AstToCpgConverter[NodeBuilderType, NodeType, EdgeBuilderType, EdgeType](
}

override def visit(astLabel: Label): Unit = {
val cpgLabel = newUnknownNode(astLabel)
val cpgLabel = adapter
.createNodeBuilder(NodeKind.JUMP_TARGET)
.addProperty(NodeProperty.PARSER_TYPE_NAME, astLabel.getClass.getSimpleName)
.addProperty(NodeProperty.NAME, astLabel.getLabelName)
.addCommons(astLabel, context)
.createNode(astLabel)
addAstChild(cpgLabel)
}

Expand Down

0 comments on commit c721a88

Please sign in to comment.