Preprocessor statements now abort Dead Write analysis.
This commit is contained in:
parent
921449cbb8
commit
6c9a726b86
@ -7,10 +7,7 @@ import com.intellij.psi.util.PsiTreeUtil
|
|||||||
import com.intellij.util.SmartList
|
import com.intellij.util.SmartList
|
||||||
import de.platon42.intellij.plugins.m68k.asm.*
|
import de.platon42.intellij.plugins.m68k.asm.*
|
||||||
import de.platon42.intellij.plugins.m68k.asm.M68kIsa.findMatchingInstructions
|
import de.platon42.intellij.plugins.m68k.asm.M68kIsa.findMatchingInstructions
|
||||||
import de.platon42.intellij.plugins.m68k.psi.M68kAddressModeUtil
|
import de.platon42.intellij.plugins.m68k.psi.*
|
||||||
import de.platon42.intellij.plugins.m68k.psi.M68kAsmInstruction
|
|
||||||
import de.platon42.intellij.plugins.m68k.psi.M68kGlobalLabel
|
|
||||||
import de.platon42.intellij.plugins.m68k.psi.M68kStatement
|
|
||||||
import de.platon42.intellij.plugins.m68k.utils.M68kIsaUtil
|
import de.platon42.intellij.plugins.m68k.utils.M68kIsaUtil
|
||||||
import de.platon42.intellij.plugins.m68k.utils.M68kIsaUtil.checkIfInstructionUsesRegister
|
import de.platon42.intellij.plugins.m68k.utils.M68kIsaUtil.checkIfInstructionUsesRegister
|
||||||
import de.platon42.intellij.plugins.m68k.utils.M68kIsaUtil.evaluateRegisterUse
|
import de.platon42.intellij.plugins.m68k.utils.M68kIsaUtil.evaluateRegisterUse
|
||||||
@ -63,7 +60,7 @@ class M68kDeadWriteInspection : AbstractBaseM68kLocalInspectionTool() {
|
|||||||
currStatement = PsiTreeUtil.getNextSiblingOfType(currStatement, M68kStatement::class.java) ?: break
|
currStatement = PsiTreeUtil.getNextSiblingOfType(currStatement, M68kStatement::class.java) ?: break
|
||||||
val globalLabel = PsiTreeUtil.findChildOfType(currStatement, M68kGlobalLabel::class.java)
|
val globalLabel = PsiTreeUtil.findChildOfType(currStatement, M68kGlobalLabel::class.java)
|
||||||
if (globalLabel != null) break
|
if (globalLabel != null) break
|
||||||
|
if (PsiTreeUtil.getChildOfType(currStatement, M68kPreprocessorDirective::class.java) != null) break
|
||||||
val currAsmInstruction = PsiTreeUtil.getChildOfType(currStatement, M68kAsmInstruction::class.java) ?: continue
|
val currAsmInstruction = PsiTreeUtil.getChildOfType(currStatement, M68kAsmInstruction::class.java) ?: continue
|
||||||
val (isaData, currAdrMode) = findExactIsaDataAndAllowedAdrModeForInstruction(currAsmInstruction) ?: continue
|
val (isaData, currAdrMode) = findExactIsaDataAndAllowedAdrModeForInstruction(currAsmInstruction) ?: continue
|
||||||
if (isaData.changesControlFlow) break
|
if (isaData.changesControlFlow) break
|
||||||
@ -95,7 +92,6 @@ class M68kDeadWriteInspection : AbstractBaseM68kLocalInspectionTool() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return hints.toTypedArray()
|
return hints.toTypedArray()
|
||||||
}
|
}
|
||||||
|
@ -132,8 +132,7 @@ class M68kSyntaxInspection : AbstractBaseM68kLocalInspectionTool() {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val supportedOpSizes = findSupportedOpSizes(matchingModeIsaDataIgnoringSize, op1, op2, specialReg)
|
val supportedOpSizes = findSupportedOpSizes(matchingModeIsaDataIgnoringSize, op1, op2, specialReg)
|
||||||
return arrayOf(
|
return arrayOf(
|
||||||
when (supportedOpSizes) {
|
when (supportedOpSizes) {
|
||||||
|
@ -4,7 +4,8 @@ Finds dead writes to registers, i.e. writes that will not have any effect.
|
|||||||
|
|
||||||
Issues a weak warning if the instruction affects only condition codes that are later tested.
|
Issues a weak warning if the instruction affects only condition codes that are later tested.
|
||||||
|
|
||||||
Analysis is terminated at the next global label or instruction that reads the register or changes control flow.
|
Analysis is terminated at the next global label or instruction that reads the register or changes control flow
|
||||||
|
(or preprocessor statements, like conditional IF statements).
|
||||||
<!-- tooltip end -->
|
<!-- tooltip end -->
|
||||||
<p>Note: As there is no evaluation of macros right now, the inspection might report some false positives.</p>
|
<p>Note: As there is no evaluation of macros right now, the inspection might report some false positives.</p>
|
||||||
</body>
|
</body>
|
||||||
|
@ -154,4 +154,19 @@ internal class M68kDeadWriteInspectionTest : AbstractInspectionTest() {
|
|||||||
)
|
)
|
||||||
assertHighlightings(myFixture, 1, "Register d3 is overwritten later without being used")
|
assertHighlightings(myFixture, 1, "Register d3 is overwritten later without being used")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
internal fun conditional_write_does_not_cause_a_warning(@MyFixture myFixture: CodeInsightTestFixture) {
|
||||||
|
myFixture.enableInspections(M68kDeadWriteInspection::class.java)
|
||||||
|
myFixture.configureByText(
|
||||||
|
"deadwrite.asm", """
|
||||||
|
IF 0
|
||||||
|
move.w #123,d3
|
||||||
|
ELSE
|
||||||
|
clr.w d3
|
||||||
|
ENDC
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
assertThat(myFixture.doHighlighting()).isEmpty()
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user