Un-preprocessing: Extended CPP that works with your tools

Many tools directly change programs, such as bug-fixing tools, program migration tools, etc. We call them program-modification tools. On the other hand, many programming languages use the C preprocessor, such as C, C++, and Objective-C. Because of the complexity of preprocessors, many program-modification tools either fail to produce sound results under the presence of preprocessor directives, or give up completely and deal only with preprocessed code. In this paper we propose a lightweight approach that enables program-modification tools to work with the C preprocessor for free. The idea is that program-modification tools now simply target the preprocessed code, and our system, acting as a bidirectional C preprocessor, automatically propagates the changes on the preprocessed code back to the un-preprocessed code. The resulting source code is guaranteed to be correct and is kept similar to the original source as much as possible. We have evaluated our approach on Linux kernel with a set of generated changes. The evaluation results show the feasibility and effectiveness of our approach.

[1]  Jeffrey Overbey,et al.  A foundation for refactoring C with macros , 2014, SIGSOFT FSE.

[2]  Jaechang Nam,et al.  Automatic patch generation learned from human-written patches , 2013, 2013 35th International Conference on Software Engineering (ICSE).

[3]  Janis Voigtländer Bidirectionalization for free! (Pearl) , 2009, POPL '09.

[4]  Benjamin C. Pierce,et al.  Combinators for bi-directional tree transformations: a linguistic approach to the view update problem , 2005, POPL '05.

[5]  Sebastian Erdweg,et al.  Variability-aware parsing in the presence of lexical macros and conditional compilation , 2011, OOPSLA '11.

[6]  Ralph E. Johnson,et al.  Analyzing multiple configurations of a C program , 2005, 21st IEEE International Conference on Software Maintenance (ICSM'05).

[7]  Umeshwar Dayal,et al.  On the correct translation of update operations on relational views , 1982, TODS.

[8]  Claire Le Goues,et al.  GenProg: A Generic Method for Automatic Software Repair , 2012, IEEE Transactions on Software Engineering.

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

[10]  Yoann Padioleau,et al.  Parsing C/C++ Code without Pre-processing , 2009, CC.

[11]  Matthias Felleisen,et al.  Hygienic macro expansion , 1986, LFP '86.

[12]  Henry Spencer,et al.  #ifdef Considered Harmful, or Portability Experience with C News , 1992, USENIX Summer.

[13]  Sven Apel,et al.  Analyzing the discipline of preprocessor annotations in 30 million lines of C code , 2011, AOSD '11.

[14]  Ralph E. Johnson,et al.  Embracing the C preprocessor during refactoring , 2013, J. Softw. Evol. Process..

[15]  Eric A. Brewer,et al.  ASTEC: a new approach to refactoring C , 2005, ESEC/FSE-13.

[16]  Wolfgang Schröder-Preikschat,et al.  A quantitative analysis of aspects in the eCos kernel , 2006, EuroSys.

[17]  Márcio Ribeiro,et al.  The Love/Hate Relationship with the C Preprocessor: An Interview Study , 2015, ECOOP.

[18]  Diomidis Spinellis,et al.  Global Analysis and Transformations in Preprocessed Languages , 2003, IEEE Trans. Software Eng..

[19]  Jennifer Widom,et al.  Tracing the lineage of view data in a warehousing environment , 2000, TODS.

[20]  Miryung Kim,et al.  Systematic editing: generating program transformations from an example , 2011, PLDI '11.

[21]  Jun Li,et al.  SWIN: Towards Type-Safe Java Program Adaptation between APIs , 2015, PEPM.

[22]  Yuhua Qi,et al.  The strength of random search on automated program repair , 2014, ICSE.

[23]  Leonidas Fegaras,et al.  Propagating updates through XML views using lineage tracing , 2010, 2010 IEEE 26th International Conference on Data Engineering (ICDE 2010).

[24]  Kazutaka Matsuda,et al.  Bidirectionalizing graph transformations , 2010, ICFP '10.

[25]  Claire Le Goues,et al.  A systematic study of automated program repair: Fixing 55 out of 105 bugs for $8 each , 2012, 2012 34th International Conference on Software Engineering (ICSE).

[26]  Robert Grimm,et al.  SuperC: parsing all of C by taming the preprocessor , 2012, PLDI.

[27]  Julia L. Lawall,et al.  Semantic patches for documenting and automating collateral evolutions in Linux device drivers , 2006, PLOS '06.

[28]  Andreas Classen,et al.  Tag and prune: a pragmatic approach to software product line implementation , 2010, ASE.

[29]  NotkinDavid,et al.  An Empirical Analysis of C Preprocessor Use , 2002 .

[30]  Robert Grimm,et al.  Marco: Safe, Expressive Macros for Any Language , 2012, ECOOP.

[31]  Michael D. Ernst,et al.  An Empirical Analysis of C Preprocessor Use , 2002, IEEE Trans. Software Eng..

[32]  Daniel Weise,et al.  Programmable syntax macros , 1993, PLDI '93.

[33]  Nicolas Spyratos,et al.  Update semantics of relational views , 1981, TODS.

[34]  Perdita Stevens,et al.  Bidirectional model transformations in QVT: semantic issues and open questions , 2007, MODELS'07.

[35]  Stephen J. Hegner,et al.  Foundations of Canonical Update Support for Closed Database Views , 1990, ICDT.

[36]  Kazutaka Matsuda,et al.  Bidirectionalization transformation based on automatic derivation of view complement functions , 2007, ICFP '07.

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

[38]  Sven Apel,et al.  Scalable analysis of variable software , 2013, ESEC/FSE 2013.

[39]  Wolfgang De Meuter,et al.  Can we refactor conditional compilation into aspects? , 2009, AOSD '09.

[40]  Andy Schürr,et al.  Specification of Graph Translators with Triple Graph Grammars , 1994, WG.

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

[42]  Dawei Qi,et al.  SemFix: Program repair via semantic analysis , 2013, 2013 35th International Conference on Software Engineering (ICSE).