Mario Latendresse. Fast Symbolic Evaluation of C/C++ Preprocessing Using Conditional Values, in Proc. of the 7th European Conference on Software Maintenance and Reengineering (CSMR), pp. 170-179, Mar 2003.
C/C++ code relying on preprocessing can be quite complex to analyze. This is often due to free preprocessing variables set at compile time. In general, preprocessing selectively compile parts of the source code based on the values of preprocessing variables which may be free. In this case, the relations between these parts can only be represented by conditional expressions using the free variables. Traditional symbolic evaluation can be used to infer these expressions, but its best case time complexity is exponential. We present a new approach for symbolic evaluation that can efficiently compute these conditions by binding variables to conditional values and avoiding the path feasibility analysis of traditional symbolic evaluation. It infers the exact conditional expressions for which the lines of code are compiled and the (conditional) values of preprocessing variables at each point of the source code. Our prototype shows the approach as practical and scaleable to large C/C++ software.