Skip to content

Commit

Permalink
Formatting and stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
oxisto committed Apr 7, 2023
1 parent ec45362 commit 0e8378e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
48 changes: 24 additions & 24 deletions cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/ScopeManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ class ScopeManager : ScopeProvider {
if (scope == null) {
LOGGER.error(
"Break inside of unbreakable scope. The break will be ignored, but may lead " +
"to an incorrect graph. The source code is not valid or incomplete."
"to an incorrect graph. The source code is not valid or incomplete."
)
return
}
Expand All @@ -487,7 +487,7 @@ class ScopeManager : ScopeProvider {
if (scope == null) {
LOGGER.error(
"Continue inside of not continuable scope. The continue will be ignored, but may lead " +
"to an incorrect graph. The source code is not valid or incomplete."
"to an incorrect graph. The source code is not valid or incomplete."
)
return
}
Expand Down Expand Up @@ -599,30 +599,30 @@ class ScopeManager : ScopeProvider {
scope: Scope? = currentScope
): ValueDeclaration? {
return resolve<ValueDeclaration>(scope) {
if (
it.name.lastPartsMatch(ref.name)
) { // TODO: This place is likely to make things fail
// If the reference seems to point to a function the entire signature is checked
// for equality
if (ref.type is FunctionPointerType && it is FunctionDeclaration) {
val fptrType = (ref as HasType).type as FunctionPointerType
// TODO(oxisto): This is the third place where function pointers are
// resolved. WHY?
// TODO(oxisto): Support multiple return values
val returnType = it.returnTypes.firstOrNull() ?: IncompleteType()
if (
returnType == fptrType.returnType &&
it.hasSignature(fptrType.parameters)
) {
return@resolve true
if (
it.name.lastPartsMatch(ref.name)
) { // TODO: This place is likely to make things fail
// If the reference seems to point to a function the entire signature is checked
// for equality
if (ref.type is FunctionPointerType && it is FunctionDeclaration) {
val fptrType = (ref as HasType).type as FunctionPointerType
// TODO(oxisto): This is the third place where function pointers are
// resolved. WHY?
// TODO(oxisto): Support multiple return values
val returnType = it.returnTypes.firstOrNull() ?: IncompleteType()
if (
returnType == fptrType.returnType &&
it.hasSignature(fptrType.parameters)
) {
return@resolve true
}
} else {
return@resolve it !is FunctionDeclaration
}
} else {
return@resolve it !is FunctionDeclaration
}
}

return@resolve false
}
return@resolve false
}
.firstOrNull()
}

Expand Down Expand Up @@ -827,4 +827,4 @@ class ScopeManager : ScopeProvider {
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ class Inference(val start: Node, val scopeManager: ScopeManager) :
return scopeManager.withScope(scopeManager.lookupScope(start), init)
}


private fun createInferredParameters(function: FunctionDeclaration, signature: List<Type?>) {
// To save some unnecessary scopes, we only want to "enter" the function if it is necessary,
// e.g., if we need to create parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class GoExtraPass : Pass(), ScopeProvider {
when (node) {
is CallExpression -> handleCall(node, parent)
is IncludeDeclaration -> handleInclude(node)
is AssignExpression -> handleAssign(node, parent)
is AssignExpression -> handleAssign(node)
is ForEachStatement -> handleForEachStatement(node)
}
}
Expand Down Expand Up @@ -170,7 +170,7 @@ class GoExtraPass : Pass(), ScopeProvider {
* This function gets called for every [AssignExpression], to check, whether we need to
* implicitly define any variables assigned in the statement.
*/
private fun handleAssign(assign: AssignExpression, parent: Node?) {
private fun handleAssign(assign: AssignExpression) {
// Only filter nodes that could potentially declare
if (assign.operatorCode != ":=") {
return
Expand Down

0 comments on commit 0e8378e

Please sign in to comment.