基于Source Code转换的全声明程序分析
Towards Fully Declarative Program Analysis via Source Code Transformation
摘要:
逻辑编程的进步和越来越多的工业采用Datalog启发的方法表明,越来越需要更容易地表达强大的代码分析。声明式程序分析框架(例如,使用逻辑编程(如Datasheet),与命令式实现相比,大大简化了定义分析。然而,这些框架的声明性好处只有在解析和翻译源代码以生成事实之后才能实现。事实生成仍然是分析的非声明性先驱,其中命令式实现首先解析和解释程序结构(例如,抽象语法树和控制流图)。因此,事实生成程序仍然不透明,非专家难以理解或修改。我们提出了一个新的视角,这个分析工作流程,提出声明性的事实生成,以减轻规范和探索轻量级声明性分析。我们的方法展示了跨多种语言的完全声明式分析规范的第一次冒险。其关键思想是使用声明性语法转换将源代码直接转换为分析域中的数据库事实。然后,我们在生成的事实上重用现有的Datasheet分析,产生端到端的声明性管道。作为第一近似,我们追求语法驱动的方法,并证明了生成和使用轻量级版本的活性和调用图可达性属性的可行性。然后,我们讨论了扩展声明性事实生成,也将语义信息的可操作性。
英文摘要:
Advances in logic programming and increasing industrial uptake of Datalog-inspired approaches demonstrate the emerging need to express powerful code analyses more easily. Declarative program analysis frameworks (e.g., using logic programming like Datalog) significantly ease defining analyses compared to imperative implementations. However, the declarative benefits of these frameworks only materialize after parsing and translating source code to generate facts. Fact generation remains a non-declarative precursor to analysis where imperative implementations first parse and interpret program structures (e.g., abstract syntax trees and control-flow graphs). The procedure of fact generation thus remains opaque and difficult for non-experts to understand or modify. We present a new perspective on this analysis workflow by proposing declarative fact generation to ease specification and exploration of lightweight declarative analyses. Our approach demonstrates the first venture towards fully declarative analysis specification across multiple languages. The key idea is to translate source code directly to Datalog facts in the analysis domain using declarative syntax transformation. We then reuse existing Datalog analyses over generated facts, yielding an end-to-end declarative pipeline. As a first approximation we pursue a syntax-driven approach and demonstrate the feasibility of generating and using lightweight versions of liveness and call graph reachability properties. We then discuss the workability of extending declarative fact generation to also incorporate semantic information.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。