[cfe-dev] DoPrintPreprocessedInput and predefined macros

Robert Ankeney rrankene at gmail.com
Thu Jan 16 03:05:34 PST 2014

Ping -

A bit more information about the following - Since preprocessor
arguments passed can affect what the preprocessor does, is there a way
to get these arguments to DoPrintPreprocessedInput()? For example
optimization or the -fno-inline flag affect whether or not
__NO_INLINE__ is defined. Also I see no way to pass something like the
-ftraditional_cpp flag which affects whitespace handling.

I am using the DoPrintPreprocessedInput() function to preprocess some
source code, and see a difference from using clang -E -P to do the
same preprocessing. Using a simple test file:
#include <stdio.h>
#include <stdlib.h>

The difference I see is that the predefined macro __NO_INLINE__ is not
set when calling DoPrintPreprocessedInput. Is there a way to do this
other than by calling addMacroDef? Setting UsePredefines to 1 in
PreprocessorOptions didn't seem to help. Are there other predefines I
should be concerned with?

Another thing I noticed is the slow speed of preprocessing the above
with clang on a Window7 x64 box with MinGW:

real    0m3.249s
user    0m0.016s
sys     0m0.046s

versus gcc:

real    0m0.109s
user    0m0.015s
sys     0m0.000s

This is with clang version 3.3 (trunk 176785).

Robert Ankeney

More information about the cfe-dev mailing list