Skip to content

Commit

Permalink
++
Browse files Browse the repository at this point in the history
  • Loading branch information
oxisto committed Dec 30, 2023
1 parent 93f11a3 commit 2731977
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,6 @@ abstract class Language<T : LanguageFrontend<*, *>> : Node() {
internal class KClassSerializer : JsonSerializer<KClass<*>>() {
override fun serialize(value: KClass<*>, gen: JsonGenerator, provider: SerializerProvider) {
// Write the fully qualified name as a string
gen.writeString(value.simpleName)
gen.writeString(value.qualifiedName)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import de.fraunhofer.aisec.cpg.graph.declarations.VariableDeclaration
import de.fraunhofer.aisec.cpg.graph.types.HasType
import de.fraunhofer.aisec.cpg.graph.types.TupleType
import de.fraunhofer.aisec.cpg.graph.types.Type
import de.fraunhofer.aisec.cpg.helpers.Util.unwrapReference
import org.slf4j.Logger
import org.slf4j.LoggerFactory

Expand Down Expand Up @@ -62,15 +61,15 @@ class AssignExpression :
field = value
if (operatorCode == "=") {
field.forEach {
val unwrapped = unwrapReference(it)
val unwrapped = it.unwrapReference()
unwrapped?.let {
it.access = AccessValues.WRITE
it.dfgHandlerHint = true
}
}
} else {
field.forEach {
val unwrapped = unwrapReference(it)
val unwrapped = it.unwrapReference()
unwrapped?.let {
it.access = AccessValues.READWRITE
it.dfgHandlerHint = true
Expand Down
16 changes: 0 additions & 16 deletions cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/helpers/Util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -405,20 +405,4 @@ object Util {
ENTRIES,
EXITS
}

fun unwrapReference(node: Node?): Reference? {
return if (node is Reference) node
else if (node is UnaryOperator && (node.operatorCode == "*" || node.operatorCode == "&"))
unwrapReference(node.input)
else if (node is CastExpression) unwrapReference(node.expression)
else if (
node is BinaryOperator &&
(node.operatorCode == "&" || node.operatorCode == "*") &&
node.lhs is CastExpression &&
(node.lhs as CastExpression).expression is ProblemExpression
)
// TODO: This is only a hotfix for a bug in the language frontend.
unwrapReference(node.rhs)
else if (node is SubscriptExpression) unwrapReference(node.arrayExpression) else null
}
}

0 comments on commit 2731977

Please sign in to comment.