From 576f8525cad29d3329a4329d3f1453756ef34352 Mon Sep 17 00:00:00 2001 From: Alexey Volkov Date: Wed, 30 Aug 2023 16:12:46 +0300 Subject: [PATCH] JacoDB produces incorrect 3-address code for IINC instruction #146 --- .../org/jacodb/impl/cfg/RawInstListBuilder.kt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/RawInstListBuilder.kt b/jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/RawInstListBuilder.kt index c4eb9e0b2..c00039ff6 100644 --- a/jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/RawInstListBuilder.kt +++ b/jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/RawInstListBuilder.kt @@ -409,15 +409,18 @@ class RawInstListBuilder( } else { instructionList(insn).add(inst) } - when { - insn.isBranchingInst -> postfixInstructions.forEach { - instructionList(insn).add(0, it.value) - } - inst !is JcRawReturnInst -> postfixInstructions.forEach { - instructionList(insn).add(it.value) + if (postfixInstructions.isNotEmpty()) { + when { + insn.isBranchingInst -> postfixInstructions.forEach { + instructionList(insn).add(0, it.value) + } + + inst !is JcRawReturnInst -> postfixInstructions.forEach { + instructionList(insn).add(it.value) + } } + postfixInstructions.clear() } - postfixInstructions.clear() } private fun nextRegister(typeName: TypeName): JcRawValue {