-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Symbol resolver with EOG power #1315
Conversation
48c1f9f
to
572c7bd
Compare
9c87cb0
to
22bb061
Compare
cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/EOGBreaker.kt
Outdated
Show resolved
Hide resolved
687789b
to
15127bf
Compare
c2cea18
to
3273ed3
Compare
420d130
to
d399fd6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor changes, and an idea for how to document and change a Todo in code. I did also ask some questions to help me understand some things that are unclear to me.
cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/declarations/FunctionDeclaration.kt
Show resolved
Hide resolved
cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/helpers/SubgraphWalker.kt
Outdated
Show resolved
Hide resolved
cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/EvaluationOrderGraphPass.kt
Outdated
Show resolved
Hide resolved
cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/declarations/FunctionDeclaration.kt
Show resolved
Hide resolved
cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/EvaluationOrderGraphPass.kt
Outdated
Show resolved
Hide resolved
...nguage-python/src/test/kotlin/de/fraunhofer/aisec/cpg/frontends/python/PythonFrontendTest.kt
Show resolved
Hide resolved
cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/SymbolResolver.kt
Outdated
Show resolved
Hide resolved
8ae3521
to
a25a96f
Compare
We also need to update https://fraunhofer-aisec.github.io/cpg/CPG/specs/eog/#variabledeclaration because the EOG of variable declarations changed. |
a25a96f
to
b28ab58
Compare
Co-Authored-By: KuechA <[email protected]>
b28ab58
to
d10154d
Compare
Kudos, SonarCloud Quality Gate passed! |
This PR leverages the power of the already established EOG to establish a relatively good order of resolving symbols. This may not be 100 % accurate yet, but gives us a good enough approximation for now.
In this PR, we also merged the
VariableUsageResolver
andFunctionCallResolver
into a singleSymbolResolver
. The code is mostly copy/paste from both resolvers and still has a lot of potential for more refactoring in the future, because both did similar things.The resolver will look for
EOGStartHolder
nodes (a new interface), to start the resolving cycle. Examples include function declarations, top-level declarations or catch-clauses of try-statements. After gathering all start nodes, it will follow the EOG edges and resolve variables and functions, depending on the type of node it encounters.This allows us to resolve scenarios where a variable's type depends on the outcome of a function call and then a method call is called on it (which was not possible to resolve before), like the following:
It also slightly improves symbol resolving in the individual languages, primarily Go, by modelling more language specifics, such as built-in functions or type derivation logic.