[cfe-dev] Interact with clang's preprocessor
Chris Lattner
clattner at apple.com
Thu Feb 12 16:07:35 PST 2009
On Feb 12, 2009, at 4:00 PM, Neil Booth wrote:
> Paolo Bolzoni wrote:-
>
>> dear cfe-list,
>>
>> I would like to interface with the clang preprocessor in order to
>> check
>> programming-style rules. For instance:
>>
>> `Arguments to a function-like macro shall not contain tokens that
>> look
>> like preprocessing directives.'
>>
>> An example of violation.
>> ------->
>> #define AB define
>> #define C A ## B
>> #define macro(X) X
>> int define;
>> int f() {
>> return macro(C);
>> }
>> -------<
>
> That doesn't look like a pp directive; there is no '#', and it is
> certainly not at the start of a logical line.
>
> return macro(
> #ifdef foo
> #endif
> );
>
> would be such an example.
clang already warns about this iirc.
-Chris
More information about the cfe-dev
mailing list