diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt index ed489e40eda..c85778d7ac6 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt @@ -143,7 +143,7 @@ object UncaughtExceptionPath : EdgeLabel(label = "onUncaughtException") // TODO: Label `return`ing edge with this. class ReturnPath( returnTargetSymbol: FirFunctionSymbol<*> -) : EdgeLabel(label = "return@${returnTargetSymbol.callableId}") +) : EdgeLabel(label = "\"return@${returnTargetSymbol.callableId}\"") enum class EdgeKind( val usedInDfa: Boolean, diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphRenderer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphRenderer.kt index 665fbe7d430..aef735688d4 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphRenderer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphRenderer.kt @@ -25,6 +25,8 @@ class FirControlFlowGraphRenderVisitor( private const val RED = "red" private const val BLUE = "blue" + private val DIGIT_REGEX = """\d""".toRegex() + private val EDGE_STYLE = EnumMap( mapOf( EdgeKind.Forward to "", @@ -47,8 +49,12 @@ class FirControlFlowGraphRenderVisitor( private val allGraphs = mutableSetOf() override fun visitFile(file: FirFile) { + var name = file.name.replace(".", "_") + if (DIGIT_REGEX.matches(name.first().toString())) { + name = "_$name" + } printer - .println("digraph ${file.name.replace(".", "_")} {") + .println("digraph $name {") .pushIndent() .println("graph [nodesep=3]") .println("node [shape=box penwidth=2]")