Skip to content

Commit f6ccafd

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

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/TranslationResult.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ class TranslationResult(
8484
/** A free-for-use HashMap where passes can store whatever they want. */
8585
val scratch: MutableMap<String, Any> = ConcurrentHashMap()
8686

87-
@Transient
88-
@PopulatedByPass(ImportResolver::class)
89-
var importDependencies = ImportDependencies(mutableListOf())
90-
9187
/**
9288
* A free-for-use collection of unique nodes. Nodes stored here will be exported to Neo4j, too.
9389
*/

cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/declarations/RecordDeclaration.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ open class RecordDeclaration :
169169
get() {
170170
val list = mutableListOf<Node>()
171171

172-
// list += statements
173172
list += fields
174173
list += methods
175174
list += constructors

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

Lines changed: 7 additions & 1 deletion
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) {

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

Lines changed: 3 additions & 3 deletions
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)

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

Lines changed: 1 addition & 1 deletion
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)