[FIR] Add ability to render node levels in CFG graph dumper
This commit is contained in:
+5
@@ -17,6 +17,11 @@ object FirDiagnosticsDirectives : SimpleDirectivesContainer() {
|
|||||||
applicability = Global
|
applicability = Global
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val RENDERER_CFG_LEVELS by directive(
|
||||||
|
description = "Render leves of nodes in CFG dump",
|
||||||
|
applicability = Global
|
||||||
|
)
|
||||||
|
|
||||||
val FIR_DUMP by directive(
|
val FIR_DUMP by directive(
|
||||||
description = """
|
description = """
|
||||||
Dumps resulting fir to `testName.fir` file
|
Dumps resulting fir to `testName.fir` file
|
||||||
|
|||||||
+3
-1
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.test.frontend.fir.handlers
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.FirControlFlowGraphRenderVisitor
|
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.FirControlFlowGraphRenderVisitor
|
||||||
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives
|
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives
|
||||||
|
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives.RENDERER_CFG_LEVELS
|
||||||
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
|
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
|
||||||
import org.jetbrains.kotlin.test.frontend.fir.FirOutputArtifact
|
import org.jetbrains.kotlin.test.frontend.fir.FirOutputArtifact
|
||||||
import org.jetbrains.kotlin.test.model.TestModule
|
import org.jetbrains.kotlin.test.model.TestModule
|
||||||
@@ -24,7 +25,8 @@ class FirCfgDumpHandler(testServices: TestServices) : FirAnalysisHandler(testSer
|
|||||||
override fun processModule(module: TestModule, info: FirOutputArtifact) {
|
override fun processModule(module: TestModule, info: FirOutputArtifact) {
|
||||||
if (alreadyDumped || FirDiagnosticsDirectives.DUMP_CFG !in module.directives) return
|
if (alreadyDumped || FirDiagnosticsDirectives.DUMP_CFG !in module.directives) return
|
||||||
val file = info.firFiles.values.first()
|
val file = info.firFiles.values.first()
|
||||||
file.accept(FirControlFlowGraphRenderVisitor(builder))
|
val renderLevels = RENDERER_CFG_LEVELS in module.directives
|
||||||
|
file.accept(FirControlFlowGraphRenderVisitor(builder, renderLevels))
|
||||||
alreadyDumped = true
|
alreadyDumped = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user