File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
joern-cli/frontends/c2cpg/src
main/scala/io/joern/c2cpg/astcreation
test/scala/io/joern/c2cpg/querying Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -329,7 +329,10 @@ trait AstCreatorHelper(implicit withSchemaValidation: ValidationMode) { this: As
329
329
}
330
330
331
331
private def typeForCPPAstNamedTypeSpecifier (s : ICPPASTNamedTypeSpecifier , stripKeywords : Boolean ): String = {
332
- val tpe = safeGetBinding(s).map(_.toString).getOrElse(s.getRawSignature)
332
+ val tpe = safeGetBinding(s) match {
333
+ case Some (binding) if stripKeywords => binding.toString
334
+ case _ => s.getRawSignature
335
+ }
333
336
cleanType(tpe, stripKeywords)
334
337
}
335
338
Original file line number Diff line number Diff line change @@ -29,6 +29,25 @@ class LocalQueryTests extends C2CpgSuite {
29
29
}
30
30
31
31
" local query example 2" should {
32
+ " allow to query for the local" in {
33
+ val cpg = code(
34
+ """
35
+ |class Foo {
36
+ | static Foo* foo() {
37
+ | static Foo bar;
38
+ | return &bar;
39
+ | }
40
+ |}
41
+ |""" .stripMargin,
42
+ " test.cpp"
43
+ )
44
+ val List (barLocal) = cpg.method.name(" foo" ).local.nameExact(" bar" ).l
45
+ barLocal.typeFullName shouldBe " Foo"
46
+ barLocal.code shouldBe " static Foo bar"
47
+ }
48
+ }
49
+
50
+ " local query example 3" should {
32
51
val cpg = code("""
33
52
| struct node {
34
53
| int value;
You can’t perform that action at this time.
0 commit comments