The C preprocessor is heavily used in C programs because it provides useful and even necessary additions to the C language. Since preprocessor directives are not part of C, they are removed before parsing and program analysis take place, during the phase called preprocessing. In the context of refactoring, it is inappropriate to remove preprocessor directives: if changes are applied on the preprocessed version of a program, it may not be possible to recover the un-preprocessed version. This means that after refactoring, all the source code would be contained in a single unit, targeted to a single configuration and without preprocessor macros.
This thesis describes a novel approach to preserve preprocessor directives during parsing and program analysis, and integrate them in the program representations. Furthermore, it illustrates how the program representations are used during refactoring and how transformations preserve preprocessor directives.
Additionally, the semantics of the C preprocessor are formally specified, and the results of implementing this approach in a refactoring tool for C, CRefactory, are presented.
Cited By
- Liebig J, Apel S, Janker A, Garbe F and Oster S (2017). Handling Static Configurability in Refactoring Engines, Computer, 50:7, (44-53), Online publication date: 1-Jan-2017.
- Hills M Variable feature usage patterns in PHP Proceedings of the 30th IEEE/ACM International Conference on Automated Software Engineering, (563-573)
- Liebig J, Janker A, Garbe F, Apel S and Lengauer C Morpheus Proceedings of the 37th International Conference on Software Engineering - Volume 1, (380-391)
- Overbey J, Behrang F and Hafiz M A foundation for refactoring C with macros Proceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering, (75-85)
- Méndez M, Tinetti F and Overbey J Climate models Proceedings of the 2nd International workshop on Software Engineering for High Performance Computing in Computational Science and Engineering, (6-12)
- Hafiz M, Overbey J, Behrang F and Hall J OpenRefactory/C Proceedings of the 2013 ACM workshop on Workshop on refactoring tools, (1-4)
- Hills M, Klint P and Vinju J An empirical study of PHP feature usage: a static analysis perspective Proceedings of the 2013 International Symposium on Software Testing and Analysis, (325-335)
- Overbey J Immutable source-mapped abstract syntax tree Proceedings of the 20th Conference on Pattern Languages of Programs, (1-8)
- Tartler R, Sincero J, Dietrich C, Schröder-Preikschat W and Lohmann D (2012). Revealing and repairing configuration inconsistencies in large-scale system software, International Journal on Software Tools for Technology Transfer (STTT), 14:5, (531-551), Online publication date: 1-Oct-2012.
- Kästner C, Giarrusso P, Rendel T, Erdweg S, Ostermann K and Berger T (2011). Variability-aware parsing in the presence of lexical macros and conditional compilation, ACM SIGPLAN Notices, 46:10, (805-824), Online publication date: 18-Oct-2011.
- Kästner C, Giarrusso P, Rendel T, Erdweg S, Ostermann K and Berger T Variability-aware parsing in the presence of lexical macros and conditional compilation Proceedings of the 2011 ACM international conference on Object oriented programming systems languages and applications, (805-824)
- Liebig J, Kästner C and Apel S Analyzing the discipline of preprocessor annotations in 30 million lines of C code Proceedings of the tenth international conference on Aspect-oriented software development, (191-202)
- Sincero J, Tartler R, Lohmann D and Schröder-Preikschat W (2010). Efficient extraction and analysis of preprocessor-based variability, ACM SIGPLAN Notices, 46:2, (33-42), Online publication date: 26-Jan-2011.
- Kenner A, Kästner C, Haase S and Leich T TypeChef Proceedings of the 2nd International Workshop on Feature-Oriented Software Development, (25-32)
- Sincero J, Tartler R, Lohmann D and Schröder-Preikschat W Efficient extraction and analysis of preprocessor-based variability Proceedings of the ninth international conference on Generative programming and component engineering, (33-42)
- Kitlei R, Bozó I, Kozsik T, Tejfel M and Tóth M Analysis of preprocessor constructs in Erlang Proceedings of the 9th ACM SIGPLAN workshop on Erlang, (45-56)
- Spinellis D (2010). CScout, Science of Computer Programming, 75:4, (216-231), Online publication date: 1-Apr-2010.
- Overbey J and Johnson R Regrowing a language Proceedings of the 24th ACM SIGPLAN conference on Object oriented programming systems languages and applications, (493-502)
- Overbey J and Johnson R (2009). Regrowing a language, ACM SIGPLAN Notices, 44:10, (493-502), Online publication date: 25-Oct-2009.
- Adams B, De Meuter W, Tromp H and Hassan A Can we refactor conditional compilation into aspects? Proceedings of the 8th ACM international conference on Aspect-oriented software development, (243-254)
- Overbey J, Negara S and Johnson R Refactoring and the evolution of Fortran Proceedings of the 2009 ICSE Workshop on Software Engineering for Computational Science and Engineering, (28-34)
- Adams B, Van Rompaey B, Gibbs C and Coady Y Aspect mining in the presence of the C preprocessor Proceedings of the 2008 AOSD workshop on Linking aspect technology and evolution, (1-6)
- Padioleau Y, Lawall J, Hansen R and Muller G (2008). Documenting and automating collateral evolutions in linux device drivers, ACM SIGOPS Operating Systems Review, 42:4, (247-260), Online publication date: 25-Apr-2008.
- Padioleau Y, Lawall J, Hansen R and Muller G Documenting and automating collateral evolutions in linux device drivers Proceedings of the 3rd ACM SIGOPS/EuroSys European Conference on Computer Systems 2008, (247-260)
- Sultana N and Thompson S Mechanical verification of refactorings Proceedings of the 2008 ACM SIGPLAN symposium on Partial evaluation and semantics-based program manipulation, (51-60)
- Meseguer J and Rou G (2007). The rewriting logic semantics project, Theoretical Computer Science, 373:3, (213-237), Online publication date: 30-Mar-2007.
- Padioleau Y, Hansen R, Lawall J and Muller G Semantic patches for documenting and automating collateral evolutions in Linux device drivers Proceedings of the 3rd workshop on Programming languages and operating systems: linguistic support for modern operating systems, (10-es)
Index Terms
- Program refactoring in the presence of preprocessor directives
Recommendations
Preprocessor
Encyclopedia of Computer ScienceA preprocessor is a language processor that accepts, as input, statements written in one computer language and writes to an output file statements that are acceptable to a similar but less complete language. Suppose, for example, that we have available ...
Ada as a preprocessor language
Preprocessors are components of a software development environment that can increase productivity by providing semantic capabilities for expressing certain source language statement s concisely and directly which would otherwise be expressed indirectly ...
Tool support for refactoring functional programs
WRT '08: Proceedings of the 2nd Workshop on Refactoring ToolsWe present the Haskell Refactorer, HaRe, and the Erlang Refactorer, Wrangler, as examples of fully-functional refactoring tools for functional programming languages. HaRe and Wrangler are designed to handle multi-module projects in complete languages: ...