Visible to the public Discipline Matters: Refactoring of Preprocessor Directives in the #ifdef HellConflict Detection Enabled

TitleDiscipline Matters: Refactoring of Preprocessor Directives in the #ifdef Hell
Publication TypeJournal Article
Year of Publication2017
AuthorsFlavio Medeiros, Marcio Ribeiro, Rohit Gheyi, Sven Apel, Christian Kästner, Bruno Ferreira, Luiz Carvalho, Baldoino Fonseca
JournalIEEE Transactions on Software Engineering
Issue99
Date Published03/2017
ISSN0098-5589
KeywordsApr'17, CMU, Configurable Systems, preprocessors, Refactoring
Abstract

The C preprocessor is used in many C projects to support variability and portability. However, researchers and practitioners criticize the C preprocessor because of its negative effect on code understanding and maintainability and its error proneness. More importantly, the use of the preprocessor hinders the development of tool support that is standard in other languages, such as automated refactoring. Developers aggravate these problems when using the preprocessor in undisciplined ways (e.g., conditional blocks that do not align with the syntactic structure of the code). In this article, we proposed a catalogue of refactorings and we evaluated the number of application possibilities of the refactorings in practice, the opinion of developers about the usefulness of the refactorings, and whether the refactorings preserve behavior. Overall, we found 5670 application possibilities for the refactorings in 63 real-world C projects. In addition, we performed an online survey among 246 developers, and we submitted 28 patches to convert undisciplined directives into disciplined ones. According to our results, 63% of developers prefer to use the refactored (i.e., disciplined) version of the code instead of the original code with undisciplined preprocessor usage. To verify that the refactorings are indeed behavior preserving, we applied them to more than 36 thousand programs generated automatically using a model of a subset of the C language, running the same test cases in the original and refactored programs. Furthermore, we applied the refactorings to three real-world projects: BusyBox, OpenSSL, and SQLite. This way, we detected and fixed a few behavioral changes, 62% caused by unspecified behavior in the C language.

URLhttp://ieeexplore.ieee.org/document/7888579/
DOI10.1109/TSE.2017.2688333
Citation Keynode-34444

Other available formats:

Medeiros_Discipline_Matters_CK.pdf
AttachmentTaxonomyKindSize
Medeiros_Discipline_Matters_CK.pdfPDF document776.31 KBDownloadPreview