[cfe-dev] using the original file name for compiling preprocessed files ("-main-file-name"?)

Richard Smith richard at metafoo.co.uk
Thu May 1 16:35:25 PDT 2014


On Thu, May 1, 2014 at 2:22 AM, Robert Lytton <robert at xmos.com> wrote:

>  Hi,
>
> I would like to call clang twice, once to preprocess and second time to
> compile.
> The second time clang is called, I would like to pass in the original file
> name for it to use as the ModuleID.
> I tried to use:
>    clang -E test.c -o tmp.i
>    clang -S -x c tmp.i -o test.s    -Xclang -main-file-name -Xclang test.c
>   -emit-llvm
>
> However, the ModuleID is 'tmp.i' rather than that passed in by
> '-main-file-name'.
>

This seems like a bug to me; -main-file-name should be used as the name of
the input in all respects other than where we find it on disk. Care to put
together a patch to fix this? (I doubt you'll be able to get anyone else to
care much about what ends up in ModuleID, so I think you'll need to do the
work yourself here...)


> Same with:
>     clang -cc1 -triple x86_64-unknown-linux-gnu -x c tmp.i -o test.s
> -main-file-name test.c -emit-llvm
>
>
> I am trying to achieve the same affect as using "-fpreprocessed -dumpbase
> <file>" with llvm-gcc.
> Here it seems the gcc front end fetches the file name from the first line
> of the preprocessed file.
>
> Thank you.
>
> Robert
>
>
>
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140501/f855eb3f/attachment.html>


More information about the cfe-dev mailing list