一句话:结合静态分析与渲染器在环自我修正,将遗留代码库转为可渲染流程图,成功率超99%。
大型遗留代码库的维护常受困于复杂的函数内控制流与陈旧的文档,代码理解成本高昂。LLM生成的文本摘要虽能提供语义信息,却难以直观表达非线性的控制逻辑;而现有自动流程图工具往往输出杂乱的图形或语法非法、无法渲染的脚本。为此,作者提出通用工具 AutoFLC:它结合静态分析以精确抽取函数结构,并引入渲染器在环(renderer-in-the-loop)的自我修正机制,迭代精化生成的 PlantUML 脚本,从而保证语法有效与最终流程图的成功渲染。在三个真实航天系统上的评估表明,流程图生成成功率超过 99%;针对 10 名工业从业者的用户研究进一步显示,所生成的流程图显著降低了认知负荷,有效支持逻辑理解。工具已以 MIT 许可开源。
Code comprehension remains a major bottleneck in maintaining large-scale legacy code repositories, particularly due to their complex intra-procedural control flows and lack of up-to-date documentation. While textual summaries generated by large language models (LLMs) provide semantic insights, they fail to intuitively represent non-linear control logic. Visual flowcharts are therefore highly desirable, yet existing automated approaches either produce cluttered diagrams or generate syntactically invalid scripts that cannot be rendered. To address these challenges, we present AutoFLC, a general-purpose tool to transform repository-scale legacy codebases into comprehensive visual flowcharts. AutoFLC combines static analysis for precise function extraction with a renderer-in-the-loop self-correction mechanism. This tool iteratively refines the generated PlantUML script to guarantee syntactic validity, thereby ensuring the successful rendering of the final visual flowchart. Evaluations on three real-world aerospace systems demonstrate that AutoFLC achieves a flowchart generation success rate exceeding 99%. A user study with 10 industrial practitioners further confirms that the generated flowcharts significantly reduce cognitive load and effectively support logic comprehension. The tool is publicly available at https://github.com/dfjdkjkdf/AutoFLC/tree/main under the MIT License, with a demonstration video accessible at https://youtu.be/AeEi9Nbw7xI.