From 348f46e62c7ebac2e8c8336bb13f4527521b6733 Mon Sep 17 00:00:00 2001 From: Christian Banse Date: Fri, 8 Sep 2023 17:33:49 +0200 Subject: [PATCH] Only add Go builtins to Go code --- .../kotlin/de/fraunhofer/aisec/cpg/passes/GoExtraPass.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cpg-language-go/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/GoExtraPass.kt b/cpg-language-go/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/GoExtraPass.kt index 7852ea822da..de72773b27c 100644 --- a/cpg-language-go/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/GoExtraPass.kt +++ b/cpg-language-go/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/GoExtraPass.kt @@ -115,8 +115,10 @@ class GoExtraPass(ctx: TranslationContext) : ComponentPass(ctx), ScopeProvider { get() = scopeManager.currentScope override fun accept(component: Component) { - // Add built-int functions - component.translationUnits += addBuiltIn() + // Add built-int functions, but only if one of the components contains a GoLanguage + if (component.translationUnits.any { it.language is GoLanguage }) { + component.translationUnits += addBuiltIn() + } val walker = SubgraphWalker.ScopedWalker(scopeManager) walker.registerHandler { _, parent, node ->