File tree 3 files changed +11
-5
lines changed
cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes
cpg-language-python/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/python
3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ import de.fraunhofer.aisec.cpg.graph.statements.expressions.*
40
40
import de.fraunhofer.aisec.cpg.graph.types.Type
41
41
import de.fraunhofer.aisec.cpg.helpers.IdentitySet
42
42
import de.fraunhofer.aisec.cpg.helpers.SubgraphWalker
43
+ import de.fraunhofer.aisec.cpg.helpers.identitySetOf
43
44
import de.fraunhofer.aisec.cpg.tryCast
44
45
import java.util.*
45
46
import org.slf4j.LoggerFactory
@@ -120,6 +121,8 @@ open class EvaluationOrderGraphPass(ctx: TranslationContext) : TranslationUnitPa
120
121
*/
121
122
protected val intermediateNodes = mutableListOf<Node >()
122
123
124
+ val alreadySeen = identitySetOf<Node >()
125
+
123
126
protected fun doNothing () {
124
127
// Nothing to do for this node type
125
128
}
@@ -341,9 +344,12 @@ open class EvaluationOrderGraphPass(ctx: TranslationContext) : TranslationUnitPa
341
344
* e.g. [LoopStatement]s or [BreakStatement].
342
345
*/
343
346
protected fun handleEOG (node : Node ? ) {
344
- if (node == null ) {
347
+ if (node == null || alreadySeen.contains(node) ) {
345
348
return
346
349
}
350
+
351
+ alreadySeen.add(node)
352
+
347
353
intermediateNodes.add(node)
348
354
349
355
when (node) {
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ import org.slf4j.LoggerFactory
81
81
@DependsOn(TypeHierarchyResolver ::class )
82
82
@DependsOn(EvaluationOrderGraphPass ::class )
83
83
@DependsOn(ImportResolver ::class )
84
- open class SymbolResolver (ctx : TranslationContext ) : TranslationResultPass (ctx) {
84
+ open class SymbolResolver (ctx : TranslationContext ) : ComponentPass (ctx) {
85
85
86
86
/* * Configuration for the [SymbolResolver]. */
87
87
class Configuration (
@@ -122,8 +122,8 @@ open class SymbolResolver(ctx: TranslationContext) : TranslationResultPass(ctx)
122
122
null
123
123
}
124
124
125
- override fun accept (component : TranslationResult ) {
126
- // ctx.currentComponent = component
125
+ override fun accept (component : Component ) {
126
+ ctx.currentComponent = component
127
127
walker = ScopedWalker (scopeManager)
128
128
129
129
cacheTemplates(component)
Original file line number Diff line number Diff line change @@ -1218,7 +1218,7 @@ class StatementHandler(frontend: PythonLanguageFrontend) :
1218
1218
*/
1219
1219
private fun wrapDeclarationToStatement (decl : Declaration ): DeclarationStatement {
1220
1220
val declStmt = newDeclarationStatement().codeAndLocationFrom(decl)
1221
- declStmt.addDeclaration( decl)
1221
+ declStmt.declarations + = decl
1222
1222
return declStmt
1223
1223
}
1224
1224
You can’t perform that action at this time.
0 commit comments