Computer Science ›› 2017, Vol. 44 ›› Issue (4): 16-20.doi: 10.11896/j.issn.1002-137X.2017.04.004

Previous Articles     Next Articles

CCodeExtractor:Automatic Approach of Function Extraction for C Programs

ZHANG Qi-liang, ZHANG Yu and ZHOU Kun   

  • Online:2018-11-13 Published:2018-11-13

Abstract: As program complexity increases,code refactoring plays an important role in improving quality and perfor-mance of software,and is also essential for improving the maintainability and extensibility of programs.Current code extraction approach for C code in Eclipse,can only deal with some simple code,and cannot refactor the code automatically.In this paper,we proposed a code extraction approach for C code,CCodeExtractor.It can extract the C code fragments that meet the specified conditions into new functions,and replace the fragments with these new functions calls automatically.The refactored code has the same program semantics as the original code.In order to verify the validity of CCodeExtractor,we implemented it in LLVM to extract some for statements in C programs into new functions since loop ana-lysis and optimization has been widely explored in recent years.Our experiments evaluated CCodeExtractor using six actual applications of different size,and compared the outcomes of the original and transformed programs.Experimental results show that CCodeExtractor can provide correct source-level transformation for programs of different size.

Key words: C program refactoring,Program transformation,Program comprehension,Code extraction,Loop analysis,LLVM

[1] FOWLER M.Refactoring:improving the design of existing code[M].Pearson Education India,1999.
[2] Code refactoring.http://en.wikipedia.org/wiki/Code_re-factoring.
[3] HAFIZ M,OVERBEY J.OpenRefactory/C:An infrastructurefor developing program transformations for C programs[C]∥Proceedings of the 3rd annual conference on Systems,programming,and applications:software for humanity.ACM,2012:27-28.
[4] HAFIZ M,OVERBEY J,BEHRANG F,et al.OpenRefactory/C:An infrastructure for building correct and complex C transformations[C]∥Proceedings of the 2013 ACM Workshop on Refactoring Tools.ACM,2013:1-4.
[5] Microsoft Visual Studio.http://www.wholetomato.com/features/ feature-refactoring.asp#extract.
[6] Extract method In Eclipse.https://sourcemaking.com/re-factoring/ extract-method.
[7] JEFFREY L.Overbey,Farnaz Behrang,and Munawar Hafiz.A foundation for refactoring C with macros[C]∥22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering (FSE).New York,NY,USA,2014:75-85.
[8] LATTNER C,ADVE V.LLVM:A compilation framework for lifelong program analysis & transformation[C]∥ International Symposium on Code Generation and Optimization,2004(CGO 2004).IEEE,2004:75-86.
[9] LATTNER C.LLVM and Clang:Next generation compiler tech-nology[C]∥The BSD Conference.2008:1-2.
[10] LLVM extractCode.http://llvm.org/docs/doxygen/html/CodeExtractor 8cpp _source.html.
[11] PROKAJ J.C code for SIFT feature point extraction.http://www.pudn.com/downloads93/sourcecode/graph/texture_mapping/detail365370.html.

No related articles found!
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!