mirror of
https://github.com/irmen/prog8.git
synced 2024-09-10 09:54:32 +00:00
unused subroutine warning only for main compilation module
This commit is contained in:
parent
28c1b208c1
commit
cce08d95db
@ -37,9 +37,9 @@ class IRUnusedCodeRemover(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
irprog.st.allVariables().forEach { stVar->
|
irprog.st.allVariables().forEach { variable ->
|
||||||
val initValue = stVar.onetimeInitializationArrayValue
|
val initValue = variable.onetimeInitializationArrayValue
|
||||||
if(initValue!=null && !initValue.isEmpty()) {
|
if(!initValue.isNullOrEmpty()) {
|
||||||
if(initValue.any {
|
if(initValue.any {
|
||||||
it.addressOfSymbol?.startsWith(blockLabel)==true
|
it.addressOfSymbol?.startsWith(blockLabel)==true
|
||||||
})
|
})
|
||||||
@ -61,9 +61,6 @@ class IRUnusedCodeRemover(
|
|||||||
irprog.blocks.forEach { block ->
|
irprog.blocks.forEach { block ->
|
||||||
block.children.filterIsInstance<IRSubroutine>().reversed().forEach { sub ->
|
block.children.filterIsInstance<IRSubroutine>().reversed().forEach { sub ->
|
||||||
if(sub.isEmpty()) {
|
if(sub.isEmpty()) {
|
||||||
if(!sub.position.file.startsWith(LIBRARYFILEPREFIX)) {
|
|
||||||
errors.warn("unused subroutine ${sub.label}", sub.position)
|
|
||||||
}
|
|
||||||
block.children.remove(sub)
|
block.children.remove(sub)
|
||||||
irprog.st.removeTree(sub.label)
|
irprog.st.removeTree(sub.label)
|
||||||
numRemoved++
|
numRemoved++
|
||||||
|
@ -99,7 +99,7 @@ class UnusedCodeRemover(private val program: Program,
|
|||||||
}
|
}
|
||||||
return removals
|
return removals
|
||||||
}
|
}
|
||||||
if(!subroutine.definingModule.isLibrary && !subroutine.hasBeenInlined) {
|
if(!subroutine.hasBeenInlined && subroutine.definingModule===program.toplevelModule) {
|
||||||
errors.warn("unused subroutine '${subroutine.name}'", subroutine.position)
|
errors.warn("unused subroutine '${subroutine.name}'", subroutine.position)
|
||||||
}
|
}
|
||||||
if(!subroutine.inline) {
|
if(!subroutine.inline) {
|
||||||
|
Loading…
Reference in New Issue
Block a user