| The rapid development of software has brought higher requirements for software adaptability and for the frequency of source code changing to meet various demands.However,it's hard to predict the impacts that source code changes bring,which may produce new bugs or safety problems.Therefore,how to deal effectively with the impacts is one of the key issues to improve the safety and reliability of software.Source code differ analysis has been established for many years;however,current research has been focused on the level of source code.For instance we can use ChangeDistiller to get diff information from source codes.Based on the differ analysis results of source code,programmers predict the effects on software by their experiences;but it tends to be wrong,leading to unmeasurable consequences.More accurate program analysis and verification methods could help programmers figure out those impacts brought by the change of source code.But these methods are focused on intermediate representations such as control flow graph analysis,symbol execution and so on.Therefore,this paper studies the relationship between the change of source code and intermediate representation,trying to bring convenience to the execution of the methods mentioned above.This paper starts with the translation process from source code to intermediate representation and progresses to the obtainment of information on intermediate representation changes based on the results of analysis on source code.In this paper,we design an incremental approach to intermediate representation generation based on code change analysis called IRChange,on the basis of problem analysis above,to adding annotations indicating the changes between the source code and intermediate representation.IRChange is based on Clang/LLVM framework.It obtains the new intermediate representation after source code change through source code change analysis,which could be done to the intermediate representation generated by IRChange.Incremental programming analysis and verification can be easier after the part of intermediate representation that is changed is picked out by IRChange.During the process of getting after-change intermediate representation,IRChange uses annotations to track the source code changes,figuring out the specific content that has been changed.IRChange annotation technique can effectively avoid the translation process from the modified source code to intermediate representation,minimizes the degree of coupling with compiler,and makes it easier to extend other functions.Key points of study: First,IRChange adds annotations to indicate the changes to the source code,transfers the changes at the compiling time,and generates the intermediate representations with annotations;Then EditScripts are obtained through the Diff tool based on the analysis of Clang abstract syntax tree;After that IRChange can quickly generate a set of commands from the changed part of source code according to the generation rule of intermediate representation;Finally,new intermediate representations can be produced based on the algorithm MergeIR that synthesizes old intermediate representations and the annotations with change information.In this paper,sufficient source codes from Clang and LLVM project are chosen as test objects of IRChange technical verification experiment.Evaluation standards of the experiment,namely correctness and effectiveness,are established in this paper based on the designation of IRChange.The result of experiments shows that new intermediate representations with added information produced by IRChange are correct.They can also be used for diff analysis at the intermediate representation level such that the increments can be used for incremental program analysis and verification.After code changes,IRChange technique has strong advantages over the traditional compile in that the compiling time of IRChange is far less than the traditional one.In summary,IRChange technique is not only more accurate but also less time consuming after source code changes. |