[cfe-dev] Question of main() in llvm/tools/clang/tools/driver/driver.cpp

David Wiberg dwiberg at gmail.com
Mon Nov 24 09:26:32 PST 2014


2014-11-24 5:38 GMT+01:00 Xiaohui Chen <xchen422 at uwo.ca>:
> hi all:
>
> i am looking into the "main function" of
> llvm/tools/clang/tools/driver/driver.cpp,
> i only add several llvm::outs() in the source code, and re-compile the
> source code again,
> then i use the clang to compile  my input file(t.c) like this:
>
> xchen422 at dimsum:~$ clang  t.c
>
>  the output is :
>
> xchen422 at dimsum:~$ clang  t.c
> clang main function start point 1
> clang main function start point 3
> clang main function start point 4
> clang main function start point 1
> clang main function start point 2
> clang main function start point 5
> clang main function start point 6
> xchen422 at dimsum:~$
>
> It seems that the main() function is called twice, also it seems that there
> are
> some magic in this function(line 468):
>  Res = TheDriver.ExecuteCompilation(*C, FailingCommands);
>
> i could not understand, could someone give me a brief explanation.
>

Hi,

Please see the Clang FAQ (http://clang.llvm.org/docs/FAQ.html#id2)
which describes the difference between the Clang driver and the Clang
frontend.

Best regards
David



More information about the cfe-dev mailing list