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 31, 2025
1 parent abfb690 commit 9f002df
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 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 @@ -81,7 +81,7 @@ import org.slf4j.LoggerFactory
@DependsOn(TypeHierarchyResolver::class)
@DependsOn(EvaluationOrderGraphPass::class)
@DependsOn(ImportResolver::class)
open class SymbolResolver(ctx: TranslationContext) : TranslationResultPass(ctx) {
open class SymbolResolver(ctx: TranslationContext) : ComponentPass(ctx) {

/** Configuration for the [SymbolResolver]. */
class Configuration(
Expand Down Expand Up @@ -122,8 +122,8 @@ open class SymbolResolver(ctx: TranslationContext) : TranslationResultPass(ctx)
null
}

override fun accept(component: TranslationResult) {
// ctx.currentComponent = component
override fun accept(component: Component) {
ctx.currentComponent = component
walker = ScopedWalker(scopeManager)

cacheTemplates(component)
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 9f002df

Please sign in to comment.