Skip to content

Commit

Permalink
Python tests work, broke everthing else
Browse files Browse the repository at this point in the history
  • Loading branch information
oxisto committed Jan 29, 2025
1 parent 3dbac77 commit 7074b3b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import de.fraunhofer.aisec.cpg.graph.statements.expressions.*
import de.fraunhofer.aisec.cpg.graph.types.Type
import de.fraunhofer.aisec.cpg.helpers.IdentitySet
import de.fraunhofer.aisec.cpg.helpers.SubgraphWalker
import de.fraunhofer.aisec.cpg.helpers.identitySetOf
import de.fraunhofer.aisec.cpg.tryCast
import java.util.*
import org.slf4j.LoggerFactory
Expand Down Expand Up @@ -120,6 +121,8 @@ open class EvaluationOrderGraphPass(ctx: TranslationContext) : TranslationUnitPa
*/
protected val intermediateNodes = mutableListOf<Node>()

val alreadySeen = identitySetOf<Node>()

protected fun doNothing() {
// Nothing to do for this node type
}
Expand Down Expand Up @@ -341,9 +344,12 @@ open class EvaluationOrderGraphPass(ctx: TranslationContext) : TranslationUnitPa
* e.g. [LoopStatement]s or [BreakStatement].
*/
protected fun handleEOG(node: Node?) {
if (node == null) {
if (node == null || alreadySeen.contains(node)) {
return
}

alreadySeen.add(node)

intermediateNodes.add(node)

when (node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ class StatementHandler(frontend: PythonLanguageFrontend) :
*/
private fun wrapDeclarationToStatement(decl: Declaration): DeclarationStatement {
val declStmt = newDeclarationStatement().codeAndLocationFrom(decl)
declStmt.addDeclaration(decl)
declStmt.declarations += decl
return declStmt
}

Expand Down

0 comments on commit 7074b3b

Please sign in to comment.