[cfe-dev] Interact with the preprocessor

Sebastian Redl sebastian.redl at getdesigned.at
Mon Feb 9 09:32:33 PST 2009


Paolo Bolzoni wrote:
> dear cfe-list,
>
> we need a way to verify the source code has some proprieties that
> are lost after preprocessing, but impossible to detect directly from
> source code without a full-fledged preprocessor.
>
> For example, the `High-Integrity C++ Coding Standard Manual' has a rule
> (14.10) that says that include directives can't contains path specifiers.
>   
Poor Boosters. :-(
> Is the clang preprocessor easy to interact/interface with?  As far we could
> understand, the answer should be negative because clang's preprocessor
> seems to be tightly integrated with the subsequent parsing phases, but
> we could be wrong (actually, we _hope_ to be wrong), so I asked here.
>   
The preprocessor and the main lexer are pretty tightly integrated, but
the parser is completely separate. You can run some of your validation
steps as a run separate from actual compilation and replace the parser.
I'm pretty sure you have enough control over the PP to do what you want.

Sebastian



More information about the cfe-dev mailing list