Analyzing multiple configurations of a C program

Preprocessor conditionals are heavily used in C programs since they allow the source code to be configured for different platforms or capabilities. However, preprocessor conditionals, as well as other preprocessor directives, are not part of the C language. They need to be evaluated and removed, and so a single configuration selected, before parsing can take place. Most analysis and program understanding tools run on this preprocessed version of the code so their results are based on a single configuration. This paper describes the approach of CRefactory, a refactoring tool for C programs. A refactoring tool cannot consider only a single configuration: changing the code for one configuration may break the rest of the code. CRefactory analyses the program for all possible configurations simultaneously. CRefactory also preserves preprocessor directives and integrates them in the internal representations. The paper also presents metrics from two case studies to show that CRefactory's program representation is practical.

[1]  Marian Vittek Refactoring browser with preprocessor , 2003, Seventh European Conference onSoftware Maintenance and Reengineering, 2003. Proceedings..

[2]  Peter A. Darnell,et al.  The C Preprocessor , 1991 .

[3]  Don S. Batory,et al.  Evolving Object-Oriented Designs with Refactorings , 2004, Automated Software Engineering.

[4]  Alejandra Garrido,et al.  Challenges of refactoring C programs , 2002, IWPSE '02.

[5]  Premkumar T. Devanbu GENOA—a customizable, front-end-retargetable source code analysis framework , 1999, TSEM.

[6]  Ralph E. Johnson,et al.  A Refactoring Tool for Smalltalk , 1997, Theory Pract. Object Syst..

[7]  Tibor Gyimóthy,et al.  Extracting facts from open source software , 2004, 20th IEEE International Conference on Software Maintenance, 2004. Proceedings..

[8]  William F. Opdyke,et al.  Refactoring object-oriented frameworks , 1992 .

[9]  Ralph E. Johnson,et al.  Refactoring C with conditional compilation , 2003, 18th IEEE International Conference on Automated Software Engineering, 2003. Proceedings..

[10]  Bjarne Stroustrup,et al.  C++ Programming Language , 1986, IEEE Softw..

[11]  Stéphane S. Somé,et al.  Parsing minimization when extracting information from code in the presence of conditional compilation , 1998, Proceedings. 6th International Workshop on Program Comprehension. IWPC'98 (Cat. No.98TB100242).

[12]  David Notkin,et al.  A framework for preprocessor-aware C source code analyses , 2000 .

[13]  Don S. Batory,et al.  Evolving object-oriented designs with refactorings , 1999, 14th IEEE International Conference on Automated Software Engineering.

[14]  Ira D. Baxter,et al.  Preprocessor conditional removal by simple partial evaluation , 2001, Proceedings Eighth Working Conference on Reverse Engineering.