[cfe-dev] DoPrintPreprocessedInput and predefined macros
rrankene at gmail.com
Thu Jan 16 11:37:14 PST 2014
Thanks for the reply!
As for the __NO_INLINE__, you get different results depending on whether
clang -E -P t.c
clang -E -P -O t.c
clang -E -P -traditional-cpp t.c
Note the only difference between the first and third is the white space is
maintained in the third.
So I guess my point is that preprocessing is affected not just by the macro
definitions supplied but also by the command line arguments provided. I'm
not sure where all that is handled in clang or if it's even feasible to get
this information into DoPrintPreprocessedInput.
As to the performance issue I mentioned, it's probably more to do with the
size of the clang executable (about 30 meg) compared with gcc (1.6 meg), as
"time clang" takes 1.5 seconds.
On Thu, Jan 16, 2014 at 6:20 PM, Reid Kleckner <rnk at google.com> wrote:
> On Thu, Jan 16, 2014 at 3:05 AM, Robert Ankeney <rrankene at gmail.com>wrote:
>> 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.
> We could handle this in the driver by adding -D__NO_INLINE__ I suppose.
>> Also I see no way to pass something like the
>> -ftraditional_cpp flag which affects whitespace handling.
> $ clang --help | grep tradi
> -traditional-cpp Enable some traditional CPP emulation
>> 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).
> With clang TOT built by MSVC with optimizations and assertions I get:
> $ time clang -E t.cpp -P > t
> real 0m0.226s
> user 0m0.000s
> sys 0m0.077s
> Did you compile with optimizations? Clang, being C++-y, relies pretty
> heavily on compiler optimizations in order to get reasonable performance.
>> Robert Ankeney
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev