Variability Analysis of Legacy C Code: Parsing and Type-Checking Millions of Product Line Variants
Despite much research on sophisticated programming languages and generators to implement software product lines, practitioners still implement variability in most industrial product lines with the C preprocessor. The ad-hoc nature and undisciplined use of file inclusion, macro substitution and conditional compilation on text level makes analysis difficult. While product-line-aware type systems and safe generators have been developed for novel languages, product lines implemented with the C preprocessor must still be checked by checking the (potentially millions of) generated variants instead of checking the generator. We present an approach to parse, analyze, and type check unpreprocessed C code including all #ifdef variability. To that end, we are developing a partial preprocessor, a specialized feature-aware parser, and a product-line-aware type system for C. Our long term goal is to type check all variants of the Linux kernel with its over 8000 features.