Skip to content

Commit 0985dba

Browse files
authored
update cpg2 (#134)
call signature improvements Signed-off-by: Prabhu Subramanian <[email protected]>
1 parent 261b78e commit 0985dba

File tree

22 files changed

+365
-264
lines changed

22 files changed

+365
-264
lines changed

build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name := "chen"
22
ThisBuild / organization := "io.appthreat"
3-
ThisBuild / version := "2.5.3"
3+
ThisBuild / version := "2.5.4"
44
ThisBuild / scalaVersion := "3.6.2"
55

6-
val cpgVersion = "2.0.0"
6+
val cpgVersion = "2.0.1"
77

88
lazy val platform = Projects.platform
99
lazy val console = Projects.console

codemeta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"downloadUrl": "https://github.com/AppThreat/chen",
88
"issueTracker": "https://github.com/AppThreat/chen/issues",
99
"name": "chen",
10-
"version": "2.5.3",
10+
"version": "2.5.4",
1111
"description": "Code Hierarchy Exploration Net (chen) is an advanced exploration toolkit for your application source code and its dependency hierarchy.",
1212
"applicationCategory": "code-analysis",
1313
"keywords": [

console/src/main/scala/io/appthreat/console/Help.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package io.appthreat.console
22

3-
import org.apache.commons.lang.WordUtils
43
import overflowdb.traversal.help.DocFinder.*
54
import overflowdb.traversal.help.{Table, DocFinder}
5+
import io.appthreat.x2cpg.utils.{StringUtils, WordUtils}
66

77
object Help:
88

console/src/test/scala/io/appthreat/console/ConsoleTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ConsoleTests extends AnyWordSpec with Matchers {
4343
}
4444

4545
"provide overview of available language modules" in ConsoleFixture() { (console, _) =>
46-
console.importCode.toString.contains("| C") shouldBe true
46+
console.importCode.toString.contains("C") shouldBe true
4747
}
4848

4949
"allow importing code with specific module (c2cpg)" in ConsoleFixture() { (console, codeDir) =>

console/src/test/scala/io/appthreat/console/HelpTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class HelpTests extends AnyWordSpec with Matchers {
99

1010
"Help" should {
1111
"provide overview of commands as table" in {
12-
Help.overview(classOf[Console[Project]]).contains("| CPG") shouldBe true
12+
Help.overview(classOf[Console[Project]]).contains("CPG") shouldBe true
1313
}
1414
}
1515

console/src/test/scala/io/appthreat/console/workspacehandling/WorkspaceTests.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ class WorkspaceTests extends AnyWordSpec with Matchers {
2727
val workspace = new Workspace(projects)
2828
val output = workspace.toString
2929
val lines = output.split("\n")
30-
lines.length shouldBe 5
31-
lines(4).contains(project.name) shouldBe true
32-
lines(4).contains(inputPath)
33-
lines(4).contains("foo,bar")
30+
lines.length shouldBe 4
31+
lines(3).contains(project.name) shouldBe true
32+
lines(3).contains(inputPath)
33+
lines(3).contains("foo,bar")
3434
}
3535

3636
}

dataflowengineoss/src/main/scala/io/appthreat/dataflowengineoss/language/Path.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ package io.appthreat.dataflowengineoss.language
33
import io.shiftleft.codepropertygraph.generated.nodes.*
44
import io.shiftleft.semanticcpg.language.*
55
import me.shadaj.scalapy.py
6-
import org.apache.commons.lang.StringUtils
7-
6+
import io.appthreat.x2cpg.utils.StringUtils
87
import scala.collection.mutable.{ArrayBuffer, Set}
98

109
case class Path(elements: List[AstNode]):

meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% set version = "2.5.3" %}
1+
{% set version = "2.5.4" %}
22

33
package:
44
name: chen

platform/frontends/c2cpg/src/main/scala/io/appthreat/c2cpg/astcreation/AstCreatorHelper.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package io.appthreat.c2cpg.astcreation
33
import io.appthreat.c2cpg.datastructures.CGlobal
44
import io.appthreat.x2cpg.utils.NodeBuilders.newDependencyNode
55
import io.appthreat.x2cpg.Defines as X2CpgDefines
6+
import io.appthreat.x2cpg.utils.StringUtils
67
import io.appthreat.x2cpg.{Ast, SourceFiles, ValidationMode}
78
import io.shiftleft.codepropertygraph.generated.nodes.{ExpressionNew, NewCall, NewNode}
89
import io.shiftleft.codepropertygraph.generated.{DispatchTypes, EdgeTypes, Operators}
910
import io.shiftleft.utils.IOUtils
10-
import org.apache.commons.lang.StringUtils
1111
import org.eclipse.cdt.core.dom.ast.*
1212
import org.eclipse.cdt.core.dom.ast.c.{
1313
ICASTArrayDesignator,

platform/frontends/c2cpg/src/main/scala/io/appthreat/c2cpg/astcreation/AstForExpressionsCreator.scala

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,21 @@ trait AstForExpressionsCreator(implicit withSchemaValidation: ValidationMode):
331331
idExpr: CASTIdExpression,
332332
callTypeFullName: String
333333
): Ast =
334-
val name = idExpr.getName.getLastName.toString
335-
val signature = ""
334+
val name = idExpr.getName.getLastName.toString
335+
val (signature: String, fullName: String) =
336+
idExpr.getName.getBinding match
337+
case function: IFunction =>
338+
val functionType: IFunctionType = function.getType
339+
val derivedSignature = functionTypeToSignature(functionType)
340+
val nameFromBinding = function.getName
341+
val constructedFullName = s"$nameFromBinding:$derivedSignature"
342+
(derivedSignature, constructedFullName)
343+
344+
case _ =>
345+
val fallbackSignature = ""
346+
(fallbackSignature, s"$name:$fallbackSignature")
336347

337348
val dispatchType = DispatchTypes.STATIC_DISPATCH
338-
339349
val callCpgNode = callNode(
340350
call,
341351
code(call),

0 commit comments

Comments
 (0)