From c2982d0f4d671d2f434c24115510e5cffd69cd2d Mon Sep 17 00:00:00 2001 From: Christian Banse Date: Wed, 9 Aug 2023 11:37:22 +0200 Subject: [PATCH] Using `IdentityHashSet` in EOG pass to remove superfluous EOG nodes (#1275) * EOG pass speedup There was an issue that massivly slowed down the EOG pass for programs that a LOT (>500.000) EOG nodes. Now we are using an identity hash set instead of a regular hash set to store the set of unique EOG nodes. * Add some comments * revert js change --------- Co-authored-by: Alexander Kuechler --- .../aisec/cpg/frontends/Language.kt | 2 ++ .../frontends/cxx/CXXLanguageFrontendTest.kt | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/Language.kt b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/Language.kt index f522474f52c..cf099ea84c6 100644 --- a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/Language.kt +++ b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/Language.kt @@ -34,9 +34,11 @@ import de.fraunhofer.aisec.cpg.TranslationContext import de.fraunhofer.aisec.cpg.graph.Name import de.fraunhofer.aisec.cpg.graph.Node import de.fraunhofer.aisec.cpg.graph.statements.expressions.BinaryOperator +import de.fraunhofer.aisec.cpg.graph.statements.expressions.CastExpression import de.fraunhofer.aisec.cpg.graph.types.* import de.fraunhofer.aisec.cpg.graph.types.Type import de.fraunhofer.aisec.cpg.graph.unknownType +import de.fraunhofer.aisec.cpg.helpers.Util import java.io.File import kotlin.reflect.KClass import kotlin.reflect.full.primaryConstructor diff --git a/cpg-language-cxx/src/test/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/CXXLanguageFrontendTest.kt b/cpg-language-cxx/src/test/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/CXXLanguageFrontendTest.kt index b618ca00f92..13ac72bb791 100644 --- a/cpg-language-cxx/src/test/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/CXXLanguageFrontendTest.kt +++ b/cpg-language-cxx/src/test/kotlin/de/fraunhofer/aisec/cpg/frontends/cxx/CXXLanguageFrontendTest.kt @@ -638,11 +638,19 @@ internal class CXXLanguageFrontendTest : BaseTest() { // a = b * 2 var assign = statements[2] as? AssignExpression assertNotNull(assign) +<<<<<<< HEAD var ref = assign.lhs() assertNotNull(ref) assertLocalName("a", ref) +======= + + var ref = assign.lhs() + assertNotNull(ref) + assertLocalName("a", ref) + +>>>>>>> f8cf854d8 (Overhaul of type propagation (#1268)) var binOp = assign.rhs() assertNotNull(binOp) @@ -658,10 +666,23 @@ internal class CXXLanguageFrontendTest : BaseTest() { ref = assign.lhs() assertNotNull(ref) assertLocalName("a", ref) +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> f8cf854d8 (Overhaul of type propagation (#1268)) + + binOp = assign.rhs() + assertNotNull(binOp) + +<<<<<<< HEAD +======= +======= binOp = assign.rhs() assertNotNull(binOp) +>>>>>>> 490562dce (Overhaul of type propagation (#1268)) +>>>>>>> f8cf854d8 (Overhaul of type propagation (#1268)) assertTrue(binOp.lhs is Literal<*>) assertEquals(1, (binOp.lhs as Literal<*>).value) assertTrue(binOp.rhs is Literal<*>)