This Article 
   
 Share 
   
 Bibliographic References 
   
 Add to: 
 
Digg
Furl
Spurl
Blink
Simpy
Google
Del.icio.us
Y!MyWeb
 
 Search 
   
Global Analysis and Transformations in Preprocessed Languages
November 2003 (vol. 29 no. 11)
pp. 1019-1030

Abstract—Tool support for refactoring code written in mainstream languages such as C and C++ is currently lacking due to the complexity introduced by the mandatory preprocessing phase that forms part of the C/C++ compilation cycle. The defintion and use of macros complicates the notions of scope and of identifier boundaries. The concept of token equivalence classes can be used to bridge the gap between the language proper semantic analysis and the nonpreprocessed source code. The CScout toolchest uses the developed theory to analyze large interdependent program families. A Web-based interactive front end allows the precise realization of rename and remove refactorings on the original C source code. In addition, CScout can convert programs into a portable obfuscated format or store a complete and accurate representation of the code and its identifiers in a relational database.

[1] R.M. Burstall and J. Darlington, A Transformation System for Developing Recursive Programs J. ACM, vol. 24, pp. 44-67, 1977.
[2] W.F. Opdyke, ”Refactoring Object-Oriented Frameworks,” technical report, PhD thesis, Univ. of Illinois at Urbana-Champaign, 1992.
[3] W.J. Brown et al., Antipatterns: Refactoring Software, Architectures, and Projects in Crisis, John Wiley&Sons, New York, 1998.
[4] M. Fowler, Refactoring: Improving the Design of Existing Code. Addison-Wesley, 2000.
[5] L. Tokuda and D. Batory, Evolving Object-Oriented Designs with Refactorings Automated Software Eng., vol. 8, pp. 89-120, 2001.
[6] F. Tip, A Survey of Program Slicing Techniques J. Programming Languages, vol. 3, no. 3, pp. 121-189, Sept. 1995.
[7] A. Goldberg and D. Robson, Smalltalk-80 the Language, Addison Wesley Longman, Reading, Mass., 1989.
[8] D. Roberts, J. Brant, and R.E. Johnson, A Refactoring Tool for Smalltalk Theory and Practice of Object Systems (TAPOS), vol. 3, no. 4, pp. 253-263, 1997.
[9] I. Moore, Automatic Inheritance Hierarchy and Method Refactoring ACM SIGPLAN Notices, vol. 31, no. 10, pp. 235-250, Oct. 1996.
[10] E. Casais and A. Taivalsaari, Object-Oriented Software Evolution and Re-Engineering (special issue) Theory and Practice of Object Systems, vol. 3, no. 4, 1997.
[11] B. W. Kernighan and D. M. Ritchie,The C Programming Language. Englewood Cliffs, NJ: Prentice-Hall, 1988, 2nd ed.
[12] American National Standard for Information Systems Programming Language C: ANSI X3. 159 1989 New York: Am. Nat'l Standards Inst., Dec. 1989.
[13] B. Stroustrup, The C++ Programming Language. third ed. Addison-Wesley, 1997.
[14] T. Jim, G. Morrisett, D. Grossman, M. Hicks, J. Cheney, and Y. Wang, Cyclone: A Safe Dialect of C USENIX Technical Conf. Proc., June 2002.
[15] D. Spinellis, Code Reading: The Open Source Perspective. Effective Software Development Series, Addison-Wesley, 2003.
[16] M.D. Ernst, G.J. Badros, and D. Notkin, An Empirical Analysis of C Preprocessor Use IEEE Trans. Software Eng., vol. 28, no. 12, pp. 1146-1170, Dec. 2002.
[17] S.C. Johnson, Lint, a C Program Checker Computer Science Technical Report 65, Bell Laboratories, Murray Hill, New Jersey, Dec. 1977.
[18] G. Badros and D. Notkin, “A Framework for Preprocessor-Aware C Source Code Analyses,” Software—Practice and Experience, vol. 30, no. 8, pp. 907–924, 2000.
[19] M.A. Ellis and B. Stroustrup,The Annotated C++ Reference Manual.Reading, Mass.: Addison-Wesley, 1990.
[20] D. Spinellis, Checking C Declarations at Link Time The J. C Language Translation, vol. 4, no. 3, pp. 238-249, Mar. 1993.
[21] S. Graham, P. Kessler, and M.K. McKusick, An Execution Profiler for Modular Programs Software: Practice&Experience, vol. 13, pp. 671-685, 1983.
[22] B. Tuthill and K.J. Dunlap, Debugging with dbx UNIX Programmer's Supplementary Documents, vol. 1, Computer Systems Research Group, Dept. of Electrical Eng. and Computer Science, Univ. of California, Berkeley, Apr. 1986.
[23] D.L. Parnas, On the Design and Development of Program Families IEEE Trans. Software Eng., vol. 2, no. 1, pp. 1-9, Mar. 1976.
[24] J.D. McGregor, L.M. Northrop, S. Jarrad, and K. Pohl, Initiating Software Product Lines IEEE Software, vol. 19, no. 4, pp. 24-27, July/Aug. 2002.
[25] B.W. Kernighan and R. Pike, The UNIX Programming Environment. Prentice-Hall, 1984.
[26] A. Hunt and D. Thomas, "Don't Repeat Yourself," The Pragmatic Programmer, Addison-Wesley, Boston, 2000.
[27] G. Snelting, “Reengineering of Configurations Based on Mathematical Concept Analysis,” ACM Trans. Software Eng. and Methodology, vol. 5, no. 2, pp. 146-189, Apr. 1996.
[28] J.-M. Favre, “Preprocessors from an Abstract Point of View,” Proc. Int'l Conf. Software Maintenance (ICSM '96), Nov. 1996.
[29] A. Zavras, A New Solution to the Problem of Source Code Presentation PhD thesis, Dept. of Electrical Eng. and Computer Science, Nat'l Technical Univ. of Athens, Greece, May 1999, (in Greek).
[30] Microsoft Corporation, Microsoft C# Language Specifications. Redmond, Wa.: Microsoft Press, 2001.
[31] D. Spinellis, Notable Design Patterns for Domain Specific Languages J. Systems and Software, vol. 56, no. 1, pp. 91-99, Feb. 2001.
[32] M.H. Austern, Generic Programming and the STL: Using and Extending the C++ Standard Template Library, Addison-Wesley, 1999.
[33] H. Abelson, G.J. Sussman, and J. Sussman, Structure and Interpretation of Computer Programs. MIT Press and McGraw-Hill, 1985.
[34] B.C. Smith, Procedural Reflection in Programming Languages PhD thesis, Mass. Inst. of Tech nology, Jan. 1982.
[35] D. Flanagan, Java in a Nutshell. Sebastopol, Calif.: O'Reilly and Associates, 1997.
[36] A.V. Aho, R. Sethi, and J.D. Ullman, Compilers, Principles, Techniques and Tools.New York: Addison-Wesley, 1985.
[37] S.C. Johnson and M.E. Lesk, Language Development Tools Bell System Technical J., vol. 56, no. 6, pp. 2155-2176, July-Aug. 1987.
[38] D. Spinellis and V. Guruprasad, Lightweight Languages as Software Engineering Tools Proc. USENIX Conf. Domain-Specific Languages, pp. 67-76, Oct. 1997.
[39] W. G. Griswold and D. Notkin,“Automated assistance for program restructuring,”ACM Trans. Software Eng. and Method.,vol. 2, no. 3, pp. 228–269, July 1993.
[40] T. Bui, S. Chaudhuri, T. Leighton, and M. Sipser, Graph Bisection Algorithms with Good Average Case Behavior Proc. 25th Int'l Symp. Foundations of Computer Science, pp. 181-192, 1984.
[41] B.S. Hansen and J.U. Toft, The Formal Specification of ANDF, an Application of Action Semantics Proc. First Int'l Workshop Action Semantics, Apr. 1994.
[42] S.I. Feldman, Make A Program for Maintaining Computer Programs Software: Practice&Experience, vol. 9, no. 4, pp. 255-265, 1979.
[43] D. Atkinson and W. Griswold, “The Design of Whole-Program Analysis Tools,” Proc. 18th Int'l Conf. Software Eng., pp. 16–27, 1996.
[44] S. Horwitz, T. Reps, and D. Binkley, “Interprocedural Slicing Using Dependence Graphs,” ACM Trans. Programming Languages and Systems. vol. 12, no. 1, pp. 26-60, Jan. 1990.

Index Terms:
Refactoring, preprocessor, program families, renaming, C, C++, reverse engineering.
Citation:
Diomidis Spinellis, "Global Analysis and Transformations in Preprocessed Languages," IEEE Transactions on Software Engineering, vol. 29, no. 11, pp. 1019-1030, Nov. 2003, doi:10.1109/TSE.2003.1245303
Usage of this product signifies your acceptance of the Terms of Use.