Skip to content

Commit 9f002df

Browse files
committed
Python tests work, broke everthing else
1 parent abfb690 commit 9f002df

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

Diff for: cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/EvaluationOrderGraphPass.kt

+7-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import de.fraunhofer.aisec.cpg.graph.statements.expressions.*
4040
import de.fraunhofer.aisec.cpg.graph.types.Type
4141
import de.fraunhofer.aisec.cpg.helpers.IdentitySet
4242
import de.fraunhofer.aisec.cpg.helpers.SubgraphWalker
43+
import de.fraunhofer.aisec.cpg.helpers.identitySetOf
4344
import de.fraunhofer.aisec.cpg.tryCast
4445
import java.util.*
4546
import org.slf4j.LoggerFactory
@@ -120,6 +121,8 @@ open class EvaluationOrderGraphPass(ctx: TranslationContext) : TranslationUnitPa
120121
*/
121122
protected val intermediateNodes = mutableListOf<Node>()
122123

124+
val alreadySeen = identitySetOf<Node>()
125+
123126
protected fun doNothing() {
124127
// Nothing to do for this node type
125128
}
@@ -341,9 +344,12 @@ open class EvaluationOrderGraphPass(ctx: TranslationContext) : TranslationUnitPa
341344
* e.g. [LoopStatement]s or [BreakStatement].
342345
*/
343346
protected fun handleEOG(node: Node?) {
344-
if (node == null) {
347+
if (node == null || alreadySeen.contains(node)) {
345348
return
346349
}
350+
351+
alreadySeen.add(node)
352+
347353
intermediateNodes.add(node)
348354

349355
when (node) {

Diff for: cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/SymbolResolver.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ import org.slf4j.LoggerFactory
8181
@DependsOn(TypeHierarchyResolver::class)
8282
@DependsOn(EvaluationOrderGraphPass::class)
8383
@DependsOn(ImportResolver::class)
84-
open class SymbolResolver(ctx: TranslationContext) : TranslationResultPass(ctx) {
84+
open class SymbolResolver(ctx: TranslationContext) : ComponentPass(ctx) {
8585

8686
/** Configuration for the [SymbolResolver]. */
8787
class Configuration(
@@ -122,8 +122,8 @@ open class SymbolResolver(ctx: TranslationContext) : TranslationResultPass(ctx)
122122
null
123123
}
124124

125-
override fun accept(component: TranslationResult) {
126-
// ctx.currentComponent = component
125+
override fun accept(component: Component) {
126+
ctx.currentComponent = component
127127
walker = ScopedWalker(scopeManager)
128128

129129
cacheTemplates(component)

Diff for: cpg-language-python/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/python/StatementHandler.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,7 @@ class StatementHandler(frontend: PythonLanguageFrontend) :
12181218
*/
12191219
private fun wrapDeclarationToStatement(decl: Declaration): DeclarationStatement {
12201220
val declStmt = newDeclarationStatement().codeAndLocationFrom(decl)
1221-
declStmt.addDeclaration(decl)
1221+
declStmt.declarations += decl
12221222
return declStmt
12231223
}
12241224

0 commit comments

Comments
 (0)