cpg icon indicating copy to clipboard operation
cpg copied to clipboard

Bring tutorial up-to-date with new query extensions and changes to query API

Open fwendland opened this issue 2 years ago • 1 comments

Stack trace

When using the console for v4.6.2 with the example file cpg-console/src/test/resources/array.cpp I'm getting:

[25] var expr = result.all<ArraySubscriptionExpression>().map { Triple(
        it.subscriptExpression.evaluate() as Int,
        it.arrayExpression.dfgFrom<ArrayCreationExpression>().first().capacity,
        it
    ) }
java.lang.ClassCastException: class java.lang.Long cannot be cast to class java.lang.Integer (java.lang.Long and java.lang.Integer are in module java.base of loader 'bootstrap')
	at Line_26.<init>(Line_26.kts:2)

Thinking it might be a type change not reflected in the tutorial yet, I've tried changing the type to Long:

[26] var expr = result.all<ArraySubscriptionExpression>().map { Triple(
        it.subscriptExpression.evaluate() as Long,
        it.arrayExpression.dfgFrom<ArrayCreationExpression>().first().capacity,
        it
    ) }
java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.Long (java.lang.Integer and java.lang.Long are in module java.base of loader 'bootstrap')
	at Line_27.<init>(Line_27.kts:2)

... producing the opposite exception.

Unexpected behavior

Not applicable

Code of interest

Part of this repo

Extensions to the library, e.g. added or changed LanguageFrontends or Passes

Used default console configuration

Changes to the configuration

None

fwendland avatar Sep 07 '22 10:09 fwendland

We also need to re-work the tutorial to incorporate changes of https://github.com/Fraunhofer-AISEC/cpg/pull/900

oxisto avatar Sep 08 '22 06:09 oxisto