Premium
Embracing the C preprocessor during refactoring
Author(s) -
Garrido Alejandra,
Johnson Ralph
Publication year - 2013
Publication title -
journal of software: evolution and process
Language(s) - English
Resource type - Journals
SCImago Journal Rank - 0.371
H-Index - 29
eISSN - 2047-7481
pISSN - 2047-7473
DOI - 10.1002/smr.1603
Subject(s) - code refactoring , preprocessor , computer science , programming language , process (computing) , parsing , code (set theory) , class (philosophy) , software engineering , source code , transformation (genetics) , program analysis , program transformation , artificial intelligence , software , biochemistry , chemistry , set (abstract data type) , gene
C preprocessor directives are heavily used in C programs because they provide useful and even necessary additions to the C language. However, they are usually executed and discarded before any analysis is applied on C programs. In refactoring, preprocessor directives must be preserved through the whole process of parsing, analysis and transformation to retain editable yet correct source code. We propose a new preprocessing approach and special program representations that allow a program to be analyzed and transformed without losing its preprocessor directives, but treating them as first‐class program entities. These representations are essential for a correct refactoring tool. We also describe the challenges that preprocessor directives bring to refactoring and how the program representations that we propose solve those challenges. Finally, we give details of two refactorings and present some case studies with our successfully applied solution. Copyright © 2013 John Wiley & Sons, Ltd.