为了能够正确的分析源程序的控制依赖关系和数据依赖关系,以便在此基础上进行程序切片及冗余代码和重复代码检测,提出一种利用GCC抽象语法树(AST)文本来提取源程序静态信息的方法.首先,对GCCAST文本进行标准化及消除文本中与控制流分析和数据流分析无关的结点信息;其次,构建控制依赖子图;同时如果需要数据流分析,在控制依赖子图的基础上构建控制流图,在控制流图的基础上构建数据流子图;最后通过引入过程间分析来完善系统依赖图.实验结果表明,这种方法基本能正确的分析源程序的控制依赖和数据依赖关系,具有更好的适应性和灵活性.
In order to correctly analyze the control dependence and data dependence relations of C program,and then carry out the program slicing,code redundancy and code duplication detection,a method to extract the static information of C program from GCC AST text was put forward.Firstly,the GCC AST text was standardized and the nodes unrelated to control dependence and data dependence analysis were eliminated.Secondly,control dependence subgraph was constructed.If data flow analysis was necessary,control flow graph was constructed based on control dependence subgraph and data dependence subgraph was constructed based on control flow graph.At last,by the introduction of inter-process analysis,system dependence graph was improved.It is indicated that the research can correctly analyze the control dependence and data dependence relations.