From fa416fd5dfe1731d86c7ca1e7c2947acd477a94b Mon Sep 17 00:00:00 2001 From: Christian Banse Date: Tue, 17 Oct 2023 20:09:52 +0200 Subject: [PATCH] adding resolution helper to tag --- .../main/kotlin/de/fraunhofer/aisec/cpg/ScopeManager.kt | 8 +++----- .../aisec/cpg/graph/statements/expressions/Reference.kt | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/ScopeManager.kt b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/ScopeManager.kt index 56c321f297a..830bdf7f1ec 100644 --- a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/ScopeManager.kt +++ b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/ScopeManager.kt @@ -622,7 +622,7 @@ class ScopeManager : ScopeProvider { */ @JvmOverloads fun resolveReference(ref: Reference, startScope: Scope? = currentScope): ValueDeclaration? { - // Retrieve a unique tag for the particular reference, based on the current scope + // Retrieve a unique tag for the particular reference based on the current scope val tag = ref.buildUniqueTag(startScope) // If we find a match in our symbol table, we can immediately return the declaration @@ -640,8 +640,7 @@ class ScopeManager : ScopeProvider { val helper = ref.resolutionHelper return@resolve when { // If the reference seems to point to a function (using a function - // pointer) - // the entire signature is checked for equality + // pointer) the entire signature is checked for equality helper?.type is FunctionPointerType && it is FunctionDeclaration -> { val fptrType = helper.type as FunctionPointerType // TODO(oxisto): Support multiple return values @@ -650,8 +649,7 @@ class ScopeManager : ScopeProvider { it.hasSignature(fptrType.parameters) } // If our language has first-class functions, we can safely return them - // as a - // reference + // as a reference ref.language is HasFirstClassFunctions -> { true } diff --git a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/statements/expressions/Reference.kt b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/statements/expressions/Reference.kt index deba326bca7..0c7c1922a4f 100644 --- a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/statements/expressions/Reference.kt +++ b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/statements/expressions/Reference.kt @@ -161,7 +161,7 @@ open class Reference : Expression(), HasType.TypeObserver { * Resolution (USR). */ fun buildUniqueTag(startScope: Scope?): ReferenceTag { - return Objects.hash(this.name, startScope) + return Objects.hash(this.name, this.resolutionHelper, startScope) } }