Clang entry point

Hi!

I’m trying to get more familiar with clang internals and I was trying to find the main function of the clang executable from the sources.

I was able to find clang_main() in driver.cpp. Is this the entry function or is there something else behind it (I mean properly named main() )?.

There were some older topics related to this, but I wasn’t sure if it has changed in 10+ years.

Thanks,

T

There is a properly named main. It is generated by the build system from llvm/cmake/modules/llvm-driver-template.cpp.in For clang, the file will be llvm/tools/clang/tools/driver/clang-driver.cpp in the build directory.

1 Like

If ever in doubt, make it crash and see the stack trace :wink:
Or checkout some issues with the crash label on the issue tracker.

3 Likes

The main function will get you into the driver internals. If you want to look at what the frontend does, maybe start with ParseAST.

1 Like

Thanks, appreciate all the answers!