CIL is a impressive library for analyzing and transforming C - code. Though Language.C does by no means aim to be a competitor to CIL, it will be a good idea to have a look at it.
The concept of CIL is quite different from ordinary parsers. It transforms C code so that it becomes easier to analyze, but does not aim to preserve the source code structure at all.
Parser
CIL parses C99 code and most gcc extensions, but notes some exceptions and problems
- int bar(int ());
cannot be parsed, because it needs a bad parser hack.
tbc.
Limitations
- CIL operates after preprocessing, and therefore cannot preserve comments or preprocessor directives.
This makes perfect sense for CIL, but makes it unusable for some applications.
- CIL does not preserve code, but transforms it to make analysis easier.
- CIL does not support Tri-Graph sequences.
Analysis and Transformation
This is really the strong point of CIL. A quick overview of its capabilities:
- Control Flow Graphs
- Data Flow Analysis (Constant Folding, Partial evaluation, Available Expression, Liveness)
- Dominators
- Points-to analysis
- Stack Guard / Heapify
- Simplify (One return, Simplified Memory Operations)
- Three address code
