[cfe-dev] clang -E -o support

Shantonu Sen ssen at apple.com
Sun Jan 27 11:56:19 PST 2008


To be more compatible with gcc, clang should support outputting  
preprocessed source to a file, instead of relying on shell  
redirection. The attached patch allows "clang -E a.c -o a.i" to work.  
In fact, it supports the following:

> $ echo "" > a.c
> $ clang -E a.c
> # 1 "a.c" 1
> # 0 "a.c"
> # 1 "<predefines>" 1
> # 1 "a.c" 2
>
> $ clang -E a.c -o -
> # 1 "a.c" 1
> # 0 "a.c"
> # 1 "<predefines>" 1
> # 1 "a.c" 2
>
> $ clang -E a.c -o a.i
> $ cat a.i
> # 1 "a.c" 1
> # 0 "a.c"
> # 1 "<predefines>" 1
> # 1 "a.c" 2
> $ clang -E a.c -o /dev/null
> $ clang -E a.c -o /System/unwritable
> Assertion failed: (OutputFD >= 0 && "failed to open output file"),  
> function InitOutputBuffer, file PrintPreprocessedOutput.cpp, line 73.
> 0   clang                               0x0022d655  
> _ZN40_GLOBAL__N_Signals.cpp_00000000_62F12DC115PrintStackTraceEv + 45
> 1   clang                               0x0022d9fb  
> _ZN40_GLOBAL__N_Signals.cpp_00000000_62F12DC113SignalHandlerEi + 323
> ...

I also compiled PrintPreprocessedOutput.cpp with USE_STDIO set to 1 on  
Mac OS X, so I believe that codepath should work as well.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-E-o.patch
Type: application/octet-stream
Size: 3615 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080127/4bb47c5d/attachment.obj>
-------------- next part --------------


Shantonu Sen
Apple Inc.



More information about the cfe-dev mailing list